added new of dashboard and log apply on routes
This commit is contained in:
@@ -2,7 +2,7 @@
|
||||
|
||||
{% block content %}
|
||||
<div class="container-fluid px-2 px-md-4">
|
||||
<h4 class="mb-3 text-center text-md-start">Comparison dSoftware Solapur (UGD) - Live Dashboard</h4>
|
||||
<h4 class="mb-3 text-center text-md-start">Comparison Software Solapur (UGD) - Live Dashboard</h4>
|
||||
|
||||
<div class="row g-3 mb-4">
|
||||
<div class="col-12 col-md-4">
|
||||
|
||||
@@ -2,39 +2,39 @@
|
||||
{% block content %}
|
||||
|
||||
<div class="card shadow-sm p-4">
|
||||
|
||||
<h4 class="mb-3">Add New Subcontractor</h4>
|
||||
|
||||
<form action="/subcontractor/save" method="POST">
|
||||
<form action="{{ url_for('subcontractor.save_subcontractor') }}" method="POST">
|
||||
|
||||
<div class="mb-3">
|
||||
<label class="form-label">Subcontractor Name</label>
|
||||
<label class="form-label">Subcontractor Name:</label>
|
||||
<input type="text" class="form-control" name="subcontractor_name" required>
|
||||
</div>
|
||||
|
||||
<div class="mb-3">
|
||||
<label class="form-label">Contact Person Name</label>
|
||||
<label class="form-label">Contact Person Name:</label>
|
||||
<input type="text" class="form-control" name="contact_person">
|
||||
</div>
|
||||
|
||||
<div class="mb-3">
|
||||
<label class="form-label">Mobile</label>
|
||||
<label class="form-label">Mobile No:</label>
|
||||
<input type="text" class="form-control" name="mobile_no">
|
||||
</div>
|
||||
|
||||
<div class="mb-3">
|
||||
<label class="form-label">Email</label>
|
||||
<label class="form-label">Email:</label>
|
||||
<input type="email" class="form-control" name="email_id">
|
||||
</div>
|
||||
|
||||
<div class="mb-3">
|
||||
<label class="form-label">GST No</label>
|
||||
<label class="form-label">GST No:</label>
|
||||
<input type="text" class="form-control" name="gst_no">
|
||||
</div>
|
||||
|
||||
<button class="btn btn-success">Save</button>
|
||||
</form>
|
||||
<a href="{{ url_for('subcontractor.subcontractor_list') }}" class="btn btn-secondary">Back</a>
|
||||
|
||||
</form>
|
||||
</div>
|
||||
|
||||
{% endblock %}
|
||||
@@ -4,7 +4,7 @@
|
||||
<div class="card shadow-sm p-4">
|
||||
<h4 class="mb-3">Edit Subcontractor</h4>
|
||||
|
||||
<form action="/subcontractor/update/{{ subcontractor.id }}" method="POST">
|
||||
<form action="{{ url_for('subcontractor.update_subcontractor', id=subcontractor.id) }}" method="POST">
|
||||
|
||||
<div class="mb-3">
|
||||
<label class="form-label">Subcontractor Name</label>
|
||||
@@ -33,7 +33,7 @@
|
||||
</div>
|
||||
|
||||
<button class="btn btn-success">Update</button>
|
||||
<a href="/subcontractor/list" class="btn btn-secondary">Back</a>
|
||||
<a href="{{ url_for('subcontractor.subcontractor_list') }}" class="btn btn-secondary">Back</a>
|
||||
|
||||
</form>
|
||||
</div>
|
||||
|
||||
@@ -12,8 +12,9 @@
|
||||
</div>
|
||||
|
||||
<div class="col-12 col-md-3 text-center text-md-end">
|
||||
<a href="/subcontractor/add" class="btn btn-success w-100 w-md-auto">
|
||||
➕ Add Subcontractor
|
||||
<!-- <a href="/subcontractor/add" class="btn btn-success w-100 w-md-auto"> -->
|
||||
<a href="{{ url_for('subcontractor.add_subcontractor') }}" class="btn btn-success"></a>
|
||||
➕ Add Subcontractor
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
@@ -56,11 +57,15 @@
|
||||
<!-- Action Buttons -->
|
||||
<td class="text-center">
|
||||
<div class="d-flex flex-column gap-1">
|
||||
<a href="/subcontractor/edit/{{ s.id }}" class="btn btn-sm btn-warning">
|
||||
Edit
|
||||
<!-- <a href="/subcontractor/edit/{{ s.id }}" class="btn btn-sm btn-warning"> -->
|
||||
<a href="{{ url_for('subcontractor.edit_subcontractor', id=s.id) }}"
|
||||
class="btn btn-warning btn-sm"></a>
|
||||
Edit
|
||||
</a>
|
||||
<a href="/subcontractor/delete/{{ s.id }}" class="btn btn-sm btn-danger"
|
||||
onclick="return confirm('Are you sure?')">
|
||||
<!-- <a href="/subcontractor/delete/{{ s.id }}" class="btn btn-sm btn-danger"
|
||||
onclick="return confirm('Are you sure?')"> -->
|
||||
<a href="{{ url_for('subcontractor.delete_subcontractor', id=s.id) }}"
|
||||
class="btn btn-danger btn-sm" onclick="return confirm('Are you sure?')">
|
||||
Delete
|
||||
</a>
|
||||
</div>
|
||||
|
||||
@@ -6,24 +6,117 @@
|
||||
|
||||
<h4 class="mb-3 text-center text-md-start">Subcontractor Dashboard </h4>
|
||||
|
||||
<!-- Charts -->
|
||||
<div class="row g-3">
|
||||
<div class="row g-3 mb-4">
|
||||
<div class="col-12 col-md-4">
|
||||
<div class="card text-white bg-primary shadow h-100">
|
||||
<div class="card-body text-center text-md-start">
|
||||
<h6>Trenching Units</h6>
|
||||
<h3 class="fw-bold" id="card-trench">0</h3>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-12 col-md-4">
|
||||
<div class="card text-white bg-success shadow h-100">
|
||||
<div class="card-body text-center text-md-start">
|
||||
<h6>Manhole Units</h6>
|
||||
<h3 class="fw-bold" id="card-manhole">0</h3>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-12 col-md-4">
|
||||
<div class="card text-dark bg-warning shadow h-100">
|
||||
<div class="card-body text-center text-md-start">
|
||||
<h6>Laying Units</h6>
|
||||
<h3 class="fw-bold" id="card-laying">0</h3>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Bar Chart -->
|
||||
<div class="row g-3">
|
||||
<div class="col-12 col-md-6">
|
||||
<div class="card shadow-sm h-100">
|
||||
<div class="card-header bg-dark text-white text-center text-md-start">
|
||||
Work Category Bar Chart
|
||||
</div>
|
||||
<div class="card-body text-center">
|
||||
<img src="data:image/png;base64,{{ bar_chart }}" class="img-fluid" style="max-height:300px;">
|
||||
<div class="card-header bg-dark text-white">Live Category Bar Chart</div>
|
||||
<div class="card-body">
|
||||
<canvas id="liveBarChart" style="max-height:300px;"></canvas>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
<div class="col-12 col-md-6">
|
||||
<div class="card shadow-sm h-100">
|
||||
<div class="card-header bg-dark text-white">Location Distribution Pie Chart</div>
|
||||
<div class="card-body">
|
||||
<canvas id="livePieChart" style="max-height:300px;"></canvas>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
<script src="https://cdn.jsdelivr.net/npm/chart.js"></script>
|
||||
|
||||
<script>
|
||||
// 2. Initialize the Bar Chart
|
||||
const barCtx = document.getElementById('liveBarChart').getContext('2d');
|
||||
let liveBarChart = new Chart(barCtx, {
|
||||
type: 'bar',
|
||||
data: {
|
||||
labels: ['Trenching', 'Manholes', 'Laying'],
|
||||
datasets: [{
|
||||
label: 'Units Completed',
|
||||
data: [0, 0, 0],
|
||||
backgroundColor: ['#0d6efd', '#198754', '#ffc107']
|
||||
}]
|
||||
},
|
||||
options: { responsive: true, maintainAspectRatio: false }
|
||||
});
|
||||
|
||||
// 3. Initialize the Pie Chart
|
||||
const pieCtx = document.getElementById('livePieChart').getContext('2d');
|
||||
let livePieChart = new Chart(pieCtx, {
|
||||
type: 'pie',
|
||||
data: {
|
||||
labels: [], // Will be filled from SQL
|
||||
datasets: [{
|
||||
data: [],
|
||||
backgroundColor: ['#0d6efd', '#198754', '#ffc107', '#6f42c1', '#fd7e14']
|
||||
}]
|
||||
},
|
||||
options: { responsive: true, maintainAspectRatio: false }
|
||||
});
|
||||
|
||||
// 4. Function to Fetch Live Data from your Python API
|
||||
function fetchLiveData() {
|
||||
fetch('/dashboard/api/live-stats') // This matches the route we created in the "Kitchen"
|
||||
.then(response => response.json())
|
||||
.then(data => {
|
||||
// Update the Summary Cards
|
||||
document.getElementById('card-trench').innerText = data.summary.trench;
|
||||
document.getElementById('card-manhole').innerText = data.summary.manhole;
|
||||
document.getElementById('card-laying').innerText = data.summary.laying;
|
||||
|
||||
// Update Bar Chart
|
||||
liveBarChart.data.datasets[0].data = [
|
||||
data.summary.trench,
|
||||
data.summary.manhole,
|
||||
data.summary.laying
|
||||
];
|
||||
liveBarChart.update();
|
||||
|
||||
// Update Pie Chart (Location stats)
|
||||
livePieChart.data.labels = Object.keys(data.locations);
|
||||
livePieChart.data.datasets[0].data = Object.values(data.locations);
|
||||
livePieChart.update();
|
||||
})
|
||||
.catch(err => console.error("Error fetching live data:", err));
|
||||
}
|
||||
|
||||
// 5. Check for updates every 10 seconds (Real-time effect)
|
||||
setInterval(fetchLiveData, 10000);
|
||||
fetchLiveData(); // Load immediately on page open
|
||||
</script>
|
||||
|
||||
{% endblock %}
|
||||
Reference in New Issue
Block a user