| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187 |
- <!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>{% block title %}Administrador Squid Proxy{% endblock %}</title>
- <script src="https://cdn.tailwindcss.com"></script>
- <script src="https://unpkg.com/alpinejs@3.x.x/dist/cdn.min.js" defer></script>
- <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.0.0/css/all.min.css">
- </head>
- <body class="bg-gray-50 min-h-screen" x-data="{ sidebarOpen: false }">
- <!-- Navigation -->
- <nav class="bg-blue-600 text-white shadow-lg">
- <div class="max-w-7xl mx-auto px-4">
- <div class="flex justify-between items-center py-4">
- <div class="flex items-center space-x-2 md:space-x-4">
- <!-- Mobile menu button -->
- <button @click="sidebarOpen = !sidebarOpen" class="lg:hidden text-white focus:outline-none">
- <i class="fas fa-bars text-xl"></i>
- </button>
- <i class="fas fa-server text-xl md:text-2xl"></i>
- <h1 class="text-sm md:text-xl font-bold hidden sm:block">Administrador Squid Proxy (BETA version)</h1>
- <h1 class="text-sm font-bold sm:hidden">Admin Squid</h1>
- </div>
- <div class="flex items-center space-x-1 sm:space-x-2 md:space-x-4">
- <button onclick="reloadSquid()" class="bg-gradient-to-r from-green-500 to-green-600 hover:from-green-600 hover:to-green-700 text-white font-medium px-2 sm:px-4 md:px-6 py-2 md:py-3 rounded-lg md:rounded-xl shadow-md hover:shadow-lg transition-all duration-200 flex items-center text-xs md:text-base">
- <i class="fas fa-sync-alt"></i>
- <span class="ml-1 md:ml-2 hidden sm:inline">Recargar</span>
- </button>
- <button onclick="restartSquid()" class="bg-gradient-to-r from-orange-500 to-orange-600 hover:from-orange-600 hover:to-orange-700 text-white font-medium px-2 sm:px-4 md:px-6 py-2 md:py-3 rounded-lg md:rounded-xl shadow-md hover:shadow-lg transition-all duration-200 flex items-center text-xs md:text-base">
- <i class="fas fa-power-off"></i>
- <span class="ml-1 md:ml-2 hidden sm:inline">Reiniciar</span>
- </button>
- <div class="hidden md:flex items-center space-x-2 text-white bg-blue-700 bg-opacity-50 px-3 py-2 rounded-lg">
- <i class="fas fa-user"></i>
- <span>{{ session.user.username if session.user else 'Admin' }}</span>
- </div>
- <a href="{{ url_for('auth.logout') }}" class="bg-gradient-to-r from-blue-500 to-blue-600 hover:from-blue-600 hover:to-blue-700 text-white font-medium px-2 sm:px-4 md:px-6 py-2 md:py-3 rounded-lg md:rounded-xl shadow-md hover:shadow-lg transition-all duration-200 flex items-center text-xs md:text-base">
- <i class="fas fa-sign-out-alt"></i>
- <span class="ml-1 md:ml-2 hidden sm:inline">Cerrar Sesión</span>
- </a>
- </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.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.clean_data') }}" 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>Limpiar Datos
- </a>
- <div class="flex items-center px-4 py-3 text-gray-400 cursor-not-allowed rounded-lg">
- <i class="fas fa-shield-alt mr-3"></i>
- <span>ACLs</span>
- <span class="ml-auto bg-yellow-100 text-yellow-800 text-xs font-medium px-2.5 py-0.5 rounded">Próximamente</span>
- </div>
- <div class="flex items-center px-4 py-3 text-gray-400 cursor-not-allowed rounded-lg">
- <i class="fas fa-clock mr-3"></i>
- <span>Delay Pools</span>
- <span class="ml-auto bg-yellow-100 text-yellow-800 text-xs font-medium px-2.5 py-0.5 rounded">Próximamente</span>
- </div>
- <div class="flex items-center px-4 py-3 text-gray-400 cursor-not-allowed rounded-lg">
- <i class="fas fa-key mr-3"></i>
- <span>HTTP Access</span>
- <span class="ml-auto bg-yellow-100 text-yellow-800 text-xs font-medium px-2.5 py-0.5 rounded">Próximamente</span>
- </div>
- <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/confirm_modal.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á seguro de que desea recargar Squid? Esto aplicará los cambios de configuración sin interrumpir el servicio.', 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', 'error');
- }
- });
- }
- async function restartSquid() {
- showCustomConfirm('¿Está seguro de que desea reiniciar Squid? Esto interrumpirá temporalmente el servicio.', 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', 'error');
- }
- });
- }
- function showNotification(message, type) {
- const notification = document.createElement('div');
- notification.className = `fixed top-4 right-4 p-4 rounded-lg shadow-lg z-50 ${
- type === 'success' ? 'bg-blue-500 text-white' : 'bg-orange-500 text-white'
- }`;
- notification.innerHTML = `
- <div class="flex items-center">
- <i class="fas fa-${type === 'success' ? 'check-circle' : 'exclamation-triangle'} mr-2"></i>
- ${message}
- </div>
- `;
-
- document.body.appendChild(notification);
-
- setTimeout(() => {
- notification.remove();
- }, 5000);
- }
- </script>
- </body>
- </html>
|