feat(audit): implement institutional audit logging for logins and system operations v3.4.8
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "frontend",
|
||||
"version": "3.4.7",
|
||||
"version": "3.4.8",
|
||||
"description": "",
|
||||
"main": "index.js",
|
||||
"scripts": {
|
||||
|
||||
+3
-3
@@ -85,9 +85,9 @@ const env = nunjucks.configure(path.join(__dirname, '../views'), {
|
||||
});
|
||||
|
||||
// Versiones institucionales del sistema
|
||||
const APP_VERSION = '3.4.7';
|
||||
const FRONTEND_VERSION = '3.4.7';
|
||||
const BACKEND_VERSION = '3.4.7';
|
||||
const APP_VERSION = '3.4.8';
|
||||
const FRONTEND_VERSION = '3.4.8';
|
||||
const BACKEND_VERSION = '3.4.8';
|
||||
|
||||
env.addGlobal('app_version', APP_VERSION);
|
||||
env.addGlobal('frontend_version', FRONTEND_VERSION);
|
||||
|
||||
@@ -1441,16 +1441,65 @@ const handleAuditLogs = async (req, res) => {
|
||||
const search = req.query.search || '';
|
||||
const current_module = req.query.module || '';
|
||||
const current_action = req.query.action || '';
|
||||
res.render('admin/audit_logs', {
|
||||
title: 'Bitácora de Auditoría - Edu-Space Admin',
|
||||
logs: [],
|
||||
modules: ['classrooms', 'reservations', 'users', 'auth', 'academic', 'optimizer'],
|
||||
actions: ['CREATE', 'UPDATE', 'DELETE', 'LOGIN', 'LOGOUT'],
|
||||
current_module,
|
||||
current_action,
|
||||
search,
|
||||
pagination: { pages: 1, page: 1, total: 0, has_prev: false, has_next: false }
|
||||
});
|
||||
const page = parseInt(req.query.page, 10) || 1;
|
||||
|
||||
try {
|
||||
const resp = await req.apiClient.get('/admin/audit-logs', {
|
||||
params: {
|
||||
page,
|
||||
per_page: 25,
|
||||
search,
|
||||
module: current_module,
|
||||
action: current_action
|
||||
}
|
||||
});
|
||||
|
||||
const data = resp.data || {};
|
||||
const audit_logs = data.logs || [];
|
||||
const pagination = data.pagination || { pages: 1, page: 1, total: 0, has_prev: false, has_next: false };
|
||||
|
||||
// Generar lista de números de páginas para la plantilla Nunjucks
|
||||
const pages_list = [];
|
||||
const totalPages = pagination.pages || 1;
|
||||
const maxPages = 7;
|
||||
let startPage = Math.max(1, page - Math.floor(maxPages / 2));
|
||||
let endPage = Math.min(totalPages, startPage + maxPages - 1);
|
||||
if (endPage - startPage + 1 < maxPages) {
|
||||
startPage = Math.max(1, endPage - maxPages + 1);
|
||||
}
|
||||
for (let i = startPage; i <= endPage; i++) {
|
||||
pages_list.push(i);
|
||||
}
|
||||
pagination.pages_list = pages_list;
|
||||
|
||||
const modules = (data.modules && data.modules.length > 0) ? data.modules : ['auth', 'reservations', 'classrooms', 'buildings', 'academic', 'optimizer', 'users', 'admin'];
|
||||
const actions = (data.actions && data.actions.length > 0) ? data.actions : ['LOGIN', 'LOGIN_FAILED', 'LOGOUT', 'CREATE', 'UPDATE', 'DELETE', 'CONFIRM', 'CANCEL'];
|
||||
|
||||
res.render('admin/audit_logs', {
|
||||
title: 'Registro de Auditoría Institucional - Edu-Space Admin',
|
||||
audit_logs,
|
||||
logs: audit_logs,
|
||||
modules,
|
||||
actions,
|
||||
current_module,
|
||||
current_action,
|
||||
search,
|
||||
pagination
|
||||
});
|
||||
} catch (err) {
|
||||
console.warn('[Admin] Error fetching audit logs from backend:', err.response?.data || err.message);
|
||||
res.render('admin/audit_logs', {
|
||||
title: 'Registro de Auditoría Institucional - Edu-Space Admin',
|
||||
audit_logs: [],
|
||||
logs: [],
|
||||
modules: ['auth', 'reservations', 'classrooms', 'buildings', 'academic', 'optimizer', 'users', 'admin'],
|
||||
actions: ['LOGIN', 'LOGIN_FAILED', 'LOGOUT', 'CREATE', 'UPDATE', 'DELETE', 'CONFIRM', 'CANCEL'],
|
||||
current_module,
|
||||
current_action,
|
||||
search,
|
||||
pagination: { pages: 1, page: 1, total: 0, has_prev: false, has_next: false, pages_list: [1] }
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
router.get(['/audit_logs', '/audit-logs', '/audit'], handleAuditLogs);
|
||||
|
||||
@@ -1,39 +1,53 @@
|
||||
{% extends "base.html" %}
|
||||
|
||||
{% block title %}Bitácora de Auditoría - Edu-Space Admin{% endblock %}
|
||||
{% block title %}Registro de Auditoría Institucional - Edu-Space Admin{% endblock %}
|
||||
|
||||
{% block content %}
|
||||
<div class="container-fluid pt-5 mt-4">
|
||||
<!-- Header -->
|
||||
<!-- Header Institucional -->
|
||||
<div class="d-flex justify-content-between align-items-center mb-4 flex-wrap gap-2">
|
||||
<div>
|
||||
<h1 class="h3 mb-1">
|
||||
<i class="bi bi-shield-check text-primary me-2"></i>Registro de Auditoría Institucional
|
||||
</h1>
|
||||
<p class="text-muted small mb-0">Trazabilidad completa de operaciones, modificaciones y eventos de seguridad</p>
|
||||
<p class="text-muted small mb-0">Trazabilidad inmutable de inicios de sesión, cambios en espacios, reservas y operaciones del sistema</p>
|
||||
</div>
|
||||
<div>
|
||||
<a href="/main/dashboard" class="btn btn-outline-secondary btn-sm">
|
||||
<div class="d-flex gap-2">
|
||||
<a href="/admin/audit_logs" class="btn btn-outline-secondary btn-sm" title="Recargar eventos">
|
||||
<i class="bi bi-arrow-clockwise me-1"></i>Actualizar
|
||||
</a>
|
||||
<a href="/main/dashboard" class="btn btn-outline-primary btn-sm">
|
||||
<i class="bi bi-arrow-left me-1"></i>Volver al Panel
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Filtros -->
|
||||
<!-- Filtros y Búsqueda -->
|
||||
<div class="card border-0 shadow-sm mb-4">
|
||||
<div class="card-body p-3">
|
||||
<form method="GET" action="/admin/audit_logs" class="row g-2 align-items-center">
|
||||
<div class="col-md-4">
|
||||
<div class="input-group input-group-sm">
|
||||
<span class="input-group-text bg-transparent"><i class="bi bi-search"></i></span>
|
||||
<input type="text" name="search" class="form-control" placeholder="Buscar por email, IP o detalles..." value="{{ search }}">
|
||||
<input type="text" name="search" class="form-control" placeholder="Buscar por usuario, IP, acción o detalle..." value="{{ search }}">
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-md-3">
|
||||
<select name="module" class="form-select form-select-sm">
|
||||
<option value="">Todos los módulos</option>
|
||||
{% for mod in modules %}
|
||||
<option value="{{ mod }}" {% if current_module == mod %}selected{% endif %}>{{ mod|capitalize }}</option>
|
||||
<option value="{{ mod }}" {% if current_module == mod %}selected{% endif %}>
|
||||
{% if mod == 'auth' %}Autenticación y Sesiones
|
||||
{% elif mod == 'reservations' %}Reservas de Aulas
|
||||
{% elif mod == 'classrooms' %}Gestión de Aulas
|
||||
{% elif mod == 'buildings' %}Sedes y Edificios
|
||||
{% elif mod == 'optimizer' %}Optimizador Genético IA
|
||||
{% elif mod == 'users' %}Usuarios y Roles
|
||||
{% elif mod == 'academic' %}Ciclos y Carreras
|
||||
{% elif mod == 'admin' %}Sistema y Reinicio
|
||||
{% else %}{{ mod|capitalize }}
|
||||
{% endif %}
|
||||
</option>
|
||||
{% endfor %}
|
||||
</select>
|
||||
</div>
|
||||
@@ -41,13 +55,34 @@
|
||||
<select name="action" class="form-select form-select-sm">
|
||||
<option value="">Todas las acciones</option>
|
||||
{% for act in actions %}
|
||||
<option value="{{ act }}" {% if current_action == act %}selected{% endif %}>{{ act }}</option>
|
||||
<option value="{{ act }}" {% if current_action == act %}selected{% endif %}>
|
||||
{% if act == 'LOGIN' %}Inicio de Sesión (Local)
|
||||
{% elif act == 'LOGIN_GOOGLE' %}Inicio de Sesión (Google)
|
||||
{% elif act == 'LOGIN_MOODLE' %}Inicio de Sesión (Moodle)
|
||||
{% elif act == 'LOGIN_FAILED' %}Inicio de Sesión Fallido
|
||||
{% elif act == 'LOGIN_BLOCKED' %}Acceso Bloqueado
|
||||
{% elif act == 'LOGOUT' %}Cierre de Sesión
|
||||
{% elif act == 'PASSWORD_CHANGE' %}Cambio de Contraseña
|
||||
{% elif act == 'IMPERSONATE_START' %}Inicio Impersonación
|
||||
{% elif act == 'IMPERSONATE_END' %}Fin Impersonación
|
||||
{% elif act == 'CREATE' %}Creación (Alta)
|
||||
{% elif act == 'UPDATE' %}Modificación (Edición)
|
||||
{% elif act == 'DELETE' %}Eliminación (Baja)
|
||||
{% elif act == 'CANCEL' %}Cancelación
|
||||
{% elif act == 'CONFIRM' %}Confirmación
|
||||
{% elif act == 'TOGGLE' %}Alternar Estado
|
||||
{% elif act == 'OPTIMIZE_RUN' %}Ejecución Optimizador IA
|
||||
{% elif act == 'OPTIMIZE_APPLY' %}Aplicación Optimizador IA
|
||||
{% elif act == 'SYSTEM_RESET' %}Reinicio del Sistema
|
||||
{% else %}{{ act }}
|
||||
{% endif %}
|
||||
</option>
|
||||
{% endfor %}
|
||||
</select>
|
||||
</div>
|
||||
<div class="col-md-2 d-flex gap-1">
|
||||
<button type="submit" class="btn btn-primary btn-sm flex-grow-1">
|
||||
<i class="bi bi-filter me-1"></i>Filtrar
|
||||
<i class="bi bi-funnel me-1"></i>Filtrar
|
||||
</button>
|
||||
{% if search or current_module or current_action %}
|
||||
<a href="/admin/audit_logs" class="btn btn-outline-secondary btn-sm" title="Limpiar filtros">
|
||||
@@ -56,58 +91,188 @@
|
||||
{% endif %}
|
||||
</div>
|
||||
</form>
|
||||
|
||||
<!-- Acceso Rápido por Categorías -->
|
||||
<div class="d-flex flex-wrap gap-1 mt-3 pt-2 border-top">
|
||||
<span class="text-muted small align-self-center me-2"><i class="bi bi-lightning-charge me-1"></i>Filtros rápidos:</span>
|
||||
<a href="/admin/audit_logs?module=auth" class="badge rounded-pill text-decoration-none {% if current_module == 'auth' %}bg-primary text-white{% else %}bg-light text-dark border{% endif %}">
|
||||
<i class="bi bi-key me-1"></i>Sesiones y Accesos
|
||||
</a>
|
||||
<a href="/admin/audit_logs?action=LOGIN_FAILED" class="badge rounded-pill text-decoration-none {% if current_action == 'LOGIN_FAILED' %}bg-danger text-white{% else %}bg-light text-danger border{% endif %}">
|
||||
<i class="bi bi-shield-x me-1"></i>Fallos de Login
|
||||
</a>
|
||||
<a href="/admin/audit_logs?module=reservations" class="badge rounded-pill text-decoration-none {% if current_module == 'reservations' %}bg-primary text-white{% else %}bg-light text-dark border{% endif %}">
|
||||
<i class="bi bi-calendar-event me-1"></i>Reservas
|
||||
</a>
|
||||
<a href="/admin/audit_logs?module=classrooms" class="badge rounded-pill text-decoration-none {% if current_module == 'classrooms' %}bg-primary text-white{% else %}bg-light text-dark border{% endif %}">
|
||||
<i class="bi bi-door-open me-1"></i>Aulas
|
||||
</a>
|
||||
<a href="/admin/audit_logs?module=buildings" class="badge rounded-pill text-decoration-none {% if current_module == 'buildings' %}bg-primary text-white{% else %}bg-light text-dark border{% endif %}">
|
||||
<i class="bi bi-building me-1"></i>Sedes
|
||||
</a>
|
||||
<a href="/admin/audit_logs?module=optimizer" class="badge rounded-pill text-decoration-none {% if current_module == 'optimizer' %}bg-primary text-white{% else %}bg-light text-dark border{% endif %}">
|
||||
<i class="bi bi-cpu me-1"></i>Optimizador IA
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Tabla de Auditoría -->
|
||||
<div class="card border-0 shadow-sm">
|
||||
<div class="card-body p-0">
|
||||
{% if audit_logs %}
|
||||
{% if audit_logs and audit_logs.length > 0 %}
|
||||
<div class="table-responsive">
|
||||
<table class="table table-hover align-middle mb-0">
|
||||
<thead class="table-light small text-uppercase">
|
||||
<tr>
|
||||
<th class="ps-3">Fecha / Hora</th>
|
||||
<th>Usuario</th>
|
||||
<th>Acción</th>
|
||||
<th>Módulo</th>
|
||||
<th>ID Entidad</th>
|
||||
<th>Detalles</th>
|
||||
<th class="pe-3">IP</th>
|
||||
<th class="ps-3" style="width: 170px;">Fecha / Hora</th>
|
||||
<th style="min-width: 180px;">Usuario</th>
|
||||
<th style="width: 160px;">Acción</th>
|
||||
<th style="width: 130px;">Módulo</th>
|
||||
<th style="width: 90px;">ID</th>
|
||||
<th>Detalles de la Operación</th>
|
||||
<th class="pe-3 text-end" style="width: 130px;">IP Origen</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{% for log in audit_logs %}
|
||||
<tr>
|
||||
<td class="ps-3 text-nowrap">
|
||||
<span class="small font-monospace">{{ log.created_at }}</span>
|
||||
<span class="small font-monospace text-dark fw-semibold">
|
||||
{{ log.created_at or log.created_at_iso or '-' }}
|
||||
</span>
|
||||
</td>
|
||||
<td>
|
||||
<div class="fw-semibold small">{{ log.user_email or 'Sistema' }}</div>
|
||||
<div class="d-flex align-items-center gap-2">
|
||||
<div class="avatar-sm rounded-circle d-flex align-items-center justify-content-center small {% if 'FAILED' in log.action or 'BLOCKED' in log.action %}bg-danger-subtle text-danger{% elif 'LOGIN' in log.action %}bg-success-subtle text-success{% else %}bg-primary-subtle text-primary{% endif %}" style="width: 28px; height: 28px;">
|
||||
{% if 'LOGIN' in log.action %}
|
||||
<i class="bi bi-person-check"></i>
|
||||
{% elif 'FAILED' in log.action %}
|
||||
<i class="bi bi-person-x"></i>
|
||||
{% elif 'IMPERSONATE' in log.action %}
|
||||
<i class="bi bi-person-badge"></i>
|
||||
{% else %}
|
||||
<i class="bi bi-person"></i>
|
||||
{% endif %}
|
||||
</div>
|
||||
<div>
|
||||
<div class="fw-semibold small text-truncate" style="max-width: 200px;" title="{{ log.user_email or 'Sistema' }}">
|
||||
{{ log.user_email or 'Sistema' }}
|
||||
</div>
|
||||
{% if log.user_id %}
|
||||
<span class="text-muted" style="font-size: 0.75rem;">ID Usuario: #{{ log.user_id }}</span>
|
||||
{% endif %}
|
||||
</div>
|
||||
</div>
|
||||
</td>
|
||||
<td>
|
||||
{% if log.action == 'CREATE' %}
|
||||
<span class="badge bg-success-subtle text-success border border-success-subtle">{{ log.action }}</span>
|
||||
<span class="badge bg-success-subtle text-success border border-success-subtle px-2 py-1">
|
||||
<i class="bi bi-plus-circle me-1"></i>ALTA
|
||||
</span>
|
||||
{% elif log.action == 'UPDATE' %}
|
||||
<span class="badge bg-primary-subtle text-primary border border-primary-subtle">{{ log.action }}</span>
|
||||
<span class="badge bg-primary-subtle text-primary border border-primary-subtle px-2 py-1">
|
||||
<i class="bi bi-pencil-square me-1"></i>EDICIÓN
|
||||
</span>
|
||||
{% elif log.action == 'DELETE' %}
|
||||
<span class="badge bg-danger-subtle text-danger border border-danger-subtle">{{ log.action }}</span>
|
||||
{% elif 'LOGIN' in log.action %}
|
||||
<span class="badge bg-info-subtle text-info border border-info-subtle">{{ log.action }}</span>
|
||||
<span class="badge bg-danger-subtle text-danger border border-danger-subtle px-2 py-1">
|
||||
<i class="bi bi-trash me-1"></i>BAJA
|
||||
</span>
|
||||
{% elif log.action == 'CANCEL' %}
|
||||
<span class="badge bg-warning-subtle text-warning-emphasis border border-warning-subtle px-2 py-1">
|
||||
<i class="bi bi-dash-circle me-1"></i>CANCELACIÓN
|
||||
</span>
|
||||
{% elif log.action == 'CONFIRM' %}
|
||||
<span class="badge bg-info-subtle text-info-emphasis border border-info-subtle px-2 py-1">
|
||||
<i class="bi bi-check-circle me-1"></i>CONFIRMADA
|
||||
</span>
|
||||
{% elif log.action == 'TOGGLE' %}
|
||||
<span class="badge bg-secondary-subtle text-secondary border px-2 py-1">
|
||||
<i class="bi bi-toggle-on me-1"></i>ESTADO
|
||||
</span>
|
||||
{% elif log.action == 'LOGIN' %}
|
||||
<span class="badge bg-success-subtle text-success border border-success-subtle px-2 py-1">
|
||||
<i class="bi bi-box-arrow-in-right me-1"></i>LOGIN LOCAL
|
||||
</span>
|
||||
{% elif log.action == 'LOGIN_GOOGLE' %}
|
||||
<span class="badge bg-info-subtle text-primary border border-info-subtle px-2 py-1">
|
||||
<i class="bi bi-google me-1"></i>LOGIN GOOGLE
|
||||
</span>
|
||||
{% elif log.action == 'LOGIN_MOODLE' %}
|
||||
<span class="badge bg-warning-subtle text-dark border border-warning-subtle px-2 py-1">
|
||||
<i class="bi bi-mortarboard me-1"></i>LOGIN MOODLE
|
||||
</span>
|
||||
{% elif log.action == 'LOGIN_FAILED' %}
|
||||
<span class="badge bg-danger text-white px-2 py-1">
|
||||
<i class="bi bi-shield-x me-1"></i>LOGIN FALLIDO
|
||||
</span>
|
||||
{% elif log.action == 'LOGIN_BLOCKED' %}
|
||||
<span class="badge bg-danger-subtle text-danger border border-danger-subtle px-2 py-1">
|
||||
<i class="bi bi-slash-circle me-1"></i>BLOQUEADO
|
||||
</span>
|
||||
{% elif log.action == 'LOGOUT' %}
|
||||
<span class="badge bg-secondary-subtle text-secondary border px-2 py-1">
|
||||
<i class="bi bi-box-arrow-right me-1"></i>LOGOUT
|
||||
</span>
|
||||
{% elif log.action == 'PASSWORD_CHANGE' %}
|
||||
<span class="badge bg-purple-subtle text-purple border px-2 py-1" style="background-color: #f3e8ff; color: #6b21a8;">
|
||||
<i class="bi bi-key me-1"></i>CAMBIO CLAVE
|
||||
</span>
|
||||
{% elif log.action == 'IMPERSONATE_START' %}
|
||||
<span class="badge bg-warning text-dark px-2 py-1">
|
||||
<i class="bi bi-person-badge me-1"></i>IMPERSONACIÓN
|
||||
</span>
|
||||
{% elif log.action == 'IMPERSONATE_END' %}
|
||||
<span class="badge bg-light text-dark border px-2 py-1">
|
||||
<i class="bi bi-person-check me-1"></i>FIN IMPERSON.
|
||||
</span>
|
||||
{% elif log.action == 'OPTIMIZE_RUN' %}
|
||||
<span class="badge bg-info text-white px-2 py-1">
|
||||
<i class="bi bi-cpu me-1"></i>CORRIDA IA
|
||||
</span>
|
||||
{% elif log.action == 'OPTIMIZE_APPLY' %}
|
||||
<span class="badge bg-success text-white px-2 py-1">
|
||||
<i class="bi bi-magic me-1"></i>APLICACIÓN IA
|
||||
</span>
|
||||
{% elif log.action == 'SYSTEM_RESET' %}
|
||||
<span class="badge bg-danger text-white px-2 py-1">
|
||||
<i class="bi bi-arrow-counterclockwise me-1"></i>REINICIO SISTEMA
|
||||
</span>
|
||||
{% else %}
|
||||
<span class="badge bg-secondary-subtle text-secondary border">{{ log.action }}</span>
|
||||
<span class="badge bg-secondary-subtle text-secondary border px-2 py-1">{{ log.action }}</span>
|
||||
{% endif %}
|
||||
</td>
|
||||
<td>
|
||||
<span class="badge bg-body-secondary text-body border font-monospace small">{{ log.module }}</span>
|
||||
{% if log.module == 'auth' %}
|
||||
<span class="badge bg-primary-subtle text-primary border font-monospace small">auth</span>
|
||||
{% elif log.module == 'reservations' %}
|
||||
<span class="badge bg-info-subtle text-info border font-monospace small">reservas</span>
|
||||
{% elif log.module == 'classrooms' %}
|
||||
<span class="badge bg-success-subtle text-success border font-monospace small">aulas</span>
|
||||
{% elif log.module == 'buildings' %}
|
||||
<span class="badge bg-warning-subtle text-dark border font-monospace small">sedes</span>
|
||||
{% elif log.module == 'optimizer' %}
|
||||
<span class="badge bg-dark text-white font-monospace small">optimizador</span>
|
||||
{% else %}
|
||||
<span class="badge bg-body-secondary text-body border font-monospace small">{{ log.module }}</span>
|
||||
{% endif %}
|
||||
</td>
|
||||
<td class="font-monospace small text-muted">
|
||||
{{ log.entity_id or '-' }}
|
||||
</td>
|
||||
<td class="small text-muted" style="max-width: 320px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;" title="{{ log.details }}">
|
||||
{{ log.details or '-' }}
|
||||
<td>
|
||||
<div class="d-flex align-items-center justify-content-between gap-2">
|
||||
<div class="small text-muted text-truncate" style="max-width: 480px;" title="{{ log.details }}">
|
||||
{{ log.details or '-' }}
|
||||
</div>
|
||||
{% if log.details and log.details.length > 50 %}
|
||||
<button type="button" class="btn btn-link btn-sm p-0 text-decoration-none text-primary" onclick="showLogDetailModal('{{ log.id }}', '{{ log.action }}', '{{ log.module }}', '{{ log.user_email or 'Sistema' }}', '{{ log.created_at }}', '{{ log.ip_address }}', {{ log.details | dump | escape }})">
|
||||
<i class="bi bi-eye"></i>
|
||||
</button>
|
||||
{% endif %}
|
||||
</div>
|
||||
</td>
|
||||
<td class="pe-3 font-monospace small text-muted">
|
||||
<td class="pe-3 text-end font-monospace small text-muted">
|
||||
{{ log.ip_address or '-' }}
|
||||
</td>
|
||||
</tr>
|
||||
@@ -116,31 +281,29 @@
|
||||
</table>
|
||||
</div>
|
||||
|
||||
<!-- Paginación -->
|
||||
<!-- Paginación Dinámica -->
|
||||
{% if pagination.pages > 1 %}
|
||||
<div class="p-3 border-top d-flex justify-content-between align-items-center">
|
||||
<div class="p-3 border-top d-flex justify-content-between align-items-center flex-wrap gap-2">
|
||||
<small class="text-muted">
|
||||
Mostrando página {{ pagination.page }} de {{ pagination.pages }} ({{ pagination.total }} registros)
|
||||
Mostrando página {{ pagination.page }} de {{ pagination.pages }} (Total: <strong>{{ pagination.total }}</strong> eventos registrados)
|
||||
</small>
|
||||
<nav>
|
||||
<nav aria-label="Navegación de auditoría">
|
||||
<ul class="pagination pagination-sm mb-0">
|
||||
<li class="page-item {% if not pagination.has_prev %}disabled{% endif %}">
|
||||
<a class="page-link" href="/admin/audit_logs">
|
||||
«
|
||||
<a class="page-link" href="/admin/audit_logs?page={{ pagination.page - 1 }}{% if search %}&search={{ search }}{% endif %}{% if current_module %}&module={{ current_module }}{% endif %}{% if current_action %}&action={{ current_action }}{% endif %}">
|
||||
« Anterior
|
||||
</a>
|
||||
</li>
|
||||
{% for p in pagination.iter_pages(left_edge=2, left_current=2, right_current=3, right_edge=2) %}
|
||||
{% if p %}
|
||||
<li class="page-item {% if p == pagination.page %}active{% endif %}">
|
||||
<a class="page-link" href="/admin/audit_logs">{{ p }}</a>
|
||||
</li>
|
||||
{% else %}
|
||||
<li class="page-item disabled"><span class="page-link">…</span></li>
|
||||
{% endif %}
|
||||
{% for p in pagination.pages_list %}
|
||||
<li class="page-item {% if p == pagination.page %}active{% endif %}">
|
||||
<a class="page-link" href="/admin/audit_logs?page={{ p }}{% if search %}&search={{ search }}{% endif %}{% if current_module %}&module={{ current_module }}{% endif %}{% if current_action %}&action={{ current_action }}{% endif %}">
|
||||
{{ p }}
|
||||
</a>
|
||||
</li>
|
||||
{% endfor %}
|
||||
<li class="page-item {% if not pagination.has_next %}disabled{% endif %}">
|
||||
<a class="page-link" href="/admin/audit_logs">
|
||||
»
|
||||
<a class="page-link" href="/admin/audit_logs?page={{ pagination.page + 1 }}{% if search %}&search={{ search }}{% endif %}{% if current_module %}&module={{ current_module }}{% endif %}{% if current_action %}&action={{ current_action }}{% endif %}">
|
||||
Siguiente »
|
||||
</a>
|
||||
</li>
|
||||
</ul>
|
||||
@@ -152,10 +315,92 @@
|
||||
<div class="text-center py-5">
|
||||
<i class="bi bi-shield-slash text-muted fs-1 d-block mb-2"></i>
|
||||
<h6 class="fw-bold">No se encontraron registros de auditoría</h6>
|
||||
<p class="text-muted small">Los eventos del sistema se registrarán automáticamente a medida que ocurran cambios.</p>
|
||||
<p class="text-muted small">Los eventos de inicio de sesión y modificaciones de espacios áulicos se registrarán automáticamente a medida que ocurran.</p>
|
||||
{% if search or current_module or current_action %}
|
||||
<a href="/admin/audit_logs" class="btn btn-outline-primary btn-sm mt-2">
|
||||
<i class="bi bi-x-circle me-1"></i>Limpiar filtros de búsqueda
|
||||
</a>
|
||||
{% endif %}
|
||||
</div>
|
||||
{% endif %}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Modal de Detalle Extendido -->
|
||||
<div class="modal fade" id="logDetailModal" tabindex="-1" aria-labelledby="logDetailModalLabel" aria-hidden="true">
|
||||
<div class="modal-dialog modal-dialog-centered modal-lg">
|
||||
<div class="modal-content">
|
||||
<div class="modal-header">
|
||||
<h5 class="modal-title" id="logDetailModalLabel">
|
||||
<i class="bi bi-info-circle text-primary me-2"></i>Detalle del Registro de Auditoría
|
||||
</h5>
|
||||
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Cerrar"></button>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
<div class="row g-2 mb-3 small">
|
||||
<div class="col-sm-6">
|
||||
<span class="text-muted">Fecha y Hora:</span>
|
||||
<div class="fw-semibold font-monospace" id="modalLogTime">-</div>
|
||||
</div>
|
||||
<div class="col-sm-6">
|
||||
<span class="text-muted">Usuario Actuante:</span>
|
||||
<div class="fw-semibold" id="modalLogUser">-</div>
|
||||
</div>
|
||||
<div class="col-sm-4">
|
||||
<span class="text-muted">Acción:</span>
|
||||
<div class="fw-semibold" id="modalLogAction">-</div>
|
||||
</div>
|
||||
<div class="col-sm-4">
|
||||
<span class="text-muted">Módulo:</span>
|
||||
<div class="fw-semibold" id="modalLogModule">-</div>
|
||||
</div>
|
||||
<div class="col-sm-4">
|
||||
<span class="text-muted">IP de Conexión:</span>
|
||||
<div class="fw-semibold font-monospace" id="modalLogIp">-</div>
|
||||
</div>
|
||||
</div>
|
||||
<div>
|
||||
<label class="form-label small fw-semibold text-muted">Contenido del Evento / Payload:</label>
|
||||
<pre class="bg-light p-3 rounded border font-monospace small mb-0" id="modalLogDetails" style="max-height: 300px; overflow-y: auto; white-space: pre-wrap; word-break: break-word;"></pre>
|
||||
</div>
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<button type="button" class="btn btn-outline-secondary btn-sm" onclick="copyModalDetails()">
|
||||
<i class="bi bi-clipboard me-1"></i>Copiar Detalle
|
||||
</button>
|
||||
<button type="button" class="btn btn-secondary btn-sm" data-bs-dismiss="modal">Cerrar</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script>
|
||||
function showLogDetailModal(id, action, module, user, time, ip, details) {
|
||||
document.getElementById('modalLogTime').textContent = time || '-';
|
||||
document.getElementById('modalLogUser').textContent = user || 'Sistema';
|
||||
document.getElementById('modalLogAction').textContent = action || '-';
|
||||
document.getElementById('modalLogModule').textContent = module || '-';
|
||||
document.getElementById('modalLogIp').textContent = ip || '-';
|
||||
|
||||
let formatted = details || '';
|
||||
try {
|
||||
const parsed = JSON.parse(details);
|
||||
formatted = JSON.stringify(parsed, null, 2);
|
||||
} catch(e) {
|
||||
// es texto plano
|
||||
}
|
||||
document.getElementById('modalLogDetails').textContent = formatted;
|
||||
|
||||
const modal = new bootstrap.Modal(document.getElementById('logDetailModal'));
|
||||
modal.show();
|
||||
}
|
||||
|
||||
function copyModalDetails() {
|
||||
const text = document.getElementById('modalLogDetails').textContent;
|
||||
navigator.clipboard.writeText(text).then(() => {
|
||||
alert('Detalle copiado al portapapeles.');
|
||||
});
|
||||
}
|
||||
</script>
|
||||
{% endblock %}
|
||||
|
||||
@@ -1127,7 +1127,7 @@
|
||||
|
||||
<div class="sidebar-footer-text mt-3 pt-2 border-top border-secondary-subtle text-center">
|
||||
<span class="badge bg-secondary-subtle text-secondary-emphasis font-monospace px-2 py-1" style="font-size:0.68rem;" title="Versión Institucional de Edu-Space">
|
||||
<i class="bi bi-tag-fill me-1"></i>v{{ app_version or '3.4.7' }} <span class="opacity-75">(FE: {{ frontend_version or '3.4.7' }} · BE: {{ backend_version or '3.4.7' }})</span>
|
||||
<i class="bi bi-tag-fill me-1"></i>v{{ app_version or '3.4.8' }} <span class="opacity-75">(FE: {{ frontend_version or '3.4.8' }} · BE: {{ backend_version or '3.4.8' }})</span>
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user