base.html 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187
  1. <!DOCTYPE html>
  2. <html lang="es">
  3. <head>
  4. <meta charset="UTF-8">
  5. <meta name="viewport" content="width=device-width, initial-scale=1.0">
  6. <meta name="csrf-token" content="{{ csrf_token() }}">
  7. <title>{% block title %}Administrador Squid Proxy{% endblock %}</title>
  8. <script src="https://cdn.tailwindcss.com"></script>
  9. <script src="https://unpkg.com/alpinejs@3.x.x/dist/cdn.min.js" defer></script>
  10. <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.0.0/css/all.min.css">
  11. </head>
  12. <body class="bg-gray-50 min-h-screen" x-data="{ sidebarOpen: false }">
  13. <!-- Navigation -->
  14. <nav class="bg-blue-600 text-white shadow-lg">
  15. <div class="max-w-7xl mx-auto px-4">
  16. <div class="flex justify-between items-center py-4">
  17. <div class="flex items-center space-x-2 md:space-x-4">
  18. <!-- Mobile menu button -->
  19. <button @click="sidebarOpen = !sidebarOpen" class="lg:hidden text-white focus:outline-none">
  20. <i class="fas fa-bars text-xl"></i>
  21. </button>
  22. <i class="fas fa-server text-xl md:text-2xl"></i>
  23. <h1 class="text-sm md:text-xl font-bold hidden sm:block">Administrador Squid Proxy (BETA version)</h1>
  24. <h1 class="text-sm font-bold sm:hidden">Admin Squid</h1>
  25. </div>
  26. <div class="flex items-center space-x-1 sm:space-x-2 md:space-x-4">
  27. <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">
  28. <i class="fas fa-sync-alt"></i>
  29. <span class="ml-1 md:ml-2 hidden sm:inline">Recargar</span>
  30. </button>
  31. <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">
  32. <i class="fas fa-power-off"></i>
  33. <span class="ml-1 md:ml-2 hidden sm:inline">Reiniciar</span>
  34. </button>
  35. <div class="hidden md:flex items-center space-x-2 text-white bg-blue-700 bg-opacity-50 px-3 py-2 rounded-lg">
  36. <i class="fas fa-user"></i>
  37. <span>{{ session.user.username if session.user else 'Admin' }}</span>
  38. </div>
  39. <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">
  40. <i class="fas fa-sign-out-alt"></i>
  41. <span class="ml-1 md:ml-2 hidden sm:inline">Cerrar Sesión</span>
  42. </a>
  43. </div>
  44. </div>
  45. </div>
  46. </nav>
  47. <!-- Sidebar -->
  48. <div class="flex relative">
  49. <!-- Mobile sidebar overlay -->
  50. <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>
  51. <aside class="w-64 bg-white shadow-lg min-h-screen">
  52. <nav class="mt-8">
  53. <div class="px-4 space-y-2">
  54. <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">
  55. <i class="fas fa-home mr-3"></i>Dashboard
  56. </a>
  57. <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">
  58. <i class="fas fa-home mr-3"></i>Dashboard Admin
  59. </a>
  60. <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">
  61. <i class="fas fa-cog mr-3"></i>Configuración
  62. </a>
  63. <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">
  64. <i class="fas fa-users mr-3"></i>Usuarios
  65. </a>
  66. <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">
  67. <i class="fas fa-database mr-3"></i>Limpiar Datos
  68. </a>
  69. <div class="flex items-center px-4 py-3 text-gray-400 cursor-not-allowed rounded-lg">
  70. <i class="fas fa-shield-alt mr-3"></i>
  71. <span>ACLs</span>
  72. <span class="ml-auto bg-yellow-100 text-yellow-800 text-xs font-medium px-2.5 py-0.5 rounded">Próximamente</span>
  73. </div>
  74. <div class="flex items-center px-4 py-3 text-gray-400 cursor-not-allowed rounded-lg">
  75. <i class="fas fa-clock mr-3"></i>
  76. <span>Delay Pools</span>
  77. <span class="ml-auto bg-yellow-100 text-yellow-800 text-xs font-medium px-2.5 py-0.5 rounded">Próximamente</span>
  78. </div>
  79. <div class="flex items-center px-4 py-3 text-gray-400 cursor-not-allowed rounded-lg">
  80. <i class="fas fa-key mr-3"></i>
  81. <span>HTTP Access</span>
  82. <span class="ml-auto bg-yellow-100 text-yellow-800 text-xs font-medium px-2.5 py-0.5 rounded">Próximamente</span>
  83. </div>
  84. <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">
  85. <i class="fas fa-file-alt mr-3"></i>Logs
  86. </a>
  87. </div>
  88. </nav>
  89. </aside>
  90. <!-- Main Content -->
  91. <main class="flex-1 p-4 sm:p-6 lg:p-8 w-full lg:w-auto">
  92. <!-- Flash Messages -->
  93. {% with messages = get_flashed_messages(with_categories=true) %}
  94. {% if messages %}
  95. <div class="mb-6">
  96. {% for category, message in messages %}
  97. <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 %}">
  98. <i class="fas fa-{% if category == 'success' %}check-circle text-blue-600{% else %}exclamation-triangle text-orange-600{% endif %} mr-2"></i>
  99. {{ message }}
  100. </div>
  101. {% endfor %}
  102. </div>
  103. {% endif %}
  104. {% endwith %}
  105. {% block content %}{% endblock %}
  106. </main>
  107. </div>
  108. <!-- Custom Confirm Modal -->
  109. {% include 'components/confirm_modal.html' %}
  110. <script src="{{ url_for('static', filename='js/confirm_modal.js') }}"></script>
  111. <script src="{{ url_for('static', filename='js/confirm_modal.js') }}"></script>
  112. <script>
  113. // Get CSRF token from meta tag
  114. function getCsrfToken() {
  115. return document.querySelector('meta[name="csrf-token"]').getAttribute('content');
  116. }
  117. async function reloadSquid() {
  118. showCustomConfirm('¿Está seguro de que desea recargar Squid? Esto aplicará los cambios de configuración sin interrumpir el servicio.', async () => {
  119. try {
  120. const response = await fetch('/api/reload-squid', {
  121. method: 'POST',
  122. headers: {
  123. 'X-CSRFToken': getCsrfToken()
  124. }
  125. });
  126. const data = await response.json();
  127. if (data.status === 'success') {
  128. showNotification(data.message, 'success');
  129. } else {
  130. showNotification(data.message, 'error');
  131. }
  132. } catch (error) {
  133. showNotification('Error al recargar Squid', 'error');
  134. }
  135. });
  136. }
  137. async function restartSquid() {
  138. showCustomConfirm('¿Está seguro de que desea reiniciar Squid? Esto interrumpirá temporalmente el servicio.', async () => {
  139. try {
  140. const response = await fetch('/api/restart-squid', {
  141. method: 'POST',
  142. headers: {
  143. 'X-CSRFToken': getCsrfToken()
  144. }
  145. });
  146. const data = await response.json();
  147. if (data.status === 'success') {
  148. showNotification(data.message, 'success');
  149. } else {
  150. showNotification(data.message, 'error');
  151. }
  152. } catch (error) {
  153. showNotification('Error al reiniciar Squid', 'error');
  154. }
  155. });
  156. }
  157. function showNotification(message, type) {
  158. const notification = document.createElement('div');
  159. notification.className = `fixed top-4 right-4 p-4 rounded-lg shadow-lg z-50 ${
  160. type === 'success' ? 'bg-blue-500 text-white' : 'bg-orange-500 text-white'
  161. }`;
  162. notification.innerHTML = `
  163. <div class="flex items-center">
  164. <i class="fas fa-${type === 'success' ? 'check-circle' : 'exclamation-triangle'} mr-2"></i>
  165. ${message}
  166. </div>
  167. `;
  168. document.body.appendChild(notification);
  169. setTimeout(() => {
  170. notification.remove();
  171. }, 5000);
  172. }
  173. </script>
  174. </body>
  175. </html>