| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229 |
- {% extends "admin/base.html" %}
- {% block content %}
- <div class="space-y-4 sm:space-y-6">
- <div class="bg-white rounded-lg shadow-lg p-4 sm:p-6">
- <h2 class="text-xl sm:text-2xl font-bold text-gray-800 mb-4 sm:mb-6">{{ _("Dashboard - Resumen del Sistema") }}</h2>
-
- <!-- Stats Cards -->
- <div class="grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-4 gap-4 sm:gap-6 mb-6 sm:mb-8">
- <!-- ACLs Card -->
- <div class="bg-gradient-to-r from-blue-500 to-blue-600 text-white p-6 rounded-lg">
- <div class="flex items-center justify-between">
- <div>
- <p class="text-blue-100">{{ _("Total ACLs") }}</p>
- {% if status.errors %}
- {% set ns = namespace(shown=False) %}
- <div class="space-y-1">
- {% for e in status.errors %}
- {% if 'ACL' in e or 'acl' in e %}
- <div class="bg-red-100 text-red-800 text-sm px-2 py-1 rounded">{{ e }}</div>
- {% set ns.shown = True %}
- {% endif %}
- {% endfor %}
- {% if not ns.shown %}
- <div class="bg-yellow-100 text-yellow-800 text-sm px-2 py-1 rounded">{{ status.errors[0] }}</div>
- {% endif %}
- </div>
- {% else %}
- <p class="text-3xl font-bold">{{ stats.total_acls }}</p>
- {% endif %}
- </div>
- <i class="fas fa-shield-alt text-4xl text-blue-200"></i>
- </div>
- </div>
- <!-- Delay Pools Card -->
- <div class="bg-gradient-to-r from-green-500 to-green-600 text-white p-6 rounded-lg">
- <div class="flex items-center justify-between">
- <div>
- <p class="text-green-100">{{ _("Delay Pools") }}</p>
- {% if status.errors %}
- {% set ns2 = namespace(shown=False) %}
- <div class="space-y-1">
- {% for e in status.errors %}
- {% if 'squid.conf' in e or 'Configuration file' in e or 'read permission' in e or 'write permission' in e or 'read permissions' in e or 'write permissions' in e %}
- <div class="bg-red-100 text-red-800 text-sm px-2 py-1 rounded">{{ e }}</div>
- {% set ns2.shown = True %}
- {% endif %}
- {% endfor %}
- {% if not ns2.shown %}
- <div class="bg-yellow-100 text-yellow-800 text-sm px-2 py-1 rounded">{{ status.errors[0] }}</div>
- {% endif %}
- </div>
- {% else %}
- <p class="text-3xl font-bold">{{ stats.total_delay_pools }}</p>
- {% endif %}
- </div>
- <i class="fas fa-tachometer-alt text-4xl text-green-200"></i>
- </div>
- </div>
- <!-- HTTP Rules Card -->
- <div class="bg-gradient-to-r from-purple-500 to-purple-600 text-white p-6 rounded-lg">
- <div class="flex items-center justify-between">
- <div>
- <p class="text-purple-100">{{ _("Reglas HTTP") }}</p>
- {% if status.errors %}
- {% set ns3 = namespace(shown=False) %}
- <div class="space-y-1">
- {% for e in status.errors %}
- {% if 'squid.conf' in e or 'Configuration file' in e or 'read permission' in e or 'write permission' in e or 'not a regular file' in e or 'Expected file named' in e %}
- <div class="bg-red-100 text-red-800 text-sm px-2 py-1 rounded">{{ e }}</div>
- {% set ns3.shown = True %}
- {% endif %}
- {% endfor %}
- {% if not ns3.shown %}
- <div class="bg-yellow-100 text-yellow-800 text-sm px-2 py-1 rounded">{{ status.errors[0] }}</div>
- {% endif %}
- </div>
- {% else %}
- <p class="text-3xl font-bold">{{ stats.total_http_rules }}</p>
- {% endif %}
- </div>
- <i class="fas fa-key text-4xl text-purple-200"></i>
- </div>
- </div>
- <!-- SSL Bump Card -->
- {% if ssl_bump.enabled %}
- <div class="bg-gradient-to-r from-yellow-500 to-orange-500 text-white p-6 rounded-lg">
- {% else %}
- <div class="bg-gradient-to-r from-gray-400 to-gray-500 text-white p-6 rounded-lg">
- {% endif %}
- <div class="flex items-center justify-between">
- <div>
- <p class="{% if ssl_bump.enabled %}text-yellow-100{% else %}text-gray-200{% endif %}">{{ _("SSL Bump") }}</p>
- {% if ssl_bump.enabled %}
- <p class="text-2xl font-bold">{{ _("Activo") }}</p>
- {% if ssl_bump.mode %}
- <p class="text-xs mt-1 {% if ssl_bump.enabled %}text-yellow-200{% else %}text-gray-300{% endif %}">{{ ssl_bump.mode }}</p>
- {% endif %}
- {% else %}
- <p class="text-2xl font-bold">{{ _("Inactivo") }}</p>
- {% endif %}
- </div>
- <i class="fas fa-user-secret text-4xl {% if ssl_bump.enabled %}text-yellow-200{% else %}text-gray-300{% endif %}"></i>
- </div>
- </div>
- </div>
- <!-- Info cuando todo está en 0 -->
- {% if not status.errors and stats.total_acls == 0 and stats.total_delay_pools == 0 and stats.total_http_rules == 0 %}
- <div class="bg-yellow-50 border-l-4 border-yellow-400 p-4 sm:p-6 rounded-lg mb-6">
- <div class="flex items-start">
- <i class="fas fa-exclamation-triangle text-yellow-600 text-2xl mt-1 mr-4"></i>
- <div class="flex-1">
- <h3 class="text-lg font-semibold text-yellow-900 mb-2">{{ _("No se encontraron configuraciones") }}</h3>
- <p class="text-yellow-800 mb-3">{{ _("No se han detectado ACLs, reglas HTTP ni delay pools en tu configuración de Squid.") }}</p>
- <div class="bg-white rounded-lg p-4 border border-yellow-200">
- <p class="text-sm text-gray-700 mb-2"><strong>{{ _("¿Tu configuración ya está dividida en módulos?") }}</strong></p>
- <p class="text-sm text-gray-600 mb-3">{{ _("Si ya tienes tu configuración organizada en archivos separados (por ejemplo: acls.conf, http_access.conf, delay_pools.conf), SquidStats puede leerla directamente sin necesidad de unificarla.") }}</p>
- <div class="flex flex-col sm:flex-row gap-2">
- <a href="{{ url_for('admin.split_config') }}" class="inline-flex items-center justify-center bg-yellow-500 hover:bg-yellow-600 text-white font-semibold px-4 py-2 rounded-lg transition-colors">
- <i class="fas fa-cog mr-2"></i>{{ _("Gestionar Configuración Modular") }}
- </a>
- <a href="{{ url_for('admin.edit_config') }}" class="inline-flex items-center justify-center bg-blue-500 hover:bg-blue-600 text-white font-semibold px-4 py-2 rounded-lg transition-colors">
- <i class="fas fa-edit mr-2"></i>{{ _("Editar squid.conf") }}
- </a>
- </div>
- </div>
- </div>
- </div>
- </div>
- {% endif %}
- <!-- Quick Actions -->
- <div class="bg-gray-50 rounded-lg p-4 sm:p-6">
- <h3 class="text-base sm:text-lg font-semibold text-gray-800 mb-4">{{ _("Acciones Rápidas") }}</h3>
- <div class="grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-4 gap-4">
- {% if status.errors %}
- <div class="bg-white p-4 rounded-lg shadow border-l-4 border-blue-300 opacity-60 cursor-not-allowed" title="{{ _("Deshabilitado por errores de configuración") }}">
- <i class="fas fa-edit text-blue-300 text-2xl mb-2"></i>
- <h4 class="font-semibold text-gray-500">{{ _("Editar Configuración") }}</h4>
- <p class="text-sm text-gray-400">{{ _("Modificar archivo squid.conf (deshabilitado)") }}</p>
- </div>
- <div class="bg-white p-4 rounded-lg shadow border-l-4 border-green-300 opacity-60 cursor-not-allowed" title="{{ _("Deshabilitado por errores de configuración") }}">
- <i class="fas fa-plus text-green-300 text-2xl mb-2"></i>
- <h4 class="font-semibold text-gray-500">{{ _("Agregar ACL") }}</h4>
- <p class="text-sm text-gray-400">{{ _("Crear nueva regla de acceso (deshabilitado)") }}</p>
- </div>
- {% else %}
- <a href="/admin/config/edit" class="bg-white p-4 rounded-lg shadow hover:shadow-md transition-shadow border-l-4 border-blue-500">
- <i class="fas fa-edit text-blue-500 text-2xl mb-2"></i>
- <h4 class="font-semibold text-gray-800">{{ _("Editar Configuración") }}</h4>
- <p class="text-sm text-gray-600">{{ _("Modificar archivo squid.conf") }}</p>
- </a>
-
- <a href="/admin/acls" class="bg-white p-4 rounded-lg shadow hover:shadow-md transition-shadow border-l-4 border-green-500">
- <i class="fas fa-plus text-green-500 text-2xl mb-2"></i>
- <h4 class="font-semibold text-gray-800">{{ _("Agregar ACL") }}</h4>
- <p class="text-sm text-gray-600">{{ _("Crear nueva regla de acceso") }}</p>
- </a>
- {% endif %}
-
- <a href="{{ url_for('admin.view_logs') }}" class="bg-white p-4 rounded-lg shadow hover:shadow-md transition-shadow border-l-4 border-yellow-500">
- <i class="fas fa-file-alt text-yellow-500 text-2xl mb-2"></i>
- <h4 class="font-semibold text-gray-800">{{ _("Ver Logs") }}</h4>
- <p class="text-sm text-gray-600">{{ _("Revisar logs del sistema") }}</p>
- </a>
-
- <div class="bg-white p-4 rounded-lg shadow hover:shadow-md transition-shadow border-l-4 border-red-500 cursor-pointer" onclick="restartSquid()">
- <i class="fas fa-power-off text-red-500 text-2xl mb-2"></i>
- <h4 class="font-semibold text-gray-800">{{ _("Reiniciar Squid") }}</h4>
- <p class="text-sm text-gray-600">{{ _("Reiniciar el servicio") }}</p>
- </div>
- </div>
- </div>
- <!-- System Status -->
- <div class="mt-8 bg-white border rounded-lg p-6">
- <h3 class="text-lg font-semibold text-gray-800 mb-4">{{ _("Estado del Sistema") }}</h3>
- <div class="space-y-3">
- <div class="flex items-center justify-between p-3 bg-green-50 rounded-lg">
- <div class="flex items-center">
- <i class="fas fa-circle text-green-500 mr-3"></i>
- <span class="font-medium">{{ _("Servicio Squid") }}</span>
- </div>
- <span class="text-green-600 font-semibold">{{ _("Activo") }}</span>
- </div>
-
- <div class="flex items-center justify-between p-3 bg-blue-50 rounded-lg">
- <div class="flex items-center">
- <i class="fas fa-database text-blue-500 mr-3"></i>
- <span class="font-medium">{{ _("Configuración") }}</span>
- </div>
- {% if status.errors %}
- <span class="text-red-600 font-semibold">{{ _("No cargada") }}</span>
- {% else %}
- <span class="text-blue-600 font-semibold">{{ _("Cargada") }}</span>
- {% endif %}
- </div>
- <div class="flex items-center justify-between p-3 {% if ssl_bump.enabled %}bg-yellow-50{% else %}bg-gray-50{% endif %} rounded-lg">
- <div class="flex items-center">
- <i class="fas fa-user-secret {% if ssl_bump.enabled %}text-yellow-500{% else %}text-gray-400{% endif %} mr-3"></i>
- <span class="font-medium">{{ _("SSL Bump (MITM)") }}</span>
- </div>
- <div class="text-right">
- {% if ssl_bump.enabled %}
- <span class="text-yellow-600 font-semibold">{{ _("Activo") }}</span>
- {% if ssl_bump.mode %}
- <span class="ml-2 text-xs bg-yellow-100 text-yellow-800 px-2 py-0.5 rounded-full">{{ ssl_bump.mode }}</span>
- {% endif %}
- {% if ssl_bump.cert %}
- <br><span class="text-xs text-gray-500">{{ _("cert:") }} {{ ssl_bump.cert }}</span>
- {% endif %}
- {% else %}
- <span class="text-gray-500 font-semibold">{{ _("Inactivo") }}</span>
- {% endif %}
- </div>
- </div>
- </div>
- </div>
- </div>
- </div>
- {% endblock %}
|