diff --git a/CHANGELOG.md b/CHANGELOG.md index 5cefd8b..de111cf 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,6 +11,20 @@ El formato está basado en [Keep a Changelog](https://keepachangelog.com/es-ES/1 - **Sincronización Continua Moodle (Fase 6):** Automatización de workers persistentes en background para el procesamiento continuo de la cola de Web Services Moodle 4.1. - **Pruebas de Carga y Hardening (Fase 6):** Pruebas de estrés de concurrencia y validación final de producción. +## [3.8.19] - 2026-10-26 +### Added & Improved +- **Dashboard: Paginación y Filtro por Carrera en Panel de Comisiones**: + - Implementado selector interactivo de carrera (``, badges de titulación en filas y alerta de estado vacío. + - **Tarjeta KPI de Comisiones Sin Asignar**: Agregada al lado de "Aulas Sin Asignar" en la sección de Percentiles de Asignación tanto en Bedelía (`dashbede.html`) como en Administración (`dashadm.html`), con conteo dinámico y porcentaje respecto al total de comisiones del ciclo. + - **Gráficos de Torta de Ocupación en Día (Hoy)**: Implementados dos gráficos Chart.js Doughnut interactivos (`#bedeliaClassroomsPieChart` / `#bedeliaCommissionsPieChart` y análogos de administración) para Aulas (Asignadas vs Libres) y Comisiones (Con Aula vs Sin Asignar), con leyendas reactivas y tooltip con porcentajes. + - **Enriquecimiento de Backend (`dashboard_service.py`)**: `build_comm_item` provee `career_name`, `career_names` y `career_id`, y el endpoint de dashboard expone el listado global de carreras (`careers`). + - **QA & Seguridad**: 79 tests aprobados en `pytest` (100%), 0 vulnerabilidades en auditoría de seguridad (Bandit, pip-audit, njsscan, npm audit) y balance de etiquetas verificado (`diff=0`). + - **Versión Consolidada**: `v3.8.19`. ## Decisiones (y por qué) - **Flujo Secuencial de Bedelía (9 Pasos)**: Estandarizar la carga operativa en: 1) Sede -> 2) Aula -> 3) Ciclo Lectivo -> 4) Carrera -> 5) Materia (vinculada a Carrera) -> 6) Comisión (asociada a Materia, Carrera y Ciclo) -> 7) Profesores -> 8) Alumnos -> 9) Reserva de Espacio. Esto asegura consistencia e integridad relacional. diff --git a/backend/app/__init__.py b/backend/app/__init__.py index 8553411..e8c3f22 100644 --- a/backend/app/__init__.py +++ b/backend/app/__init__.py @@ -7,7 +7,7 @@ from typing import Any from database import db, get_db, engine, SessionLocal, session from config.config import Config -__version__ = "3.8.18" +__version__ = "3.8.19" class DummyContext: def __enter__(self): diff --git a/backend/app/services/dashboard_service.py b/backend/app/services/dashboard_service.py index 67eba39..ccd9e83 100644 --- a/backend/app/services/dashboard_service.py +++ b/backend/app/services/dashboard_service.py @@ -10,6 +10,7 @@ from sqlalchemy import func from app import db from app.models.classroom import Classroom from app.models.subject import Subject, Commission +from app.models.career import Career from app.models.user import User from app.models.reservation import Reservation from app.models.audit_log import AuditLog @@ -366,12 +367,20 @@ class DashboardService: if r_first: assigned_room = r_first.classroom.code if r_first.classroom else 'Aula Virtual' assigned_time = f"{r_first.start_time.strftime('%H:%M')} - {r_first.end_time.strftime('%H:%M')} hs" + + career_name = comm.career_name if hasattr(comm, 'career_name') else (comm.subject.career.name if (comm.subject and comm.subject.career) else 'UniCABA') + career_names = comm.career_names if hasattr(comm, 'career_names') else career_name + career_id = comm.career_id if hasattr(comm, 'career_id') else None + return { 'id': comm.id, 'code': comm.code, 'full_code': comm.get_full_code(), 'subject_name': comm.subject.name if comm.subject else 'Sin materia', 'subject_code': comm.subject.code if comm.subject else '', + 'career_name': career_name, + 'career_names': career_names, + 'career_id': career_id, 'teacher_name': comm.teacher_name or 'Sin docente', 'schedule': comm.schedule or 'Sin horario', 'shift': comm.shift or 'Sin turno', @@ -639,6 +648,7 @@ class DashboardService: 'milestones': milestones, 'filter_stats': filter_stats, 'date_labels': date_labels, + 'careers': [c.to_dict() for c in Career.query.order_by(Career.name.asc()).all()], 'ui': { 'show_role_banner': SystemSetting.get_value('dashboard_role_banner_enabled', 'true') in ['true', 'True', '1', True] }, diff --git a/backend/setup.py b/backend/setup.py index f4ecb79..876ab71 100644 --- a/backend/setup.py +++ b/backend/setup.py @@ -2,7 +2,7 @@ from setuptools import setup, find_packages setup( name="edu-space-admin", - version="3.8.18", + version="3.8.19", description="Administrative interface for Edu-Space Classroom Management System (FastAPI ASGI Core)", author="Edu-Space Development Team", author_email="admin@edu-space.com", diff --git a/frontend/package.json b/frontend/package.json index 40466e1..fb13191 100644 --- a/frontend/package.json +++ b/frontend/package.json @@ -1,6 +1,6 @@ { "name": "frontend", - "version": "3.8.18", + "version": "3.8.19", "description": "", "main": "index.js", "scripts": { diff --git a/frontend/src/app.js b/frontend/src/app.js index 7c09952..4e50019 100644 --- a/frontend/src/app.js +++ b/frontend/src/app.js @@ -86,9 +86,9 @@ const env = nunjucks.configure(path.join(__dirname, '../views'), { }); // Versiones institucionales del sistema -const APP_VERSION = '3.8.18'; -const FRONTEND_VERSION = '3.8.18'; -const BACKEND_VERSION = '3.8.18'; +const APP_VERSION = '3.8.19'; +const FRONTEND_VERSION = '3.8.19'; +const BACKEND_VERSION = '3.8.19'; env.addGlobal('app_version', APP_VERSION); env.addGlobal('frontend_version', FRONTEND_VERSION); diff --git a/frontend/src/routes/dashboard.js b/frontend/src/routes/dashboard.js index 810a732..2c253e8 100644 --- a/frontend/src/routes/dashboard.js +++ b/frontend/src/routes/dashboard.js @@ -244,6 +244,7 @@ router.get('/', async (req, res) => { upcoming_reservations, filter_stats, date_labels, + careers: apiData.careers || [], floor_availability, all_physical_rooms_today: allPhysicalToday }); diff --git a/frontend/views/dashadm.html b/frontend/views/dashadm.html index 2f5c2ed..16b74db 100644 --- a/frontend/views/dashadm.html +++ b/frontend/views/dashadm.html @@ -137,9 +137,10 @@
-
- -
+ +
+ +
- -
+ +
- -
-
-
- - Ocupación en Día (Hoy): - - - {{ filter_stats.today.classrooms.assigned_count }} asignadas ({{ filter_stats.today.classrooms.assigned_pct }}%) · {{ filter_stats.today.classrooms.unassigned_count }} libres ({{ filter_stats.today.classrooms.unassigned_pct }}%) - -
-
-
- {{ filter_stats.today.classrooms.assigned_pct }}% + +
+ + - -
- - Referencia Cuatrimestral Global: - - - {{ stats.assigned_classrooms_pct }}% asignadas · {{ stats.unassigned_classrooms_pct }}% libres - + + + + +
+ +
+
+
+ + Ocupación de Aulas: Día (Hoy) + + Total: {{ filter_stats.today.classrooms.total }} aulas +
+
+ +
+
+
+ + Asignadas: {{ filter_stats.today.classrooms.assigned_count }} ({{ filter_stats.today.classrooms.assigned_pct }}%) +
+
+ + Libres: {{ filter_stats.today.classrooms.unassigned_count }} ({{ filter_stats.today.classrooms.unassigned_pct }}%) +
+ + +
+
+
+ + Asignación de Comisiones: Día (Hoy) + + Total: {{ filter_stats.today.commissions.total }} comisiones +
+
+ +
+
+
+ + Con Aula: {{ filter_stats.today.commissions.assigned_count }} ({{ filter_stats.today.commissions.assigned_pct }}%) +
+
+ + Sin Asignar: {{ filter_stats.today.commissions.unassigned_count }} ({{ filter_stats.today.commissions.unassigned_pct }}%) +
+
+
+
+
+ + +
+ + Referencia Cuatrimestral Global de Aulas: + +
+
+
+
+
+
+ + {{ stats.assigned_classrooms_pct }}% asignadas · {{ stats.unassigned_classrooms_pct }}% libres +
diff --git a/frontend/views/dashbede.html b/frontend/views/dashbede.html index 075be38..c5eb30d 100644 --- a/frontend/views/dashbede.html +++ b/frontend/views/dashbede.html @@ -126,9 +126,10 @@
-
+ +
-
+
@@ -148,7 +149,7 @@
-
+
- -
-
-
- - Ocupación en Día (Hoy): - - - {{ filter_stats.today.classrooms.assigned_count }} asignadas ({{ filter_stats.today.classrooms.assigned_pct }}%) · {{ filter_stats.today.classrooms.unassigned_count }} libres ({{ filter_stats.today.classrooms.unassigned_pct }}%) - -
-
-
- {{ filter_stats.today.classrooms.assigned_pct }}% + +
+ + - -
- - Referencia Cuatrimestral Global: - - - {{ stats.assigned_classrooms_pct }}% asignadas · {{ stats.unassigned_classrooms_pct }}% libres - + + + + +
+ +
+
+
+ + Ocupación de Aulas: Día (Hoy) + + Total: {{ filter_stats.today.classrooms.total }} aulas +
+
+ +
+
+
+ + Asignadas: {{ filter_stats.today.classrooms.assigned_count }} ({{ filter_stats.today.classrooms.assigned_pct }}%) +
+
+ + Libres: {{ filter_stats.today.classrooms.unassigned_count }} ({{ filter_stats.today.classrooms.unassigned_pct }}%) +
+ + +
+
+
+ + Asignación de Comisiones: Día (Hoy) + + Total: {{ filter_stats.today.commissions.total }} comisiones +
+
+ +
+
+
+ + Con Aula: {{ filter_stats.today.commissions.assigned_count }} ({{ filter_stats.today.commissions.assigned_pct }}%) +
+
+ + Sin Asignar: {{ filter_stats.today.commissions.unassigned_count }} ({{ filter_stats.today.commissions.unassigned_pct }}%) +
+
+
+
+
+ + +
+ + Referencia Cuatrimestral Global de Aulas: + +
+
+
+
+
+
+ + {{ stats.assigned_classrooms_pct }}% asignadas · {{ stats.unassigned_classrooms_pct }}% libres +
@@ -484,7 +554,7 @@
- +
+ + +
+ + +
+
Período activo: {{ filter_stats.today.label }}
@@ -522,13 +606,18 @@ {% for comm in filter_stats.today.commissions.unassigned %} - + {{ comm.full_code }}
{{ comm.subject_name }}
- {% if comm.subject_code %}{{ comm.subject_code }}{% endif %} +
+ {% if comm.subject_code %}{{ comm.subject_code }}{% endif %} + + {{ comm.career_name }} + +
{{ comm.teacher_name }} {{ comm.schedule }} @@ -544,6 +633,10 @@
+ {% else %}
@@ -571,13 +664,18 @@ {% for comm in filter_stats.today.commissions.assigned %} - + {{ comm.full_code }}
{{ comm.subject_name }}
- {% if comm.subject_code %}{{ comm.subject_code }}{% endif %} +
+ {% if comm.subject_code %}{{ comm.subject_code }}{% endif %} + + {{ comm.career_name }} + +
@@ -597,6 +695,10 @@
+ {% else %}
@@ -624,13 +726,18 @@ {% for comm in filter_stats.tomorrow.commissions.unassigned %} - + {{ comm.full_code }}
{{ comm.subject_name }}
- {% if comm.subject_code %}{{ comm.subject_code }}{% endif %} +
+ {% if comm.subject_code %}{{ comm.subject_code }}{% endif %} + + {{ comm.career_name }} + +
{{ comm.teacher_name }} {{ comm.schedule }} @@ -646,6 +753,10 @@
+ {% else %}
@@ -673,13 +784,18 @@ {% for comm in filter_stats.tomorrow.commissions.assigned %} - + {{ comm.full_code }}
{{ comm.subject_name }}
- {% if comm.subject_code %}{{ comm.subject_code }}{% endif %} +
+ {% if comm.subject_code %}{{ comm.subject_code }}{% endif %} + + {{ comm.career_name }} + +
@@ -699,6 +815,10 @@
+ {% else %}
@@ -726,13 +846,18 @@ {% for comm in filter_stats.week.commissions.unassigned %} - + {{ comm.full_code }}
{{ comm.subject_name }}
- {% if comm.subject_code %}{{ comm.subject_code }}{% endif %} +
+ {% if comm.subject_code %}{{ comm.subject_code }}{% endif %} + + {{ comm.career_name }} + +
{{ comm.teacher_name }} {{ comm.schedule }} @@ -748,6 +873,10 @@
+ {% else %}
@@ -756,7 +885,7 @@ {% endif %}
- +
+
diff --git a/frontend/views/dashboard.html b/frontend/views/dashboard.html index ddf6617..33966c9 100644 --- a/frontend/views/dashboard.html +++ b/frontend/views/dashboard.html @@ -179,8 +179,131 @@ $(document).ready(function() { } }); } + + // Inicialización de Gráficos de Torta (Doughnut) para Aulas y Comisiones + initDoughnutCharts(); + + // Poblar dinámicamente opciones de carrera si faltaran en el selector + const careerSelect = document.getElementById('commCareerFilter'); + if (careerSelect) { + const existingValues = new Set(Array.from(careerSelect.options).map(o => o.value)); + document.querySelectorAll('tr[data-career]').forEach(function(tr) { + const cName = tr.getAttribute('data-career'); + if (cName && !existingValues.has(cName)) { + existingValues.add(cName); + const opt = document.createElement('option'); + opt.value = cName; + opt.textContent = cName; + careerSelect.appendChild(opt); + } + }); + } + + // Inicializar la paginación y filtrado de comisiones + applyCommPaginationAndFilter(); }); +// Referencias globales a los gráficos Doughnut +let classroomsPieChart = null; +let commissionsPieChart = null; + +function initDoughnutCharts() { + const classCanvas = document.getElementById('bedeliaClassroomsPieChart') || document.getElementById('adminClassroomsPieChart'); + const commCanvas = document.getElementById('bedeliaCommissionsPieChart') || document.getElementById('adminCommissionsPieChart'); + + if (classCanvas && FILTER_STATS_DATA && FILTER_STATS_DATA.today) { + const todayClass = FILTER_STATS_DATA.today.classrooms || {}; + const assigned = todayClass.assigned_count || 0; + const unassigned = todayClass.unassigned_count || 0; + + classroomsPieChart = new Chart(classCanvas.getContext('2d'), { + type: 'doughnut', + data: { + labels: ['Aulas Asignadas', 'Aulas Libres'], + datasets: [{ + data: [assigned, unassigned], + backgroundColor: ['#198754', '#ffc107'], + borderColor: 'transparent', + borderWidth: 2, + hoverOffset: 4 + }] + }, + options: { + responsive: true, + maintainAspectRatio: false, + cutout: '68%', + plugins: { + legend: { display: false }, + tooltip: { + callbacks: { + label: function(ctx) { + const val = ctx.raw || 0; + const total = ctx.dataset.data.reduce((a, b) => a + b, 0); + const pct = total > 0 ? Math.round((val / total) * 100) : 0; + return ` ${ctx.label}: ${val} (${pct}%)`; + } + } + } + } + } + }); + } + + if (commCanvas && FILTER_STATS_DATA && FILTER_STATS_DATA.today) { + const todayComm = FILTER_STATS_DATA.today.commissions || {}; + const assigned = todayComm.assigned_count || 0; + const unassigned = todayComm.unassigned_count || 0; + + commissionsPieChart = new Chart(commCanvas.getContext('2d'), { + type: 'doughnut', + data: { + labels: ['Con Aula Asignada', 'Sin Asignar (Pendientes)'], + datasets: [{ + data: [assigned, unassigned], + backgroundColor: ['#0d6efd', '#dc3545'], + borderColor: 'transparent', + borderWidth: 2, + hoverOffset: 4 + }] + }, + options: { + responsive: true, + maintainAspectRatio: false, + cutout: '68%', + plugins: { + legend: { display: false }, + tooltip: { + callbacks: { + label: function(ctx) { + const val = ctx.raw || 0; + const total = ctx.dataset.data.reduce((a, b) => a + b, 0); + const pct = total > 0 ? Math.round((val / total) * 100) : 0; + return ` ${ctx.label}: ${val} (${pct}%)`; + } + } + } + } + } + }); + } +} + +function updateDoughnutCharts(period) { + if (!FILTER_STATS_DATA || !FILTER_STATS_DATA[period]) return; + const periodData = FILTER_STATS_DATA[period]; + const classData = periodData.classrooms || {}; + const commData = periodData.commissions || {}; + + if (classroomsPieChart) { + classroomsPieChart.data.datasets[0].data = [classData.assigned_count || 0, classData.unassigned_count || 0]; + classroomsPieChart.update(); + } + if (commissionsPieChart) { + commissionsPieChart.data.datasets[0].data = [commData.assigned_count || 0, commData.unassigned_count || 0]; + commissionsPieChart.update(); + } +} + // Apply dynamic colors from data-color attributes (milestone type badges) document.querySelectorAll('[data-color]').forEach(function(el) { const color = el.getAttribute('data-color'); @@ -222,15 +345,19 @@ function switchBedeliaPercentiles(period) { if (!FILTER_STATS_DATA || !FILTER_STATS_DATA[period]) return; const periodData = FILTER_STATS_DATA[period]; const classData = periodData.classrooms || {}; + const commData = periodData.commissions || {}; const dateText = document.getElementById('bedeliaPctDateText'); if (dateText) dateText.innerText = periodData.label || ''; - const periodTitle = document.getElementById('bedeliaPctPeriodTitle'); - if (periodTitle) { - periodTitle.innerText = period === 'today' ? 'Día (Hoy)' : (period === 'tomorrow' ? 'Mañana' : (period === 'week' ? 'Semana' : 'Mes')); - } + const periodName = period === 'today' ? 'Día (Hoy)' : (period === 'tomorrow' ? 'Mañana' : (period === 'week' ? 'Semana' : 'Mes')); + const classPieTitle = document.getElementById('bedeliaClassPiePeriodTitle'); + const commPieTitle = document.getElementById('bedeliaCommPiePeriodTitle'); + if (classPieTitle) classPieTitle.innerText = periodName; + if (commPieTitle) commPieTitle.innerText = periodName; + + // Tarjetas KPI Aulas const assignedCount = document.getElementById('bedeliaPctAssignedCount'); const assignedPct = document.getElementById('bedeliaPctAssignedPct'); const unassignedCount = document.getElementById('bedeliaPctUnassignedCount'); @@ -245,28 +372,30 @@ function switchBedeliaPercentiles(period) { assignedLabel.innerText = period === 'today' ? 'Con cursada activa hoy' : (period === 'tomorrow' ? 'Con cursada activa mañana' : (period === 'week' ? 'Con cursada activa esta semana' : 'Con cursada activa este mes')); } - // Actualizar leyendas y barras - const legendAssigned = document.getElementById('bedeliaPctLegendAssigned'); - const legendUnassigned = document.getElementById('bedeliaPctLegendUnassigned'); - if (legendAssigned) legendAssigned.innerText = (classData.assigned_count ?? 0) + ' asignadas (' + (classData.assigned_pct ?? 0) + '%)'; - if (legendUnassigned) legendUnassigned.innerText = (classData.unassigned_count ?? 0) + ' libres (' + (classData.unassigned_pct ?? 0) + '%)'; + // Tarjetas KPI Comisiones + const commUnassignedCount = document.getElementById('bedeliaPctCommUnassignedCount'); + const commUnassignedPct = document.getElementById('bedeliaPctCommUnassignedPct'); + const commAssignedCount = document.getElementById('bedeliaPctCommAssignedCount'); + const commAssignedPct = document.getElementById('bedeliaPctCommAssignedPct'); - const barAssigned = document.getElementById('bedeliaPctProgressBarAssigned'); - const barUnassigned = document.getElementById('bedeliaPctProgressBarUnassigned'); - const barTextAssigned = document.getElementById('bedeliaPctBarTextAssigned'); - const barTextUnassigned = document.getElementById('bedeliaPctBarTextUnassigned'); + if (commUnassignedCount) commUnassignedCount.innerText = commData.unassigned_count ?? 0; + if (commUnassignedPct) commUnassignedPct.innerText = (commData.unassigned_pct ?? 0) + '%'; + if (commAssignedCount) commAssignedCount.innerText = commData.assigned_count ?? 0; + if (commAssignedPct) commAssignedPct.innerText = (commData.assigned_pct ?? 0) + '%'; - if (barAssigned) { - barAssigned.style.width = (classData.assigned_pct ?? 0) + '%'; - barAssigned.setAttribute('aria-valuenow', classData.assigned_pct ?? 0); - } - if (barTextAssigned) barTextAssigned.innerText = (classData.assigned_pct ?? 0) + '%'; + // Leyendas de los gráficos de torta + const classLegendAssigned = document.getElementById('bedeliaClassPieLegendAssigned'); + const classLegendUnassigned = document.getElementById('bedeliaClassPieLegendUnassigned'); + const commLegendAssigned = document.getElementById('bedeliaCommPieLegendAssigned'); + const commLegendUnassigned = document.getElementById('bedeliaCommPieLegendUnassigned'); - if (barUnassigned) { - barUnassigned.style.width = (classData.unassigned_pct ?? 0) + '%'; - barUnassigned.setAttribute('aria-valuenow', classData.unassigned_pct ?? 0); - } - if (barTextUnassigned) barTextUnassigned.innerText = (classData.unassigned_pct ?? 0) + '%'; + if (classLegendAssigned) classLegendAssigned.innerText = 'Asignadas: ' + (classData.assigned_count ?? 0) + ' (' + (classData.assigned_pct ?? 0) + '%)'; + if (classLegendUnassigned) classLegendUnassigned.innerText = 'Libres: ' + (classData.unassigned_count ?? 0) + ' (' + (classData.unassigned_pct ?? 0) + '%)'; + if (commLegendAssigned) commLegendAssigned.innerText = 'Con Aula: ' + (commData.assigned_count ?? 0) + ' (' + (commData.assigned_pct ?? 0) + '%)'; + if (commLegendUnassigned) commLegendUnassigned.innerText = 'Sin Asignar: ' + (commData.unassigned_count ?? 0) + ' (' + (commData.unassigned_pct ?? 0) + '%)'; + + // Actualizar gráficos Doughnut + updateDoughnutCharts(period); // Botones activos document.querySelectorAll('#bedeliaPctPeriodSwitcher button').forEach(function(btn) { @@ -279,15 +408,19 @@ function switchAdminPercentiles(period) { if (!FILTER_STATS_DATA || !FILTER_STATS_DATA[period]) return; const periodData = FILTER_STATS_DATA[period]; const classData = periodData.classrooms || {}; + const commData = periodData.commissions || {}; const dateText = document.getElementById('adminPctDateText'); if (dateText) dateText.innerText = periodData.label || ''; - const periodTitle = document.getElementById('adminPctPeriodTitle'); - if (periodTitle) { - periodTitle.innerText = period === 'today' ? 'Día (Hoy)' : (period === 'tomorrow' ? 'Mañana' : (period === 'week' ? 'Semana' : 'Mes')); - } + const periodName = period === 'today' ? 'Día (Hoy)' : (period === 'tomorrow' ? 'Mañana' : (period === 'week' ? 'Semana' : 'Mes')); + const classPieTitle = document.getElementById('adminClassPiePeriodTitle'); + const commPieTitle = document.getElementById('adminCommPiePeriodTitle'); + if (classPieTitle) classPieTitle.innerText = periodName; + if (commPieTitle) commPieTitle.innerText = periodName; + + // Tarjetas KPI Aulas const assignedCount = document.getElementById('adminPctAssignedCount'); const assignedPct = document.getElementById('adminPctAssignedPct'); const unassignedCount = document.getElementById('adminPctUnassignedCount'); @@ -298,33 +431,145 @@ function switchAdminPercentiles(period) { if (unassignedCount) unassignedCount.innerText = classData.unassigned_count ?? 0; if (unassignedPct) unassignedPct.innerText = (classData.unassigned_pct ?? 0) + '%'; - const legendAssigned = document.getElementById('adminPctLegendAssigned'); - const legendUnassigned = document.getElementById('adminPctLegendUnassigned'); - if (legendAssigned) legendAssigned.innerText = (classData.assigned_count ?? 0) + ' asignadas (' + (classData.assigned_pct ?? 0) + '%)'; - if (legendUnassigned) legendUnassigned.innerText = (classData.unassigned_count ?? 0) + ' libres (' + (classData.unassigned_pct ?? 0) + '%)'; + // Tarjetas KPI Comisiones + const commUnassignedCount = document.getElementById('adminPctCommUnassignedCount'); + const commUnassignedPct = document.getElementById('adminPctCommUnassignedPct'); + const commAssignedCount = document.getElementById('adminPctCommAssignedCount'); + const commAssignedPct = document.getElementById('adminPctCommAssignedPct'); - const barAssigned = document.getElementById('adminPctProgressBarAssigned'); - const barUnassigned = document.getElementById('adminPctProgressBarUnassigned'); - const barTextAssigned = document.getElementById('adminPctBarTextAssigned'); - const barTextUnassigned = document.getElementById('adminPctBarTextUnassigned'); + if (commUnassignedCount) commUnassignedCount.innerText = commData.unassigned_count ?? 0; + if (commUnassignedPct) commUnassignedPct.innerText = (commData.unassigned_pct ?? 0) + '%'; + if (commAssignedCount) commAssignedCount.innerText = commData.assigned_count ?? 0; + if (commAssignedPct) commAssignedPct.innerText = (commData.assigned_pct ?? 0) + '%'; - if (barAssigned) { - barAssigned.style.width = (classData.assigned_pct ?? 0) + '%'; - barAssigned.setAttribute('aria-valuenow', classData.assigned_pct ?? 0); - } - if (barTextAssigned) barTextAssigned.innerText = (classData.assigned_pct ?? 0) + '%'; + // Leyendas de los gráficos de torta + const classLegendAssigned = document.getElementById('adminClassPieLegendAssigned'); + const classLegendUnassigned = document.getElementById('adminClassPieLegendUnassigned'); + const commLegendAssigned = document.getElementById('adminCommPieLegendAssigned'); + const commLegendUnassigned = document.getElementById('adminCommPieLegendUnassigned'); - if (barUnassigned) { - barUnassigned.style.width = (classData.unassigned_pct ?? 0) + '%'; - barUnassigned.setAttribute('aria-valuenow', classData.unassigned_pct ?? 0); - } - if (barTextUnassigned) barTextUnassigned.innerText = (classData.unassigned_pct ?? 0) + '%'; + if (classLegendAssigned) classLegendAssigned.innerText = 'Asignadas: ' + (classData.assigned_count ?? 0) + ' (' + (classData.assigned_pct ?? 0) + '%)'; + if (classLegendUnassigned) classLegendUnassigned.innerText = 'Libres: ' + (classData.unassigned_count ?? 0) + ' (' + (classData.unassigned_pct ?? 0) + '%)'; + if (commLegendAssigned) commLegendAssigned.innerText = 'Con Aula: ' + (commData.assigned_count ?? 0) + ' (' + (commData.assigned_pct ?? 0) + '%)'; + if (commLegendUnassigned) commLegendUnassigned.innerText = 'Sin Asignar: ' + (commData.unassigned_count ?? 0) + ' (' + (commData.unassigned_pct ?? 0) + '%)'; + + // Actualizar gráficos Doughnut + updateDoughnutCharts(period); document.querySelectorAll('#adminPctPeriodSwitcher button').forEach(function(btn) { btn.classList.toggle('active', btn.getAttribute('data-period') === period); }); } +// ======================== Paginación y Filtro de Carrera para Comisiones ======================== +let commCurrentPage = 1; +const commPageSize = 10; +let commSelectedCareer = ''; + +function onCommCareerFilterChange(career) { + commSelectedCareer = (career || '').trim(); + commCurrentPage = 1; + applyCommPaginationAndFilter(); +} + +function goToCommPage(page) { + commCurrentPage = page; + applyCommPaginationAndFilter(); +} + +function applyCommPaginationAndFilter() { + const activeBlock = document.getElementById('commBlock-' + currentCommPeriod + '-' + currentCommStatus); + const paginationContainer = document.getElementById('commPaginationContainer'); + if (!activeBlock) { + if (paginationContainer) paginationContainer.style.display = 'none'; + return; + } + + const table = activeBlock.querySelector('table'); + const tableContainer = activeBlock.querySelector('.table-responsive'); + const noMatchAlert = activeBlock.querySelector('.comm-no-match-alert'); + + if (!table) { + if (paginationContainer) paginationContainer.style.display = 'none'; + if (noMatchAlert) noMatchAlert.style.display = 'none'; + return; + } + + const rows = Array.from(table.querySelectorAll('tbody tr')); + if (rows.length === 0) { + if (paginationContainer) paginationContainer.style.display = 'none'; + if (noMatchAlert) noMatchAlert.style.display = 'none'; + return; + } + + // Filtrar por carrera seleccionada + const filterLower = commSelectedCareer.toLowerCase(); + const filteredRows = rows.filter(function(row) { + if (!filterLower) return true; + const career = (row.getAttribute('data-career') || '').toLowerCase(); + const careerNames = (row.getAttribute('data-career-names') || '').toLowerCase(); + return career.includes(filterLower) || careerNames.includes(filterLower); + }); + + if (filteredRows.length === 0) { + rows.forEach(function(r) { r.style.display = 'none'; }); + if (tableContainer) tableContainer.style.display = 'none'; + if (noMatchAlert) noMatchAlert.style.display = 'block'; + if (paginationContainer) paginationContainer.style.display = 'none'; + return; + } + + if (noMatchAlert) noMatchAlert.style.display = 'none'; + if (tableContainer) tableContainer.style.display = 'block'; + + // Calcular páginas + const totalItems = filteredRows.length; + const totalPages = Math.ceil(totalItems / commPageSize); + if (commCurrentPage > totalPages) commCurrentPage = totalPages; + if (commCurrentPage < 1) commCurrentPage = 1; + + const startIndex = (commCurrentPage - 1) * commPageSize; + const endIndex = Math.min(startIndex + commPageSize, totalItems); + + // Ocultar todas las filas + rows.forEach(function(r) { r.style.display = 'none'; }); + + // Mostrar únicamente las filas de la página actual + for (let i = startIndex; i < endIndex; i++) { + filteredRows[i].style.display = ''; + } + + // Actualizar resumen + const startEl = document.getElementById('commPageStart'); + const endEl = document.getElementById('commPageEnd'); + const totalEl = document.getElementById('commPageTotal'); + if (startEl) startEl.innerText = startIndex + 1; + if (endEl) endEl.innerText = endIndex; + if (totalEl) totalEl.innerText = totalItems; + + // Renderizar botones de paginación + const navEl = document.getElementById('commPaginationNav'); + if (navEl) { + let navHtml = ''; + const prevDisabled = commCurrentPage === 1 ? 'disabled' : ''; + navHtml += `
  • `; + + for (let p = 1; p <= totalPages; p++) { + const activeClass = p === commCurrentPage ? 'active' : ''; + navHtml += `
  • ${p}
  • `; + } + + const nextDisabled = commCurrentPage === totalPages ? 'disabled' : ''; + navHtml += `
  • `; + + navEl.innerHTML = navHtml; + } + + if (paginationContainer) { + paginationContainer.style.display = totalItems > 0 ? 'block' : 'none'; + } +} + // Bedelía: Switcher de Período para Comisiones (Día / Semana / Mes) function switchCommFilterPeriod(period) { currentCommPeriod = period; @@ -364,6 +609,9 @@ function renderActiveCommBlock() { }); const target = document.getElementById('commBlock-' + currentCommPeriod + '-' + currentCommStatus); if (target) target.style.display = 'block'; + + commCurrentPage = 1; + applyCommPaginationAndFilter(); } // Bedelía: Switcher de Período para Aulas (Día / Semana / Mes) diff --git a/frontend/views/dashboard/dashadm.html b/frontend/views/dashboard/dashadm.html index 2f5c2ed..16b74db 100644 --- a/frontend/views/dashboard/dashadm.html +++ b/frontend/views/dashboard/dashadm.html @@ -137,9 +137,10 @@
    -
    - -
    + +
    + +
    - -
    + +
    - -
    -
    -
    - - Ocupación en Día (Hoy): - - - {{ filter_stats.today.classrooms.assigned_count }} asignadas ({{ filter_stats.today.classrooms.assigned_pct }}%) · {{ filter_stats.today.classrooms.unassigned_count }} libres ({{ filter_stats.today.classrooms.unassigned_pct }}%) - -
    -
    -
    - {{ filter_stats.today.classrooms.assigned_pct }}% + +
    + + - -
    - - Referencia Cuatrimestral Global: - - - {{ stats.assigned_classrooms_pct }}% asignadas · {{ stats.unassigned_classrooms_pct }}% libres - + + + + +
    + +
    +
    +
    + + Ocupación de Aulas: Día (Hoy) + + Total: {{ filter_stats.today.classrooms.total }} aulas +
    +
    + +
    +
    +
    + + Asignadas: {{ filter_stats.today.classrooms.assigned_count }} ({{ filter_stats.today.classrooms.assigned_pct }}%) +
    +
    + + Libres: {{ filter_stats.today.classrooms.unassigned_count }} ({{ filter_stats.today.classrooms.unassigned_pct }}%) +
    + + +
    +
    +
    + + Asignación de Comisiones: Día (Hoy) + + Total: {{ filter_stats.today.commissions.total }} comisiones +
    +
    + +
    +
    +
    + + Con Aula: {{ filter_stats.today.commissions.assigned_count }} ({{ filter_stats.today.commissions.assigned_pct }}%) +
    +
    + + Sin Asignar: {{ filter_stats.today.commissions.unassigned_count }} ({{ filter_stats.today.commissions.unassigned_pct }}%) +
    +
    +
    +
    +
    + + +
    + + Referencia Cuatrimestral Global de Aulas: + +
    +
    +
    +
    +
    +
    + + {{ stats.assigned_classrooms_pct }}% asignadas · {{ stats.unassigned_classrooms_pct }}% libres +
    diff --git a/frontend/views/dashboard/dashbede.html b/frontend/views/dashboard/dashbede.html index 8080136..c5eb30d 100644 --- a/frontend/views/dashboard/dashbede.html +++ b/frontend/views/dashboard/dashbede.html @@ -126,9 +126,10 @@
    -
    + +
    -
    +
    @@ -148,7 +149,7 @@
    -
    +
    - -
    -
    -
    - - Ocupación en Día (Hoy): - - - {{ filter_stats.today.classrooms.assigned_count }} asignadas ({{ filter_stats.today.classrooms.assigned_pct }}%) · {{ filter_stats.today.classrooms.unassigned_count }} libres ({{ filter_stats.today.classrooms.unassigned_pct }}%) - -
    -
    -
    - {{ filter_stats.today.classrooms.assigned_pct }}% + +
    + + - -
    - - Referencia Cuatrimestral Global: - - - {{ stats.assigned_classrooms_pct }}% asignadas · {{ stats.unassigned_classrooms_pct }}% libres - + + + + +
    + +
    +
    +
    + + Ocupación de Aulas: Día (Hoy) + + Total: {{ filter_stats.today.classrooms.total }} aulas +
    +
    + +
    +
    +
    + + Asignadas: {{ filter_stats.today.classrooms.assigned_count }} ({{ filter_stats.today.classrooms.assigned_pct }}%) +
    +
    + + Libres: {{ filter_stats.today.classrooms.unassigned_count }} ({{ filter_stats.today.classrooms.unassigned_pct }}%) +
    + + +
    +
    +
    + + Asignación de Comisiones: Día (Hoy) + + Total: {{ filter_stats.today.commissions.total }} comisiones +
    +
    + +
    +
    +
    + + Con Aula: {{ filter_stats.today.commissions.assigned_count }} ({{ filter_stats.today.commissions.assigned_pct }}%) +
    +
    + + Sin Asignar: {{ filter_stats.today.commissions.unassigned_count }} ({{ filter_stats.today.commissions.unassigned_pct }}%) +
    +
    +
    +
    +
    + + +
    + + Referencia Cuatrimestral Global de Aulas: + +
    +
    +
    +
    +
    +
    + + {{ stats.assigned_classrooms_pct }}% asignadas · {{ stats.unassigned_classrooms_pct }}% libres +
    @@ -484,7 +554,7 @@
    - +
    + + +
    + + +
    +
    Período activo: {{ filter_stats.today.label }}
    @@ -522,13 +606,18 @@ {% for comm in filter_stats.today.commissions.unassigned %} - + {{ comm.full_code }}
    {{ comm.subject_name }}
    - {% if comm.subject_code %}{{ comm.subject_code }}{% endif %} +
    + {% if comm.subject_code %}{{ comm.subject_code }}{% endif %} + + {{ comm.career_name }} + +
    {{ comm.teacher_name }} {{ comm.schedule }} @@ -544,6 +633,10 @@
    + {% else %}
    @@ -571,13 +664,18 @@ {% for comm in filter_stats.today.commissions.assigned %} - + {{ comm.full_code }}
    {{ comm.subject_name }}
    - {% if comm.subject_code %}{{ comm.subject_code }}{% endif %} +
    + {% if comm.subject_code %}{{ comm.subject_code }}{% endif %} + + {{ comm.career_name }} + +
    @@ -597,6 +695,10 @@
    + {% else %}
    @@ -624,13 +726,18 @@ {% for comm in filter_stats.tomorrow.commissions.unassigned %} - + {{ comm.full_code }}
    {{ comm.subject_name }}
    - {% if comm.subject_code %}{{ comm.subject_code }}{% endif %} +
    + {% if comm.subject_code %}{{ comm.subject_code }}{% endif %} + + {{ comm.career_name }} + +
    {{ comm.teacher_name }} {{ comm.schedule }} @@ -646,6 +753,10 @@
    + {% else %}
    @@ -673,13 +784,18 @@ {% for comm in filter_stats.tomorrow.commissions.assigned %} - + {{ comm.full_code }}
    {{ comm.subject_name }}
    - {% if comm.subject_code %}{{ comm.subject_code }}{% endif %} +
    + {% if comm.subject_code %}{{ comm.subject_code }}{% endif %} + + {{ comm.career_name }} + +
    @@ -699,6 +815,10 @@
    + {% else %}
    @@ -726,13 +846,18 @@ {% for comm in filter_stats.week.commissions.unassigned %} - + {{ comm.full_code }}
    {{ comm.subject_name }}
    - {% if comm.subject_code %}{{ comm.subject_code }}{% endif %} +
    + {% if comm.subject_code %}{{ comm.subject_code }}{% endif %} + + {{ comm.career_name }} + +
    {{ comm.teacher_name }} {{ comm.schedule }} @@ -748,6 +873,10 @@
    + {% else %}
    @@ -756,7 +885,7 @@ {% endif %}
    - +