Преглед изворни кода

refactor: reorganize templates structure: move components to partials and create layouts

- Move template components from 'components' to 'partials' directory
- Create new 'layouts' directory for base template
- Add macros.html for reusable template functions
- Improve template organization for better maintainability
Yoelvis Mariné Ramos пре 1 година
родитељ
комит
d92bab8137

+ 0 - 366
templates/components/auditoria.html

@@ -1,366 +0,0 @@
-<script src="{{ url_for('static', filename='js/chart.js') }}"></script>
-<link
-  rel="stylesheet"
-  href="{{ url_for('static', filename='css/toastr.min.css') }}"
-/>
-<script src="{{ url_for('static', filename='js/jquery-3.7.1.min.js') }}"></script>
-<script src="{{ url_for('static', filename='js/toastr.min.js') }}"></script>
-
-<style>
-  /* Estilo para los "chips" de redes sociales */
-  .social-chip {
-    padding: 8px 16px;
-    border-radius: 9999px;
-    font-size: 0.875rem;
-    font-weight: 600;
-    cursor: pointer;
-    transition: all 0.2s ease-in-out;
-    border: 1px solid #e5e7eb; /* gray-200 */
-    background-color: #f9fafb; /* gray-50 */
-    color: #374151; /* gray-700 */
-    box-shadow: 0 1px 2px 0 rgb(0 0 0 / 0.05);
-  }
-  .social-chip:hover {
-    border-color: #93c5fd; /* blue-300 */
-    background-color: #eff6ff; /* blue-50 */
-    transform: translateY(-1px);
-    box-shadow: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
-  }
-  .social-chip.selected {
-    background-color: #2563eb; /* blue-600 */
-    color: white;
-    border-color: #1d4ed8; /* blue-800 */
-    box-shadow: 0 1px 3px 0 rgb(0 0 0 / 0.1), 0 1px 2px -1px rgb(0 0 0 / 0.1);
-  }
-  .social-chip.selected:hover {
-    background-color: #1d4ed8;
-  }
-
-  /* Estilo para el tooltip de ayuda sobre los chips */
-  .tooltip {
-    position: absolute;
-    bottom: 100%;
-    left: 50%;
-    transform: translateX(-50%);
-    margin-bottom: 8px;
-    background-color: #111827; /* gray-900 */
-    color: white;
-    padding: 4px 8px;
-    border-radius: 4px;
-    font-size: 0.75rem;
-    font-weight: 500;
-    white-space: nowrap;
-    opacity: 0;
-    transition: opacity 0.2s ease-in-out, transform 0.2s ease-in-out;
-    pointer-events: none; /* Para que no interfiera con el click */
-    transform-origin: bottom center;
-    transform: translateX(-50%) scale(0.95);
-  }
-  .group:hover .tooltip {
-    opacity: 1;
-    transform: translateX(-50%) scale(1);
-  }
-</style>
-
-<div class="max-w-7xl mx-auto px-4 sm:px-6 lg:px-8 py-8">
-  <div class="flex items-center mb-6 border-b pb-4">
-    <i class="fas fa-magnifying-glass text-3xl text-blue-600 mr-4"></i>
-    <div>
-      <h1 class="text-3xl font-bold text-gray-800">Centro de Auditoría</h1>
-      <p class="text-gray-500 mt-1">
-        Herramienta para el análisis de actividad y seguridad.
-      </p>
-    </div>
-  </div>
-
-  <div class="bg-white p-6 rounded-lg shadow-lg mb-8">
-    <form
-      id="audit-form"
-      class="grid grid-cols-1 lg:grid-cols-3 gap-x-8 gap-y-6"
-    >
-      <div class="lg:col-span-2 grid grid-cols-1 md:grid-cols-2 gap-6">
-        <div class="md:col-span-2">
-          <label
-            for="audit-type"
-            class="block text-sm font-semibold text-gray-700 mb-1"
-            >Tipo de Auditoría</label
-          >
-          <select
-            id="audit-type"
-            name="audit_type"
-            class="w-full border-gray-300 rounded-md shadow-sm focus:border-blue-500 focus:ring-blue-500 bg-gray-50"
-          >
-            <optgroup label="Actividad General">
-              <option value="user_summary" data-requires="user">
-                Resumen por Usuario
-              </option>
-              <option value="top_users_data">Top 10 Usuarios (Datos)</option>
-              <option value="top_urls_data">Top 15 URLs (Datos)</option>
-              <option value="top_users_requests">Top 10 Usuarios (Peticiones)</option>
-              <option value="top_ips_data">Top 10 IPs (Datos)</option>
-              <!-- <option value="daily_activity" data-requires="user">
-                Actividad Diaria
-              </option> -->
-            </optgroup>
-            <optgroup label="Seguridad y Políticas">
-              <option
-                value="keyword_search"
-                data-requires="user_optional,keyword"
-              >
-                Búsqueda por Palabra Clave
-              </option>
-              <option
-                value="social_media_activity"
-                data-requires="user_optional,social_media"
-              >
-                Actividad en Redes Sociales
-              </option>
-            </optgroup>
-            <optgroup label="Auditoría Técnica">
-              <option value="ip_activity" data-requires="ip">
-                Actividad por Dirección IP
-              </option>
-              <option
-                value="response_code_search"
-                data-requires="user_optional,response_code"
-              >
-                Análisis por Código de Respuesta
-              </option>
-            </optgroup>
-          </select>
-        </div>
-
-        <div id="conditional-inputs" class="contents">
-          <div id="user-filter-container" class="conditional-input">
-            <label
-              for="username-filter"
-              class="block text-sm font-semibold text-gray-700 mb-1"
-              >Usuario</label
-            >
-            <div class="relative">
-              <input
-                type="text"
-                id="user-search-input"
-                placeholder="Buscar usuario..."
-                class="w-full border-gray-300 rounded-md shadow-sm focus:border-blue-500 focus:ring-blue-500 bg-gray-50 pr-8"
-                autocomplete="off"
-              />
-              <i
-                class="fas fa-search absolute right-3 top-1/2 transform -translate-y-1/2 text-gray-400 text-sm"
-              ></i>
-              <div
-                id="user-dropdown"
-                class="absolute z-50 w-full mt-1 bg-white border border-gray-300 rounded-md shadow-lg max-h-48 overflow-y-auto hidden"
-              >
-                <div id="user-options-container">
-                  <!-- Las opciones se llenarán dinámicamente -->
-                </div>
-              </div>
-            </div>
-            <select id="username-filter" name="username" class="hidden">
-              <option value="">-- Todos --</option>
-            </select>
-          </div>
-          <div id="keyword-input-container" class="conditional-input">
-            <label
-              for="keyword-input"
-              class="block text-sm font-semibold text-gray-700 mb-1"
-              >Palabra Clave</label
-            >
-            <input
-              type="text"
-              id="keyword-input"
-              name="keyword"
-              class="w-full border-gray-300 rounded-md shadow-sm bg-gray-50"
-              placeholder="Ej: juegos, descargas..."
-            />
-          </div>
-          <div id="ip-input-container" class="conditional-input">
-            <label
-              for="ip-input"
-              class="block text-sm font-semibold text-gray-700 mb-1"
-              >Dirección IP</label
-            >
-            <input
-              type="text"
-              id="ip-input"
-              name="ip_address"
-              class="w-full border-gray-300 rounded-md shadow-sm bg-gray-50"
-              placeholder="Ej: 192.168.1.100"
-            />
-          </div>
-          <div
-            id="social-media-input-container"
-            class="conditional-input md:col-span-2"
-          >
-            <label class="block text-sm font-semibold text-gray-700 mb-2"
-              >Redes Sociales</label
-            >
-            <div id="social-media-chips" class="flex flex-wrap gap-3">
-              <div class="relative group">
-                <button type="button" class="social-chip" data-value="Facebook">
-                  Facebook
-                </button>
-                <span class="tooltip">Selección múltiple</span>
-              </div>
-              <div class="relative group">
-                <button
-                  type="button"
-                  class="social-chip"
-                  data-value="Instagram"
-                >
-                  Instagram
-                </button>
-                <span class="tooltip">Selección múltiple</span>
-              </div>
-              <div class="relative group">
-                <button type="button" class="social-chip" data-value="YouTube">
-                  YouTube
-                </button>
-                <span class="tooltip">Selección múltiple</span>
-              </div>
-              <div class="relative group">
-                <button
-                  type="button"
-                  class="social-chip"
-                  data-value="Twitter/X"
-                >
-                  Twitter/X
-                </button>
-                <span class="tooltip">Selección múltiple</span>
-              </div>
-              <div class="relative group">
-                <button type="button" class="social-chip" data-value="WhatsApp">
-                  WhatsApp
-                </button>
-                <span class="tooltip">Selección múltiple</span>
-              </div>
-              <div class="relative group">
-                <button type="button" class="social-chip" data-value="Telegram">
-                  Telegram
-                </button>
-                <span class="tooltip">Selección múltiple</span>
-              </div>
-              <div class="relative group">
-                <button
-                  type="button"
-                  class="social-chip"
-                  data-value="Pinterest"
-                >
-                  Pinterest
-                </button>
-                <span class="tooltip">Selección múltiple</span>
-              </div>
-            </div>
-          </div>
-          <div id="response-code-input-container" class="conditional-input">
-            <label
-              for="response-code-input"
-              class="block text-sm font-semibold text-gray-700 mb-1"
-              >Código HTTP</label
-            >
-            <select
-              id="response-code-input"
-              name="response_code"
-              class="w-full border-gray-300 rounded-md shadow-sm focus:border-blue-500 focus:ring-blue-500 bg-gray-50"
-            >
-              <option value="">-- Seleccione un código --</option>
-              <optgroup label="Respuestas Exitosas (2xx)">
-                <option value="200">200 OK</option>
-              </optgroup>
-              <optgroup label="Redirecciones (3xx)">
-                <option value="301">301 Moved Permanently</option>
-                <option value="302">302 Found</option>
-                <option value="304">304 Not Modified</option>
-              </optgroup>
-              <optgroup label="Errores de Cliente (4xx)">
-                <option value="400">400 Bad Request</option>
-                <option value="401">401 Unauthorized</option>
-                <option value="403">403 Forbidden</option>
-                <option value="404">404 Not Found</option>
-              </optgroup>
-              <optgroup label="Errores de Servidor (5xx)">
-                <option value="500">500 Internal Server Error</option>
-                <option value="502">502 Bad Gateway</option>
-                <option value="503">503 Service Unavailable</option>
-                <option value="504">504 Gateway Timeout</option>
-              </optgroup>
-            </select>
-          </div>
-        </div>
-      </div>
-
-      <div
-        class="lg:col-span-1 bg-slate-50 border border-slate-200 rounded-lg p-4 h-fit"
-      >
-        <h3 class="text-md font-semibold text-slate-800 mb-4 border-b pb-2">
-          Fecha del Reporte
-        </h3>
-        <div class="space-y-4">
-          <div id="start-date-container">
-            <label
-              for="start-date"
-              class="block text-sm font-semibold text-gray-700 mb-1"
-              >Fecha</label
-            >
-            <input
-              type="date"
-              id="start-date"
-              name="start_date"
-              class="w-full border-gray-300 rounded-md shadow-sm focus:border-blue-500 focus:ring-blue-500 bg-gray-50"
-            />
-          </div>
-          <div id="end-date-container">
-            <label
-              for="end-date"
-              class="block text-sm font-semibold text-gray-700 mb-1"
-              >Fecha de Fin</label
-            >
-            <input
-              type="date"
-              id="end-date"
-              name="end_date"
-              class="w-full border-gray-300 rounded-md shadow-sm focus:border-blue-500 focus:ring-blue-500 bg-gray-50"
-            />
-          </div>
-        </div>
-      </div>
-
-      <div class="lg:col-span-3">
-        <button
-          type="submit"
-          class="w-full bg-blue-600 text-white font-bold py-2.5 px-4 rounded-md hover:bg-blue-700 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-blue-500 transition-all duration-300 flex items-center justify-center shadow-lg hover:shadow-xl"
-        >
-          <i class="fas fa-play mr-2"></i>
-          Generar Reporte
-        </button>
-      </div>
-    </form>
-  </div>
-
-  <div id="audit-results-container" class="space-y-4">
-    <div
-      class="bg-white p-6 rounded-lg shadow-lg min-h-[300px] flex items-center justify-center"
-    >
-      <div class="text-center text-gray-500 py-10">
-        <i class="fas fa-clipboard-list text-5xl mb-4 text-gray-300"></i>
-        <h3 class="text-xl font-semibold">
-          Seleccione los filtros y genere un reporte
-        </h3>
-        <p class="mt-2">Los resultados de su auditoría aparecerán aquí.</p>
-      </div>
-    </div>
-  </div>
-</div>
-
-<!-- Scripts divididos -->
-<script src="{{ url_for('static', filename='js/auditoria/config_and_utils.js') }}"></script>
-<script src="{{ url_for('static', filename='js/auditoria/renderers.js') }}"></script>
-<script src="{{ url_for('static', filename='js/auditoria/user_search_and_inputs.js') }}"></script>
-<script src="{{ url_for('static', filename='js/auditoria/form_and_results.js') }}"></script>
-<script>
-  document.addEventListener('DOMContentLoaded', ()=>{
-    window.__AUD_FORM__ && window.__AUD_FORM__.initFormAndResults();
-    window.__AUD_USER_INPUTS__ && window.__AUD_USER_INPUTS__.initUserAndInputs();
-  });
-</script>

+ 0 - 937
templates/components/cache_stats.html

