base.html 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265
  1. <!DOCTYPE html>
  2. <html lang="{{ get_locale() }}">
  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. <meta name="description" content="{{ _('Administración y configuración del servidor proxy Squid.') }}">
  8. <title>{% block title %}{{ _("Administrador Squid Proxy") }}{% endblock %}</title>
  9. <link rel="icon" href="{{ url_for('static', filename='favicon.ico') }}" type="image/x-icon"/>
  10. <script src="{{ url_for('static', filename='src/tailwind.min.js') }}"></script>
  11. <script src="{{ url_for('static', filename='src/alpine.min.js') }}" defer></script>
  12. <link rel="stylesheet" href="{{ url_for('static', filename='all.min.css') }}">
  13. <link rel="stylesheet" href="{{ url_for('static', filename='css/toastr.min.css') }}">
  14. </head>
  15. <body class="bg-gray-50 min-h-screen" x-data="{ sidebarOpen: false }">
  16. <!-- Navigation -->
  17. <nav class="bg-gradient-to-r from-blue-600 via-blue-700 to-blue-800 text-white shadow-xl border-b border-blue-500">
  18. <div class="max-w-7xl mx-auto px-4 sm:px-6 lg:px-8">
  19. <div class="flex justify-between items-center py-4">
  20. <div class="flex items-center space-x-3 md:space-x-6">
  21. <!-- Mobile menu button -->
  22. <button type="button" aria-label="{{ _('Abrir menú') }}" @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">
  23. <i class="fas fa-bars text-xl"></i>
  24. </button>
  25. <div class="flex items-center space-x-3">
  26. <img src="{{ url_for('static', filename='squidstats-64.webp') }}" alt="" width="32" height="32" class="w-8 h-8 object-contain" />
  27. <i class="fas fa-server text-2xl md:text-3xl text-blue-200"></i>
  28. <div>
  29. <h1 class="text-lg md:text-2xl font-bold hidden sm:block">{{ _("Administrador Squid Proxy") }}</h1>
  30. <h1 class="text-lg font-bold sm:hidden">{{ _("Admin Squid") }}</h1>
  31. </div>
  32. </div>
  33. </div>
  34. <div class="flex items-center space-x-2 sm:space-x-3 md:space-x-4">
  35. <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">
  36. <i class="fas fa-sync-alt mr-2"></i>
  37. <span class="hidden sm:inline">{{ _("Recargar") }}</span>
  38. </button>
  39. <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">
  40. <i class="fas fa-power-off mr-2"></i>
  41. <span class="hidden sm:inline">{{ _("Reiniciar") }}</span>
  42. </button>
  43. <div class="relative" x-data="{ langOpen: false }">
  44. <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">
  45. <i class="fas fa-globe"></i>
  46. <span class="hidden sm:inline uppercase">{{ get_locale() }}</span>
  47. </button>
  48. <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;">
  49. {% for code, name in LANGUAGES.items() %}
  50. <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 %}">
  51. {{ name }}
  52. </a>
  53. {% endfor %}
  54. </div>
  55. </div>
  56. <!-- User Dropdown -->
  57. <div class="relative" x-data="{ userMenuOpen: false }">
  58. <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">
  59. <div class="flex items-center space-x-2">
  60. <div class="w-8 h-8 bg-gradient-to-r from-blue-400 to-blue-500 rounded-full flex items-center justify-center">
  61. <i class="fas fa-user text-sm"></i>
  62. </div>
  63. <div class="hidden md:block text-left">
  64. <div class="text-sm font-semibold">{{ session.user.username if session.user else 'Admin' }}</div>
  65. <div class="text-xs text-blue-200">{{ session.user.role if session.user else 'Administrator' }}</div>
  66. </div>
  67. </div>
  68. <i class="fas fa-chevron-down text-sm transition-transform duration-200" :class="userMenuOpen ? 'rotate-180' : ''"></i>
  69. </button>
  70. <!-- Dropdown Menu -->
  71. <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;">
  72. <!-- User Info Header -->
  73. <div class="px-4 py-3 border-b border-gray-200 bg-gradient-to-r from-blue-50 to-indigo-50 rounded-t-lg">
  74. <div class="flex items-center space-x-3">
  75. <div class="w-10 h-10 bg-gradient-to-r from-blue-500 to-indigo-600 rounded-full flex items-center justify-center">
  76. <i class="fas fa-user text-white"></i>
  77. </div>
  78. <div>
  79. <p class="text-sm font-semibold text-gray-800">{{ session.user.username if session.user else 'Admin' }}</p>
  80. <p class="text-xs text-gray-600">{{ session.user.role if session.user else 'Administrator' }}</p>
  81. </div>
  82. </div>
  83. </div>
  84. <!-- Menu Items -->
  85. <div class="py-2">
  86. <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">
  87. <i class="fas fa-users mr-3 text-gray-400"></i>
  88. {{ _("Gestionar Usuarios") }}
  89. </a>
  90. <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">
  91. <i class="fas fa-cog mr-3 text-gray-400"></i>
  92. {{ _("Configuración") }}
  93. </a>
  94. <div class="border-t border-gray-200 my-1"></div>
  95. <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">
  96. <i class="fas fa-sign-out-alt mr-3"></i>
  97. {{ _("Cerrar Sesión") }}
  98. </a>
  99. </div>
  100. </div>
  101. </div>
  102. </div>
  103. </div>
  104. </div>
  105. </nav>
  106. <!-- Sidebar -->
  107. <div class="flex relative">
  108. <!-- Mobile sidebar overlay -->
  109. <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>
  110. <aside class="w-64 bg-white shadow-lg min-h-screen">
  111. <nav class="mt-8">
  112. <div class="px-4 space-y-2">
  113. <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">
  114. <i class="fas fa-home mr-3"></i>{{ _("Dashboard") }}
  115. </a>
  116. <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">
  117. <i class="fas fa-home mr-3"></i>{{ _("Dashboard Admin") }}
  118. </a>
  119. <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">
  120. <i class="fas fa-cog mr-3"></i>{{ _("Configuración") }}
  121. </a>
  122. <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">
  123. <span class="flex items-center">
  124. <i class="fas fa-code-branch mr-3"></i>{{ _("Dividir Squid Config") }}
  125. </span>
  126. <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>
  127. </a>
  128. <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">
  129. <i class="fas fa-users mr-3"></i>{{ _("Usuarios") }}
  130. </a>
  131. <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") }}">
  132. <i class="fas fa-network-wired mr-3"></i>{{ _("LDAP / Active Directory") }}
  133. </a>
  134. <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">
  135. <i class="fas fa-database mr-3"></i>{{ _("Base de Datos") }}
  136. </a>
  137. <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">
  138. <span class="flex items-center">
  139. <i class="fas fa-shield-alt mr-3"></i>{{ _("ACLs") }}
  140. </span>
  141. <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>
  142. </a>
  143. <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">
  144. <span class="flex items-center">
  145. <i class="fas fa-clock mr-3"></i>{{ _("Delay Pools") }}
  146. </span>
  147. <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>
  148. </a>
  149. <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">
  150. <span class="flex items-center">
  151. <i class="fas fa-key mr-3"></i>{{ _("HTTP Access") }}
  152. </span>
  153. <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>
  154. </a>
  155. <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") }}">
  156. <i class="fas fa-tachometer-alt mr-3"></i>{{ _("Cuotas") }}
  157. <!--<span class="ml-2 text-xs font-semibold text-white bg-yellow-500 px-2 py-0.5 rounded">{{ _("Beta") }}</span>-->
  158. </a>
  159. <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">
  160. <i class="fas fa-ban mr-3"></i>{{ _("Blacklist") }}
  161. </a>
  162. <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">
  163. <i class="fas fa-file-alt mr-3"></i>{{ _("Logs") }}
  164. </a>
  165. </div>
  166. </nav>
  167. </aside>
  168. <!-- Main Content -->
  169. <main class="flex-1 p-4 sm:p-6 lg:p-8 w-full lg:w-auto">
  170. <!-- Flash Messages -->
  171. {% with messages = get_flashed_messages(with_categories=true) %}
  172. {% if messages %}
  173. <div class="mb-6">
  174. {% for category, message in messages %}
  175. <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 %}">
  176. <i class="fas fa-{% if category == 'success' %}check-circle text-blue-600{% else %}exclamation-triangle text-orange-600{% endif %} mr-2"></i>
  177. {{ message }}
  178. </div>
  179. {% endfor %}
  180. </div>
  181. {% endif %}
  182. {% endwith %}
  183. {% block content %}{% endblock %}
  184. </main>
  185. </div>
  186. <!-- Custom Confirm Modal -->
  187. {% include 'components/confirm_modal.html' %}
  188. <script src="{{ url_for('static', filename='js/jquery-4.0.0.min.js') }}"></script>
  189. <script src="{{ url_for('static', filename='js/toastr.min.js') }}"></script>
  190. <script src="{{ url_for('static', filename='js/toastr-config.js') }}"></script>
  191. <script src="{{ url_for('static', filename='js/confirm_modal.js') }}"></script>
  192. <script>
  193. // Get CSRF token from meta tag
  194. function getCsrfToken() {
  195. return document.querySelector('meta[name="csrf-token"]').getAttribute('content');
  196. }
  197. async function reloadSquid() {
  198. showCustomConfirm({{ _('¿Estás seguro de que desea recargar Squid? Esto aplicará los cambios de configuración sin interrumpir el servicio.')|tojson }}, async () => {
  199. try {
  200. const response = await fetch('/api/reload-squid', {
  201. method: 'POST',
  202. headers: {
  203. 'X-CSRFToken': getCsrfToken()
  204. }
  205. });
  206. const data = await response.json();
  207. if (data.status === 'success') {
  208. showNotification(data.message, 'success');
  209. } else {
  210. showNotification(data.message, 'error');
  211. }
  212. } catch (error) {
  213. showNotification({{ _('Error al recargar Squid')|tojson }}, 'error');
  214. }
  215. });
  216. }
  217. async function restartSquid() {
  218. showCustomConfirm({{ _('¿Estás seguro de que desea reiniciar Squid? Esto interrumpirá temporalmente el servicio.')|tojson }}, async () => {
  219. try {
  220. const response = await fetch('/api/restart-squid', {
  221. method: 'POST',
  222. headers: {
  223. 'X-CSRFToken': getCsrfToken()
  224. }
  225. });
  226. const data = await response.json();
  227. if (data.status === 'success') {
  228. showNotification(data.message, 'success');
  229. } else {
  230. showNotification(data.message, 'error');
  231. }
  232. } catch (error) {
  233. showNotification({{ _('Error al reiniciar Squid')|tojson }}, 'error');
  234. }
  235. });
  236. }
  237. function showNotification(message, type) {
  238. if (window.toastr) {
  239. if (type === 'success') {
  240. toastr.success(message);
  241. } else if (type === 'error') {
  242. toastr.error(message);
  243. } else if (type === 'warning') {
  244. toastr.warning(message);
  245. } else {
  246. toastr.info(message);
  247. }
  248. }
  249. }
  250. </script>
  251. </body>
  252. </html>