all_notifications.html 26 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594
  1. {% extends "layouts/base.html" %}
  2. {% block styles %}
  3. <style>
  4. .notification-fade-in {
  5. animation: fadeIn 0.3s ease-in-out;
  6. }
  7. @keyframes fadeIn {
  8. from { opacity: 0; transform: translateY(-10px); }
  9. to { opacity: 1; transform: translateY(0); }
  10. }
  11. .notification-item {
  12. transition: all 0.2s ease;
  13. }
  14. .notification-read {
  15. opacity: 0.7;
  16. background-color: #f9fafb;
  17. }
  18. .notification-removing {
  19. opacity: 0;
  20. transform: translateX(-100%);
  21. transition: all 0.3s ease;
  22. }
  23. .pagination-btn:disabled {
  24. opacity: 0.5;
  25. cursor: not-allowed;
  26. }
  27. </style>
  28. {% endblock %}
  29. {% block header_actions %}
  30. <div class="flex flex-col sm:flex-row items-stretch sm:items-center gap-2 w-full sm:w-auto">
  31. <!-- Counter -->
  32. <div class="bg-blue-50 px-3 py-1.5 rounded-lg border border-blue-200 flex-shrink-0 text-center">
  33. <span class="text-xs sm:text-sm text-blue-700 font-medium">
  34. <span id="unread-count">{{ unread_count }}</span> No leídas
  35. </span>
  36. </div>
  37. <!-- Mark all as read button -->
  38. <button id="mark-all-read" class="bg-green-600 hover:bg-green-700 text-white px-3 sm:px-4 py-2 rounded-lg transition-colors duration-200 flex items-center justify-center gap-2 text-sm flex-1 sm:flex-none">
  39. <i class="fas fa-check-double"></i>
  40. <span class="hidden xs:inline">Marcar todas</span>
  41. </button>
  42. <!-- Delete all button -->
  43. <button id="delete-all" class="bg-red-600 hover:bg-red-700 text-white px-3 sm:px-4 py-2 rounded-lg transition-colors duration-200 flex items-center justify-center gap-2 text-sm flex-1 sm:flex-none">
  44. <i class="fas fa-trash"></i>
  45. <span class="hidden xs:inline">Eliminar todas</span>
  46. </button>
  47. </div>
  48. {% endblock %}
  49. {% block content %}
  50. <div class="w-full space-y-6">
  51. <!-- Filters -->
  52. <div class="bg-white rounded-lg shadow-sm border border-gray-200 p-4">
  53. <div class="flex flex-wrap gap-4 items-center">
  54. <div class="flex items-center gap-2">
  55. <span class="text-sm font-medium text-gray-700">Filtrar por:</span>
  56. <select id="filter-type" class="text-sm border border-gray-300 rounded-lg px-3 py-1 focus:outline-none focus:ring-2 focus:ring-blue-500 min-w-[140px]">
  57. <option value="all">Todos los tipos</option>
  58. <option value="error">Errores</option>
  59. <option value="warning">Advertencias</option>
  60. <option value="success">Éxitos</option>
  61. <option value="info">Información</option>
  62. </select>
  63. </div>
  64. <div class="flex items-center gap-2">
  65. <select id="filter-source" class="text-sm border border-gray-300 rounded-lg px-3 py-1 focus:outline-none focus:ring-2 focus:ring-blue-500 min-w-[150px]">
  66. <option value="all">Todas las fuentes</option>
  67. <option value="squid">Squid</option>
  68. <option value="system">Sistema</option>
  69. <option value="security">Seguridad</option>
  70. <option value="users">Usuarios</option>
  71. <option value="git">Git</option>
  72. </select>
  73. </div>
  74. <div class="flex items-center gap-2">
  75. <select id="filter-status" class="text-sm border border-gray-300 rounded-lg px-3 py-1 focus:outline-none focus:ring-2 focus:ring-blue-500 min-w-[155px]">
  76. <option value="all">Todos los estados</option>
  77. <option value="unread">Sin leer</option>
  78. <option value="read">Leída</option>
  79. </select>
  80. </div>
  81. <button id="clear-filters" class="text-sm text-gray-600 hover:text-gray-800 flex items-center gap-1">
  82. <i class="fas fa-times"></i>
  83. <span>Limpiar filtros</span>
  84. </button>
  85. </div>
  86. </div>
  87. <!-- Pagination information -->
  88. <div class="bg-white rounded-lg shadow-sm border border-gray-200 p-4">
  89. <div class="flex flex-col sm:flex-row justify-between items-center gap-4">
  90. <div class="text-sm text-gray-600">
  91. Mostrando <span id="current-range">1-{{ notifications|length }}</span> de
  92. <span id="total-notifications">{{ pagination.total_notifications if pagination else notifications|length }}</span> notificaciones
  93. </div>
  94. <div class="flex items-center gap-2">
  95. <button id="prev-page" class="pagination-btn px-3 py-1 bg-gray-200 rounded hover:bg-gray-300 disabled:opacity-50 disabled:cursor-not-allowed transition-colors"
  96. {% if not pagination or not pagination.has_prev %}disabled{% endif %}>
  97. <i class="fas fa-chevron-left"></i>
  98. </button>
  99. <span id="page-info" class="px-3 py-1 text-gray-700 text-sm">
  100. Página {{ pagination.current_page if pagination else 1 }} de {{ pagination.total_pages if pagination else 1 }}
  101. </span>
  102. <button id="next-page" class="pagination-btn px-3 py-1 bg-gray-200 rounded hover:bg-gray-300 disabled:opacity-50 disabled:cursor-not-allowed transition-colors"
  103. {% if not pagination or not pagination.has_next %}disabled{% endif %}>
  104. <i class="fas fa-chevron-right"></i>
  105. </button>
  106. </div>
  107. </div>
  108. </div>
  109. <!-- Notifications List -->
  110. <div class="bg-white rounded-lg shadow-sm border border-gray-200 overflow-hidden">
  111. {% if notifications %}
  112. <div id="notifications-list">
  113. {% for notification in notifications %}
  114. <div class="notification-item border-b border-gray-100 last:border-b-0 {% if notification.read %}notification-read{% endif %}"
  115. data-id="{{ notification.id }}"
  116. data-type="{{ notification.type }}"
  117. data-source="{{ notification.source }}"
  118. data-read="{{ notification.read|lower }}">
  119. <div class="p-6 flex items-start gap-4">
  120. <!-- Icon -->
  121. <div class="flex-shrink-0">
  122. <div class="w-12 h-12 rounded-full flex items-center justify-center
  123. {% if notification.type == 'error' %}bg-red-100 text-red-600
  124. {% elif notification.type == 'warning' %}bg-yellow-100 text-yellow-600
  125. {% elif notification.type == 'success' %}bg-green-100 text-green-600
  126. {% else %}bg-blue-100 text-blue-600{% endif %}">
  127. <i class="fas {{ notification.icon }} text-lg"></i>
  128. </div>
  129. </div>
  130. <!-- Content -->
  131. <div class="flex-1 min-w-0">
  132. <div class="flex items-start justify-between mb-2">
  133. <div>
  134. <span class="inline-flex items-center px-2.5 py-0.5 rounded-full text-xs font-medium
  135. {% if notification.type == 'error' %}bg-red-100 text-red-800
  136. {% elif notification.type == 'warning' %}bg-yellow-100 text-yellow-800
  137. {% elif notification.type == 'success' %}bg-green-100 text-green-800
  138. {% else %}bg-blue-100 text-blue-800{% endif %}">
  139. {{ notification.source|upper }}
  140. </span>
  141. <span class="ml-2 text-sm text-gray-500">{{ notification.time }}</span>
  142. </div>
  143. {% if not notification.read %}
  144. <span class="inline-flex items-center px-2 py-1 rounded-full text-xs font-medium bg-blue-100 text-blue-800">
  145. No leída
  146. </span>
  147. {% endif %}
  148. </div>
  149. <p class="text-gray-900 font-medium mb-1">{{ notification.message }}</p>
  150. <div class="flex items-center gap-4 mt-3 text-sm text-gray-500">
  151. <span class="flex items-center gap-1">
  152. <i class="fas fa-clock"></i>
  153. <span>{{ notification.timestamp|datetime_format }}</span>
  154. </span>
  155. <span class="flex items-center gap-1">
  156. <i class="fas fa-{{ notification.icon }}"></i>
  157. <span class="capitalize">{{ notification.type }}</span>
  158. </span>
  159. </div>
  160. </div>
  161. <!-- Actions -->
  162. <div class="flex-shrink-0 flex items-center gap-2">
  163. {% if not notification.read %}
  164. <button class="mark-read-btn text-green-600 hover:text-green-800 p-2 rounded-lg hover:bg-green-50 transition-colors duration-150"
  165. data-id="{{ notification.id }}"
  166. title="Marcar como leída">
  167. <i class="fas fa-check"></i>
  168. </button>
  169. {% endif %}
  170. <button class="delete-btn text-red-600 hover:text-red-800 p-2 rounded-lg hover:bg-red-50 transition-colors duration-150"
  171. data-id="{{ notification.id }}"
  172. title="Eliminar notificación">
  173. <i class="fas fa-trash"></i>
  174. </button>
  175. </div>
  176. </div>
  177. </div>
  178. {% endfor %}
  179. </div>
  180. {% else %}
  181. <!-- Empty state -->
  182. <div class="text-center py-16">
  183. <div class="w-24 h-24 mx-auto mb-4 rounded-full bg-gray-100 flex items-center justify-center">
  184. <i class="fas fa-bell-slash text-gray-400 text-3xl"></i>
  185. </div>
  186. <h3 class="text-lg font-medium text-gray-900 mb-2">No hay notificaciones</h3>
  187. <p class="text-gray-500 max-w-md mx-auto">Todas las notificaciones aparecerán aquí. ¡Mantente atento a las actualizaciones del sistema!</p>
  188. </div>
  189. {% endif %}
  190. </div>
  191. </div>
  192. {% endblock %}
  193. {% block scripts %}
  194. <script>
  195. document.addEventListener('DOMContentLoaded', function() {
  196. const csrfToken = document.querySelector('meta[name="csrf-token"]').getAttribute('content');
  197. let currentPage = {{ pagination.current_page if pagination else 1 }};
  198. const totalPages = {{ pagination.total_pages if pagination else 1 }};
  199. const perPage = {{ pagination.per_page if pagination else 20 }};
  200. // Función para mostrar toast usando toastr
  201. function showToast(message, type = 'info') {
  202. if (window.toastr) {
  203. if (type === 'error') {
  204. toastr.error(message);
  205. } else if (type === 'success') {
  206. toastr.success(message);
  207. } else if (type === 'warning') {
  208. toastr.warning(message);
  209. } else {
  210. toastr.info(message);
  211. }
  212. }
  213. }
  214. // Function to load notifications with pagination
  215. function loadNotifications(page = currentPage) {
  216. const url = `/api/notifications?page=${page}&per_page=${perPage}`;
  217. fetch(url)
  218. .then(response => response.json())
  219. .then(data => {
  220. if (data.notifications && data.notifications.length > 0) {
  221. renderNotifications(data.notifications);
  222. updatePagination(data.pagination);
  223. } else {
  224. showEmptyState();
  225. }
  226. })
  227. .catch(error => {
  228. console.error('Error loading notifications:', error);
  229. showToast('Error al cargar notificaciones', 'error');
  230. });
  231. }
  232. // Function to render notifications
  233. function renderNotifications(notifications) {
  234. const container = document.getElementById('notifications-list');
  235. if (!container) return;
  236. container.innerHTML = notifications.map(notification => `
  237. <div class="notification-item border-b border-gray-100 last:border-b-0 ${notification.read ? 'notification-read' : ''}"
  238. data-id="${notification.id}"
  239. data-type="${notification.type}"
  240. data-source="${notification.source}"
  241. data-read="${notification.read}">
  242. <div class="p-6 flex items-start gap-4">
  243. <div class="flex-shrink-0">
  244. <div class="w-12 h-12 rounded-full flex items-center justify-center
  245. ${notification.type === 'error' ? 'bg-red-100 text-red-600' :
  246. notification.type === 'warning' ? 'bg-yellow-100 text-yellow-600' :
  247. notification.type === 'success' ? 'bg-green-100 text-green-600' :
  248. 'bg-blue-100 text-blue-600'}">
  249. <i class="fas ${notification.icon} text-lg"></i>
  250. </div>
  251. </div>
  252. <div class="flex-1 min-w-0">
  253. <div class="flex items-start justify-between mb-2">
  254. <div>
  255. <span class="inline-flex items-center px-2.5 py-0.5 rounded-full text-xs font-medium
  256. ${notification.type === 'error' ? 'bg-red-100 text-red-800' :
  257. notification.type === 'warning' ? 'bg-yellow-100 text-yellow-800' :
  258. notification.type === 'success' ? 'bg-green-100 text-green-800' :
  259. 'bg-blue-100 text-blue-800'}">
  260. ${notification.source.toUpperCase()}
  261. </span>
  262. <span class="ml-2 text-sm text-gray-500">${formatTimeAgo(notification.timestamp)}</span>
  263. </div>
  264. ${!notification.read ? `
  265. <span class="inline-flex items-center px-2 py-1 rounded-full text-xs font-medium bg-blue-100 text-blue-800">
  266. No leída
  267. </span>
  268. ` : ''}
  269. </div>
  270. <p class="text-gray-900 font-medium mb-1">${notification.message}</p>
  271. <div class="flex items-center gap-4 mt-3 text-sm text-gray-500">
  272. <span class="flex items-center gap-1">
  273. <i class="fas fa-clock"></i>
  274. <span>${new Date(notification.timestamp).toLocaleString('es-ES')}</span>
  275. </span>
  276. <span class="flex items-center gap-1">
  277. <i class="fas fa-${notification.icon}"></i>
  278. <span class="capitalize">${notification.type}</span>
  279. </span>
  280. </div>
  281. </div>
  282. <div class="flex-shrink-0 flex items-center gap-2">
  283. ${!notification.read ? `
  284. <button class="mark-read-btn text-green-600 hover:text-green-800 p-2 rounded-lg hover:bg-green-50 transition-colors duration-150"
  285. data-id="${notification.id}"
  286. title="Marcar como leída">
  287. <i class="fas fa-check"></i>
  288. </button>
  289. ` : ''}
  290. <button class="delete-btn text-red-600 hover:text-red-800 p-2 rounded-lg hover:bg-red-50 transition-colors duration-150"
  291. data-id="${notification.id}"
  292. title="Eliminar notificación">
  293. <i class="fas fa-trash"></i>
  294. </button>
  295. </div>
  296. </div>
  297. </div>
  298. `).join('');
  299. // Re-aplicar filtros después de cargar
  300. applyFilters();
  301. }
  302. // Función para actualizar la paginación
  303. function updatePagination(pagination) {
  304. currentPage = pagination.current_page;
  305. const totalPages = pagination.total_pages;
  306. const totalNotifications = pagination.total_notifications;
  307. // Actualizar información de paginación
  308. document.getElementById('current-range').textContent =
  309. `${((currentPage - 1) * perPage) + 1}-${Math.min(currentPage * perPage, totalNotifications)}`;
  310. document.getElementById('total-notifications').textContent = totalNotifications;
  311. document.getElementById('page-info').textContent = `Página ${currentPage} de ${totalPages}`;
  312. // Actualizar botones de paginación
  313. document.getElementById('prev-page').disabled = currentPage <= 1;
  314. document.getElementById('next-page').disabled = currentPage >= totalPages;
  315. }
  316. // Función para mostrar estado vacío
  317. function showEmptyState() {
  318. const container = document.getElementById('notifications-list');
  319. if (!container) return;
  320. container.innerHTML = `
  321. <div class="text-center py-16">
  322. <div class="w-24 h-24 mx-auto mb-4 rounded-full bg-gray-100 flex items-center justify-center">
  323. <i class="fas fa-bell-slash text-gray-400 text-3xl"></i>
  324. </div>
  325. <h3 class="text-lg font-medium text-gray-900 mb-2">No hay notificaciones</h3>
  326. <p class="text-gray-500 max-w-md mx-auto">Todas las notificaciones aparecerán aquí. ¡Mantente atento a las actualizaciones del sistema!</p>
  327. </div>
  328. `;
  329. }
  330. // Función para formatear "hace X tiempo"
  331. function formatTimeAgo(timestamp) {
  332. const now = new Date();
  333. const notificationTime = new Date(timestamp);
  334. const diffMs = now - notificationTime;
  335. const diffMins = Math.floor(diffMs / 60000);
  336. const diffHours = Math.floor(diffMs / 3600000);
  337. const diffDays = Math.floor(diffMs / 86400000);
  338. if (diffMins < 1) return 'Hace unos momentos';
  339. if (diffMins < 60) return `Hace ${diffMins} minuto${diffMins > 1 ? 's' : ''}`;
  340. if (diffHours < 24) return `Hace ${diffHours} hora${diffHours > 1 ? 's' : ''}`;
  341. return `Hace ${diffDays} día${diffDays > 1 ? 's' : ''}`;
  342. }
  343. // Function to mark notification as read
  344. function markAsRead(notificationIds) {
  345. fetch('/api/notifications/mark-read', {
  346. method: 'POST',
  347. headers: {
  348. 'Content-Type': 'application/json',
  349. 'X-CSRFToken': csrfToken,
  350. },
  351. body: JSON.stringify({
  352. notification_ids: notificationIds // Cambiado de 'ids' a 'notification_ids'
  353. })
  354. })
  355. .then(response => {
  356. if (!response.ok) {
  357. throw new Error(`Error HTTP: ${response.status}`);
  358. }
  359. return response.json();
  360. })
  361. .then(data => {
  362. if (data.success) {
  363. // Actualizar contador en el header
  364. document.getElementById('unread-count').textContent = data.unread_count;
  365. // Reload notifications to reflect changes
  366. loadNotifications(currentPage);
  367. showToast(`${notificationIds.length} notificación(es) marcada(s) como leída(s)`, 'success');
  368. } else {
  369. showToast('Error al marcar notificaciones como leídas: ' + (data.error || 'Error desconocido'), 'error');
  370. }
  371. })
  372. .catch(error => {
  373. console.error('Error:', error);
  374. showToast('Error de conexión: ' + error.message, 'error');
  375. });
  376. }
  377. // Función para marcar TODAS las notificaciones como leídas
  378. function markAllAsRead() {
  379. const unreadNotifications = document.querySelectorAll('.notification-item[data-read="false"]');
  380. const unreadIds = Array.from(unreadNotifications).map(el => parseInt(el.getAttribute('data-id')));
  381. if (unreadIds.length > 0) {
  382. markAsRead(unreadIds);
  383. } else {
  384. showToast('No hay notificaciones sin leer', 'info');
  385. }
  386. }
  387. // Función para ELIMINAR notificación
  388. function deleteNotification(notificationId) {
  389. if (!confirm('¿Estás seguro de que quieres eliminar esta notificación?')) {
  390. return;
  391. }
  392. fetch(`/api/notifications/${notificationId}`, {
  393. method: 'DELETE',
  394. headers: {
  395. 'X-CSRFToken': csrfToken,
  396. }
  397. })
  398. .then(response => {
  399. if (!response.ok) {
  400. throw new Error(`Error HTTP: ${response.status}`);
  401. }
  402. return response.json();
  403. })
  404. .then(data => {
  405. if (data.success) {
  406. // Recargar notificaciones
  407. loadNotifications(currentPage);
  408. // Actualizar contador
  409. document.getElementById('unread-count').textContent = data.unread_count;
  410. showToast('Notificación eliminada', 'success');
  411. } else {
  412. showToast('Error al eliminar notificación: ' + (data.error || 'Error desconocido'), 'error');
  413. }
  414. })
  415. .catch(error => {
  416. console.error('Error:', error);
  417. showToast('Error de conexión: ' + error.message, 'error');
  418. });
  419. }
  420. // Función para ELIMINAR TODAS las notificaciones
  421. function deleteAllNotifications() {
  422. if (!confirm('¿Estás seguro de que quieres eliminar TODAS las notificaciones? Esta acción no se puede deshacer.')) {
  423. return;
  424. }
  425. fetch('/api/notifications/delete-all', {
  426. method: 'DELETE',
  427. headers: {
  428. 'X-CSRFToken': csrfToken,
  429. }
  430. })
  431. .then(response => {
  432. if (!response.ok) {
  433. throw new Error(`Error HTTP: ${response.status}`);
  434. }
  435. return response.json();
  436. })
  437. .then(data => {
  438. if (data.success) {
  439. // Mostrar estado vacío
  440. showEmptyState();
  441. // Actualizar contador
  442. document.getElementById('unread-count').textContent = '0';
  443. // Actualizar paginación
  444. document.getElementById('current-range').textContent = '0-0';
  445. document.getElementById('total-notifications').textContent = '0';
  446. document.getElementById('page-info').textContent = 'Página 1 de 1';
  447. // Deshabilitar botones de paginación
  448. document.getElementById('prev-page').disabled = true;
  449. document.getElementById('next-page').disabled = true;
  450. showToast('Todas las notificaciones han sido eliminadas', 'success');
  451. } else {
  452. showToast('Error al eliminar notificaciones: ' + (data.error || 'Error desconocido'), 'error');
  453. }
  454. })
  455. .catch(error => {
  456. console.error('Error:', error);
  457. showToast('Error de conexión: ' + error.message, 'error');
  458. });
  459. }
  460. // Filtros
  461. function applyFilters() {
  462. const typeFilter = document.getElementById('filter-type').value;
  463. const sourceFilter = document.getElementById('filter-source').value;
  464. const statusFilter = document.getElementById('filter-status').value;
  465. const notifications = document.querySelectorAll('.notification-item');
  466. let visibleCount = 0;
  467. notifications.forEach(notification => {
  468. const type = notification.getAttribute('data-type');
  469. const source = notification.getAttribute('data-source');
  470. const read = notification.getAttribute('data-read') === 'true';
  471. const typeMatch = typeFilter === 'all' || type === typeFilter;
  472. const sourceMatch = sourceFilter === 'all' || source === sourceFilter;
  473. const statusMatch = statusFilter === 'all' ||
  474. (statusFilter === 'unread' && !read) ||
  475. (statusFilter === 'read' && read);
  476. if (typeMatch && sourceMatch && statusMatch) {
  477. notification.style.display = 'block';
  478. visibleCount++;
  479. } else {
  480. notification.style.display = 'none';
  481. }
  482. });
  483. if (visibleCount === 0 && notifications.length > 0) {
  484. // No mostrar toast aquí para evitar spam al aplicar filtros
  485. }
  486. }
  487. // Event Listeners
  488. document.addEventListener('click', function(e) {
  489. if (e.target.closest('.mark-read-btn')) {
  490. const button = e.target.closest('.mark-read-btn');
  491. const notificationId = parseInt(button.getAttribute('data-id'));
  492. markAsRead([notificationId]);
  493. }
  494. if (e.target.closest('.delete-btn')) {
  495. const button = e.target.closest('.delete-btn');
  496. const notificationId = parseInt(button.getAttribute('data-id'));
  497. deleteNotification(notificationId);
  498. }
  499. });
  500. document.getElementById('mark-all-read').addEventListener('click', markAllAsRead);
  501. document.getElementById('delete-all').addEventListener('click', deleteAllNotifications);
  502. // Paginación
  503. document.getElementById('prev-page').addEventListener('click', function() {
  504. if (currentPage > 1) {
  505. currentPage--;
  506. loadNotifications(currentPage);
  507. }
  508. });
  509. document.getElementById('next-page').addEventListener('click', function() {
  510. if (currentPage < totalPages) {
  511. currentPage++;
  512. loadNotifications(currentPage);
  513. }
  514. });
  515. // Filtros
  516. document.getElementById('filter-type').addEventListener('change', applyFilters);
  517. document.getElementById('filter-source').addEventListener('change', applyFilters);
  518. document.getElementById('filter-status').addEventListener('change', applyFilters);
  519. document.getElementById('clear-filters').addEventListener('click', function() {
  520. document.getElementById('filter-type').value = 'all';
  521. document.getElementById('filter-source').value = 'all';
  522. document.getElementById('filter-status').value = 'all';
  523. applyFilters();
  524. showToast('Filtros limpiados', 'info');
  525. });
  526. });
  527. </script>
  528. {% endblock %}