397 lines
18 KiB
HTML
397 lines
18 KiB
HTML
{% extends "base.html" %}
|
|
|
|
{% block title %}
|
|
{% if not role or role == 'admin' %}
|
|
Panel de Administración - Edu-Space Admin
|
|
{% elif role == 'bedelia' %}
|
|
Panel Operativo de Bedelía - Edu-Space Admin
|
|
{% elif role == 'docente' %}
|
|
Panel Docente - Edu-Space Admin
|
|
{% else %}
|
|
Mi Portal de Cursada - Edu-Space Admin
|
|
{% endif %}
|
|
{% endblock %}
|
|
|
|
{% block content %}
|
|
{% if user.is_authenticated %}
|
|
<div class="container-fluid px-0">
|
|
{% endif %}
|
|
|
|
<!-- ========================================================================= -->
|
|
<!-- 1. HEADER & ROLE PERSPECTIVE SWITCHER -->
|
|
<!-- ========================================================================= -->
|
|
{% if show_role_banner %}
|
|
<div class="dashboard-role-banner mb-3 shadow-sm">
|
|
<div class="d-flex justify-content-between align-items-center flex-wrap gap-3">
|
|
<div>
|
|
<div class="d-flex align-items-center gap-2 mb-1 flex-wrap">
|
|
<h1 class="h4 mb-0 fw-bold">
|
|
¡Hola, {{ user.first_name or user.name }}!
|
|
</h1>
|
|
<span class="badge {{ user.role_badge_display.class }} role-pill">
|
|
<i class="bi {{ user.role_badge_display.icon }}"></i>
|
|
{{ user.role_badge_display.label }}
|
|
</span>
|
|
{% if role != actual_role %}
|
|
<span class="badge bg-warning text-dark border font-monospace small">
|
|
<i class="bi bi-eye-fill me-1"></i>Modo Vista Previa: {{ role|capitalize }}
|
|
</span>
|
|
{% endif %}
|
|
</div>
|
|
<p class="text-muted small mb-0">
|
|
{% if not role or role == 'admin' %}
|
|
<i class="bi bi-shield-check text-primary me-1"></i>Gestión centralizada de infraestructura, oferta académica, seguridad y trazabilidad institucional.
|
|
{% elif role == 'bedelia' %}
|
|
<i class="bi bi-building-gear text-warning me-1"></i>Control operativo de campus: asignación de aulas físicas y virtuales, cartelera del día y aprobaciones.
|
|
{% elif role == 'docente' %}
|
|
<i class="bi bi-person-video3 text-info me-1"></i>Espacio docente: gestión de cursadas, horarios de clase, solicitudes de aula y enlaces de videoconferencia.
|
|
{% else %}
|
|
<i class="bi bi-mortarboard text-success me-1"></i>Portal de cursada: consulta tu aula de hoy, cronograma semanal de clases y fechas de exámenes.
|
|
{% endif %}
|
|
</p>
|
|
</div>
|
|
|
|
<!-- Role Perspective Switcher for Admins & Managers -->
|
|
{% if user.is_admin() or user.can_manage() %}
|
|
<div class="d-flex flex-column align-items-end">
|
|
<small class="text-muted fw-semibold mb-1" style="font-size: 0.72rem; letter-spacing: 0.3px;">
|
|
<i class="bi bi-person-bounding-box me-1"></i>VER PANEL COMO ROL:
|
|
</small>
|
|
<div class="btn-group role-view-selector bg-body-tertiary p-1 rounded-pill border" role="group">
|
|
<a href="/dashboard?role=admin"
|
|
class="btn btn-sm {% if not role or role == 'admin' %}btn-primary active{% else %}btn-outline-secondary border-0{% endif %}">
|
|
<i class="bi bi-shield-check me-1"></i>Admin
|
|
</a>
|
|
<a href="/dashboard?role=bedelia"
|
|
class="btn btn-sm {% if role == 'bedelia' %}btn-warning active text-dark{% else %}btn-outline-secondary border-0{% endif %}">
|
|
<i class="bi bi-building-gear me-1"></i>Bedelía
|
|
</a>
|
|
<a href="/dashboard?role=docente"
|
|
class="btn btn-sm {% if role == 'docente' %}btn-info active text-white{% else %}btn-outline-secondary border-0{% endif %}">
|
|
<i class="bi bi-person-video3 me-1"></i>Docente
|
|
</a>
|
|
<a href="/dashboard?role=alumno"
|
|
class="btn btn-sm {% if role == 'alumno' %}btn-success active text-white{% else %}btn-outline-secondary border-0{% endif %}">
|
|
<i class="bi bi-mortarboard me-1"></i>Alumno
|
|
</a>
|
|
</div>
|
|
</div>
|
|
{% endif %}
|
|
</div>
|
|
</div>
|
|
{% endif %}
|
|
|
|
<!-- ========================================================================= -->
|
|
<!-- 2. ROLE SPECIFIC DASHBOARDS (MODULAR INJECTION) -->
|
|
<!-- ========================================================================= -->
|
|
|
|
{% if not role or role == 'admin' %}
|
|
<!-- [A] ADMIN DASHBOARD -->
|
|
{% include "dashboard/dashadm.html" %}
|
|
|
|
{% elif role == 'bedelia' %}
|
|
<!-- [B] BEDELÍA DASHBOARD -->
|
|
{% include "dashboard/dashbede.html" %}
|
|
|
|
{% elif role == 'docente' or role == 'profesor' %}
|
|
<!-- [C] DOCENTE DASHBOARD -->
|
|
{% include "dashboard/dashprof.html" %}
|
|
|
|
{% elif role == 'alumno' or role == 'estudiante' %}
|
|
<!-- [D] ALUMNO DASHBOARD -->
|
|
{% include "dashboard/dashalum.html" %}
|
|
|
|
{% else %}
|
|
{% include "dashboard/dashadm.html" %}
|
|
{% endif %}
|
|
|
|
{% if user.is_authenticated %}
|
|
</div>
|
|
{% endif %}
|
|
|
|
<!-- Script de datos seguros para filtrado de Aulas y Comisiones -->
|
|
<script id="filter-stats-json" type="application/json">
|
|
{{ filter_stats | 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
|
|
}]
|
|
},
|
|
options: {
|
|
responsive: true,
|
|
maintainAspectRatio: false,
|
|
resizeDelay: 100,
|
|
plugins: {
|
|
legend: {
|
|
display: false
|
|
}
|
|
},
|
|
scales: {
|
|
y: {
|
|
beginAtZero: true,
|
|
ticks: {
|
|
stepSize: 1
|
|
}
|
|
}
|
|
}
|
|
}
|
|
});
|
|
});
|
|
}
|
|
});
|
|
|
|
// Apply dynamic colors from data-color attributes (milestone type badges)
|
|
document.querySelectorAll('[data-color]').forEach(function(el) {
|
|
const color = el.getAttribute('data-color');
|
|
if (color) el.style.setProperty('background-color', color, 'important');
|
|
});
|
|
|
|
// Bedelía: Switcher para Cartelera y Agenda de Clases
|
|
function switchBedeliaScheduleView(view) {
|
|
const todayEl = document.getElementById('bedeliaScheduleToday');
|
|
const tomorrowEl = document.getElementById('bedeliaScheduleTomorrow');
|
|
const weekEl = document.getElementById('bedeliaScheduleWeek');
|
|
if (todayEl) todayEl.style.display = view === 'today' ? 'block' : 'none';
|
|
if (tomorrowEl) tomorrowEl.style.display = view === 'tomorrow' ? 'block' : 'none';
|
|
if (weekEl) weekEl.style.display = view === 'week' ? 'block' : 'none';
|
|
document.querySelectorAll('#bedeliaScheduleSwitcher button').forEach(function(btn) {
|
|
btn.classList.toggle('active', btn.getAttribute('data-view') === view);
|
|
});
|
|
}
|
|
|
|
// Cargar datos unificados de filtros desde JSON script seguro
|
|
let FILTER_STATS_DATA = {};
|
|
try {
|
|
const jsonElem = document.getElementById('filter-stats-json');
|
|
if (jsonElem) {
|
|
FILTER_STATS_DATA = JSON.parse(jsonElem.textContent || '{}');
|
|
}
|
|
} catch (e) {
|
|
console.error('Error parseando filter-stats-json:', e);
|
|
}
|
|
|
|
// Variables de estado activas para Comisiones y Aulas
|
|
let currentCommPeriod = 'today';
|
|
let currentCommStatus = 'unassigned';
|
|
let currentClassPeriod = 'today';
|
|
let currentClassStatus = 'unassigned';
|
|
|
|
// Bedelía: Switcher de Percentiles de Aulas (Día / Mañana / Semana / Mes)
|
|
function switchBedeliaPercentiles(period) {
|
|
if (!FILTER_STATS_DATA || !FILTER_STATS_DATA[period]) return;
|
|
const periodData = FILTER_STATS_DATA[period];
|
|
const classData = periodData.classrooms || {};
|
|
|
|
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 assignedCount = document.getElementById('bedeliaPctAssignedCount');
|
|
const assignedPct = document.getElementById('bedeliaPctAssignedPct');
|
|
const unassignedCount = document.getElementById('bedeliaPctUnassignedCount');
|
|
const unassignedPct = document.getElementById('bedeliaPctUnassignedPct');
|
|
const assignedLabel = document.getElementById('bedeliaPctAssignedLabel');
|
|
|
|
if (assignedCount) assignedCount.innerText = classData.assigned_count ?? 0;
|
|
if (assignedPct) assignedPct.innerText = (classData.assigned_pct ?? 0) + '%';
|
|
if (unassignedCount) unassignedCount.innerText = classData.unassigned_count ?? 0;
|
|
if (unassignedPct) unassignedPct.innerText = (classData.unassigned_pct ?? 0) + '%';
|
|
if (assignedLabel) {
|
|
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) + '%)';
|
|
|
|
const barAssigned = document.getElementById('bedeliaPctProgressBarAssigned');
|
|
const barUnassigned = document.getElementById('bedeliaPctProgressBarUnassigned');
|
|
const barTextAssigned = document.getElementById('bedeliaPctBarTextAssigned');
|
|
const barTextUnassigned = document.getElementById('bedeliaPctBarTextUnassigned');
|
|
|
|
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) + '%';
|
|
|
|
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) + '%';
|
|
|
|
// Botones activos
|
|
document.querySelectorAll('#bedeliaPctPeriodSwitcher button').forEach(function(btn) {
|
|
btn.classList.toggle('active', btn.getAttribute('data-period') === period);
|
|
});
|
|
}
|
|
|
|
// Admin: Switcher de Percentiles de Aulas (Día / Mañana / Semana / Mes)
|
|
function switchAdminPercentiles(period) {
|
|
if (!FILTER_STATS_DATA || !FILTER_STATS_DATA[period]) return;
|
|
const periodData = FILTER_STATS_DATA[period];
|
|
const classData = periodData.classrooms || {};
|
|
|
|
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 assignedCount = document.getElementById('adminPctAssignedCount');
|
|
const assignedPct = document.getElementById('adminPctAssignedPct');
|
|
const unassignedCount = document.getElementById('adminPctUnassignedCount');
|
|
const unassignedPct = document.getElementById('adminPctUnassignedPct');
|
|
|
|
if (assignedCount) assignedCount.innerText = classData.assigned_count ?? 0;
|
|
if (assignedPct) assignedPct.innerText = (classData.assigned_pct ?? 0) + '%';
|
|
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) + '%)';
|
|
|
|
const barAssigned = document.getElementById('adminPctProgressBarAssigned');
|
|
const barUnassigned = document.getElementById('adminPctProgressBarUnassigned');
|
|
const barTextAssigned = document.getElementById('adminPctBarTextAssigned');
|
|
const barTextUnassigned = document.getElementById('adminPctBarTextUnassigned');
|
|
|
|
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) + '%';
|
|
|
|
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) + '%';
|
|
|
|
document.querySelectorAll('#adminPctPeriodSwitcher button').forEach(function(btn) {
|
|
btn.classList.toggle('active', btn.getAttribute('data-period') === period);
|
|
});
|
|
}
|
|
|
|
// Bedelía: Switcher de Período para Comisiones (Día / Semana / Mes)
|
|
function switchCommFilterPeriod(period) {
|
|
currentCommPeriod = period;
|
|
const periodData = FILTER_STATS_DATA[period] || {};
|
|
const commData = periodData.commissions || {};
|
|
|
|
const dateText = document.getElementById('commActiveDateText');
|
|
if (dateText) dateText.innerText = periodData.label || '';
|
|
|
|
const badgeUnassigned = document.getElementById('commStatusBadgeUnassigned');
|
|
const badgeAssigned = document.getElementById('commStatusBadgeAssigned');
|
|
if (badgeUnassigned) badgeUnassigned.innerText = commData.unassigned_count ?? 0;
|
|
if (badgeAssigned) badgeAssigned.innerText = commData.assigned_count ?? 0;
|
|
|
|
const summaryText = document.getElementById('commStatusSummaryText');
|
|
if (summaryText) summaryText.innerHTML = 'Período activo: <strong>' + (periodData.label || '') + '</strong>';
|
|
|
|
document.querySelectorAll('#commFilterPeriodSwitcher button').forEach(function(btn) {
|
|
btn.classList.toggle('active', btn.getAttribute('data-period') === period);
|
|
});
|
|
|
|
renderActiveCommBlock();
|
|
}
|
|
|
|
// Bedelía: Switcher de Estado para Comisiones (Asignadas / Sin Asignar)
|
|
function switchCommStatusTab(status) {
|
|
currentCommStatus = status;
|
|
document.querySelectorAll('#commStatusPills button').forEach(function(btn) {
|
|
btn.classList.toggle('active', btn.getAttribute('data-status') === status);
|
|
});
|
|
renderActiveCommBlock();
|
|
}
|
|
|
|
function renderActiveCommBlock() {
|
|
document.querySelectorAll('.comm-block').forEach(function(block) {
|
|
block.style.display = 'none';
|
|
});
|
|
const target = document.getElementById('commBlock-' + currentCommPeriod + '-' + currentCommStatus);
|
|
if (target) target.style.display = 'block';
|
|
}
|
|
|
|
// Bedelía: Switcher de Período para Aulas (Día / Semana / Mes)
|
|
function switchClassFilterPeriod(period) {
|
|
currentClassPeriod = period;
|
|
const periodData = FILTER_STATS_DATA[period] || {};
|
|
const classData = periodData.classrooms || {};
|
|
|
|
const dateText = document.getElementById('classActiveDateText');
|
|
if (dateText) dateText.innerText = periodData.label || '';
|
|
|
|
const badgeUnassigned = document.getElementById('classStatusBadgeUnassigned');
|
|
const badgeAssigned = document.getElementById('classStatusBadgeAssigned');
|
|
if (badgeUnassigned) badgeUnassigned.innerText = classData.unassigned_count ?? 0;
|
|
if (badgeAssigned) badgeAssigned.innerText = classData.assigned_count ?? 0;
|
|
|
|
const summaryText = document.getElementById('classStatusSummaryText');
|
|
if (summaryText) summaryText.innerHTML = 'Período activo: <strong>' + (periodData.label || '') + '</strong>';
|
|
|
|
document.querySelectorAll('#classFilterPeriodSwitcher button').forEach(function(btn) {
|
|
btn.classList.toggle('active', btn.getAttribute('data-period') === period);
|
|
});
|
|
|
|
renderActiveClassBlock();
|
|
}
|
|
|
|
// Bedelía: Switcher de Estado para Aulas (Asignadas / Sin Asignar / Virtual)
|
|
function switchClassStatusTab(status) {
|
|
currentClassStatus = status;
|
|
document.querySelectorAll('#classStatusPills button').forEach(function(btn) {
|
|
btn.classList.toggle('active', btn.getAttribute('data-status') === status);
|
|
});
|
|
renderActiveClassBlock();
|
|
}
|
|
|
|
function renderActiveClassBlock() {
|
|
document.querySelectorAll('.class-block').forEach(function(block) {
|
|
block.style.display = 'none';
|
|
});
|
|
if (currentClassStatus === 'virtual') {
|
|
const vTarget = document.getElementById('classBlock-virtual');
|
|
if (vTarget) vTarget.style.display = 'block';
|
|
} else {
|
|
const target = document.getElementById('classBlock-' + currentClassPeriod + '-' + currentClassStatus);
|
|
if (target) target.style.display = 'block';
|
|
}
|
|
}
|
|
</script>
|
|
{% endblock %} |