feat: optimizacion zocalos aulas, metricas ocupacion dia/semana/mes, modificacion de reservas y permisos RBAC en gestion
This commit is contained in:
@@ -2,6 +2,86 @@
|
||||
|
||||
{% block title %}{% trans %}Classrooms{% endtrans %} - Edu-Space Admin{% endblock %}
|
||||
|
||||
{% block extra_css %}
|
||||
<style>
|
||||
.classroom-card {
|
||||
transition: transform 0.15s ease, box-shadow 0.15s ease, border-color 0.15s ease;
|
||||
border-radius: 0.65rem;
|
||||
}
|
||||
.classroom-card:hover {
|
||||
transform: translateY(-2px);
|
||||
box-shadow: 0 0.5rem 1rem rgba(0, 0, 0, 0.08) !important;
|
||||
}
|
||||
.metric-pill {
|
||||
padding: 0.35rem 0.2rem;
|
||||
border-radius: 0.45rem;
|
||||
transition: all 0.15s ease;
|
||||
cursor: pointer;
|
||||
line-height: 1.2;
|
||||
}
|
||||
.metric-pill:hover {
|
||||
transform: translateY(-1px);
|
||||
filter: brightness(1.06);
|
||||
}
|
||||
.metric-label {
|
||||
font-size: 0.65rem;
|
||||
font-weight: 600;
|
||||
text-transform: uppercase;
|
||||
letter-spacing: 0.3px;
|
||||
margin-bottom: 2px;
|
||||
}
|
||||
.metric-val {
|
||||
font-size: 0.85rem;
|
||||
font-weight: 700;
|
||||
font-family: SFMono-Regular, Menlo, Monaco, Consolas, monospace;
|
||||
}
|
||||
|
||||
/* Semantics light */
|
||||
.metric-high {
|
||||
background-color: #FEE2E2;
|
||||
border-color: #FCA5A5 !important;
|
||||
color: #991B1B !important;
|
||||
}
|
||||
.metric-medium {
|
||||
background-color: #FEF3C7;
|
||||
border-color: #FCD34D !important;
|
||||
color: #92400E !important;
|
||||
}
|
||||
.metric-low {
|
||||
background-color: #D1FAE5;
|
||||
border-color: #6EE7B7 !important;
|
||||
color: #065F46 !important;
|
||||
}
|
||||
.metric-zero {
|
||||
background-color: rgba(148, 163, 184, 0.1);
|
||||
border-color: rgba(148, 163, 184, 0.25) !important;
|
||||
color: #64748B !important;
|
||||
}
|
||||
|
||||
/* Semantics dark */
|
||||
[data-bs-theme="dark"] .metric-high {
|
||||
background-color: rgba(239, 68, 68, 0.18);
|
||||
border-color: rgba(239, 68, 68, 0.4) !important;
|
||||
color: #FCA5A5 !important;
|
||||
}
|
||||
[data-bs-theme="dark"] .metric-medium {
|
||||
background-color: rgba(245, 158, 11, 0.18);
|
||||
border-color: rgba(245, 158, 11, 0.4) !important;
|
||||
color: #FCD34D !important;
|
||||
}
|
||||
[data-bs-theme="dark"] .metric-low {
|
||||
background-color: rgba(16, 185, 129, 0.18);
|
||||
border-color: rgba(16, 185, 129, 0.4) !important;
|
||||
color: #6EE7B7 !important;
|
||||
}
|
||||
[data-bs-theme="dark"] .metric-zero {
|
||||
background-color: rgba(148, 163, 184, 0.08);
|
||||
border-color: rgba(148, 163, 184, 0.18) !important;
|
||||
color: #94A3B8 !important;
|
||||
}
|
||||
</style>
|
||||
{% endblock %}
|
||||
|
||||
{% block content %}
|
||||
<div class="container-fluid pt-5 mt-4">
|
||||
<div class="row">
|
||||
@@ -88,86 +168,113 @@
|
||||
|
||||
<!-- Classrooms Grid -->
|
||||
{% if classrooms and classrooms.items %}
|
||||
<div class="row mt-4">
|
||||
<div class="row g-3 mt-1">
|
||||
{% for classroom in classrooms.items %}
|
||||
<div class="col-lg-4 col-md-6 mb-4">
|
||||
<div class="card border-0 shadow-sm h-100">
|
||||
<div class="card-body">
|
||||
<div class="d-flex justify-content-between align-items-start mb-2">
|
||||
<div>
|
||||
<h5 class="card-title mb-1 fw-bold text-primary">
|
||||
{{ classroom.code }}
|
||||
</h5>
|
||||
<div class="d-flex flex-wrap gap-1 mb-2">
|
||||
<span class="badge bg-primary-subtle text-primary border">
|
||||
<i class="bi bi-buildings me-1"></i>{{ classroom.building_name }}
|
||||
</span>
|
||||
<span class="badge bg-secondary-subtle text-secondary border">
|
||||
<i class="bi bi-layers me-1"></i>{{ classroom.floor_display }}
|
||||
</span>
|
||||
<div class="col-xxl-3 col-xl-3 col-lg-4 col-md-6 col-sm-12 mb-2">
|
||||
<div class="card classroom-card border shadow-sm h-100">
|
||||
<div class="card-body p-3 d-flex flex-column justify-content-between">
|
||||
<div>
|
||||
<!-- Encabezado con Código y Estado -->
|
||||
<div class="d-flex justify-content-between align-items-start mb-2">
|
||||
<div class="text-truncate me-2">
|
||||
<h5 class="card-title mb-0 fw-bold text-primary text-truncate fs-6" title="{{ classroom.code }}">
|
||||
<i class="bi bi-door-open me-1"></i>{{ classroom.code }}
|
||||
</h5>
|
||||
</div>
|
||||
<span class="badge rounded-pill {% if classroom.is_active %}bg-success-subtle text-success border border-success-subtle{% else %}bg-secondary-subtle text-secondary border{% endif %}" style="font-size: 0.68rem;">
|
||||
{% if classroom.is_active %}{% trans %}Activa{% endtrans %}{% else %}{% trans %}Inactiva{% endtrans %}{% endif %}
|
||||
</span>
|
||||
</div>
|
||||
|
||||
<!-- Ubicación: Edificio y Piso -->
|
||||
<div class="d-flex flex-wrap gap-1 mb-2">
|
||||
<span class="badge bg-primary-subtle text-primary border" style="font-size: 0.7rem;">
|
||||
<i class="bi bi-buildings me-1"></i>{{ classroom.building_name }}
|
||||
</span>
|
||||
<span class="badge bg-secondary-subtle text-secondary border" style="font-size: 0.7rem;">
|
||||
<i class="bi bi-layers me-1"></i>{{ classroom.floor_display }}
|
||||
</span>
|
||||
</div>
|
||||
|
||||
<!-- Capacidad y Recursos -->
|
||||
<div class="d-flex justify-content-between align-items-center small py-1 px-2 bg-body-tertiary rounded mb-2" style="font-size: 0.75rem;">
|
||||
<div>
|
||||
<span class="text-muted">{% trans %}Cap:{% endtrans %}</span>
|
||||
<strong>
|
||||
{% if classroom.is_unlimited %}
|
||||
<span class="badge bg-primary-subtle text-primary border"><i class="bi bi-infinity"></i></span>
|
||||
{% else %}
|
||||
{{ classroom.capacity }}
|
||||
{% endif %}
|
||||
</strong>
|
||||
</div>
|
||||
<div>
|
||||
<span class="text-muted"><i class="bi bi-tools me-1"></i>{{ classroom.resources|length if classroom.resources else 0 }}</span>
|
||||
</div>
|
||||
</div>
|
||||
<span class="badge {% if classroom.is_active %}bg-success{% else %}bg-secondary{% endif %}">
|
||||
{% if classroom.is_active %}{% trans %}Active{% endtrans %}{% else %}{% trans %}Inactive{% endtrans %}{% endif %}
|
||||
</span>
|
||||
</div>
|
||||
|
||||
<div class="row small py-1 bg-body-tertiary rounded px-2 mb-2">
|
||||
<div class="col-6">
|
||||
<span class="text-muted">{% trans %}Capacidad{% endtrans %}:</span>
|
||||
<strong>
|
||||
{% if classroom.is_unlimited %}
|
||||
<span class="badge bg-primary-subtle text-primary border"><i class="bi bi-infinity me-1"></i>∞</span>
|
||||
{% else %}
|
||||
{{ classroom.capacity }}
|
||||
{% endif %}
|
||||
</strong>
|
||||
</div>
|
||||
<div class="col-6 text-end">
|
||||
<span class="text-muted">{% trans %}Ubicación{% endtrans %}:</span>
|
||||
<strong class="text-truncate d-inline-block" style="max-width: 100px;">{{ classroom.floor_display }}</strong>
|
||||
|
||||
<!-- Barra de Métricas de Ocupación (Día, Semana, Mes) -->
|
||||
{% set metrics = occupancy_metrics.get(classroom.id, {'day_pct': 0, 'day_count': 0, 'week_pct': 0, 'week_count': 0, 'month_pct': 0, 'month_count': 0}) %}
|
||||
<div class="classroom-occupancy-bar p-2 rounded bg-body-tertiary border mb-2">
|
||||
<div class="d-flex justify-content-between align-items-center mb-1">
|
||||
<span class="small fw-semibold text-muted" style="font-size: 0.72rem;">
|
||||
<i class="bi bi-graph-up me-1 text-primary"></i>{% trans %}Ocupación{% endtrans %}
|
||||
</span>
|
||||
<span class="text-muted" style="font-size: 0.65rem;" title="{% trans %}Haz clic en cualquier métrica para ver las reservas de ese período{% endtrans %}">
|
||||
<i class="bi bi-info-circle me-1"></i>{% trans %}Ver reservas{% endtrans %}
|
||||
</span>
|
||||
</div>
|
||||
<div class="row g-1 text-center">
|
||||
<!-- Día -->
|
||||
<div class="col-4">
|
||||
<a href="{{ url_for('schedule.list_reservations', classroom_id=classroom.id, date_from=date_filters.today, date_to=date_filters.today) }}"
|
||||
class="d-block p-1 text-decoration-none border metric-pill metric-{% if metrics.day_pct > 80 %}high{% elif metrics.day_pct > 40 %}medium{% elif metrics.day_pct > 0 %}low{% else %}zero{% endif %}"
|
||||
title="{% trans %}Ocupación Hoy{% endtrans %}: {{ metrics.day_count }} {% trans %}clases registradas{% endtrans %}">
|
||||
<div class="metric-label">{% trans %}Hoy{% endtrans %}</div>
|
||||
<div class="metric-val">{% if classroom.is_virtual %}{{ metrics.day_count }} cl.{% else %}{{ metrics.day_pct }}%{% endif %}</div>
|
||||
</a>
|
||||
</div>
|
||||
<!-- Semana -->
|
||||
<div class="col-4">
|
||||
<a href="{{ url_for('schedule.list_reservations', classroom_id=classroom.id, date_from=date_filters.week_start, date_to=date_filters.week_end) }}"
|
||||
class="d-block p-1 text-decoration-none border metric-pill metric-{% if metrics.week_pct > 80 %}high{% elif metrics.week_pct > 40 %}medium{% elif metrics.week_pct > 0 %}low{% else %}zero{% endif %}"
|
||||
title="{% trans %}Ocupación Semana{% endtrans %}: {{ metrics.week_count }} {% trans %}clases registradas{% endtrans %}">
|
||||
<div class="metric-label">{% trans %}Semana{% endtrans %}</div>
|
||||
<div class="metric-val">{% if classroom.is_virtual %}{{ metrics.week_count }} cl.{% else %}{{ metrics.week_pct }}%{% endif %}</div>
|
||||
</a>
|
||||
</div>
|
||||
<!-- Mes -->
|
||||
<div class="col-4">
|
||||
<a href="{{ url_for('schedule.list_reservations', classroom_id=classroom.id, date_from=date_filters.month_start, date_to=date_filters.month_end) }}"
|
||||
class="d-block p-1 text-decoration-none border metric-pill metric-{% if metrics.month_pct > 80 %}high{% elif metrics.month_pct > 40 %}medium{% elif metrics.month_pct > 0 %}low{% else %}zero{% endif %}"
|
||||
title="{% trans %}Ocupación Mes{% endtrans %}: {{ metrics.month_count }} {% trans %}clases registradas{% endtrans %}">
|
||||
<div class="metric-label">{% trans %}Mes{% endtrans %}</div>
|
||||
<div class="metric-val">{% if classroom.is_virtual %}{{ metrics.month_count }} cl.{% else %}{{ metrics.month_pct }}%{% endif %}</div>
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{% if classroom.description %}
|
||||
<p class="card-text small text-muted mt-2">
|
||||
{{ classroom.description[:100] }}{% if classroom.description|length > 100 %}...{% endif %}
|
||||
</p>
|
||||
{% endif %}
|
||||
|
||||
<!-- Resources indicator -->
|
||||
<div class="mt-2">
|
||||
<small class="text-muted">
|
||||
<i class="bi bi-tools"></i>
|
||||
{% if classroom.resources %}
|
||||
{{ classroom.resources|length }} {% trans %}resources{% endtrans %}
|
||||
{% else %}
|
||||
{% trans %}No resources registered{% endtrans %}
|
||||
{% endif %}
|
||||
</small>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="card-footer bg-body-tertiary border-0">
|
||||
<div class="d-flex justify-content-between">
|
||||
<div>
|
||||
|
||||
<!-- Footer con Botones Compactos -->
|
||||
<div class="pt-2 border-top d-flex justify-content-between align-items-center">
|
||||
<div class="btn-group btn-group-sm">
|
||||
<a href="{{ url_for('classrooms.view_classroom', id=classroom.id) }}"
|
||||
class="btn btn-sm btn-outline-primary">
|
||||
<i class="bi bi-eye"></i> {% trans %}View{% endtrans %}
|
||||
class="btn btn-outline-primary py-0 px-2" title="{% trans %}Ver Ficha{% endtrans %}" style="font-size: 0.75rem;">
|
||||
<i class="bi bi-eye me-1"></i>{% trans %}Ficha{% endtrans %}
|
||||
</a>
|
||||
<a href="{{ url_for('classrooms.edit_classroom', id=classroom.id) }}"
|
||||
class="btn btn-sm btn-outline-secondary">
|
||||
<i class="bi bi-pencil"></i> {% trans %}Edit{% endtrans %}
|
||||
class="btn btn-outline-secondary py-0 px-2" title="{% trans %}Editar Aula{% endtrans %}" style="font-size: 0.75rem;">
|
||||
<i class="bi bi-pencil"></i>
|
||||
</a>
|
||||
</div>
|
||||
<form method="POST" action="{{ url_for('classrooms.toggle_classroom', id=classroom.id) }}"
|
||||
class="d-inline">
|
||||
<button type="submit" class="btn btn-sm
|
||||
{% if classroom.is_active %}btn-outline-warning{% else %}btn-outline-success{% endif %}">
|
||||
<form method="POST" action="{{ url_for('classrooms.toggle_classroom', id=classroom.id) }}" class="d-inline mb-0">
|
||||
<button type="submit" class="btn btn-sm py-0 px-2 {% if classroom.is_active %}btn-outline-warning{% else %}btn-outline-success{% endif %}"
|
||||
title="{% if classroom.is_active %}{% trans %}Desactivar{% endtrans %}{% else %}{% trans %}Activar{% endtrans %}{% endif %}" style="font-size: 0.75rem;">
|
||||
{% if classroom.is_active %}
|
||||
<i class="bi bi-pause-circle"></i> {% trans %}Deactivate{% endtrans %}
|
||||
<i class="bi bi-pause"></i>
|
||||
{% else %}
|
||||
<i class="bi bi-play-circle"></i> {% trans %}Activate{% endtrans %}
|
||||
<i class="bi bi-play"></i>
|
||||
{% endif %}
|
||||
</button>
|
||||
</form>
|
||||
|
||||
Reference in New Issue
Block a user