@@ -1,937 +0,0 @@
-{% macro flip_card(icon, title, value, back_title, description, extra_html='')
-%}
-<div class="group w-full h-48 [perspective:1000px]">
-  <div
-    class="relative h-full w-full rounded-xl shadow-xl transition-all duration-500 [transform-style:preserve-3d] group-hover:[transform:rotateY(180deg)]"
-  >
-    <div
-      class="absolute inset-0 bg-white shadow-md rounded-xl flex flex-col items-center justify-center [backface-visibility:hidden]"
-    >
-      <i class="{{ icon }} text-3xl text-blue-600 mb-2"></i>
-      <h3 class="text-lg font-semibold text-gray-800">{{ title }}</h3>
-      {% if extra_html %} {{ extra_html | safe }} {% else %}
-      <p
-        class="text-xl text-blue-800"
-        data-stat="{{ title|replace(' ', '_')|lower }}"
-      >
-        {{ value }}
-      </p>
-      {% endif %}
-    </div>
-    <div
-      class="absolute inset-0 bg-blue-600 text-white rounded-xl px-4 py-6 text-center [transform:rotateY(180deg)] [backface-visibility:hidden]"
-    >
-      <h3 class="text-lg font-semibold mb-2">{{ back_title }}</h3>
-      <p class="text-sm">{{ description }}</p>
-    </div>
-  </div>
-</div>
-{% endmacro %}
-
-<!DOCTYPE html>
-<html lang="es">
-  <head>
-    <meta charset="UTF-8" />
-    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
-    <title>Dashboard de Sistema</title>
-    <link
-      rel="icon"
-      href="{{ url_for('static', filename=page_icon) }}"
-      type="image/x-icon"
-    />
-    <script src="{{ url_for('static', filename='js/tailwindcss.js') }}"></script>
-    <link
-      rel="stylesheet"
-      href="{{ url_for('static', filename='all.min.css') }}"
-    />
-    <script src="{{ url_for('static', filename='js/chart.js') }}"></script>
-    <script src="{{ url_for('static', filename='js/chartjs-plugin-datalabels.js') }}"></script>
-    <script src="{{ url_for('static', filename='js/socket.io.min.js') }}"></script>
-    <style>
-      @keyframes progress {
-        0% {
-          stroke-dasharray: 0 100;
-        }
-      }
-      .circle-animation {
-        animation: progress 1s ease-out forwards;
-      }
-      .main-tab-content,
-      .tab-content {
-        display: none;
-      }
-      .main-tab-content.active,
-      .tab-content.active {
-        display: block;
-        animation: fadeIn 0.5s ease;
-      }
-      @keyframes fadeIn {
-        from {
-          opacity: 0;
-        }
-        to {
-          opacity: 1;
-        }
-      }
-      .main-tab-btn.active::after {
-        content: "";
-        position: absolute;
-        bottom: 0;
-        left: 0;
-        right: 0;
-        height: 3px;
-        background-color: #3b82f6;
-        animation: underline 0.3s ease;
-      }
-      @keyframes underline {
-        from {
-          transform: scaleX(0);
-        }
-        to {
-          transform: scaleX(1);
-        }
-      }
-      .value-change {
-        animation: pulse 1s;
-      }
-      @keyframes pulse {
-        0% {
-          transform: scale(1);
-        }
-        50% {
-          transform: scale(1.1);
-        }
-        100% {
-          transform: scale(1);
-        }
-      }
-      .time-range-btn {
-        transition: all 0.3s ease;
-      }
-      .time-range-btn.active {
-        background-color: white;
-        color: #2563eb;
-        box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
-      }
-      .time-range-btn:not(.active) {
-        background-color: transparent;
-        color: #6b7280;
-      }
-      .time-range-btn:not(.active):hover {
-        color: #2563eb;
-      }
-    </style>
-  </head>
-
-  <body class="bg-gray-50">
-    <div class="max-w-7xl mx-auto px-4 py-8">
-      <h1 class="text-3xl font-bold text-center text-gray-800 mb-8">
-        Dashboard de Estadísticas del Sistema
-      </h1>
-
-      <div class="flex border-b mb-6">
-        <button
-          id="dashboardTab"
-          class="main-tab-btn active relative overflow-hidden py-3 px-6 font-medium text-blue-600"
-        >
-          <i class="fas fa-tachometer-alt mr-2"></i>Dashboard del Sistema
-        </button>
-        <button
-          id="cacheTab"
-          class="main-tab-btn relative overflow-hidden py-3 px-6 font-medium text-gray-500 hover:text-blue-600"
-        >
-          <i class="fas fa-database mr-2"></i>Estadísticas de Caché
-        </button>
-        <button
-          id="networkTab"
-          class="main-tab-btn relative overflow-hidden py-3 px-6 font-medium text-gray-500 hover:text-blue-600"
-        >
-          <i class="fas fa-network-wired mr-2"></i>Tráfico de Red
-        </button>
-      </div>
-
-      <div id="dashboardContent" class="main-tab-content active">
-        <section class="mb-12">
-          <div class="grid grid-cols-1 lg:grid-cols-2 gap-8">
-            <div class="bg-white rounded-xl shadow-lg p-6">
-              <div class="flex items-center mb-6">
-                <i class="fas fa-chart-pie text-2xl text-blue-600 mr-3"></i>
-                <h2 class="text-xl font-bold text-gray-800">
-                  Estadísticas del Sistema
-                </h2>
-              </div>
-              <div
-                class="grid grid-cols-1 md:grid-cols-3 gap-6 items-center justify-center"
-              >
-                <div class="flex flex-col items-center justify-center">
-                  <div class="relative w-36 h-36">
-                    <svg viewBox="0 0 36 36" class="block mx-auto">
-                      <path
-                        class="fill-none stroke-red-100 stroke-[3.5]"
-                        d="M18 2.0845 a 15.9155 15.9155 0 0 1 0 31.831 a 15.9155 15.9155 0 0 1 0 -31.831"
-                      />
-                      <path
-                        id="cpu-ring"
-                        class="circle-animation fill-none stroke-linecap-round stroke-red-500 stroke-[3.5]"
-                        stroke-dasharray="0,100"
-                        d="M18 2.0845 a 15.9155 15.9155 0 0 1 0 31.831 a 15.9155 15.9155 0 0 1 0 -31.831"
-                      />
-                      <text
-                        id="cpu-value"
-                        x="18"
-                        y="18"
-                        class="text-[0.5rem] fill-gray-500"
-                        text-anchor="middle"
-                        dominant-baseline="middle"
-                      >
-                        0%
-                      </text>
-                    </svg>
-                  </div>
-                  <h3 class="mt-2 font-semibold text-gray-700">CPU</h3>
-                  <p
-                    class="text-xs mt-1 bg-red-500 text-white px-2 py-0.5 rounded-full font-medium"
-                  >
-                    {{ system_info.cpu.physical_cores }} núcleos
-                  </p>
-                </div>
-                <div class="flex flex-col items-center justify-center">
-                  <div class="relative w-36 h-36">
-                    <svg viewBox="0 0 36 36" class="block mx-auto">
-                      <path
-                        class="fill-none stroke-blue-100 stroke-[3.5]"
-                        d="M18 2.0845 a 15.9155 15.9155 0 0 1 0 31.831 a 15.9155 15.9155 0 0 1 0 -31.831"
-                      />
-                      <path
-                        id="ram-ring"
-                        class="circle-animation fill-none stroke-linecap-round stroke-blue-600 stroke-[3.5]"
-                        stroke-dasharray="0,100"
-                        d="M18 2.0845 a 15.9155 15.9155 0 0 1 0 31.831 a 15.9155 15.9155 0 0 1 0 -31.831"
-                      />
-                      <text
-                        id="ram-used"
-                        x="18"
-                        y="18"
-                        class="text-[0.5rem] fill-gray-500"
-                        text-anchor="middle"
-                        dominant-baseline="middle"
-                      >
-                        0G
-                      </text>
-                    </svg>
-                  </div>
-                  <h3 class="mt-2 font-semibold text-gray-700">RAM</h3>
-                  <p
-                    class="text-xs mt-1 bg-blue-500 text-white px-2 py-0.5 rounded-full font-medium"
-                  >
-                    {{ system_info.ram.total }}
-                  </p>
-                </div>
-                <div class="flex flex-col items-center justify-center">
-                  <div class="relative w-36 h-36">
-                    <svg viewBox="0 0 36 36" class="block mx-auto">
-                      <path
-                        class="fill-none stroke-emerald-100 stroke-[3.5]"
-                        d="M18 2.0845 a 15.9155 15.9155 0 0 1 0 31.831 a 15.9155 15.9155 0 0 1 0 -31.831"
-                      />
-                      <path
-                        id="swap-ring"
-                        class="circle-animation fill-none stroke-linecap-round stroke-emerald-500 stroke-[3.5]"
-                        stroke-dasharray="0,100"
-                        d="M18 2.0845 a 15.9155 15.9155 0 0 1 0 31.831 a 15.9155 15.9155 0 0 1 0 -31.831"
-                      />
-                      <text
-                        id="swap-used"
-                        x="18"
-                        y="18"
-                        class="text-[0.5rem] fill-gray-500"
-                        text-anchor="middle"
-                        dominant-baseline="middle"
-                      >
-                        0G
-                      </text>
-                    </svg>
-                  </div>
-                  <h3 class="mt-2 font-semibold text-gray-700">SWAP</h3>
-                  <p
-                    class="text-xs mt-1 bg-emerald-500 text-white px-2 py-0.5 rounded-full font-medium"
-                  >
-                    {{ system_info.swap.total }}
-                  </p>
-                </div>
-              </div>
-            </div>
-
-            <div class="bg-white rounded-xl shadow-lg p-6">
-              <div class="flex items-center mb-6">
-                <i class="fas fa-info-circle text-2xl text-blue-600 mr-3"></i>
-                <h2 class="text-xl font-bold text-gray-800">
-                  Información del Sistema
-                </h2>
-              </div>
-              <div class="grid grid-cols-1 md:grid-cols-2 gap-4">
-                <div class="flex items-start">
-                  <i class="fas fa-server text-gray-500 mt-1 mr-3"></i>
-                  <div>
-                    <h3 class="text-sm font-semibold text-gray-600">
-                      Nombre del Host
-                    </h3>
-                    <p id="hostname" class="text-gray-800">
-                      {{ system_info.hostname }}
-                    </p>
-                  </div>
-                </div>
-                <div class="flex items-start">
-                  <i class="fas fa-network-wired text-gray-500 mt-1 mr-3"></i>
-                  <div>
-                    <h3 class="text-sm font-semibold text-gray-600">
-                      Direcciones IP
-                    </h3>
-                    <p id="ip-addresses" class="text-gray-800">
-                      {% for ip in system_info.ips %}{{ ip.ip }}<br />{% endfor
-                      %}
-                    </p>
-                  </div>
-                </div>
-                <div class="flex items-start">
-                  <i class="fab fa-linux text-gray-500 mt-1 mr-3"></i>
-                  <div>
-                    <h3 class="text-sm font-semibold text-gray-600">
-                      Sistema Operativo
-                    </h3>
-                    <p id="os-info" class="text-gray-800">
-                      {{ system_info.os }}
-                    </p>
-                  </div>
-                </div>
-                <div class="flex items-start">
-                  <i class="fas fa-clock text-gray-500 mt-1 mr-3"></i>
-                  <div>
-                    <h3 class="text-sm font-semibold text-gray-600">
-                      Tiempo Encendido
-                    </h3>
-                    <p id="uptime" class="text-gray-800">
-                      {{ system_info.uptime }}
-                    </p>
-                  </div>
-                </div>
-                <div class="flex items-start">
-                  <i class="fas fa-globe text-gray-500 mt-1 mr-3"></i>
-                  <div>
-                    <h3 class="text-sm font-semibold text-gray-600">
-                      Zona Horaria
-                    </h3>
-                    <p id="timezone" class="text-gray-800">
-                      {{ system_info.timezone }}
-                    </p>
-                  </div>
-                </div>
-                <div class="flex items-start">
-                  <i class="fas fa-clock text-gray-500 mt-1 mr-3"></i>
-                  <div>
-                    <h3 class="text-sm font-semibold text-gray-600">
-                      Hora Local
-                    </h3>
-                    <p id="local-time" class="text-gray-800">
-                      {{ system_info.local_time }}
-                    </p>
-                  </div>
-                </div>
-              </div>
-            </div>
-          </div>
-        </section>
-
-        <section class="bg-white rounded-xl shadow-lg p-6 mb-12">
-          <div class="flex items-center justify-between mb-6">
-            <h2 class="text-xl font-bold text-gray-800">
-              Gráficas del Sistema
-            </h2>
-            <div class="flex bg-gray-100 rounded-lg p-1">
-              <button
-                id="todayBtn"
-                class="time-range-btn active px-4 py-2 rounded-md text-sm font-medium text-blue-600 bg-white shadow"
-              >
-                Hoy
-              </button>
-              <button
-                id="24hoursBtn"
-                class="time-range-btn px-4 py-2 rounded-md text-sm font-medium text-gray-500 hover:text-blue-600"
-              >
-                24 Horas
-              </button>
-            </div>
-          </div>
-          <div class="flex border-b mb-6">
-            <button
-              class="tab-btn active py-3 px-6 font-medium border-b-2 border-blue-600 text-blue-600 transition-all duration-300 ease-in-out hover:bg-slate-100"
-            >
-              CPU
-            </button>
-            <button
-              class="tab-btn py-3 px-6 font-medium text-gray-500 hover:text-blue-600 transition-all duration-300 ease-in-out hover:bg-slate-100"
-            >
-              RAM
-            </button>
-            <button
-              class="tab-btn py-3 px-6 font-medium text-gray-500 hover:text-blue-600 transition-all duration-300 ease-in-out hover:bg-slate-100"
-            >
-              SWAP
-            </button>
-          </div>
-          <div class="tab-content active">
-            <div class="h-80"><canvas id="cpuChart"></canvas></div>
-          </div>
-          <div class="tab-content">
-            <div class="h-80"><canvas id="ramChart"></canvas></div>
-          </div>
-          <div class="tab-content">
-            <div class="h-80"><canvas id="swapChart"></canvas></div>
-          </div>
-        </section>
-      </div>
-
-      <div id="cacheContent" class="main-tab-content">
-        <section class="cache-stats">
-          <div class="bg-white rounded-xl shadow-lg p-6 mb-8">
-            <div class="flex items-center mb-6">
-              <i class="fas fa-database text-2xl text-blue-600 mr-3"></i>
-              <h2 class="text-2xl font-bold text-gray-800">
-                Estadísticas de Caché
-              </h2>
-            </div>
-            <div
-              class="grid grid-cols-1 sm:grid-cols-2 md:grid-cols-3 gap-8 max-w-[1000px] mx-auto"
-            >
-              {{ flip_card(icon='fas fa-database', title='Entradas almacenadas',
-              value=cache_stats.store_entries, back_title='Entradas
-              Almacenadas', description='Número de objetos actualmente en la
-              caché de Squid.') }} {{ flip_card(icon='fas fa-chart-pie',
-              title='Uso de capacidad', value=cache_stats.capacity_used,
-              back_title='Uso de capacidad', description='Porcentaje del
-              almacenamiento de caché en uso actualmente.') }} {% if
-              cache_stats.fs_space_total and cache_stats.fs_space_total > 0 %}
-              {% set total_space_html %}{% if (cache_stats.fs_space_total /
-              1024) < 1024 %}
-              <p class="text-xl text-blue-800" data-stat="espacio_total">
-                {{ (cache_stats.fs_space_total / 1024)|int }} MB
-              </p>
-              {% else %}
-              <p class="text-xl text-blue-800" data-stat="espacio_total">
-                {{ (cache_stats.fs_space_total / 1024 / 1024)|round(2) }} GB
-              </p>
-              {% endif %}{% endset %} {{ flip_card(icon='fas fa-hdd',
-              title='Espacio total', back_title='Espacio total',
-              description='Tamaño total del disco asignado a la caché de
-              Squid.', extra_html=total_space_html) }} {% else %} {{
-              flip_card(icon='fas fa-hdd', title='Espacio total',
-              back_title='Espacio total', description='Tamaño total del disco
-              asignado a la caché de Squid.', extra_html='
-              <p class="text-xl text-red-600">No disponible</p>
-              ') }} {% endif %} {% set used_space_html %}{% if
-              (cache_stats.fs_space_used / 1024) < 1024 %}
-              <p class="text-xl text-blue-800" data-stat="espacio_usado">
-                {{ (cache_stats.fs_space_used / 1024)|int }} MB
-              </p>
-              {% else %}
-              <p class="text-xl text-blue-800" data-stat="espacio_usado">
-                {{ (cache_stats.fs_space_used / 1024 / 1024)|round(2) }} GB
-              </p>
-              {% endif %}{% endset %}{{ flip_card(icon='fas fa-folder-open',
-              title='Espacio usado', back_title='Espacio usado',
-              description='Cantidad de espacio de disco ya ocupado por objetos
-              en caché.', extra_html=used_space_html) }} {{ flip_card(icon='fas
-              fa-recycle', title='Eliminación',
-              value=cache_stats.removal_policy, back_title='Política de
-              eliminación', description='Método que Squid usa para eliminar
-              objetos antiguos de la caché.') }} {{ flip_card(icon='fas
-              fa-clock', title='Edad LRU', value=cache_stats.lru_age_days ~ '
-              días', back_title='Edad LRU', description='Tiempo desde que el
-              objeto menos usado fue accedido por última vez.') }}
-            </div>
-          </div>
-        </section>
-      </div>
-
-      <div id="networkContent" class="main-tab-content">
-        <section class="bg-white rounded-xl shadow-lg p-6">
-          <div class="flex items-center mb-6">
-            <i class="fas fa-network-wired text-2xl text-blue-600 mr-3"></i>
-            <h2 class="text-xl font-bold text-gray-800">Tráfico de Red</h2>
-          </div>
-          <div class="h-80"><canvas id="networkChart"></canvas></div>
-        </section>
-      </div>
-    </div>
-
-    <script>
-      Chart.register(ChartDataLabels);
-
-      let maxRamBytes = 0,
-        maxSwapBytes = 0;
-      const historySize = 240; // Reducido de 720 a 240 (4 horas de datos con intervalos de 1 minuto)
-      let liveDataCounter = 0; // Contador para manejar datos en vivo
-
-      // --- FUNCIONES ORIGINALES (COMPLETAS Y RESTAURADAS) ---
-      function getLocalTimeString() {
-        const now = new Date();
-        let hours = now.getHours();
-        const minutes = now.getMinutes().toString().padStart(2, "0");
-        const ampm = hours >= 12 ? "PM" : "AM";
-        hours = hours % 12 || 12;
-        return `${hours}:${minutes} ${ampm}`;
-      }
-
-      function formatTime(date) {
-        let hours = date.getHours();
-        const minutes = date.getMinutes().toString().padStart(2, "0");
-        const ampm = hours >= 12 ? "PM" : "AM";
-        hours = hours % 12 || 12;
-        return `${hours}:${minutes} ${ampm}`;
-      }
-      function openMainTab(tabName) {
-        document
-          .querySelectorAll(".main-tab-content")
-          .forEach((content) => content.classList.remove("active"));
-        document.querySelectorAll(".main-tab-btn").forEach((btn) => {
-          btn.classList.remove("active", "text-blue-600");
-          btn.classList.add("text-gray-500");
-        });
-        document.getElementById(tabName + "Content").classList.add("active");
-        const tabBtn = document.getElementById(tabName + "Tab");
-        tabBtn.classList.add("active", "text-blue-600");
-        tabBtn.classList.remove("text-gray-500");
-      }
-      document
-        .getElementById("dashboardTab")
-        .addEventListener("click", () => openMainTab("dashboard"));
-      document
-        .getElementById("cacheTab")
-        .addEventListener("click", () => openMainTab("cache"));
-      document
-        .getElementById("networkTab")
-        .addEventListener("click", () => openMainTab("network"));
-      document.querySelectorAll(".tab-btn").forEach((button, index) => {
-        button.addEventListener("click", () => {
-          document.querySelectorAll(".tab-btn").forEach((btn) => {
-            btn.classList.remove(
-              "active",
-              "text-blue-600",
-              "border-b-2",
-              "border-blue-600"
-            );
-            btn.classList.add("text-gray-500");
-          });
-          button.classList.add(
-            "active",
-            "text-blue-600",
-            "border-b-2",
-            "border-blue-600"
-          );
-          button.classList.remove("text-gray-500");
-          document
-            .querySelectorAll(".tab-content")
-            .forEach((content) => content.classList.remove("active"));
-          document
-            .querySelectorAll(".tab-content")
-            [index].classList.add("active");
-        });
-      });
-      const chartOptions = {
-        responsive: true,
-        maintainAspectRatio: false,
-        tension: 0.3,
-        fill: true,
-        pointRadius: 2,
-        scales: {
-          x: { grid: { color: "rgba(0, 0, 0, 0.05)" } },
-          y: { beginAtZero: true, grid: { color: "rgba(0, 0, 0, 0.05)" } },
-        },
-        plugins: { legend: { display: true }, datalabels: { display: false } },
-      };
-      const cpuChart = new Chart("cpuChart", {
-        type: "line",
-        data: {
-          labels: [],
-          datasets: [
-            {
-              label: "Uso de CPU (%)",
-              data: [],
-              borderColor: "#ef4444",
-              backgroundColor: "rgba(239, 68, 68, 0.1)",
-              pointBackgroundColor: "#ef4444",
-            },
-          ],
-        },
-        options: {
-          ...chartOptions,
-          scales: {
-            ...chartOptions.scales,
-            y: {
-              ...chartOptions.scales.y,
-              max: 100,
-              title: { display: true, text: "%" },
-            },
-          },
-        },
-      });
-      const ramChart = new Chart("ramChart", {
-        type: "line",
-        data: {
-          labels: [],
-          datasets: [
-            {
-              label: "RAM Usada",
-              data: [],
-              borderColor: "#3b82f6",
-              backgroundColor: "rgba(59, 130, 246, 0.1)",
-              pointBackgroundColor: "#3b82f6",
-            },
-          ],
-        },
-        options: {
-          ...chartOptions,
-          scales: {
-            ...chartOptions.scales,
-            y: {
-              ...chartOptions.scales.y,
-              title: { display: true, text: "Bytes" },
-              ticks: { callback: formatSizeCompact },
-            },
-          },
-          plugins: {
-            ...chartOptions.plugins,
-            tooltip: {
-              callbacks: {
-                label: (ctx) => "RAM Usada: " + formatSizeCompact(ctx.raw),
-              },
-            },
-          },
-        },
-      });
-      const swapChart = new Chart("swapChart", {
-        type: "line",
-        data: {
-          labels: [],
-          datasets: [
-            {
-              label: "Swap Usada",
-              data: [],
-              borderColor: "#10b981",
-              backgroundColor: "rgba(16, 185, 129, 0.1)",
-              pointBackgroundColor: "#10b981",
-            },
-          ],
-        },
-        options: {
-          ...chartOptions,
-          scales: {
-            ...chartOptions.scales,
-            y: {
-              ...chartOptions.scales.y,
-              title: { display: true, text: "Bytes" },
-              ticks: { callback: formatSizeCompact },
-            },
-          },
-          plugins: {
-            ...chartOptions.plugins,
-            tooltip: {
-              callbacks: {
-                label: (ctx) => "SWAP Usada: " + formatSizeCompact(ctx.raw),
-              },
-            },
-          },
-        },
-      });
-      const networkChart = new Chart("networkChart", {
-        type: "line",
-        data: {
-          labels: [],
-          datasets: [
-            {
-              label: "Subida (Mbps)",
-              data: [],
-              borderColor: "#06b6d4",
-              backgroundColor: "rgba(6,182,212,0.1)",
-              pointBackgroundColor: "#06b6d4",
-            },
-            {
-              label: "Bajada (Mbps)",
-              data: [],
-              borderColor: "#f59e42",
-              backgroundColor: "rgba(245,158,66,0.1)",
-              pointBackgroundColor: "#f59e42",
-            },
-          ],
-        },
-        options: {
-          ...chartOptions,
-          scales: {
-            ...chartOptions.scales,
-            y: {
-              ...chartOptions.scales.y,
-              title: { display: true, text: "Mbps" },
-            },
-          },
-        },
-      });
-      function formatSizeCompact(bytes) {
-        if (bytes === 0) return "0 B";
-        const units = ["B", "KB", "MB", "GB"];
-        const i = Math.floor(Math.log(bytes) / Math.log(1024));
-        return `${parseFloat(
-          (bytes / Math.pow(1024, i)).toFixed(i === 0 ? 0 : 1)
-        )} ${units[i]}`;
-      }
-      function parseSize(sizeStr) {
-        if (!sizeStr) return { value: 0, unit: "B" };
-        const parts = sizeStr.trim().split(" ");
-        return {
-          value: parseFloat(parts[0]) || 0,
-          unit: parts.length > 1 ? parts[1].charAt(0) : "B",
-        };
-      }
-      function sizeToBytes(sizeStr) {
-        const { value, unit } = parseSize(sizeStr);
-        const multipliers = { G: 1024 * 1024 * 1024, M: 1024 * 1024, K: 1024 };
-        return value * (multipliers[unit] || 1);
-      }
-      function updateRings(info) {
-        const cpuPercent = parseFloat(info.cpu.usage.replace("%", ""));
-        document
-          .getElementById("cpu-ring")
-          .setAttribute("stroke-dasharray", `${cpuPercent},100`);
-        document.getElementById(
-          "cpu-value"
-        ).textContent = `${cpuPercent.toFixed(1)}%`;
-        const ramUsedInfo = parseSize(info.ram.used);
-        document.getElementById(
-          "ram-used"
-        ).textContent = `${ramUsedInfo.value.toFixed(1)}${ramUsedInfo.unit}`;
-        document
-          .getElementById("ram-ring")
-          .setAttribute(
-            "stroke-dasharray",
-            `${parseFloat(info.ram.percent.replace("%", ""))},100`
-          );
-        const swapUsedInfo = parseSize(info.swap.used);
-        document.getElementById(
-          "swap-used"
-        ).textContent = `${swapUsedInfo.value.toFixed(1)}${swapUsedInfo.unit}`;
-        document
-          .getElementById("swap-ring")
-          .setAttribute(
-            "stroke-dasharray",
-            `${parseFloat(info.swap.percent.replace("%", "") || 0)},100`
-          );
-      }
-      function updateSystemInfo(info) {
-        document.getElementById("hostname").textContent = info.hostname;
-        document.getElementById("ip-addresses").innerHTML = info.ips
-          .map((ip) => ip.ip)
-          .join("<br>");
-        document.getElementById("os-info").textContent = info.os;
-        document.getElementById("uptime").textContent = info.uptime;
-        document.getElementById("local-time").textContent = info.local_time;
-      }
-      function updateCard(statId, value, isSize = false) {
-        const element = document.querySelector(`[data-stat="${statId}"]`);
-        if (!element) return;
-        let formattedValue = value;
-        if (isSize) {
-          const bytes = parseFloat(value);
-          formattedValue =
-            bytes / (1024 * 1024) < 1
-              ? `${Math.round(bytes / 1024)} MB`
-              : `${(bytes / (1024 * 1024)).toFixed(2)} GB`;
-        }
-        if (element.textContent !== formattedValue.toString()) {
-          element.textContent = formattedValue;
-          element.classList.add("value-change");
-          setTimeout(() => element.classList.remove("value-change"), 1000);
-        }
-      }
-      function updateCacheStats(stats) {
-        updateCard("entradas_almacenadas", stats.store_entries);
-        updateCard("uso_de_capacidad", stats.capacity_used);
-        updateCard("espacio_total", stats.fs_space_total, true);
-        updateCard("espacio_usado", stats.fs_space_used, true);
-        updateCard("eliminación", stats.removal_policy);
-        updateCard("edad_lru", `${stats.lru_age_days} días`);
-      }
-
-      // --- AÑADIDO: Carga de datos históricos desde la API con sampling optimizado ---
-      function loadHistoricData(endpoint = "/api/metrics/24hours") {
-        fetch(endpoint)
-          .then((response) => response.json())
-          .then((data) => {
-            if (!data || data.length === 0) {
-              console.log(
-                `No hay historial de métricas para el endpoint: ${endpoint}`
-              );
-              return;
-            }
-
-            // Implementar sampling inteligente para evitar sobrecarga
-            let sampledData = data;
-            if (data.length > 288) {
-              // Si hay más de 288 puntos (4.8 horas con intervalos de 1 minuto)
-              const sampleRate = Math.ceil(data.length / 288);
-              sampledData = data.filter((_, index) => index % sampleRate === 0);
-              console.log(
-                `Aplicado sampling: ${data.length} → ${sampledData.length} puntos`
-              );
-            }
-
-            const labels = [],
-              cpuData = [],
-              ramData = [],
-              swapData = [],
-              netUpData = [],
-              netDownData = [];
-            sampledData.forEach((metric) => {
-              // Crear fecha local desde el timestamp del servidor (ya incluye timezone)
-              const localDate = new Date(metric.timestamp);
-              labels.push(formatTime(localDate));
-              cpuData.push(parseFloat(metric.cpu_usage).toFixed(1));
-              ramData.push(metric.ram_usage_bytes);
-              swapData.push(metric.swap_usage_bytes);
-              netUpData.push(
-                ((metric.net_sent_bytes_sec * 8) / 1000000).toFixed(2)
-              );
-              netDownData.push(
-                ((metric.net_recv_bytes_sec * 8) / 1000000).toFixed(2)
-              );
-            });
-            const charts = [cpuChart, ramChart, swapChart, networkChart];
-            const chartData = [
-              cpuData,
-              ramData,
-              swapData,
-              [netUpData, netDownData],
-            ];
-            charts.forEach((chart, chartIndex) => {
-              chart.data.labels = [...labels];
-              if (chartIndex === 3) {
-                chart.data.datasets[0].data = chartData[chartIndex][0];
-                chart.data.datasets[1].data = chartData[chartIndex][1];
-              } else {
-                chart.data.datasets[0].data = chartData[chartIndex];
-              }
-              chart.update();
-            });
-          })
-          .catch((error) =>
-            console.error("Error al cargar historial de métricas:", error)
-          );
-      }
-
-      // --- AÑADIDO: Funcionalidad para alternar entre vistas de tiempo ---
-      function setupTimeRangeButtons() {
-        const todayBtn = document.getElementById("todayBtn");
-        const hoursBtn = document.getElementById("24hoursBtn");
-
-        todayBtn.addEventListener("click", () => {
-          setActiveTimeRange(todayBtn, hoursBtn);
-          loadHistoricData("/api/metrics/today");
-        });
-
-        hoursBtn.addEventListener("click", () => {
-          setActiveTimeRange(hoursBtn, todayBtn);
-          loadHistoricData("/api/metrics/24hours");
-        });
-      }
-
-      function setActiveTimeRange(activeBtn, inactiveBtn) {
-        activeBtn.classList.add("active");
-        activeBtn.classList.remove("text-gray-500");
-        activeBtn.classList.add("text-blue-600", "bg-white", "shadow");
-
-        inactiveBtn.classList.remove("active");
-        inactiveBtn.classList.add("text-gray-500");
-        inactiveBtn.classList.remove("text-blue-600", "bg-white", "shadow");
-      }
-
-      const socket = io();
-      socket.on("system_update", function (data) {
-        updateRings(data.system_info);
-        updateSystemInfo(data.system_info);
-        updateCacheStats(data.cache_stats);
-
-        // Incrementar contador de datos en vivo
-        liveDataCounter++;
-
-        // Solo actualizar gráficas cada 4 actualizaciones (1 minuto) para evitar sobrecarga
-        if (liveDataCounter % 4 === 0) {
-          // --- MODIFICADO: Lógica para añadir datos en vivo a las gráficas ---
-          function appendLiveData(chart, label, newData) {
-            chart.data.labels.push(label);
-            chart.data.datasets.forEach((dataset, index) => {
-              const dataPoint = Array.isArray(newData)
-                ? newData[index]
-                : newData;
-              dataset.data.push(dataPoint);
-            });
-            while (chart.data.labels.length > historySize) {
-              chart.data.labels.shift();
-              chart.data.datasets.forEach((dataset) => dataset.data.shift());
-            }
-            chart.update("none");
-          }
-
-          // --- CORREGIDO: Se usa la hora local del cliente para la etiqueta en vivo ---
-          const newLabel = getLocalTimeString();
-
-          appendLiveData(
-            cpuChart,
-            newLabel,
-            parseFloat(data.system_info.cpu.usage.replace("%", ""))
-          );
-          appendLiveData(
-            ramChart,
-            newLabel,
-            sizeToBytes(data.system_info.ram.used)
-          );
-          appendLiveData(
-            swapChart,
-            newLabel,
-            sizeToBytes(data.system_info.swap.used)
-          );
-          if (data.network_stats) {
-            appendLiveData(networkChart, newLabel, [
-              data.network_stats.up_mbps,
-              data.network_stats.down_mbps,
-            ]);
-          }
-        }
-      });
-
-      document.addEventListener("DOMContentLoaded", function () {
-        maxRamBytes = sizeToBytes("{{ system_info.ram.total }}");
-        maxSwapBytes = sizeToBytes("{{ system_info.swap.total }}");
-        ramChart.options.scales.y.max = maxRamBytes;
-        swapChart.options.scales.y.max = maxSwapBytes;
-        updateRings({
-          cpu: {
-            usage: "{{ system_info.cpu.usage }}",
-            percent: "{{ system_info.cpu.usage }}",
-          },
-          ram: {
-            used: "{{ system_info.ram.used }}",
-            percent: "{{ system_info.ram.percent }}",
-          },
-          swap: {
-            used: "{{ system_info.swap.used }}",
-            percent: "{{ system_info.swap.percent }}",
-          },
-        });
-
-        // Inicializar botones de rango de tiempo
-        setupTimeRangeButtons();
-
-        // Cargar datos históricos (por defecto 24 horas)
-        loadHistoricData("/api/metrics/24hours");
-      });
-    </script>
-  </body>
-</html>

+ 0 - 181
templates/components/connections.html

@@ -1,181 +0,0 @@
-{# Filtro para usuarios válidos (se mantiene igual) #} {% set valid_users = {}
-%} {% for user, connections in grouped_connections.items() %} {% if user and
-user != "-" and user != "Anónimo" %} {% set _ = valid_users.update({user:
-connections}) %} {% endif %} {% endfor %} {# Tarjetas de estadísticas con iconos
-Font Awesome #}
-<div class="grid grid-cols-1 md:grid-cols-2 gap-4 mb-6">
-  <!-- Tarjeta Usuarios Activos -->
-  <div class="bg-white p-4 rounded-lg shadow flex items-center">
-    <div
-      class="w-12 h-12 rounded-full bg-blue-100 flex items-center justify-center mr-3"
-    >
-      <i class="fas fa-users text-blue-500"></i>
-    </div>
-    <div>
-      <p class="text-gray-500 text-sm">Usuarios Activos</p>
-      <p class="text-xl font-bold">{{ valid_users|length }}</p>
-    </div>
-  </div>
-
-  <!-- Tarjeta Conexiones Totales -->
-  <div class="bg-white p-4 rounded-lg shadow flex items-center">
-    <div
-      class="w-12 h-12 rounded-full bg-green-100 flex items-center justify-center mr-3"
-    >
-      <i class="fas fa-exchange-alt text-green-500"></i>
-    </div>
-    <div>
-      <p class="text-gray-500 text-sm">Conexiones Totales</p>
-      <p class="text-xl font-bold">
-        {% set total = namespace(value=0) %} {% for connections in
-        valid_users.values() %} {% set total.value = total.value +
-        connections|length %} {% endfor %} {{ total.value }}
-      </p>
-    </div>
-  </div>
-</div>
-
-{# Lista de usuarios y conexiones #} {% for user, connections in
-valid_users.items() %}
-<div class="bg-white rounded-lg shadow-md mb-6 overflow-hidden">
-  <!-- Encabezado de usuario con iconos FA -->
-  <div
-    class="p-4 border-b flex flex-col sm:flex-row sm:items-center sm:justify-between"
-  >
-    <div class="flex items-center mb-2 sm:mb-0">
-      <div
-        class="w-10 h-10 rounded-full bg-blue-100 flex items-center justify-center mr-3"
-      >
-        <i class="fas fa-user text-blue-600"></i>
-      </div>
-      <h2 class="text-lg font-bold">{{ user }}</h2>
-    </div>
-
-    <div class="flex flex-wrap gap-3">
-      <div class="flex items-center text-sm text-gray-600">
-        <i class="fas fa-link mr-1 text-blue-500"></i>
-        <span>{{ connections|length }} conexiones</span>
-      </div>
-
-      {% set total_data = namespace(value=0) %} {% set total_requests =
-      namespace(value=0) %} {% for connection in connections %} {% if
-      connection.fd_total != "N/A" %} {% set total_data.value = total_data.value
-      + connection.fd_total %} {% endif %} {% set total_requests.value =
-      total_requests.value + connection.nrequests %} {% endfor %}
-
-      <div class="flex items-center text-sm text-gray-600">
-        <i class="fas fa-database mr-1 text-green-500"></i>
-        <span>{{ (total_data.value / 1024 / 1024)|round(2) }} MB</span>
-      </div>
-
-      <div class="flex items-center text-sm text-gray-600">
-        <i class="fas fa-bullhorn mr-1 text-purple-500"></i>
-        <span>{{ total_requests.value }} solicitudes</span>
-      </div>
-    </div>
-  </div>
-
-  <!-- Tabla de conexiones - Columna "Dir. Local" eliminada -->
-  <div class="overflow-x-auto">
-    <table class="min-w-full divide-y divide-gray-200">
-      <thead class="bg-gray-50">
-        <tr>
-          <th
-            class="px-4 py-2 text-left text-xs font-medium text-gray-500 uppercase"
-          >
-            Tiempo
-          </th>
-          <th
-            class="px-4 py-2 text-left text-xs font-medium text-gray-500 uppercase"
-          >
-            Método
-          </th>
-          <th
-            class="px-4 py-2 text-left text-xs font-medium text-gray-500 uppercase"
-          >
-            URL
-          </th>
-          <th
-            class="px-4 py-2 text-left text-xs font-medium text-gray-500 uppercase"
-          >
-            Datos
-          </th>
-          <th
-            class="px-4 py-2 text-left text-xs font-medium text-gray-500 uppercase"
-          >
-            Delay Pool
-          </th>
-          <th
-            class="px-4 py-2 text-left text-xs font-medium text-gray-500 uppercase"
-          >
-            Solicitudes
-          </th>
-          <th
-            class="px-4 py-2 text-left text-xs font-medium text-gray-500 uppercase"
-          >
-            Dir. Remota
-          </th>
-        </tr>
-      </thead>
-      <tbody class="divide-y divide-gray-200">
-        {% for connection in connections %}
-        <tr class="hover:bg-gray-50">
-          <!-- Tiempo -->
-          <td class="px-4 py-3 whitespace-nowrap text-sm">
-            {% set seconds = connection.elapsed_time|float %} {% if seconds >=
-            3600 %} {{ "%.2f"|format(seconds/3600) }} horas {% elif seconds >=
-            60 %} {{ "%.2f"|format(seconds/60) }} min {% else %} {{
-            "%.2f"|format(seconds) }} seg {% endif %}
-          </td>
-
-          <!-- Método con estilos mejorados -->
-          <td class="px-4 py-3 whitespace-nowrap">
-            <span
-              class="px-2 py-1 rounded-full text-xs font-semibold {% if connection.logType|lower == 'get' %}bg-green-100 text-green-800 {% elif connection.logType|lower == 'post' %}bg-blue-100 text-blue-800 {% elif connection.logType|lower == 'connect' %}bg-yellow-100 text-yellow-800 {% else %}bg-gray-100 text-gray-800{% endif %}"
-            >
-              {{ connection.logType }}
-            </span>
-          </td>
-
-          <!-- URL con truncado mejorado -->
-          <td class="px-4 py-3 max-w-xs">
-            <div class="truncate text-sm" title="{{ connection.uri }}">
-              {{ connection.uri }}
-            </div>
-          </td>
-
-          <!-- Datos -->
-          <td class="px-4 py-3 whitespace-nowrap text-sm">
-            {% if connection.fd_total != "N/A" %} {{ (connection.fd_total / 1024
-            /1024)|round(2) }} MB {% else %} N/A {% endif %}
-          </td>
-
-          <!-- Delay Pool con estilos -->
-          <td class="px-4 py-3 whitespace-nowrap">
-            {% if connection.delay_pool != "N/A" %}
-            <span
-              class="px-2 py-1 rounded-full text-xs font-semibold bg-indigo-100 text-indigo-800"
-            >
-              Pool {{ connection.delay_pool }}
-            </span>
-            {% else %}
-            <span class="text-sm text-gray-500">N/A</span>
-            {% endif %}
-          </td>
-
-          <!-- Solicitudes -->
-          <td class="px-4 py-3 whitespace-nowrap text-sm font-medium">
-            {{ connection.nrequests }}
-          </td>
-
-          <!-- Dir. Remota (única columna de IP) -->
-          <td class="px-4 py-3 whitespace-nowrap text-sm font-mono">
-            {{ connection.remote }}
-          </td>
-        </tr>
-        {% endfor %}
-      </tbody>
-    </table>
-  </div>
-</div>
-{% endfor %}

+ 0 - 544
templates/components/graph_reports.html

@@ -1,544 +0,0 @@
-<!DOCTYPE html>
-<html lang="es">
-  <head>
-    <meta charset="UTF-8" />
-    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
-    <title>Dashboard de Navegación</title>
-    <script src="{{ url_for('static', filename='js/tailwindcss.js') }}"></script>
-    <script src="{{ url_for('static', filename='js/chart.js') }}"></script>
-    <script src="{{ url_for('static', filename='js/chartjs-plugin-datalabels.js') }}"></script>
-  </head>
-  <body class="bg-gray-100">
-    <div class="container mx-auto px-4 py-8">
-      <header class="mb-8">
-        <h1 class="text-3xl font-bold text-gray-800">
-          Dashboard de Navegación
-        </h1>
-        <div class="flex flex-wrap justify-between mt-4">
-          <div
-            class="bg-white p-4 rounded-lg shadow-md w-full md:w-auto mb-4 md:mb-0"
-          >
-            <h3 class="text-lg font-semibold text-gray-700">
-              Usuarios Totales
-            </h3>
-            <p class="text-2xl font-bold text-blue-600">
-              {{ metrics.total_stats.total_users }}
-            </p>
-          </div>
-          <div
-            class="bg-white p-4 rounded-lg shadow-md w-full md:w-auto mb-4 md:mb-0"
-          >
-            <h3 class="text-lg font-semibold text-gray-700">
-              Registros de Log
-            </h3>
-            <p class="text-2xl font-bold text-green-600">
-              {{ metrics.total_stats.total_log_entries }}
-            </p>
-          </div>
-          <div
-            class="bg-white p-4 rounded-lg shadow-md w-full md:w-auto mb-4 md:mb-0"
-          >
-            <h3 class="text-lg font-semibold text-gray-700">
-              Datos Transmitidos
-            </h3>
-            <p class="text-2xl font-bold text-purple-600">
-              {{ "%.2f"|format(metrics.total_stats.total_data_transmitted /
-              (1024**3)) }} GB
-            </p>
-          </div>
-          <div class="bg-white p-4 rounded-lg shadow-md w-full md:w-auto">
-            <h3 class="text-lg font-semibold text-gray-700">Total Requests</h3>
-            <p class="text-2xl font-bold text-orange-600">
-              {{ metrics.total_stats.total_requests }}
-            </p>
-          </div>
-          <div class="w-full md:w-auto flex items-center md:ml-4 mt-4 md:mt-0">
-            <div
-              class="bg-white p-4 rounded-lg shadow-md border border-gray-200 hover:shadow-lg transition-shadow duration-200"
-            >
-              <h3 class="text-lg font-semibold text-gray-700">
-                Filtrar por Fecha
-              </h3>
-              <div class="reports-date-picker flex items-center gap-2">
-                <div
-                  class="flex items-center justify-center w-8 h-8 bg-indigo-50 rounded-md"
-                >
-                  <svg
-                    xmlns="http://www.w3.org/2000/svg"
-                    class="h-4 w-4 text-indigo-600"
-                    fill="none"
-                    viewBox="0 0 24 24"
-                    stroke="currentColor"
-                    stroke-width="2"
-                  >
-                    <path
-                      stroke-linecap="round"
-                      stroke-linejoin="round"
-                      d="M8 7V3m8 4V3M3 11h18M5 21h14a2 2 0 0 0 2-2V7a2 2 0 0 0-2-2H5a2 2 0 0 0-2 2v12a2 2 0 0 0 2 2z"
-                    />
-                  </svg>
-                </div>
-
-                <input
-                  id="reports-date"
-                  type="text"
-                  datepicker
-                  datepicker-orientation="bottom"
-                  datepicker-autohide
-                  datepicker-container="body"
-                  class="flex-1 min-w-0 w-32 rounded-md border border-gray-300 bg-white px-3 py-2 text-sm text-gray-900 placeholder-gray-500 focus:border-indigo-500 focus:outline-none focus:ring-1 focus:ring-indigo-500 transition-colors duration-200"
-                />
-
-                <button
-                  id="reports-go"
-                  class="inline-flex items-center justify-center px-3 py-2 border border-transparent text-sm font-medium rounded-md text-white bg-indigo-600 hover:bg-indigo-700 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-indigo-500 transition-colors duration-200 disabled:opacity-50 disabled:cursor-not-allowed"
-                >
-                  <svg
-                    xmlns="http://www.w3.org/2000/svg"
-                    class="h-4 w-4 mr-1"
-                    fill="none"
-                    viewBox="0 0 24 24"
-                    stroke="currentColor"
-                    stroke-width="2"
-                  >
-                    <path
-                      stroke-linecap="round"
-                      stroke-linejoin="round"
-                      d="M21 21l-6-6m2-5a7 7 0 11-14 0 7 7 0 0114 0z"
-                    />
-                  </svg>
-                  Ver
-                </button>
-              </div>
-            </div>
-          </div>
-        </div>
-      </header>
-
-      <div class="grid grid-cols-1 lg:grid-cols-2 gap-6 mb-8">
-        <div class="bg-white p-6 rounded-lg shadow-md">
-          <h2 class="text-xl font-bold mb-4 text-gray-800">
-            Top 20 Usuarios por Actividad
-          </h2>
-          <div class="h-80">
-            <canvas id="usersActivityChart"></canvas>
-          </div>
-        </div>
-
-        <div class="bg-white p-6 rounded-lg shadow-md">
-          <h2 class="text-xl font-bold mb-4 text-gray-800">
-            Top 20 Usuarios por Datos Transmitidos
-          </h2>
-          <div class="h-80">
-            <canvas id="usersDataChart"></canvas>
-          </div>
-        </div>
-      </div>
-
-      <div class="bg-white p-6 rounded-lg shadow-md mb-8">
-        <h2 class="text-xl font-bold mb-4 text-gray-800">
-          Distribución de Códigos HTTP
-        </h2>
-        <div class="h-96">
-          <canvas id="httpCodesChart"></canvas>
-        </div>
-      </div>
-
-      <div class="bg-white p-6 rounded-lg shadow-md mb-8">
-        <h2 class="text-xl font-bold mb-4 text-gray-800">
-          Top 20 Páginas Más Visitadas
-        </h2>
-        <div class="overflow-x-auto">
-          <table class="min-w-full divide-y divide-gray-200">
-            <thead class="bg-gray-50">
-              <tr>
-                <th
-                  class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider"
-                >
-                  URL
-                </th>
-                <th
-                  class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider"
-                >
-                  Total Requests
-                </th>
-                <th
-                  class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider"
-                >
-                  Visitas Únicas
-                </th>
-                <th
-                  class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider"
-                >
-                  Datos Transmitidos
-                </th>
-              </tr>
-            </thead>
-            <tbody class="bg-white divide-y divide-gray-200">
-              {% for page in metrics.top_pages %}
-              <tr class="hover:bg-gray-50">
-                <td
-                  class="px-6 py-4 whitespace-nowrap text-sm font-medium text-gray-900 truncate max-w-xs"
-                >
-                  {{ page.url }}
-                </td>
-                <td class="px-6 py-4 whitespace-nowrap text-sm text-gray-500">
-                  {{ page.total_requests }}
-                </td>
-                <td class="px-6 py-4 whitespace-nowrap text-sm text-gray-500">
-                  {{ page.unique_visits }}
-                </td>
-                <td class="px-6 py-4 whitespace-nowrap text-sm text-gray-500">
-                  {{ "%.2f"|format(page.total_data_bytes / (1024**2)) }} MB
-                </td>
-              </tr>
-              {% endfor %}
-            </tbody>
-          </table>
-        </div>
-      </div>
-
-      <div class="bg-white p-6 rounded-lg shadow-md">
-        <h2 class="text-xl font-bold mb-4 text-gray-800">
-          IPs Compartidas por Múltiples Usuarios
-        </h2>
-        <div class="overflow-x-auto">
-          <table class="min-w-full divide-y divide-gray-200">
-            <thead class="bg-gray-50">
-              <tr>
-                <th
-                  class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider"
-                >
-                  IP
-                </th>
-                <th
-                  class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider"
-                >
-                  Número de Usuarios
-                </th>
-                <th
-                  class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider"
-                >
-                  Usuarios
-                </th>
-              </tr>
-            </thead>
-            <tbody class="bg-white divide-y divide-gray-200">
-              {% for ip in metrics.users_per_ip %}
-              <tr class="hover:bg-gray-50">
-                <td
-                  class="px-6 py-4 whitespace-nowrap text-sm font-medium text-gray-900"
-                >
-                  {{ ip.ip }}
-                </td>
-                <td class="px-6 py-4 whitespace-nowrap text-sm text-gray-500">
-                  {{ ip.user_count }}
-                </td>
-                <td class="px-6 py-4 whitespace-nowrap text-sm text-gray-500">
-                  {{ ip.usernames }}
-                </td>
-              </tr>
-              {% endfor %}
-            </tbody>
-          </table>
-        </div>
-      </div>
-    </div>
-    <script type="application/json" id="chart-data">
-      {
-        "usersActivity": {
-          "labels": {{ metrics.top_users_by_activity | map(attribute='username') | list | tojson | safe }},
-          "data": {{ metrics.top_users_by_activity | map(attribute='total_visits') | list | tojson | safe }}
-        },
-        "usersData": {
-          "labels": {{ metrics.top_users_by_data_transferred | map(attribute='username') | list | tojson | safe }},
-          "data": {{ metrics.top_users_by_data_transferred | map(attribute='total_data_bytes') | map('divide', 1048576) | list | tojson | safe }}
-        },
-        "httpCodes": {
-          "labels": {{ metrics.http_response_distribution_chart.labels | tojson | safe }},
-          "data": {{ metrics.http_response_distribution_chart.data | tojson | safe }},
-          "colors": {{ metrics.http_response_distribution_chart.colors | tojson | safe }}
-        }
-      }
-    </script>
-
-    <script>
-      // Chart.js configuration
-      document.addEventListener("DOMContentLoaded", function () {
-        // Load data from JSON script tag
-        const chartDataElement = document.getElementById("chart-data");
-        const chartData = JSON.parse(chartDataElement.textContent);
-
-        const chartColors = [
-          "#3B82F6",
-          "#10B981",
-          "#F59E0B",
-          "#EF4444",
-          "#8B5CF6",
-          "#EC4899",
-          "#14B8A6",
-          "#F97316",
-          "#64748B",
-          "#84CC16",
-          "#06B6D4",
-          "#D946EF",
-          "#F43F5E",
-          "#0EA5E9",
-          "#22C55E",
-          "#EAB308",
-          "#F43F5E",
-          "#8B5CF6",
-          "#EC4899",
-          "#14B8A6",
-        ];
-
-        // Helper function to get text color based on theme
-        function getTextColor() {
-          return document.documentElement.classList.contains("dark")
-            ? "#d1d5db"
-            : "#374151";
-        }
-
-        // Helper function to get border color based on theme
-        function getBorderColor() {
-          return document.documentElement.classList.contains("dark")
-            ? "#374151"
-            : "#fff";
-        }
-
-        // Users Activity Chart
-        const usersActivityCtx = document.getElementById("usersActivityChart");
-        if (usersActivityCtx && chartData.usersActivity) {
-          new Chart(usersActivityCtx.getContext("2d"), {
-            type: "bar",
-            data: {
-              labels: chartData.usersActivity.labels,
-              datasets: [
-                {
-                  label: "Visitas",
-                  data: chartData.usersActivity.data,
-                  backgroundColor: chartColors.slice(
-                    0,
-                    chartData.usersActivity.data.length
-                  ),
-                  borderColor: chartColors
-                    .slice(0, chartData.usersActivity.data.length)
-                    .map((color) => color + "DD"),
-                  borderWidth: 1,
-                },
-              ],
-            },
-            options: {
-              responsive: true,
-              maintainAspectRatio: false,
-              plugins: {
-                legend: { display: false },
-                tooltip: { mode: "index", intersect: false },
-                datalabels: { display: false },
-              },
-              scales: {
-                y: {
-                  beginAtZero: true,
-                  title: { display: true, text: "Número de Visitas" },
-                  ticks: { color: getTextColor() },
-                },
-                x: {
-                  ticks: {
-                    autoSkip: false,
-                    color: getTextColor(),
-                  },
-                },
-              },
-            },
-          });
-        }
-
-        // Users Data Chart
-        const usersDataCtx = document.getElementById("usersDataChart");
-        if (usersDataCtx && chartData.usersData) {
-          new Chart(usersDataCtx.getContext("2d"), {
-            type: "bar",
-            data: {
-              labels: chartData.usersData.labels,
-              datasets: [
-                {
-                  label: "Datos (MB)",
-                  data: chartData.usersData.data,
-                  backgroundColor: chartColors.slice(
-                    0,
-                    chartData.usersData.data.length
-                  ),
-                  borderColor: chartColors
-                    .slice(0, chartData.usersData.data.length)
-                    .map((color) => color + "DD"),
-                  borderWidth: 1,
-                },
-              ],
-            },
-            options: {
-              responsive: true,
-              maintainAspectRatio: false,
-              plugins: {
-                legend: { display: false },
-                tooltip: {
-                  mode: "index",
-                  intersect: false,
-                  callbacks: {
-                    label: function (context) {
-                      return (
-                        context.dataset.label +
-                        ": " +
-                        context.raw.toFixed(2) +
-                        " MB"
-                      );
-                    },
-                  },
-                },
-                datalabels: { display: false },
-              },
-              scales: {
-                y: {
-                  beginAtZero: true,
-                  title: { display: true, text: "Datos Transmitidos (MB)" },
-                  ticks: { color: getTextColor() },
-                },
-                x: {
-                  ticks: {
-                    autoSkip: false,
-                    color: getTextColor(),
-                  },
-                },
-              },
-            },
-          });
-        }
-
-        // HTTP Codes Chart
-        const httpCodesCtx = document.getElementById("httpCodesChart");
-        if (httpCodesCtx && chartData.httpCodes) {
-          new Chart(httpCodesCtx.getContext("2d"), {
-            type: "pie",
-            data: {
-              labels: chartData.httpCodes.labels,
-              datasets: [
-                {
-                  data: chartData.httpCodes.data,
-                  backgroundColor: chartData.httpCodes.colors,
-                  borderColor: getBorderColor(),
-                  borderWidth: 2,
-                },
-              ],
-            },
-            options: {
-              responsive: true,
-              maintainAspectRatio: false,
-              plugins: {
-                legend: {
-                  position: "right",
-                  labels: {
-                    font: { size: 12 },
-                    color: getTextColor(),
-                  },
-                },
-                tooltip: {
-                  callbacks: {
-                    label: function (context) {
-                      const total = context.dataset.data.reduce(function (
-                        a,
-                        b
-                      ) {
-                        return a + b;
-                      },
-                      0);
-                      const percentage = ((context.raw / total) * 100).toFixed(
-                        1
-                      );
-                      return (
-                        context.label +
-                        ": " +
-                        context.raw +
-                        " (" +
-                        percentage +
-                        "%)"
-                      );
-                    },
-                  },
-                },
-                datalabels: {
-                  formatter: function (value, ctx) {
-                    const total = ctx.chart.data.datasets[0].data.reduce(
-                      function (a, b) {
-                        return a + b;
-                      },
-                      0
-                    );
-                    const percentage = ((value / total) * 100).toFixed(1);
-                    return percentage > 3 ? percentage + "%" : "";
-                  },
-                  color: "#fff",
-                  font: {
-                    weight: "bold",
-                    size: 12,
-                  },
-                },
-              },
-            },
-            plugins: [ChartDataLabels],
-          });
-        }
-
-        // Update chart colors when dark mode changes
-        const observer = new MutationObserver(function (mutations) {
-          mutations.forEach(function (mutation) {
-            if (
-              mutation.type === "attributes" &&
-              mutation.attributeName === "class"
-            ) {
-              // Re-render charts with new colors when dark mode changes
-              setTimeout(function () {
-                Chart.helpers.each(Chart.instances, function (instance) {
-                  // Update scale colors
-                  if (
-                    instance.config.options &&
-                    instance.config.options.scales
-                  ) {
-                    const textColor = getTextColor();
-                    if (
-                      instance.config.options.scales.y &&
-                      instance.config.options.scales.y.ticks
-                    ) {
-                      instance.config.options.scales.y.ticks.color = textColor;
-                    }
-                    if (
-                      instance.config.options.scales.x &&
-                      instance.config.options.scales.x.ticks
-                    ) {
-                      instance.config.options.scales.x.ticks.color = textColor;
-                    }
-                  }
-                  // Update legend colors
-                  if (
-                    instance.config.options &&
-                    instance.config.options.plugins &&
-                    instance.config.options.plugins.legend &&
-                    instance.config.options.plugins.legend.labels
-                  ) {
-                    instance.config.options.plugins.legend.labels.color =
-                      getTextColor();
-                  }
-                  instance.update();
-                });
-              }, 100);
-            }
-          });
-        });
-
-        observer.observe(document.documentElement, {
-          attributes: true,
-          attributeFilter: ["class"],
-        });
-      });
-    </script>
-  <script src="{{ url_for('static', filename='js/reports-datepicker.js') }}"></script>
-  </body>
-</html>

+ 0 - 95
templates/components/logs.html

@@ -1,95 +0,0 @@
-<div class="users-dashboard max-w-[1200px] mx-auto p-8">
-  <div
-    class="dashboard-header flex justify-between items-center mb-8 flex-wrap gap-4"
-  >
-    <h1
-      class="dashboard-title text-center font-semibold text-[2.2rem] text-blue-500"
-    >
-      Panel Actividad de Usuarios
-    </h1>
-    <div class="filters-container flex gap-4 items-center">
-      <div
-        class="date-filter max-w-xs mx-auto rounded-[0.5rem] shadow-md overflow-hidden relative"
-      >
-        <input
-          type="date"
-          id="date-filter"
-          class="w-full px-4 py-3 border border-gray-300 rounded-lg bg-white shadow-sm text-sm text-gray-700 focus:outline-none focus:ring-2 focus:ring-blue-500 focus:border-blue-500 h-12"
-        />
-      </div>
-
-      <div
-        class="search-container flex items-center bg-white rounded-[0.5rem] shadow-md overflow-hidden w-[250px] relative"
-      >
-        <input
-          type="text"
-          id="username-search"
-          placeholder="Buscar por usuario..."
-          class="search-input w-full pl-4 pr-10 py-3 rounded-[0.5rem] border border-gray-300 focus:outline-none focus:ring-2 focus:ring-blue-500 focus:border-blue-500 text-gray-800 h-12"
-        />
-
-        <!-- Botón de limpiar búsqueda (NUEVO) -->
-        <button
-          id="clear-search"
-          class="absolute right-10 h-full items-center justify-center text-gray-400 hover:text-gray-700 hidden"
-          title="Limpiar búsqueda"
-        >
-          <i class="fas fa-times"></i>
-        </button>
-
-        <div
-          class="absolute inset-y-0 right-3 flex items-center pointer-events-none"
-        >
-          <i class="fas fa-magnifying-glass text-xl text-[#1A8A9D]"></i>
-        </div>
-      </div>
-    </div>
-  </div>
-
-  <div
-    class="users-container grid grid-cols-1 sm:grid-cols-2 md:grid-cols-3 lg:grid-cols-4 xl:grid-cols-5 gap-4 max-w-screen-xl mx-auto px-4"
-    id="users-container"
-  ></div>
-  <div id="modals-container"></div>
-  <div
-    class="pagination-container flex justify-center items-center mt-12 gap-4"
-  >
-    <button
-      id="first-page"
-      aria-label="First page"
-      class="pg-btn first w-12 h-12 flex items-center justify-center rounded-full bg-white text-blue-600 cursor-pointer font-semibold shadow-md transition-all duration-200 ease-in-out text-xl hover:-translate-y-1 disabled:cursor-not-allowed disabled:opacity-50 disabled:transform-none"
-    >
-      <i class="fas fa-angle-double-left"></i>
-    </button>
-    <button
-      id="prev-page"
-      aria-label="Previous page"
-      class="pg-btn prev w-12 h-12 flex items-center justify-center rounded-full bg-white text-blue-600 cursor-pointer font-semibold shadow-md transition-all duration-200 ease-in-out text-xl hover:-translate-y-1 disabled:cursor-not-allowed disabled:opacity-50 disabled:transform-none"
-    >
-      <i class="fas fa-angle-left"></i>
-    </button>
-    <!-- Aquí el JS generará los botones de página -->
-    <div class="pagination flex gap-1" id="page-numbers"></div>
-    <button
-      id="next-page"
-      aria-label="Next page"
-      class="pg-btn next w-12 h-12 flex items-center justify-center rounded-full bg-white text-blue-600 cursor-pointer font-semibold shadow-md transition-all duration-200 ease-in-out text-xl hover:-translate-y-1 disabled:cursor-not-allowed disabled:opacity-50 disabled:transform-none"
-    >
-      <i class="fas fa-angle-right"></i>
-    </button>
-    <button
-      id="last-page"
-      aria-label="Last page"
-      class="pg-btn last w-12 h-12 flex items-center justify-center rounded-full bg-white text-blue-600 cursor-pointer font-semibold shadow-md transition-all duration-200 ease-in-out text-xl hover:-translate-y-1 disabled:cursor-not-allowed disabled:opacity-50 disabled:transform-none"
-    >
-      <i class="fas fa-angle-double-right"></i>
-    </button>
-  </div>
-</div>
-
-<div
-  class="overlay fixed inset-0 bg-black bg-opacity-50 z-50 hidden transition-opacity duration-1000 ease-in-out opacity-0"
-  id="overlay"
-></div>
-
-<script type="module" src="static/js/dashboard.js"></script>

+ 52 - 0
templates/layouts/base.html

@@ -0,0 +1,52 @@
+<!DOCTYPE html>
+<html lang="es">
+  <head>
+    <meta charset="UTF-8" />
+    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
+    <meta name="csrf-token" content="{{ csrf_token() }}">
+    <title>{{ page_title or 'Dashboard Squid' }}</title>
+
+    <!-- Favicon dinámico -->
+    <link rel="icon" href="{{ url_for('static', filename=page_icon) }}" type="image/x-icon"/>
+
+    <!-- Hojas de estilo -->
+    <link rel="stylesheet" href="{{ url_for('static', filename='styles.css') }}"/>
+    <link rel="stylesheet" href="{{url_for('static',filename='dist/output.css')}}"/>
+    <link rel="stylesheet" href="{{ url_for('static', filename='all.min.css') }}"/>
+    <!-- Font Awesome -->
+    <link rel="stylesheet" href="{{ url_for('static', filename='logs.css') }}"/>
+    <!-- Estilos específicos de cada página -->
+    {% block styles %}{% endblock styles %}
+  </head>
+  <body class="overflow-x-hidden overflow-auto" style="visibility: hidden" onload="document.body.style.visibility='visible';">
+    <!-- Barra de navegación común -->
+    <div class="relative">
+      {% include 'components/navbar.html' %}
+      <!-- Contenido principal con padding para el navbar -->
+      <main class="min-h-screen pt-10 lg:pt-10 pb-20">
+        <div class="max-w-7xl mx-auto px-4 py-8">
+          {% block title %}
+            <div class="flex items-center mb-6 border-b pb-4">
+              <i class="{{icon}} text-3xl text-blue-600 mr-4"></i> <!-- agregar icon al contexto para mostrar el icono dinamicamente -->
+              <div>
+                  <h1 class="text-3xl font-bold text-gray-800">{{page_title}}</h1>  <!-- usando page_title del contexto para mostrar el titulo dinamicamente puedes hacer lo mismo con el icono(icon) y el subtitulo(subtitle) -->
+                  <p class="text-gray-500 mt-1">
+                    {{subtitle}} <!-- agregar subtitle al contexto para mostrarlo dinamicamente -->
+                  </p>
+              </div>
+            </div>
+          {% endblock title %}
+          {% block content %}{% endblock %}
+        </div>
+      </main>
+    </div>
+    <!-- Footer -->
+    {% include 'components/footer.html' %}
+    <!-- Socket.IO -->
+    <script src="{{ url_for('static', filename='js/socket.io.min.js') }}"></script>
+    <!-- Scripts de Flowbite (UI components) -->
+    <script src="{{ url_for('static', filename='src/flowbite.min.js') }}"></script>
+    <!-- Scripts específicos de cada página -->
+    {% block scripts %}{% endblock scripts %}
+  </body>
+</html>

+ 13 - 0
templates/macros.html

@@ -0,0 +1,13 @@
+{# templates/macros.html #}
+{% macro format_bandwidth(bw_value) %}
+  {% if bw_value is defined %}
+    {% set bw = bw_value|float %}
+    {% if bw >= 1000000 %}
+      {{ (bw / 1000000)|round(2) }} Gbps
+    {% elif bw >= 1000 %}
+      {{ (bw / 1000)|round(2) }} Mbps
+    {% else %}
+      {{ bw|round(2) }} Kbps
+    {% endif %}
+  {% else %}0 kbps{% endif %}
+{% endmacro %}

+ 188 - 0
templates/partials/auditoria.html

@@ -0,0 +1,188 @@
+
+<div class="max-w-7xl mx-auto px-4 sm:px-6 lg:px-8 py-8">
+  <div class="bg-white p-6 rounded-lg shadow-lg mb-8">
+    <form id="audit-form" class="grid grid-cols-1 lg:grid-cols-3 gap-x-8 gap-y-6">
+      <div class="lg:col-span-2 grid grid-cols-1 md:grid-cols-2 gap-6">
+        <div class="md:col-span-2">
+          <label
+            for="audit-type"
+            class="block text-sm font-semibold text-gray-700 mb-1">Tipo de Auditoría</label>
+          <select
+            id="audit-type"
+            name="audit_type"
+            class="w-full border-gray-300 rounded-md shadow-sm focus:border-blue-500 focus:ring-blue-500 bg-gray-50">
+            <optgroup label="Actividad General">
+              <option value="user_summary" data-requires="user">
+                Resumen por Usuario
+              </option>
+              <option value="top_users_data">Top 10 Usuarios (Datos)</option>
+              <option value="top_urls_data">Top 15 URLs (Datos)</option>
+              <option value="top_users_requests">Top 10 Usuarios (Peticiones)</option>
+              <option value="top_ips_data">Top 10 IPs (Datos)</option>
+              <!-- <option value="daily_activity" data-requires="user">
+                Actividad Diaria
+              </option> -->
+            </optgroup>
+            <optgroup label="Seguridad y Políticas">
+              <option
+                value="keyword_search"
+                data-requires="user_optional,keyword">
+                Búsqueda por Palabra Clave
+              </option>
+              <option
+                value="social_media_activity"
+                data-requires="user_optional,social_media">
+                Actividad en Redes Sociales
+              </option>
+            </optgroup>
+            <optgroup label="Auditoría Técnica">
+              <option value="ip_activity" data-requires="ip">
+                Actividad por Dirección IP
+              </option>
+              <option
+                value="response_code_search"
+                data-requires="user_optional,response_code">
+                Análisis por Código de Respuesta
+              </option>
+            </optgroup>
+          </select>
+        </div>
+
+        <div id="conditional-inputs" class="contents">
+          <div id="user-filter-container" class="conditional-input">
+            <label for="username-filter" class="block text-sm font-semibold text-gray-700 mb-1">Usuario</label>
+            <div class="relative">
+              <input type="text" id="user-search-input" placeholder="Buscar usuario..." class="w-full border-gray-300 rounded-md shadow-sm focus:border-blue-500 focus:ring-blue-500 bg-gray-50 pr-8" autocomplete="off"/>
+              <i class="fas fa-search absolute right-3 top-1/2 transform -translate-y-1/2 text-gray-400 text-sm"></i>
+              <div id="user-dropdown" class="absolute z-50 w-full mt-1 bg-white border border-gray-300 rounded-md shadow-lg max-h-48 overflow-y-auto hidden">
+                <div id="user-options-container">
+                  <!-- Las opciones se llenarán dinámicamente -->
+                </div>
+              </div>
+            </div>
+            <select id="username-filter" name="username" class="hidden">
+              <option value="">-- Todos --</option>
+            </select>
+          </div>
+          <div id="keyword-input-container" class="conditional-input">
+            <label for="keyword-input" class="block text-sm font-semibold text-gray-700 mb-1">Palabra Clave</label>
+            <input type="text" id="keyword-input" name="keyword" class="w-full border-gray-300 rounded-md shadow-sm bg-gray-50" placeholder="Ej: juegos, descargas..."/>
+          </div>
+          <div id="ip-input-container" class="conditional-input">
+            <label for="ip-input" class="block text-sm font-semibold text-gray-700 mb-1">Dirección IP</label>
+            <input type="text" id="ip-input" name="ip_address" class="w-full border-gray-300 rounded-md shadow-sm bg-gray-50" placeholder="Ej: 192.168.1.100"/>
+          </div>
+          <div id="social-media-input-container" class="conditional-input md:col-span-2">
+            <label class="block text-sm font-semibold text-gray-700 mb-2">Redes Sociales</label>
+            <div id="social-media-chips" class="flex flex-wrap gap-3">
+              <div class="relative group">
+                <button type="button" class="social-chip" data-value="Facebook">
+                  Facebook
+                </button>
+                <span class="tooltip">Selección múltiple</span>
+              </div>
+              <div class="relative group">
+                <button type="button" class="social-chip" data-value="Instagram">
+                  Instagram
+                </button>
+                <span class="tooltip">Selección múltiple</span>
+              </div>
+              <div class="relative group">
+                <button type="button" class="social-chip" data-value="YouTube">
+                  YouTube
+                </button>
+                <span class="tooltip">Selección múltiple</span>
+              </div>
+              <div class="relative group">
+                <button type="button" class="social-chip" data-value="Twitter/X">
+                  Twitter/X
+                </button>
+                <span class="tooltip">Selección múltiple</span>
+              </div>
+              <div class="relative group">
+                <button type="button" class="social-chip" data-value="WhatsApp">
+                  WhatsApp
+                </button>
+                <span class="tooltip">Selección múltiple</span>
+              </div>
+              <div class="relative group">
+                <button type="button" class="social-chip" data-value="Telegram">
+                  Telegram
+                </button>
+                <span class="tooltip">Selección múltiple</span>
+              </div>
+              <div class="relative group">
+                <button type="button" class="social-chip" data-value="Pinterest">
+                  Pinterest
+                </button>
+                <span class="tooltip">Selección múltiple</span>
+              </div>
+            </div>
+          </div>
+          <div id="response-code-input-container" class="conditional-input">
+            <label for="response-code-input" class="block text-sm font-semibold text-gray-700 mb-1">Código HTTP</label>
+            <select id="response-code-input" name="response_code" class="w-full border-gray-300 rounded-md shadow-sm focus:border-blue-500 focus:ring-blue-500 bg-gray-50">
+              <option value="">-- Seleccione un código --</option>
+              <optgroup label="Respuestas Exitosas (2xx)">
+                <option value="200">200 OK</option>
+              </optgroup>
+              <optgroup label="Redirecciones (3xx)">
+                <option value="301">301 Moved Permanently</option>
+                <option value="302">302 Found</option>
+                <option value="304">304 Not Modified</option>
+              </optgroup>
+              <optgroup label="Errores de Cliente (4xx)">
+                <option value="400">400 Bad Request</option>
+                <option value="401">401 Unauthorized</option>
+                <option value="403">403 Forbidden</option>
+                <option value="404">404 Not Found</option>
+              </optgroup>
+              <optgroup label="Errores de Servidor (5xx)">
+                <option value="500">500 Internal Server Error</option>
+                <option value="502">502 Bad Gateway</option>
+                <option value="503">503 Service Unavailable</option>
+                <option value="504">504 Gateway Timeout</option>
+              </optgroup>
+            </select>
+          </div>
+        </div>
+      </div>
+
+      <div class="lg:col-span-1 bg-slate-50 border border-slate-200 rounded-lg p-4 h-fit">
+        <h3 class="text-md font-semibold text-slate-800 mb-4 border-b pb-2">
+          Fecha del Reporte
+        </h3>
+        <div class="space-y-4">
+          <div id="start-date-container">
+            <label for="start-date" class="block text-sm font-semibold text-gray-700 mb-1">Fecha</label>
+            <input type="date" id="start-date" name="start_date" class="w-full border-gray-300 rounded-md shadow-sm focus:border-blue-500 focus:ring-blue-500 bg-gray-50"/>
+          </div>
+          <div id="end-date-container">
+            <label for="end-date" class="block text-sm font-semibold text-gray-700 mb-1"
+              >Fecha de Fin</label>
+            <input type="date" id="end-date" name="end_date" class="w-full border-gray-300 rounded-md shadow-sm focus:border-blue-500 focus:ring-blue-500 bg-gray-50"/>
+          </div>
+        </div>
+      </div>
+
+      <div class="lg:col-span-3">
+        <button type="submit" class="w-full bg-blue-600 text-white font-bold py-2.5 px-4 rounded-md hover:bg-blue-700 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-blue-500 transition-all duration-300 flex items-center justify-center shadow-lg hover:shadow-xl">
+          <i class="fas fa-play mr-2"></i>
+          Generar Reporte
+        </button>
+      </div>
+    </form>
+  </div>
+
+  <div id="audit-results-container" class="space-y-4">
+    <div class="bg-white p-6 rounded-lg shadow-lg min-h-[300px] flex items-center justify-center">
+      <div class="text-center text-gray-500 py-10">
+        <i class="fas fa-clipboard-list text-5xl mb-4 text-gray-300"></i>
+        <h3 class="text-xl font-semibold">
+          Seleccione los filtros y genere un reporte
+        </h3>
+        <p class="mt-2">Los resultados de su auditoría aparecerán aquí.</p>
+      </div>
+    </div>
+  </div>
+</div>

+ 4 - 22
templates/components/black_list.html → templates/partials/black_list.html

@@ -1,17 +1,8 @@
 <div class="max-w-7xl mx-auto px-4 sm:px-6 lg:px-8 py-8">
-    <div class="flex flex-col md:flex-row justify-between items-start md:items-center mb-6">
-        <h1 class="text-3xl font-bold text-gray-800 mb-4 md:mb-0">
-            <svg class="h-8 w-8 inline-block mr-2 text-red-500" fill="none" stroke="currentColor" viewBox="0 0 24 24">
-                <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M18.364 18.364A9 9 0 005.636 5.636m12.728 12.728A9 9 0 015.636 5.636m12.728 12.728L5.636 5.636"/>
-            </svg>
-            Actividad en Sitios Bloqueados
-        </h1>
-        
-        <div class="bg-gray-100 px-4 py-2 rounded-lg shadow-sm">
-            <span class="text-sm font-medium text-gray-600">
-                Página {{ pagination.page }} de {{ pagination.total_pages }}
-            </span>
-        </div>
+    <div class="bg-gray-100 px-4 py-2 rounded-lg shadow-sm">
+        <span class="text-sm font-medium text-gray-600">
+            Página {{ pagination.page }} de {{ pagination.total_pages }}
+        </span>
     </div>
 
     <div class="bg-white rounded-lg shadow-md overflow-hidden">
@@ -127,12 +118,3 @@
         </div>
     </div>
 </div>
-
-<script>
-function updateQueryParam(param, value) {
-    const url = new URL(window.location.href);
-    url.searchParams.set(param, value);
-    url.searchParams.set('page', '1');
-    return url.toString();
-}
-</script>

+ 268 - 0
templates/partials/cache_stats.html

@@ -0,0 +1,268 @@
+<div class="max-w-7xl mx-auto px-4 sm:px-6 lg:px-8 py-8">
+  <div class="flex border-b mb-6">
+    <button id="dashboardTab" class="main-tab-btn active relative overflow-hidden py-3 px-6 font-medium text-blue-600">
+      <i class="fas fa-tachometer-alt mr-2"></i>Sistema
+    </button>
+    <button id="cacheTab"
+      class="main-tab-btn relative overflow-hidden py-3 px-6 font-medium text-gray-500 hover:text-blue-600">
+      <i class="fas fa-database mr-2"></i>Caché
+    </button>
+    <button id="networkTab" class="main-tab-btn relative overflow-hidden py-3 px-6 font-medium text-gray-500 hover:text-blue-600">
+      <i class="fas fa-network-wired mr-2"></i>Red
+    </button>
+  </div>
+
+  <div id="dashboardContent" class="main-tab-content active">
+    <section class="mb-12">
+      <div class="grid grid-cols-1 lg:grid-cols-2 gap-8">
+        <div class="bg-white rounded-xl shadow-lg p-6">
+          <div class="flex items-center mb-6">
+            <i class="fas fa-chart-pie text-2xl text-blue-600 mr-3"></i>
+            <h2 class="text-xl font-bold text-gray-800">
+              Estadísticas del Sistema
+            </h2>
+          </div>
+          <div class="grid grid-cols-1 md:grid-cols-3 gap-6 items-center justify-center">
+            <div class="flex flex-col items-center justify-center">
+              <div class="relative w-36 h-36">
+                <svg viewBox="0 0 36 36" class="block mx-auto">
+                  <path class="fill-none stroke-red-100 stroke-[3.5]" d="M18 2.0845 a 15.9155 15.9155 0 0 1 0 31.831 a 15.9155 15.9155 0 0 1 0 -31.831"/>
+                  <path id="cpu-ring" class="circle-animation fill-none stroke-linecap-round stroke-red-500 stroke-[3.5]" stroke-dasharray="0,100" d="M18 2.0845 a 15.9155 15.9155 0 0 1 0 31.831 a 15.9155 15.9155 0 0 1 0 -31.831"/>
+                  <text id="cpu-value" x="18" y="18" class="text-[0.5rem] fill-gray-500" text-anchor="middle" dominant-baseline="middle">0%</text>
+                </svg>
+              </div>
+              <h3 class="mt-2 font-semibold text-gray-700">CPU</h3>
+              <p class="text-xs mt-1 bg-red-500 text-white px-2 py-0.5 rounded-full font-medium">
+                {{ system_info.cpu.physical_cores }} núcleos
+              </p>
+            </div>
+            <div class="flex flex-col items-center justify-center">
+              <div class="relative w-36 h-36">
+                <svg viewBox="0 0 36 36" class="block mx-auto">
+                  <path class="fill-none stroke-blue-100 stroke-[3.5]" d="M18 2.0845 a 15.9155 15.9155 0 0 1 0 31.831 a 15.9155 15.9155 0 0 1 0 -31.831"/>
+                  <path id="ram-ring" class="circle-animation fill-none stroke-linecap-round stroke-blue-600 stroke-[3.5]" stroke-dasharray="0,100" d="M18 2.0845 a 15.9155 15.9155 0 0 1 0 31.831 a 15.9155 15.9155 0 0 1 0 -31.831"/>
+                  <text id="ram-used" x="18" y="18" class="text-[0.5rem] fill-gray-500" text-anchor="middle" dominant-baseline="middle">0G</text>
+                </svg>
+              </div>
+              <h3 class="mt-2 font-semibold text-gray-700">RAM</h3>
+              <p class="text-xs mt-1 bg-blue-500 text-white px-2 py-0.5 rounded-full font-medium">
+                {{ system_info.ram.total }}
+              </p>
+            </div>
+            <div class="flex flex-col items-center justify-center">
+              <div class="relative w-36 h-36">
+                <svg viewBox="0 0 36 36" class="block mx-auto">
+                  <path class="fill-none stroke-emerald-100 stroke-[3.5]" d="M18 2.0845 a 15.9155 15.9155 0 0 1 0 31.831 a 15.9155 15.9155 0 0 1 0 -31.831"/>
+                  <path id="swap-ring" class="circle-animation fill-none stroke-linecap-round stroke-emerald-500 stroke-[3.5]" stroke-dasharray="0,100" d="M18 2.0845 a 15.9155 15.9155 0 0 1 0 31.831 a 15.9155 15.9155 0 0 1 0 -31.831"/>
+                  <text id="swap-used" x="18" y="18" class="text-[0.5rem] fill-gray-500" text-anchor="middle" dominant-baseline="middle">0G</text>
+                </svg>
+              </div>
+              <h3 class="mt-2 font-semibold text-gray-700">SWAP</h3>
+              <p class="text-xs mt-1 bg-emerald-500 text-white px-2 py-0.5 rounded-full font-medium">
+                {{ system_info.swap.total }}
+              </p>
+            </div>
+          </div>
+        </div>
+
+        <div class="bg-white rounded-xl shadow-lg p-6">
+          <div class="flex items-center mb-6">
+            <i class="fas fa-info-circle text-2xl text-blue-600 mr-3"></i>
+            <h2 class="text-xl font-bold text-gray-800">
+              Información del Sistema
+            </h2>
+          </div>
+          <div class="grid grid-cols-1 md:grid-cols-2 gap-4">
+            <div class="flex items-start">
+              <i class="fas fa-server text-gray-500 mt-1 mr-3"></i>
+              <div>
+                <h3 class="text-sm font-semibold text-gray-600">
+                  Nombre del Host
+                </h3>
+                <p id="hostname" class="text-gray-800">
+                  {{ system_info.hostname }}
+                </p>
+              </div>
+            </div>
+            <div class="flex items-start">
+              <i class="fas fa-network-wired text-gray-500 mt-1 mr-3"></i>
+              <div>
+                <h3 class="text-sm font-semibold text-gray-600">
+                  Direcciones IP
+                </h3>
+                <p id="ip-addresses" class="text-gray-800">
+                  {% for ip in system_info.ips %}{{ ip.ip }}<br />{% endfor
+                  %}
+                </p>
+              </div>
+            </div>
+            <div class="flex items-start">
+              <i class="fab fa-linux text-gray-500 mt-1 mr-3"></i>
+              <div>
+                <h3 class="text-sm font-semibold text-gray-600">
+                  Sistema Operativo
+                </h3>
+                <p id="os-info" class="text-gray-800">
+                  {{ system_info.os }}
+                </p>
+              </div>
+            </div>
+            <div class="flex items-start">
+              <i class="fas fa-clock text-gray-500 mt-1 mr-3"></i>
+              <div>
+                <h3 class="text-sm font-semibold text-gray-600">
+                  Tiempo Encendido
+                </h3>
+                <p id="uptime" class="text-gray-800">
+                  {{ system_info.uptime }}
+                </p>
+              </div>
+            </div>
+            <div class="flex items-start">
+              <i class="fas fa-globe text-gray-500 mt-1 mr-3"></i>
+              <div>
+                <h3 class="text-sm font-semibold text-gray-600">
+                  Zona Horaria
+                </h3>
+                <p id="timezone" class="text-gray-800">
+                  {{ system_info.timezone }}
+                </p>
+              </div>
+            </div>
+            <div class="flex items-start">
+              <i class="fas fa-clock text-gray-500 mt-1 mr-3"></i>
+              <div>
+                <h3 class="text-sm font-semibold text-gray-600">
+                  Hora Local
+                </h3>
+                <p id="local-time" class="text-gray-800">
+                  {{ system_info.local_time }}
+                </p>
+              </div>
+            </div>
+          </div>
+        </div>
+      </div>
+    </section>
+
+    <section class="bg-white rounded-xl shadow-lg p-6 mb-12">
+      <div class="flex items-center justify-between mb-6">
+        <h2 class="text-xl font-bold text-gray-800">
+          Gráficas del Sistema
+        </h2>
+        <div class="flex bg-gray-100 rounded-lg p-1">
+          <button
+            id="todayBtn"
+            class="time-range-btn active px-4 py-2 rounded-md text-sm font-medium text-blue-600 bg-white shadow"
+          >
+            Hoy
+          </button>
+          <button
+            id="24hoursBtn"
+            class="time-range-btn px-4 py-2 rounded-md text-sm font-medium text-gray-500 hover:text-blue-600"
+          >
+            24 Horas
+          </button>
+        </div>
+      </div>
+      <div class="flex border-b mb-6">
+        <button
+          class="tab-btn active py-3 px-6 font-medium border-b-2 border-blue-600 text-blue-600 transition-all duration-300 ease-in-out hover:bg-slate-100"
+        >
+          CPU
+        </button>
+        <button
+          class="tab-btn py-3 px-6 font-medium text-gray-500 hover:text-blue-600 transition-all duration-300 ease-in-out hover:bg-slate-100"
+        >
+          RAM
+        </button>
+        <button
+          class="tab-btn py-3 px-6 font-medium text-gray-500 hover:text-blue-600 transition-all duration-300 ease-in-out hover:bg-slate-100"
+        >
+          SWAP
+        </button>
+      </div>
+      <div class="tab-content active">
+        <div class="h-80"><canvas id="cpuChart"></canvas></div>
+      </div>
+      <div class="tab-content">
+        <div class="h-80"><canvas id="ramChart"></canvas></div>
+      </div>
+      <div class="tab-content">
+        <div class="h-80"><canvas id="swapChart"></canvas></div>
+      </div>
+    </section>
+  </div>
+
+  <div id="cacheContent" class="main-tab-content">
+    <section class="cache-stats">
+      <div class="bg-white rounded-xl shadow-lg p-6 mb-8">
+        <div class="flex items-center mb-6">
+          <i class="fas fa-database text-2xl text-blue-600 mr-3"></i>
+          <h2 class="text-2xl font-bold text-gray-800">
+            Estadísticas de Caché
+          </h2>
+        </div>
+        <div
+          class="grid grid-cols-1 sm:grid-cols-2 md:grid-cols-3 gap-8 max-w-[1000px] mx-auto"
+        >
+          {{ flip_card(icon='fas fa-database', title='Entradas almacenadas',
+          value=cache_stats.store_entries, back_title='Entradas
+          Almacenadas', description='Número de objetos actualmente en la
+          caché de Squid.') }} {{ flip_card(icon='fas fa-chart-pie',
+          title='Uso de capacidad', value=cache_stats.capacity_used,
+          back_title='Uso de capacidad', description='Porcentaje del
+          almacenamiento de caché en uso actualmente.') }} {% if
+          cache_stats.fs_space_total and cache_stats.fs_space_total > 0 %}
+          {% set total_space_html %}{% if (cache_stats.fs_space_total /
+          1024) < 1024 %}
+          <p class="text-xl text-blue-800" data-stat="espacio_total">
+            {{ (cache_stats.fs_space_total / 1024)|int }} MB
+          </p>
+          {% else %}
+          <p class="text-xl text-blue-800" data-stat="espacio_total">
+            {{ (cache_stats.fs_space_total / 1024 / 1024)|round(2) }} GB
+          </p>
+          {% endif %}{% endset %} {{ flip_card(icon='fas fa-hdd',
+          title='Espacio total', back_title='Espacio total',
+          description='Tamaño total del disco asignado a la caché de
+          Squid.', extra_html=total_space_html) }} {% else %} {{
+          flip_card(icon='fas fa-hdd', title='Espacio total',
+          back_title='Espacio total', description='Tamaño total del disco
+          asignado a la caché de Squid.', extra_html='
+          <p class="text-xl text-red-600">No disponible</p>
+          ') }} {% endif %} {% set used_space_html %}{% if
+          (cache_stats.fs_space_used / 1024) < 1024 %}
+          <p class="text-xl text-blue-800" data-stat="espacio_usado">
+            {{ (cache_stats.fs_space_used / 1024)|int }} MB
+          </p>
+          {% else %}
+          <p class="text-xl text-blue-800" data-stat="espacio_usado">
+            {{ (cache_stats.fs_space_used / 1024 / 1024)|round(2) }} GB
+          </p>
+          {% endif %}{% endset %}{{ flip_card(icon='fas fa-folder-open',
+          title='Espacio usado', back_title='Espacio usado',
+          description='Cantidad de espacio de disco ya ocupado por objetos
+          en caché.', extra_html=used_space_html) }} {{ flip_card(icon='fas
+          fa-recycle', title='Eliminación',
+          value=cache_stats.removal_policy, back_title='Política de
+          eliminación', description='Método que Squid usa para eliminar
+          objetos antiguos de la caché.') }} {{ flip_card(icon='fas
+          fa-clock', title='Edad LRU', value=cache_stats.lru_age_days ~ '
+          días', back_title='Edad LRU', description='Tiempo desde que el
+          objeto menos usado fue accedido por última vez.') }}
+        </div>
+      </div>
+    </section>
+  </div>
+
+  <div id="networkContent" class="main-tab-content">
+    <section class="bg-white rounded-xl shadow-lg p-6">
+      <div class="flex items-center mb-6">
+        <i class="fas fa-network-wired text-2xl text-blue-600 mr-3"></i>
+        <h2 class="text-xl font-bold text-gray-800">Tráfico de Red</h2>
+      </div>
+      <div class="h-80"><canvas id="networkChart"></canvas></div>
+    </section>
+  </div>
+</div>

+ 254 - 423
templates/partials/conexiones.html

@@ -1,453 +1,284 @@
-{# Macro para formatear bandwidth #}
-{% macro format_bandwidth(bw_value) %}
-  {% if bw_value is defined %}
-    {% set bw = bw_value|float %}
-    {% if bw >= 1000000 %}
-      {{ (bw / 1000000)|round(2) }} Gbps
-    {% elif bw >= 1000 %}
-      {{ (bw / 1000)|round(2) }} Mbps
-    {% else %}
-      {{ bw|round(2) }} Kbps
-    {% endif %}
-  {% else %}0 kbps{% endif %}
-{% endmacro %}
-
-{% set valid_users = {} %} {% for user, user_data in grouped_connections.items()
-%} {% if user and user != "-" and user != "Anónimo" %} {% set _ =
-valid_users.update({user: user_data}) %} {% endif %} {% endfor %}
-
-<div class="max-w-7xl mx-auto py-6 sm:px-6 lg:px-8">
-  {# Tarjetas de estadísticas #}
-  <div class="flex justify-center mb-8">
+{% from 'macros.html' import format_bandwidth %}
+{# Tarjetas de estadísticas #}
+<div class="flex justify-center mb-8">
+  <div class="flex flex-wrap justify-center gap-4 w-full pb-2" style="scrollbar-width: none;">
+    {# Tarjeta de información del Servidor Squid --- #}
+    <div class="bg-white p-4 rounded-lg shadow flex items-center transition-all duration-300 ease-in-out hover:shadow-lg hover:-translate-y-0.5">
+      <div class="w-12 h-12 rounded-full bg-indigo-100 flex items-center justify-center mr-4 flex-shrink-0">
+        <i class="fas fa-server text-indigo-500 text-xl"></i>
+      </div>
+      <div>
+        <p class="text-gray-500 text-sm">
+          Servidor Squid Version:
+        </p>
+        <p class="text-2xl font-bold">{{ squid_version }}</p>
+      </div>
+    </div>
+    {# Tarjeta de Bandwidth Total de Todos los Usuarios #}
     <div
-      class="flex flex-wrap justify-center gap-4 w-full pb-2"
-      style="scrollbar-width: none;"
-    >
-
-      {# --- MODIFICADO: Tarjeta de información del Servidor Squid --- #}
-      <div
-        class="bg-white p-4 rounded-lg shadow flex items-center transition-all duration-300 ease-in-out hover:shadow-lg hover:-translate-y-0.5"
-      >
-        <div
-          class="w-12 h-12 rounded-full bg-indigo-100 flex items-center justify-center mr-4 flex-shrink-0"
-        >
-          <i class="fas fa-server text-indigo-500 text-xl"></i>
-        </div>
-        <div>
-          <p class="text-gray-500 text-sm">
-            Servidor Squid Version:
-          </p>
-          <p class="text-2xl font-bold">{{ squid_version }}</p>
-        </div>
+      class="bg-white p-4 rounded-lg shadow flex items-center transition-all duration-300 ease-in-out hover:shadow-lg hover:-translate-y-0.5">
+      <div class="w-12 h-12 rounded-full bg-teal-100 flex items-center justify-center mr-4 flex-shrink-0">
+        <i class="fas fa-tachometer-alt text-teal-500 text-xl"></i>
       </div>
-
-      {# Tarjeta de Bandwidth Total de Todos los Usuarios #}
-      <div
-        class="bg-white p-4 rounded-lg shadow flex items-center transition-all duration-300 ease-in-out hover:shadow-lg hover:-translate-y-0.5"
-      >
-        <div
-          class="w-12 h-12 rounded-full bg-teal-100 flex items-center justify-center mr-4 flex-shrink-0"
-        >
-          <i class="fas fa-tachometer-alt text-teal-500 text-xl"></i>
-        </div>
-        <div>
-          <p class="text-gray-500 text-sm">Total Bandwidth</p>
-          <p class="text-2xl font-bold">
-            {% set total_bw = namespace(value=0) %}
-            {% for user_data in valid_users.values() %}
-              {% for connection in user_data.connections %}
-                {% if connection.bandwidth_kbps is defined %}
-                  {% set total_bw.value = total_bw.value + (connection.bandwidth_kbps|float) %}
-                {% endif %}
-              {% endfor %}
+      <div>
+        <p class="text-gray-500 text-sm">Total Bandwidth</p>
+        <p class="text-2xl font-bold">
+          {% set total_bw = namespace(value=0) %}
+          {% for user_data in valid_users.values() %}
+            {% for connection in user_data.connections %}
+              {% if connection.bandwidth_kbps is defined %}
+                {% set total_bw.value = total_bw.value + (connection.bandwidth_kbps|float) %}
+              {% endif %}
             {% endfor %}
-            {{ format_bandwidth(total_bw.value) }}
-          </p>
-        </div>
+          {% endfor %}
+          {{ format_bandwidth(total_bw.value) }}
+        </p>
       </div>
-
-      <!-- {% if parent_proxy_ip %} 
-      {# Estado Con Padre #}
-      <div
-        class="bg-white p-4 rounded-lg shadow flex items-center transition-all duration-300 ease-in-out hover:shadow-lg hover:-translate-y-0.5"
-      >
-        <div
-          class="w-12 h-12 rounded-full bg-green-100 flex items-center justify-center mr-4 flex-shrink-0"
-        >
-          <i class="fas fa-sitemap text-green-500 text-xl"></i>
-        </div>
-        <div>
-          <p class="text-gray-500 text-sm">Proxy Padre Activo</p>
-          <p class="text-2xl font-bold">{{ parent_proxy_ip }}</p>
-        </div>
+    </div>
+    {# Tarjeta de Usuarios Activos #}
+    <div class="bg-white p-4 rounded-lg shadow flex items-center transition-all duration-300 ease-in-out hover:shadow-lg hover:-translate-y-0.5">
+      <div class="w-12 h-12 rounded-full bg-blue-100 flex items-center justify-center mr-4 flex-shrink-0">
+        <i class="fas fa-users text-blue-500 text-xl"></i>
       </div>
-      {% else %} {# Estado Sin Padre #}
-      <div
-        class="bg-white p-4 rounded-lg shadow flex items-center transition-all duration-300 ease-in-out hover:shadow-lg hover:-translate-y-0.5"
-      >
-        <div
-          class="w-12 h-12 rounded-full bg-gray-100 flex items-center justify-center mr-4 flex-shrink-0"
-        >
-          <i class="fas fa-plug-circle-xmark text-gray-500 text-xl"></i>
-        </div>
-        <div>
-          <p class="text-gray-500 text-sm">Sin Proxy Padre</p>
-          <p class="text-2xl font-bold">Conexión Directa</p>
-        </div>
+      <div>
+        <p class="text-gray-500 text-sm">Usuarios Activos</p>
+        <p class="text-2xl font-bold">{{ valid_users|length }}</p>
       </div>
-      {% endif %}  -->
-      {# Tarjeta de Usuarios Activos #}
-      <div
-        class="bg-white p-4 rounded-lg shadow flex items-center transition-all duration-300 ease-in-out hover:shadow-lg hover:-translate-y-0.5"
-      >
-        <div
-          class="w-12 h-12 rounded-full bg-blue-100 flex items-center justify-center mr-4 flex-shrink-0"
-        >
-          <i class="fas fa-users text-blue-500 text-xl"></i>
-        </div>
-        <div>
-          <p class="text-gray-500 text-sm">Usuarios Activos</p>
-          <p class="text-2xl font-bold">{{ valid_users|length }}</p>
-        </div>
+    </div>
+    {# Tarjeta de Conexiones Totales #}
+    <div class="bg-white p-4 rounded-lg shadow flex items-center transition-all duration-300 ease-in-out hover:shadow-lg hover:-translate-y-0.5">
+      <div class="w-12 h-12 rounded-full bg-green-100 flex items-center justify-center mr-4 flex-shrink-0">
+        <i class="fas fa-exchange-alt text-green-500 text-xl"></i>
       </div>
-
-      {# Tarjeta de Conexiones Totales #}
-      <div
-        class="bg-white p-4 rounded-lg shadow flex items-center transition-all duration-300 ease-in-out hover:shadow-lg hover:-translate-y-0.5"
-      >
-        <div
-          class="w-12 h-12 rounded-full bg-green-100 flex items-center justify-center mr-4 flex-shrink-0"
-        >
-          <i class="fas fa-exchange-alt text-green-500 text-xl"></i>
-        </div>
-        <div>
-          <p class="text-gray-500 text-sm">Conexiones Totales</p>
-          <p class="text-2xl font-bold">
-            {% set total = namespace(value=0) %} {% for user_data in
-            valid_users.values() %} {% set total.value = total.value +
-            user_data.connections|length %} {% endfor %} {{ total.value }}
-          </p>
-        </div>
+      <div>
+        <p class="text-gray-500 text-sm">Conexiones Totales</p>
+        <p class="text-2xl font-bold">
+          {% set total = namespace(value=0) %} 
+          {% for user_data in valid_users.values() %} 
+          {% set total.value = total.value + user_data.connections|length %} 
+          {% endfor %} 
+          {{ total.value }}
+        </p>
       </div>
-
-      {# Nueva Tarjeta: Tiempo de Actividad de Squid #} {% if squid_info_stats
-      and squid_info_stats.elapsed_hours %}
-      <div
-        class="bg-white p-4 rounded-lg shadow flex items-center transition-all duration-300 ease-in-out hover:shadow-lg hover:-translate-y-0.5"
-      >
-        <div
-          class="w-12 h-12 rounded-full bg-purple-100 flex items-center justify-center mr-4 flex-shrink-0"
-        >
-          <i class="fas fa-clock text-purple-500 text-xl"></i>
-        </div>
-        <div>
-          <p class="text-gray-500 text-sm">Tiempo Activo</p>
-          <p class="text-2xl font-bold">
-            {{ squid_info_stats.elapsed_hours }}h
-          </p>
-        </div>
+    </div>
+    {# Tiempo de Actividad de Squid #} 
+    {% if squid_info_stats and squid_info_stats.elapsed_hours %}
+    <div class="bg-white p-4 rounded-lg shadow flex items-center transition-all duration-300 ease-in-out hover:shadow-lg hover:-translate-y-0.5">
+      <div class="w-12 h-12 rounded-full bg-purple-100 flex items-center justify-center mr-4 flex-shrink-0">
+        <i class="fas fa-clock text-purple-500 text-xl"></i>
       </div>
-      {% endif %} 
-      {# Nueva Tarjeta: Peticiones HTTP Totales #} 
-      {% if squid_info_stats and squid_info_stats.requests_received %}
-      <div
-        class="bg-white p-4 rounded-lg shadow flex items-center transition-all duration-300 ease-in-out hover:shadow-lg hover:-translate-y-0.5"
-      >
-        <div
-          class="w-12 h-12 rounded-full bg-red-100 flex items-center justify-center mr-4 flex-shrink-0"
-        >
-          <i class="fas fa-globe text-red-500 text-xl"></i>
-        </div>
-        <div>
-          <p class="text-gray-500 text-sm">Total de Peticiones HTTP</p>
-          <p class="text-2xl font-bold">
-            {{ squid_info_stats.requests_received | int }}
-          </p>
-        </div>
+      <div>
+        <p class="text-gray-500 text-sm">Tiempo Activo</p>
+        <p class="text-2xl font-bold">
+          {{ squid_info_stats.elapsed_hours }}h
+        </p>
       </div>
-      {% endif %} {# Nueva Tarjeta: Promedio de Peticiones por Minuto #} {% if
-      squid_info_stats and squid_info_stats.avg_requests_per_minute %}
-      <div
-        class="bg-white p-4 rounded-lg shadow flex items-center transition-all duration-300 ease-in-out hover:shadow-lg hover:-translate-y-0.5"
-      >
-        <div
-          class="w-12 h-12 rounded-full bg-teal-100 flex items-center justify-center mr-4 flex-shrink-0"
-        >
-          <i class="fas fa-chart-line text-teal-500 text-xl"></i>
-        </div>
-        <div>
-          <p class="text-gray-500 text-sm">Peticiones/Min Promedio</p>
-          <p class="text-2xl font-bold">
-            {{ squid_info_stats.avg_requests_per_minute|round(1) }}
-          </p>
-        </div>
+    </div>
+    {% endif %} 
+    {#  Peticiones HTTP Totales #} 
+    {% if squid_info_stats and squid_info_stats.requests_received %}
+    <div class="bg-white p-4 rounded-lg shadow flex items-center transition-all duration-300 ease-in-out hover:shadow-lg hover:-translate-y-0.5">
+      <div class="w-12 h-12 rounded-full bg-red-100 flex items-center justify-center mr-4 flex-shrink-0">
+        <i class="fas fa-globe text-red-500 text-xl"></i>
       </div>
-      {% endif %} {# Nueva Tarjeta: Estado de Conexión de Squid #} {% if
-      squid_info_stats %}
-      <div
-        class="bg-white p-4 rounded-lg shadow flex items-center transition-all duration-300 ease-in-out hover:shadow-lg hover:-translate-y-0.5"
-      >
-        <div
-          class="w-12 h-12 rounded-full {% if squid_info_stats.connection_status == 'connected' %}bg-green-100{% else %}bg-red-100{% endif %} flex items-center justify-center mr-4 flex-shrink-0"
-        >
-          <i
-            class="fas {% if squid_info_stats.connection_status == 'connected' %}fa-check-circle text-green-500{% else %}fa-exclamation-triangle text-red-500{% endif %} text-xl"
-          ></i>
-        </div>
-        <div>
-          <p class="text-gray-500 text-sm">Estado Squid</p>
-          <p
-            class="text-sm font-bold {% if squid_info_stats.connection_status == 'connected' %}text-green-600{% else %}text-red-600{% endif %}"
-          >
-            {% if squid_info_stats.connection_status == 'connected' %}Conectado
-            {% elif squid_info_stats.connection_status ==
-            'connected_but_parse_error' %}Error Parsing {% elif
-            squid_info_stats.connection_status == 'timeout' %}Timeout {% elif
-            squid_info_stats.connection_status == 'connection_refused'
-            %}Conexión Rechazada {% elif squid_info_stats.connection_status ==
-            'dns_error' %}Error DNS {% else %}Error Desconocido{% endif %}
-          </p>
-        </div>
+      <div>
+        <p class="text-gray-500 text-sm">Total de Peticiones HTTP</p>
+        <p class="text-2xl font-bold">
+          {{ squid_info_stats.requests_received | int }}
+        </p>
       </div>
-      {% endif %}
     </div>
+    {% endif %} 
+    {# Promedio de Peticiones por Minuto #} 
+    {% if squid_info_stats and squid_info_stats.avg_requests_per_minute %}
+    <div class="bg-white p-4 rounded-lg shadow flex items-center transition-all duration-300 ease-in-out hover:shadow-lg hover:-translate-y-0.5">
+      <div class="w-12 h-12 rounded-full bg-teal-100 flex items-center justify-center mr-4 flex-shrink-0">
+        <i class="fas fa-chart-line text-teal-500 text-xl"></i>
+      </div>
+      <div>
+        <p class="text-gray-500 text-sm">Peticiones/Min Promedio</p>
+        <p class="text-2xl font-bold">
+          {{ squid_info_stats.avg_requests_per_minute|round(1) }}
+        </p>
+      </div>
+    </div>
+    {% endif %} 
+    {# Estado de Conexión de Squid #} {% if squid_info_stats %}
+    <div class="bg-white p-4 rounded-lg shadow flex items-center transition-all duration-300 ease-in-out hover:shadow-lg hover:-translate-y-0.5">
+      <div class="w-12 h-12 rounded-full {% if squid_info_stats.connection_status == 'connected' %}bg-green-100{% else %}bg-red-100{% endif %} flex items-center justify-center mr-4 flex-shrink-0">
+        <i class="fas {% if squid_info_stats.connection_status == 'connected' %}fa-check-circle text-green-500{% else %}fa-exclamation-triangle text-red-500{% endif %} text-xl"></i>
+      </div>
+      <div>
+        <p class="text-gray-500 text-sm">Estado Squid</p>
+        <p
+          class="text-sm font-bold {% if squid_info_stats.connection_status == 'connected' %}text-green-600{% else %}text-red-600{% endif %}">
+          {% if squid_info_stats.connection_status == 'connected' %}Conectado
+          {% elif squid_info_stats.connection_status == 'connected_but_parse_error' %}Error Parsing 
+          {% elif squid_info_stats.connection_status == 'timeout' %}Timeout 
+          {% elif squid_info_stats.connection_status == 'connection_refused'%}Conexión Rechazada 
+          {% elif squid_info_stats.connection_status == 'dns_error' %}Error DNS 
+          {% else %}Error Desconocido
+          {% endif %}
+        </p>
+      </div>
+    </div>
+    {% endif %}
   </div>
+</div>
+{% if valid_users|length > 0 %}
+<div class="flex justify-end mb-4">
+  <button id="toggle-all-button" class="bg-blue-500 hover:bg-blue-600 text-white font-bold py-2 px-4 rounded-lg transition-colors duration-300">
+    Ver Resumen
+  </button>
+</div>
+{% endif %}
+<div id="user-accordion-group">
+  {% for user, user_data in valid_users.items() %} {% set connections =
+  user_data.connections %} {% set client_ip = user_data.client_ip %}
 
-  {% if valid_users|length > 0 %}
-  <div class="flex justify-end mb-4">
-    <button
-      id="toggle-all-button"
-      class="bg-blue-500 hover:bg-blue-600 text-white font-bold py-2 px-4 rounded-lg transition-colors duration-300"
-    >
-      Ver Resumen
-    </button>
-  </div>
-  {% endif %}
-
-  <div id="user-accordion-group">
-    {% for user, user_data in valid_users.items() %} {% set connections =
-    user_data.connections %} {% set client_ip = user_data.client_ip %}
-
-    <div
-      class="user-accordion bg-white rounded-lg shadow-md mb-3 overflow-hidden"
-    >
-      <div class="w-full text-left p-4 border-b bg-white">
-        <div
-          class="flex flex-col sm:flex-row sm:items-center sm:justify-between"
-        >
-          <div class="flex items-center mb-3 sm:mb-0">
-            <div
-              class="w-10 h-10 rounded-full bg-blue-100 flex items-center justify-center mr-3 flex-shrink-0"
-            >
-              <i class="fas fa-user text-blue-600"></i>
-            </div>
-            <div>
-              <h2 class="text-lg font-bold text-gray-800">{{ user }}</h2>
-            </div>
+  <div class="user-accordion bg-white rounded-lg shadow-md mb-3 overflow-hidden">
+    <div class="w-full text-left p-4 border-b bg-white">
+      <div class="flex flex-col sm:flex-row sm:items-center sm:justify-between">
+        <div class="flex items-center mb-3 sm:mb-0">
+          <div class="w-10 h-10 rounded-full bg-blue-100 flex items-center justify-center mr-3 flex-shrink-0">
+            <i class="fas fa-user text-blue-600"></i>
+          </div>
+          <div>
+            <h2 class="text-lg font-bold text-gray-800">{{ user }}</h2>
           </div>
+        </div>
 
-          <div class="flex flex-wrap items-center gap-x-4 gap-y-2">
-            <div
-              class="flex items-center text-sm text-gray-600"
-              title="IP del Cliente"
-            >
-              <i class="fas fa-network-wired mr-1.5 text-gray-500"></i>
-              <span>{{ client_ip }}</span>
-            </div>
+        <div class="flex flex-wrap items-center gap-x-4 gap-y-2">
+          <div class="flex items-center text-sm text-gray-600" title="IP del Cliente">
+            <i class="fas fa-network-wired mr-1.5 text-gray-500"></i>
+            <span>{{ client_ip }}</span>
+          </div>
 
-            <div
-              class="flex items-center text-sm text-gray-600"
-              title="Conexiones totales de este usuario"
-            >
-              <i class="fas fa-link mr-1.5 text-blue-500"></i>
-              <span>{{ connections|length }} conexiones</span>
-            </div>
-            {% set user_bw = namespace(value=0) %}
-            {% for connection in connections %}
-              {% if connection.bandwidth_kbps is defined %}
-                {% set user_bw.value = user_bw.value + (connection.bandwidth_kbps|float) %}
-              {% endif %}
-            {% endfor %}
-            <div class="flex items-center text-sm text-gray-600" title="Total de velocidad del usuario">
-              <i class="fas fa-tachometer-alt mr-1.5 text-teal-500"></i>
-              <span>
-                {{ format_bandwidth(user_bw.value) }}
-              </span>
-            </div>
+          <div class="flex items-center text-sm text-gray-600" title="Conexiones totales de este usuario">
+            <i class="fas fa-link mr-1.5 text-blue-500"></i>
+            <span>{{ connections|length }} conexiones</span>
+          </div>
+          {% set user_bw = namespace(value=0) %}
+          {% for connection in connections %}
+            {% if connection.bandwidth_kbps is defined %}
+              {% set user_bw.value = user_bw.value + (connection.bandwidth_kbps|float) %}
+            {% endif %}
+          {% endfor %}
+          <div class="flex items-center text-sm text-gray-600" title="Total de velocidad del usuario">
+            <i class="fas fa-tachometer-alt mr-1.5 text-teal-500"></i>
+            <span>
+              {{ format_bandwidth(user_bw.value) }}
+            </span>
+          </div>
 
-            {% set total_data = namespace(value=0) %} {% set total_requests =
-            namespace(value=0) %} {% for connection in connections %} {% if
-            connection.fd_total != "N/A" %} {% set total_data.value =
-            total_data.value + connection.fd_total %} {% endif %} {% set
-            total_requests.value = total_requests.value + connection.nrequests
-            %} {% endfor %}
+          {% set total_data = namespace(value=0) %} 
+          {% set total_requests = namespace(value=0) %} 
+          {% for connection in connections %} 
+            {% if connection.fd_total != "N/A" %} 
+              {% set total_data.value = total_data.value + connection.fd_total %} 
+            {% endif %} 
+            {% set total_requests.value = total_requests.value + connection.nrequests %} 
+          {% endfor %}
 
-            <div
-              class="flex items-center text-sm text-gray-600"
-              title="Total de datos transferidos"
-            >
-              <i class="fas fa-database mr-1.5 text-green-500"></i>
-              <span>{{ (total_data.value / 1024 / 1024)|round(2) }} MB</span>
-            </div>
+          <div class="flex items-center text-sm text-gray-600" title="Total de datos transferidos">
+            <i class="fas fa-database mr-1.5 text-green-500"></i>
+            <span>{{ (total_data.value / 1024 / 1024)|round(2) }} MB</span>
+          </div>
 
-            <div
-              class="flex items-center text-sm text-gray-600"
-              title="Total de solicitudes"
-            >
-              <i class="fas fa-bullhorn mr-1.5 text-purple-500"></i>
-              <span>{{ total_requests.value }} solicitudes</span>
-            </div>
-            <div class="w-6 text-center">
-              <i
-                class="fas fa-chevron-down transition-transform duration-300 rotate-180"
-              ></i>
-            </div>
+          <div class="flex items-center text-sm text-gray-600" title="Total de solicitudes">
+            <i class="fas fa-bullhorn mr-1.5 text-purple-500"></i>
+            <span>{{ total_requests.value }} solicitudes</span>
+          </div>
+          <div class="w-6 text-center">
+            <i class="fas fa-chevron-down transition-transform duration-300 rotate-180"></i>
           </div>
         </div>
       </div>
+    </div>
 
-      <div data-accordion-content>
-        <div class="overflow-x-auto">
-          <table class="min-w-full divide-y divide-gray-200">
-            <thead class="bg-gray-50">
-              <tr>
-                <th
-                  class="px-4 py-2 text-left text-xs font-medium text-gray-500 uppercase"
-                >
-                  Duración
-                </th>
-                <th
-                  class="px-4 py-2 text-left text-xs font-medium text-gray-500 uppercase"
-                >
-                  Método
-                </th>
-                <th
-                  class="px-4 py-2 text-left text-xs font-medium text-gray-500 uppercase"
-                >
-                  URL
-                </th>
-                <th
-                  class="px-4 py-2 text-left text-xs font-medium text-gray-500 uppercase"
-                >
-                  Datos
-                </th>
-                <th
-                  class="px-4 py-2 text-left text-xs font-medium text-gray-500 uppercase"
-                >
-                  Velocidad
-                </th>
-                <th
-                  class="px-4 py-2 text-left text-xs font-medium text-gray-500 uppercase"
-                >
-                  Delay Pool
-                </th>
-                <th
-                  class="px-4 py-2 text-left text-xs font-medium text-gray-500 uppercase"
-                >
-                  Solicitudes
-                </th>
-                <th
-                  class="px-4 py-2 text-left text-xs font-medium text-gray-500 uppercase"
-                >
-                  Dir. Remota
-                </th>
-              </tr>
-            </thead>
-            <tbody class="divide-y divide-gray-200">
-              {% for connection in connections %}
-              <tr
-                class="transition-colors duration-200 ease-in-out hover:bg-gray-50"
-              >
-                <td class="px-4 py-3 whitespace-nowrap text-sm text-gray-500">
-                  {% set seconds = connection.elapsed_time|float %} {% if
-                  seconds >= 3600 %}{{ "%.2f"|format(seconds/3600) }} h {% elif
-                  seconds >= 60 %}{{ "%.2f"|format(seconds/60) }} min {% else
-                  %}{{ "%.2f"|format(seconds) }} seg{% endif %}
-                </td>
-                <td class="px-4 py-3 whitespace-nowrap">
-                  {% set method = connection.logType|lower %}
-                  <span
-                    class="px-2 py-1 rounded-full text-xs font-semibold ... {% if method == 'connect' or method == 'tcp_tunnel' %}bg-green-100 text-green-800 ... {% endif %}"
-                  >
-                    {{ connection.logType }}
-                  </span>
-                </td>
-                <td class="px-4 py-3 max-w-xs">
-                  <div
-                    class="truncate text-sm transition-colors duration-200 hover:text-blue-600"
-                    title="{{ connection.uri }}"
-                  >
-                    {{ connection.uri }}
-                  </div>
-                </td>
-                <td class="px-4 py-3 whitespace-nowrap text-sm">
-                  {% if connection.fd_total != "N/A" %}{{ (connection.fd_total /
-                  1024 / 1024)|round(2) }} MB {% else %}N/A{% endif %}
-                </td>
-                <td class="px-4 py-3 whitespace-nowrap text-sm">
-                  {{ format_bandwidth(connection.bandwidth_kbps) }}
-                </td>
-                <td class="px-4 py-3 whitespace-nowrap">
-                  {% if connection.delay_pool != "N/A" %} {% set pool =
-                  connection.delay_pool|string %}
-                  <span
-                    class="px-2 py-1 rounded-full text-xs font-semibold ... {% if pool == '0' %}bg-sky-100 text-sky-800 ... {% endif %}"
-                  >
+    <div data-accordion-content>
+      <div class="overflow-x-auto">
+        <table class="min-w-full divide-y divide-gray-200">
+          <thead class="bg-gray-50">
+            <tr>
+              <th class="px-4 py-2 text-left text-xs font-medium text-gray-500 uppercase">
+                Duración
+              </th>
+              <th class="px-4 py-2 text-left text-xs font-medium text-gray-500 uppercase">
+                Método
+              </th>
+              <th class="px-4 py-2 text-left text-xs font-medium text-gray-500 uppercase">
+                URL
+              </th>
+              <th class="px-4 py-2 text-left text-xs font-medium text-gray-500 uppercase">
+                Datos
+              </th>
+              <th class="px-4 py-2 text-left text-xs font-medium text-gray-500 uppercase">
+                Velocidad
+              </th>
+              <th class="px-4 py-2 text-left text-xs font-medium text-gray-500 uppercase">
+                Delay Pool
+              </th>
+              <th class="px-4 py-2 text-left text-xs font-medium text-gray-500 uppercase">
+                Solicitudes
+              </th>
+              <th class="px-4 py-2 text-left text-xs font-medium text-gray-500 uppercase">
+                Dir. Remota
+              </th>
+            </tr>
+          </thead>
+          <tbody class="divide-y divide-gray-200">
+            {% for connection in connections %}
+            <tr class="transition-colors duration-200 ease-in-out hover:bg-gray-50">
+              <td class="px-4 py-3 whitespace-nowrap text-sm text-gray-500">
+                {% set seconds = connection.elapsed_time|float %} 
+                {% if seconds >= 3600 %}{{ "%.2f"|format(seconds/3600) }} h 
+                {% elif seconds >= 60 %}{{ "%.2f"|format(seconds/60) }} min {% else %}
+                {{ "%.2f"|format(seconds) }} seg
+                {% endif %}
+              </td>
+              <td class="px-4 py-3 whitespace-nowrap">
+                {% set method = connection.logType|lower %}
+                <span class="px-2 py-1 rounded-full text-xs font-semibold ... {% if method == 'connect' or method == 'tcp_tunnel' %}bg-green-100 text-green-800 ... {% endif %}">
+                  {{ connection.logType }}
+                </span>
+              </td>
+              <td class="px-4 py-3 max-w-xs">
+                <div class="truncate text-sm transition-colors duration-200 hover:text-blue-600"
+                  title="{{ connection.uri }}">
+                  {{ connection.uri }}
+                </div>
+              </td>
+              <td class="px-4 py-3 whitespace-nowrap text-sm">
+                {% if connection.fd_total != "N/A" %}
+                  {{ (connection.fd_total / 1024 / 1024)|round(2) }} MB 
+                  {% else %}N/A
+                {% endif %}
+              </td>
+              <td class="px-4 py-3 whitespace-nowrap text-sm">
+                {{ format_bandwidth(connection.bandwidth_kbps) }}
+              </td>
+              <td class="px-4 py-3 whitespace-nowrap">
+                {% if connection.delay_pool != "N/A" %} 
+                  {% set pool = connection.delay_pool|string %}
+                  <span class="px-2 py-1 rounded-full text-xs font-semibold ... {% if pool == '0' %}bg-sky-100 text-sky-800 ... {% endif %}">
                     Pool {{ connection.delay_pool }}
                   </span>
-                  {% else %}<span class="text-sm text-gray-500">N/A</span>{%
-                  endif %}
-                </td>
-                <td class="px-4 py-3 whitespace-nowrap text-sm font-medium">
-                  {{ connection.nrequests }}
-                </td>
-                <td
-                  class="px-4 py-3 whitespace-nowrap text-sm font-mono ... hover:text-blue-600"
-                >
-                  {{ connection.proxy_local_ip }}
-                </td>
-              </tr>
-              {% endfor %}
-            </tbody>
-          </table>
-        </div>
+                  
+                {% endif %}
+              </td>
+              <td class="px-4 py-3 whitespace-nowrap text-sm font-medium">
+                {{ connection.nrequests }}
+              </td>
+              <td class="px-4 py-3 whitespace-nowrap text-sm font-mono ... hover:text-blue-600">
+                {{ connection.proxy_local_ip }}
+              </td>
+            </tr>
+            {% endfor %}
+          </tbody>
+        </table>
       </div>
     </div>
-    {% endfor %}
   </div>
-</div>
-
-<!-- function sortAndDisplayUsers() {
-    const userAccordionGroup = document.getElementById('user-accordion-group');
-    if (!userAccordionGroup) return;
-
-    const usersData = {{ valid_users | tojson }};
-    
-    const usersArray = Object.entries(usersData);
-    const sortedUsers = usersArray.sort((a, b) => {
-        const bwA = calculateUserBandwidth(a[1].connections);
-        const bwB = calculateUserBandwidth(b[1].connections);
-        return bwB - bwA; // Orden descendente
-    });
-
-    userAccordionGroup.innerHTML = '';
-
-    sortedUsers.forEach(([user, userData]) => {
-        userAccordionGroup.innerHTML += createUserHTML(user, userData);
-    });
-
-    initializeAccordions();
-}
-
-document.addEventListener('DOMContentLoaded', function() {
-    sortAndDisplayUsers();
-});
-
-if (typeof updateConnections === 'function') {
-    const originalUpdateConnections = updateConnections;
-    updateConnections = function() {
-        originalUpdateConnections();
-        setTimeout(sortAndDisplayUsers, 100); // Esperar a que se renderice el nuevo contenido
-    };
-}
-</script> -->
+  {% endfor %}
+</div>

+ 192 - 0
templates/partials/graph_reports.html

@@ -0,0 +1,192 @@
+  <header class="mb-8">
+    <div class="flex flex-wrap justify-between mt-4">
+      <div
+        class="bg-white p-4 rounded-lg shadow-md w-full md:w-auto mb-4 md:mb-0">
+        <h3 class="text-lg font-semibold text-gray-700">
+          Usuarios Totales
+        </h3>
+        <p class="text-2xl font-bold text-blue-600">
+          {{ metrics.total_stats.total_users }}
+        </p>
+      </div>
+      <div
+        class="bg-white p-4 rounded-lg shadow-md w-full md:w-auto mb-4 md:mb-0">
+        <h3 class="text-lg font-semibold text-gray-700">
+          Registros de Log
+        </h3>
+        <p class="text-2xl font-bold text-green-600">
+          {{ metrics.total_stats.total_log_entries }}
+        </p>
+      </div>
+      <div
+        class="bg-white p-4 rounded-lg shadow-md w-full md:w-auto mb-4 md:mb-0">
+        <h3 class="text-lg font-semibold text-gray-700">
+          Datos Transmitidos
+        </h3>
+        <p class="text-2xl font-bold text-purple-600">
+          {{ "%.2f"|format(metrics.total_stats.total_data_transmitted /
+          (1024**3)) }} GB
+        </p>
+      </div>
+      <div class="bg-white p-4 rounded-lg shadow-md w-full md:w-auto">
+        <h3 class="text-lg font-semibold text-gray-700">Total Requests</h3>
+        <p class="text-2xl font-bold text-orange-600">
+          {{ metrics.total_stats.total_requests }}
+        </p>
+      </div>
+      <div class="w-full md:w-auto flex items-center md:ml-4 mt-4 md:mt-0">
+        <div
+          class="bg-white p-4 rounded-lg shadow-md border border-gray-200 hover:shadow-lg transition-shadow duration-200">
+          <h3 class="text-lg font-semibold text-gray-700">
+            Filtrar por Fecha
+          </h3>
+          <div class="reports-date-picker flex items-center gap-2">
+            <div
+              class="flex items-center justify-center w-8 h-8 bg-indigo-50 rounded-md">
+              <svg xmlns="http://www.w3.org/2000/svg" class="h-4 w-4 text-indigo-600" fill="none" viewBox="0 0 24 24" stroke="currentColor" stroke-width="2">
+                <path stroke-linecap="round" stroke-linejoin="round" d="M8 7V3m8 4V3M3 11h18M5 21h14a2 2 0 0 0 2-2V7a2 2 0 0 0-2-2H5a2 2 0 0 0-2 2v12a2 2 0 0 0 2 2z"/>
+              </svg>
+            </div>
+
+            <input id="reports-date" type="text" datepicker datepicker-orientation="bottom" datepicker-autohide datepicker-container="body" class="flex-1 min-w-0 w-32 rounded-md border border-gray-300 bg-white px-3 py-2 text-sm text-gray-900 placeholder-gray-500 focus:border-indigo-500 focus:outline-none focus:ring-1 focus:ring-indigo-500 transition-colors duration-200"/>
+
+            <button id="reports-go" class="inline-flex items-center justify-center px-3 py-2 border border-transparent text-sm font-medium rounded-md text-white bg-indigo-600 hover:bg-indigo-700 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-indigo-500 transition-colors duration-200 disabled:opacity-50 disabled:cursor-not-allowed">
+              <svg xmlns="http://www.w3.org/2000/svg" class="h-4 w-4 mr-1" fill="none" viewBox="0 0 24 24" stroke="currentColor" stroke-width="2">
+                <path stroke-linecap="round" stroke-linejoin="round" d="M21 21l-6-6m2-5a7 7 0 11-14 0 7 7 0 0114 0z"/>
+              </svg>
+              Ver
+            </button>
+          </div>
+        </div>
+      </div>
+    </div>
+  </header>
+
+  <div class="grid grid-cols-1 lg:grid-cols-2 gap-6 mb-8">
+    <div class="bg-white p-6 rounded-lg shadow-md">
+      <h2 class="text-xl font-bold mb-4 text-gray-800">
+        Top 20 Usuarios por Actividad
+      </h2>
+      <div class="h-80">
+        <canvas id="usersActivityChart"></canvas>
+      </div>
+    </div>
+
+    <div class="bg-white p-6 rounded-lg shadow-md">
+      <h2 class="text-xl font-bold mb-4 text-gray-800">
+        Top 20 Usuarios por Datos Transmitidos
+      </h2>
+      <div class="h-80">
+        <canvas id="usersDataChart"></canvas>
+      </div>
+    </div>
+  </div>
+
+  <div class="bg-white p-6 rounded-lg shadow-md mb-8">
+    <h2 class="text-xl font-bold mb-4 text-gray-800">
+      Distribución de Códigos HTTP
+    </h2>
+    <div class="h-96">
+      <canvas id="httpCodesChart"></canvas>
+    </div>
+  </div>
+
+  <div class="bg-white p-6 rounded-lg shadow-md mb-8">
+    <h2 class="text-xl font-bold mb-4 text-gray-800">
+      Top 20 Páginas Más Visitadas
+    </h2>
+    <div class="overflow-x-auto">
+      <table class="min-w-full divide-y divide-gray-200">
+        <thead class="bg-gray-50">
+          <tr>
+            <th
+              class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider"
+            >
+              URL
+            </th>
+            <th
+              class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider"
+            >
+              Total Requests
+            </th>
+            <th
+              class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider"
+            >
+              Visitas Únicas
+            </th>
+            <th
+              class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider"
+            >
+              Datos Transmitidos
+            </th>
+          </tr>
+        </thead>
+        <tbody class="bg-white divide-y divide-gray-200">
+          {% for page in metrics.top_pages %}
+          <tr class="hover:bg-gray-50">
+            <td
+              class="px-6 py-4 whitespace-nowrap text-sm font-medium text-gray-900 truncate max-w-xs"
+            >
+              {{ page.url }}
+            </td>
+            <td class="px-6 py-4 whitespace-nowrap text-sm text-gray-500">
+              {{ page.total_requests }}
+            </td>
+            <td class="px-6 py-4 whitespace-nowrap text-sm text-gray-500">
+              {{ page.unique_visits }}
+            </td>
+            <td class="px-6 py-4 whitespace-nowrap text-sm text-gray-500">
+              {{ "%.2f"|format(page.total_data_bytes / (1024**2)) }} MB
+            </td>
+          </tr>
+          {% endfor %}
+        </tbody>
+      </table>
+    </div>
+  </div>
+
+  <div class="bg-white p-6 rounded-lg shadow-md">
+    <h2 class="text-xl font-bold mb-4 text-gray-800">
+      IPs Compartidas por Múltiples Usuarios
+    </h2>
+    <div class="overflow-x-auto">
+      <table class="min-w-full divide-y divide-gray-200">
+        <thead class="bg-gray-50">
+          <tr>
+            <th
+              class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider"
+            >
+              IP
+            </th>
+            <th
+              class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider"
+            >
+              Número de Usuarios
+            </th>
+            <th
+              class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider"
+            >
+              Usuarios
+            </th>
+          </tr>
+        </thead>
+        <tbody class="bg-white divide-y divide-gray-200">
+          {% for ip in metrics.users_per_ip %}
+          <tr class="hover:bg-gray-50">
+            <td
+              class="px-6 py-4 whitespace-nowrap text-sm font-medium text-gray-900"
+            >
+              {{ ip.ip }}
+            </td>
+            <td class="px-6 py-4 whitespace-nowrap text-sm text-gray-500">
+              {{ ip.user_count }}
+            </td>
+            <td class="px-6 py-4 whitespace-nowrap text-sm text-gray-500">
+              {{ ip.usernames }}
+            </td>
+          </tr>
+          {% endfor %}
+        </tbody>
+      </table>
+    </div>
+  </div>

+ 47 - 0
templates/partials/logs.html

@@ -0,0 +1,47 @@
+<div class="users-dashboard max-w-[1200px] mx-auto p-8">
+  <div class="dashboard-header flex justify-between items-center mb-8 flex-wrap gap-4">
+    <div class="filters-container flex gap-4 items-center">
+      <div class="date-filter max-w-xs mx-auto rounded-[0.5rem] shadow-md overflow-hidden relative">
+        <input type="date" id="date-filter" class="w-full px-4 py-3 border border-gray-300 rounded-lg bg-white shadow-sm text-sm text-gray-700 focus:outline-none focus:ring-2 focus:ring-blue-500 focus:border-blue-500 h-12"/>
+      </div>
+
+      <div class="search-container flex items-center bg-white rounded-[0.5rem] shadow-md overflow-hidden w-[250px] relative">
+        <input type="text" id="username-search" placeholder="Buscar por usuario..." class="search-input w-full pl-4 pr-10 py-3 rounded-[0.5rem] border border-gray-300 focus:outline-none focus:ring-2 focus:ring-blue-500 focus:border-blue-500 text-gray-800 h-12"/>
+
+        <!-- Botón de limpiar búsqueda -->
+        <button id="clear-search" class="absolute right-10 h-full items-center justify-center text-gray-400 hover:text-gray-700 hidden" title="Limpiar búsqueda">
+          <i class="fas fa-times"></i>
+        </button>
+
+        <div class="absolute inset-y-0 right-3 flex items-center pointer-events-none">
+          <i class="fas fa-magnifying-glass text-xl text-[#1A8A9D]"></i>
+        </div>
+      </div>
+    </div>
+  </div>
+
+  <div class="users-container grid grid-cols-1 sm:grid-cols-2 md:grid-cols-3 lg:grid-cols-4 xl:grid-cols-5 gap-4 max-w-screen-xl mx-auto px-4" id="users-container"></div>
+  <div id="modals-container"></div>
+  <div class="pagination-container flex justify-center items-center mt-12 gap-4">
+    <button id="first-page" aria-label="First page" class="pg-btn first w-12 h-12 flex items-center justify-center rounded-full bg-white text-blue-600 cursor-pointer font-semibold shadow-md transition-all duration-200 ease-in-out text-xl hover:-translate-y-1 disabled:cursor-not-allowed disabled:opacity-50 disabled:transform-none">
+      <i class="fas fa-angle-double-left"></i>
+    </button>
+    <button id="prev-page" aria-label="Previous page" class="pg-btn prev w-12 h-12 flex items-center justify-center rounded-full bg-white text-blue-600 cursor-pointer font-semibold shadow-md transition-all duration-200 ease-in-out text-xl hover:-translate-y-1 disabled:cursor-not-allowed disabled:opacity-50 disabled:transform-none">
+      <i class="fas fa-angle-left"></i>
+    </button>
+    <!-- Aquí el JS generará los botones de página -->
+    <div class="pagination flex gap-1" id="page-numbers"></div>
+    <button
+      id="next-page"
+      aria-label="Next page"
+      class="pg-btn next w-12 h-12 flex items-center justify-center rounded-full bg-white text-blue-600 cursor-pointer font-semibold shadow-md transition-all duration-200 ease-in-out text-xl hover:-translate-y-1 disabled:cursor-not-allowed disabled:opacity-50 disabled:transform-none">
+      <i class="fas fa-angle-right"></i>
+    </button>
+    <button id="last-page" aria-label="Last page" class="pg-btn last w-12 h-12 flex items-center justify-center rounded-full bg-white text-blue-600 cursor-pointer font-semibold shadow-md transition-all duration-200 ease-in-out text-xl hover:-translate-y-1 disabled:cursor-not-allowed disabled:opacity-50 disabled:transform-none">
+      <i class="fas fa-angle-double-right"></i>
+    </button>
+  </div>
+</div>
+
+<div class="overlay fixed inset-0 bg-black bg-opacity-50 z-50 hidden transition-opacity duration-1000 ease-in-out opacity-0" id="overlay"></div>
+