feat(dashboard): disponibilidad por piso, métricas reales, auditoría y UI/UX v3.8.17

This commit is contained in:
2026-10-26 15:33:02 -03:00
parent 91ea4bbfc7
commit 6e0ab7faaa
17 changed files with 618 additions and 204 deletions
+80 -37
View File
@@ -88,53 +88,96 @@
<script id="filter-stats-json" type="application/json">
{{ filter_stats | dump | safe }}
</script>
<script id="floor-availability-json" type="application/json">
{{ floor_availability | dump | safe }}
</script>
{% endblock %}
{% block extra_js %}
<script src="https://cdn.jsdelivr.net/npm/chart.js"></script>
<script>
$(document).ready(function() {
const chartElem = document.getElementById('monthlyChart');
if (chartElem) {
$.get('/api/dashboard-stats')
.done(function(data) {
const ctx = chartElem.getContext('2d');
new Chart(ctx, {
type: 'line',
data: {
labels: data.monthly_data.map(item => item.month),
datasets: [{
label: 'Reservas',
data: data.monthly_data.map(item => item.reservations),
borderColor: '#B43E8E',
backgroundColor: 'rgba(180, 62, 142, 0.12)',
borderWidth: 2,
fill: true,
tension: 0.4,
pointBackgroundColor: '#B43E8E',
pointRadius: 3
}]
const floorChartElem = document.getElementById('floorAvailabilityChart');
if (floorChartElem) {
let floorData = [];
try {
const rawJson = document.getElementById('floor-availability-json');
if (rawJson) {
floorData = JSON.parse(rawJson.textContent || '[]');
}
} catch (e) {
console.warn('Error leyendo floor-availability-json:', e);
}
const labels = floorData.map(f => f.floor);
const availableData = floorData.map(f => f.available);
const occupiedData = floorData.map(f => f.occupied);
const ctx = floorChartElem.getContext('2d');
new Chart(ctx, {
type: 'bar',
data: {
labels: labels.length > 0 ? labels : ['Piso 2', 'Piso 3'],
datasets: [
{
label: 'Aulas Libres (Hoy)',
data: availableData.length > 0 ? availableData : [1, 2],
backgroundColor: '#198754',
borderRadius: 6,
barThickness: 24
},
options: {
responsive: true,
maintainAspectRatio: false,
resizeDelay: 100,
plugins: {
legend: {
display: false
}
},
scales: {
y: {
beginAtZero: true,
ticks: {
stepSize: 1
}
{
label: 'Aulas Asignadas con Cursada',
data: occupiedData.length > 0 ? occupiedData : [0, 0],
backgroundColor: '#B43E8E',
borderRadius: 6,
barThickness: 24
}
]
},
options: {
indexAxis: 'y',
responsive: true,
maintainAspectRatio: false,
resizeDelay: 100,
plugins: {
legend: {
position: 'top',
labels: {
boxWidth: 12,
padding: 12,
font: { size: 12 }
}
},
tooltip: {
callbacks: {
label: function(context) {
return ` ${context.dataset.label}: ${context.raw} aula(s)`;
}
}
}
});
});
},
scales: {
x: {
stacked: true,
beginAtZero: true,
ticks: {
stepSize: 1,
precision: 0
},
grid: {
color: 'rgba(0,0,0,0.06)'
}
},
y: {
stacked: true,
grid: {
display: false
}
}
}
}
});
}
});