| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264 |
- <!DOCTYPE html>
- <html lang="{{ get_locale() }}">
- <head>
- <meta charset="UTF-8">
- <meta name="viewport" content="width=device-width, initial-scale=1.0">
- <meta name="csrf-token" content="{{ csrf_token() }}">
- <title>{% block title %}{{ _("Administrador Squid Proxy") }}{% endblock %}</title>
- <link rel="icon" href="{{ url_for('static', filename='favicon.ico') }}" type="image/x-icon"/>
- <script src="{{ url_for('static', filename='src/tailwind.min.js') }}"></script>
- <script src="{{ url_for('static', filename='src/alpine.min.js') }}" defer></script>
- <link rel="stylesheet" href="{{ url_for('static', filename='all.min.css') }}">
- <link rel="stylesheet" href="{{ url_for('static', filename='css/toastr.min.css') }}">
- </head>
- <body class="bg-gray-50 min-h-screen" x-data="{ sidebarOpen: false }">
- <!-- Navigation -->
- <nav class="bg-gradient-to-r from-blue-600 via-blue-700 to-blue-800 text-white shadow-xl border-b border-blue-500">
- <div class="max-w-7xl mx-auto px-4 sm:px-6 lg:px-8">
- <div class="flex justify-between items-center py-4">
- <div class="flex items-center space-x-3 md:space-x-6">
- <!-- Mobile menu button -->
- <button @click="sidebarOpen = !sidebarOpen" class="lg:hidden text-white hover:bg-blue-500 p-2 rounded-lg transition-colors duration-200 focus:outline-none focus:ring-2 focus:ring-blue-300">
- <i class="fas fa-bars text-xl"></i>
- </button>
- <div class="flex items-center space-x-3">
- <img src="{{ url_for('static', filename='squidstats.webp') }}" alt="{{ _("SquidStats logo") }}" class="w-8 h-8 object-contain" />
- <i class="fas fa-server text-2xl md:text-3xl text-blue-200"></i>
- <div>
- <h1 class="text-lg md:text-2xl font-bold hidden sm:block">{{ _("Administrador Squid Proxy") }}</h1>
- <h1 class="text-lg font-bold sm:hidden">{{ _("Admin Squid") }}</h1>
- </div>
- </div>
- </div>
- <div class="flex items-center space-x-2 sm:space-x-3 md:space-x-4">
- <button onclick="reloadSquid()" title="{{ _("Recarga la configuración de Squid sin reiniciar el servicio") }}" class="bg-gradient-to-r from-emerald-500 to-emerald-600 hover:from-emerald-600 hover:to-emerald-700 text-white font-semibold px-3 sm:px-4 md:px-5 py-2 md:py-2.5 rounded-lg shadow-lg hover:shadow-xl transform hover:scale-105 transition-all duration-200 flex items-center text-sm md:text-base">
- <i class="fas fa-sync-alt mr-2"></i>
- <span class="hidden sm:inline">{{ _("Recargar") }}</span>
- </button>
- <button onclick="restartSquid()" title="{{ _("Reinicia Squid y vuelve a aplicar la configuración desde cero") }}" class="bg-gradient-to-r from-amber-500 to-amber-600 hover:from-amber-600 hover:to-amber-700 text-white font-semibold px-3 sm:px-4 md:px-5 py-2 md:py-2.5 rounded-lg shadow-lg hover:shadow-xl transform hover:scale-105 transition-all duration-200 flex items-center text-sm md:text-base">
- <i class="fas fa-power-off mr-2"></i>
- <span class="hidden sm:inline">{{ _("Reiniciar") }}</span>
- </button>
- <div class="relative" x-data="{ langOpen: false }">
- <button @click="langOpen = !langOpen" @click.outside="langOpen = false" title="{{ _("Idioma") }}" class="flex items-center space-x-2 text-white bg-blue-800 bg-opacity-60 hover:bg-blue-700 px-4 py-2 rounded-lg shadow-md transition-all duration-200 focus:outline-none focus:ring-2 focus:ring-blue-300">
- <i class="fas fa-globe"></i>
- <span class="hidden sm:inline uppercase">{{ get_locale() }}</span>
- </button>
- <div x-show="langOpen" x-transition:enter="transition ease-out duration-200" x-transition:enter-start="opacity-0 transform scale-95" x-transition:enter-end="opacity-100 transform scale-100" x-transition:leave="transition ease-in duration-150" x-transition:leave-start="opacity-100 transform scale-100" x-transition:leave-end="opacity-0 transform scale-95" class="absolute right-0 mt-2 w-44 bg-white rounded-lg shadow-xl border border-gray-200 z-50" style="display: none;">
- {% for code, name in LANGUAGES.items() %}
- <a href="{{ url_for('i18n.set_language', lang=code) }}" class="block px-4 py-3 text-sm text-gray-700 hover:bg-blue-50 hover:text-blue-700 transition-colors {% if get_locale() == code %}bg-blue-50 font-semibold text-blue-700{% endif %}">
- {{ name }}
- </a>
- {% endfor %}
- </div>
- </div>
- <!-- User Dropdown -->
- <div class="relative" x-data="{ userMenuOpen: false }">
- <button @click="userMenuOpen = !userMenuOpen" @click.away="userMenuOpen = false" class="flex items-center space-x-2 text-white bg-blue-800 bg-opacity-60 hover:bg-blue-700 px-4 py-2 rounded-lg shadow-md transition-all duration-200 focus:outline-none focus:ring-2 focus:ring-blue-300">
- <div class="flex items-center space-x-2">
- <div class="w-8 h-8 bg-gradient-to-r from-blue-400 to-blue-500 rounded-full flex items-center justify-center">
- <i class="fas fa-user text-sm"></i>
- </div>
- <div class="hidden md:block text-left">
- <div class="text-sm font-semibold">{{ session.user.username if session.user else 'Admin' }}</div>
- <div class="text-xs text-blue-200">{{ session.user.role if session.user else 'Administrator' }}</div>
- </div>
- </div>
- <i class="fas fa-chevron-down text-sm transition-transform duration-200" :class="userMenuOpen ? 'rotate-180' : ''"></i>
- </button>
- <!-- Dropdown Menu -->
- <div x-show="userMenuOpen" x-transition:enter="transition ease-out duration-200" x-transition:enter-start="opacity-0 transform scale-95" x-transition:enter-end="opacity-100 transform scale-100" x-transition:leave="transition ease-in duration-150" x-transition:leave-start="opacity-100 transform scale-100" x-transition:leave-end="opacity-0 transform scale-95" class="absolute right-0 mt-2 w-56 bg-white rounded-lg shadow-xl border border-gray-200 z-50" style="display: none;">
- <!-- User Info Header -->
- <div class="px-4 py-3 border-b border-gray-200 bg-gradient-to-r from-blue-50 to-indigo-50 rounded-t-lg">
- <div class="flex items-center space-x-3">
- <div class="w-10 h-10 bg-gradient-to-r from-blue-500 to-indigo-600 rounded-full flex items-center justify-center">
- <i class="fas fa-user text-white"></i>
- </div>
- <div>
- <p class="text-sm font-semibold text-gray-800">{{ session.user.username if session.user else 'Admin' }}</p>
- <p class="text-xs text-gray-600">{{ session.user.role if session.user else 'Administrator' }}</p>
- </div>
- </div>
- </div>
- <!-- Menu Items -->
- <div class="py-2">
- <a href="{{ url_for('admin.manage_users') }}" class="flex items-center px-4 py-2 text-sm text-gray-700 hover:bg-gray-50 hover:text-blue-600 transition-colors">
- <i class="fas fa-users mr-3 text-gray-400"></i>
- {{ _("Gestionar Usuarios") }}
- </a>
- <a href="{{ url_for('admin.view_config') }}" class="flex items-center px-4 py-2 text-sm text-gray-700 hover:bg-gray-50 hover:text-blue-600 transition-colors">
- <i class="fas fa-cog mr-3 text-gray-400"></i>
- {{ _("Configuración") }}
- </a>
- <div class="border-t border-gray-200 my-1"></div>
- <a href="{{ url_for('auth.logout') }}" class="flex items-center px-4 py-2 text-sm text-red-600 hover:bg-red-50 hover:text-red-700 transition-colors">
- <i class="fas fa-sign-out-alt mr-3"></i>
- {{ _("Cerrar Sesión") }}
- </a>
- </div>
- </div>
- </div>
- </div>
- </div>
- </div>
- </nav>
- <!-- Sidebar -->
- <div class="flex relative">
- <!-- Mobile sidebar overlay -->
- <div x-show="sidebarOpen" @click="sidebarOpen = false" class="fixed inset-0 bg-black bg-opacity-50 z-40 lg:hidden" x-transition:enter="transition-opacity ease-linear duration-300" x-transition:enter-start="opacity-0" x-transition:enter-end="opacity-100" x-transition:leave="transition-opacity ease-linear duration-300" x-transition:leave-start="opacity-100" x-transition:leave-end="opacity-0" style="display: none;"></div>
- <aside class="w-64 bg-white shadow-lg min-h-screen">
- <nav class="mt-8">
- <div class="px-4 space-y-2">
- <a href="{{ url_for('main.index') }}" class="flex items-center px-4 py-3 text-gray-700 hover:bg-blue-50 hover:text-blue-600 rounded-lg transition-colors">
- <i class="fas fa-home mr-3"></i>{{ _("Dashboard") }}
- </a>
- <a href="{{ url_for('admin.admin_dashboard') }}" class="flex items-center px-4 py-3 text-gray-700 hover:bg-blue-50 hover:text-blue-600 rounded-lg transition-colors">
- <i class="fas fa-home mr-3"></i>{{ _("Dashboard Admin") }}
- </a>
- <a href="{{ url_for('admin.view_config') }}" class="flex items-center px-4 py-3 text-gray-700 hover:bg-blue-50 hover:text-blue-600 rounded-lg transition-colors">
- <i class="fas fa-cog mr-3"></i>{{ _("Configuración") }}
- </a>
- <a href="{{ url_for('admin.split_config_view') }}" class="flex items-center justify-between px-4 py-3 text-gray-700 hover:bg-blue-50 hover:text-blue-600 rounded-lg transition-colors">
- <span class="flex items-center">
- <i class="fas fa-code-branch mr-3"></i>{{ _("Dividir Squid Config") }}
- </span>
- <span class="bg-gradient-to-r from-indigo-500 to-purple-600 text-white text-xs font-semibold px-2.5 py-0.5 rounded-full shadow-sm">{{ _("RC") }}</span>
- </a>
- <a href="{{ url_for('admin.manage_users') }}" class="flex items-center px-4 py-3 text-gray-700 hover:bg-blue-50 hover:text-blue-600 rounded-lg transition-colors">
- <i class="fas fa-users mr-3"></i>{{ _("Usuarios") }}
- </a>
- <a href="{{ url_for('admin.ldap_config') }}" class="flex items-center px-4 py-3 text-gray-700 hover:bg-blue-50 hover:text-blue-600 rounded-lg transition-colors" title="{{ _("Configuraciones LDAP/Active Directory") }}">
- <i class="fas fa-network-wired mr-3"></i>{{ _("LDAP / Active Directory") }}
- </a>
- <a href="{{ url_for('admin.database_view') }}" class="flex items-center px-4 py-3 text-gray-700 hover:bg-blue-50 hover:text-blue-600 rounded-lg transition-colors">
- <i class="fas fa-database mr-3"></i>{{ _("Base de Datos") }}
- </a>
- <a href="{{ url_for('admin.manage_acls') }}" class="flex items-center justify-between px-4 py-3 text-gray-700 hover:bg-blue-50 hover:text-blue-600 rounded-lg transition-colors">
- <span class="flex items-center">
- <i class="fas fa-shield-alt mr-3"></i>{{ _("ACLs") }}
- </span>
- <span class="bg-gradient-to-r from-indigo-500 to-purple-600 text-white text-xs font-semibold px-2.5 py-0.5 rounded-full shadow-sm">{{ _("RC") }}</span>
- </a>
- <a href="{{ url_for('admin.manage_delay_pools') }}" class="flex items-center justify-between px-4 py-3 text-gray-700 hover:bg-blue-50 hover:text-blue-600 rounded-lg transition-colors">
- <span class="flex items-center">
- <i class="fas fa-clock mr-3"></i>{{ _("Delay Pools") }}
- </span>
- <span class="bg-gradient-to-r from-indigo-500 to-purple-600 text-white text-xs font-semibold px-2.5 py-0.5 rounded-full shadow-sm">{{ _("RC") }}</span>
- </a>
- <a href="{{ url_for('admin.manage_http_access') }}" class="flex items-center justify-between px-4 py-3 text-gray-700 hover:bg-blue-50 hover:text-blue-600 rounded-lg transition-colors">
- <span class="flex items-center">
- <i class="fas fa-key mr-3"></i>{{ _("HTTP Access") }}
- </span>
- <span class="bg-gradient-to-r from-indigo-500 to-purple-600 text-white text-xs font-semibold px-2.5 py-0.5 rounded-full shadow-sm">{{ _("RC") }}</span>
- </a>
- <a href="/admin/quota" class="flex items-center px-4 py-3 text-gray-700 hover:bg-blue-50 hover:text-blue-600 rounded-lg transition-colors" title="{{ _("Cuotas") }}">
- <i class="fas fa-tachometer-alt mr-3"></i>{{ _("Cuotas") }}
- <span class="ml-2 text-xs font-semibold text-white bg-yellow-500 px-2 py-0.5 rounded">{{ _("Beta") }}</span>
- </a>
- <a href="/admin/blacklist" class="flex items-center px-4 py-3 text-gray-700 hover:bg-blue-50 hover:text-blue-600 rounded-lg transition-colors">
- <i class="fas fa-ban mr-3"></i>{{ _("Blacklist") }}
- </a>
- <a href="{{ url_for('admin.view_logs') }}" class="flex items-center px-4 py-3 text-gray-700 hover:bg-blue-50 hover:text-blue-600 rounded-lg transition-colors">
- <i class="fas fa-file-alt mr-3"></i>{{ _("Logs") }}
- </a>
- </div>
- </nav>
- </aside>
- <!-- Main Content -->
- <main class="flex-1 p-4 sm:p-6 lg:p-8 w-full lg:w-auto">
- <!-- Flash Messages -->
- {% with messages = get_flashed_messages(with_categories=true) %}
- {% if messages %}
- <div class="mb-6">
- {% for category, message in messages %}
- <div class="alert alert-{{ 'success' if category == 'success' else 'warning' }} p-4 rounded-lg mb-4 {% if category == 'success' %}bg-blue-50 text-blue-800 border border-blue-200{% else %}bg-orange-50 text-orange-800 border border-orange-200{% endif %}">
- <i class="fas fa-{% if category == 'success' %}check-circle text-blue-600{% else %}exclamation-triangle text-orange-600{% endif %} mr-2"></i>
- {{ message }}
- </div>
- {% endfor %}
- </div>
- {% endif %}
- {% endwith %}
- {% block content %}{% endblock %}
- </main>
- </div>
- <!-- Custom Confirm Modal -->
- {% include 'components/confirm_modal.html' %}
- <script src="{{ url_for('static', filename='js/jquery-4.0.0.min.js') }}"></script>
- <script src="{{ url_for('static', filename='js/toastr.min.js') }}"></script>
- <script src="{{ url_for('static', filename='js/toastr-config.js') }}"></script>
- <script src="{{ url_for('static', filename='js/confirm_modal.js') }}"></script>
- <script>
- // Get CSRF token from meta tag
- function getCsrfToken() {
- return document.querySelector('meta[name="csrf-token"]').getAttribute('content');
- }
- async function reloadSquid() {
- showCustomConfirm({{ _('¿Estás seguro de que desea recargar Squid? Esto aplicará los cambios de configuración sin interrumpir el servicio.')|tojson }}, async () => {
- try {
- const response = await fetch('/api/reload-squid', {
- method: 'POST',
- headers: {
- 'X-CSRFToken': getCsrfToken()
- }
- });
- const data = await response.json();
-
- if (data.status === 'success') {
- showNotification(data.message, 'success');
- } else {
- showNotification(data.message, 'error');
- }
- } catch (error) {
- showNotification({{ _('Error al recargar Squid')|tojson }}, 'error');
- }
- });
- }
- async function restartSquid() {
- showCustomConfirm({{ _('¿Estás seguro de que desea reiniciar Squid? Esto interrumpirá temporalmente el servicio.')|tojson }}, async () => {
- try {
- const response = await fetch('/api/restart-squid', {
- method: 'POST',
- headers: {
- 'X-CSRFToken': getCsrfToken()
- }
- });
- const data = await response.json();
-
- if (data.status === 'success') {
- showNotification(data.message, 'success');
- } else {
- showNotification(data.message, 'error');
- }
- } catch (error) {
- showNotification({{ _('Error al reiniciar Squid')|tojson }}, 'error');
- }
- });
- }
- function showNotification(message, type) {
- if (window.toastr) {
- if (type === 'success') {
- toastr.success(message);
- } else if (type === 'error') {
- toastr.error(message);
- } else if (type === 'warning') {
- toastr.warning(message);
- } else {
- toastr.info(message);
- }
- }
- }
- </script>
- </body>
- </html>
|