base.html 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132
  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. <title>{% block title %}Administrador Squid Proxy{% endblock %}</title>
  7. <script src="https://cdn.tailwindcss.com"></script>
  8. <script src="https://unpkg.com/alpinejs@3.x.x/dist/cdn.min.js" defer></script>
  9. <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.0.0/css/all.min.css">
  10. </head>
  11. <body class="bg-gray-50 min-h-screen">
  12. <!-- Navigation -->
  13. <nav class="bg-blue-600 text-white shadow-lg">
  14. <div class="max-w-7xl mx-auto px-4">
  15. <div class="flex justify-between items-center py-4">
  16. <div class="flex items-center space-x-4">
  17. <i class="fas fa-server text-2xl"></i>
  18. <h1 class="text-xl font-bold">Administrador Squid Proxy</h1>
  19. </div>
  20. <div class="flex space-x-4">
  21. <button onclick="reloadSquid()" class="bg-green-500 hover:bg-green-600 px-4 py-2 rounded-lg transition-colors">
  22. <i class="fas fa-sync-alt mr-2"></i>Recargar
  23. </button>
  24. <button onclick="restartSquid()" class="bg-red-500 hover:bg-red-600 px-4 py-2 rounded-lg transition-colors">
  25. <i class="fas fa-power-off mr-2"></i>Reiniciar
  26. </button>
  27. </div>
  28. </div>
  29. </div>
  30. </nav>
  31. <!-- Sidebar -->
  32. <div class="flex">
  33. <aside class="w-64 bg-white shadow-lg min-h-screen">
  34. <nav class="mt-8">
  35. <div class="px-4 space-y-2">
  36. <a href="{{ url_for('index') }}" class="flex items-center px-4 py-3 text-gray-700 hover:bg-blue-50 hover:text-blue-600 rounded-lg transition-colors">
  37. <i class="fas fa-home mr-3"></i>Dashboard
  38. </a>
  39. <a href="{{ url_for('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">
  40. <i class="fas fa-file-code mr-3"></i>Configuración
  41. </a>
  42. <a href="{{ url_for('manage_acls') }}" class="flex items-center px-4 py-3 text-gray-700 hover:bg-blue-50 hover:text-blue-600 rounded-lg transition-colors">
  43. <i class="fas fa-shield-alt mr-3"></i>ACLs
  44. </a>
  45. <a href="{{ url_for('manage_delay_pools') }}" class="flex items-center px-4 py-3 text-gray-700 hover:bg-blue-50 hover:text-blue-600 rounded-lg transition-colors">
  46. <i class="fas fa-tachometer-alt mr-3"></i>Delay Pools
  47. </a>
  48. <a href="{{ url_for('manage_http_access') }}" class="flex items-center px-4 py-3 text-gray-700 hover:bg-blue-50 hover:text-blue-600 rounded-lg transition-colors">
  49. <i class="fas fa-key mr-3"></i>Acceso HTTP
  50. </a>
  51. <a href="{{ url_for('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">
  52. <i class="fas fa-file-alt mr-3"></i>Logs
  53. </a>
  54. </div>
  55. </nav>
  56. </aside>
  57. <!-- Main Content -->
  58. <main class="flex-1 p-8">
  59. <!-- Flash Messages -->
  60. {% with messages = get_flashed_messages(with_categories=true) %}
  61. {% if messages %}
  62. <div class="mb-6">
  63. {% for category, message in messages %}
  64. <div class="alert alert-{{ 'success' if category == 'success' else 'error' }} p-4 rounded-lg mb-4 {% if category == 'success' %}bg-green-100 text-green-700 border border-green-300{% else %}bg-red-100 text-red-700 border border-red-300{% endif %}">
  65. <i class="fas fa-{% if category == 'success' %}check-circle{% else %}exclamation-triangle{% endif %} mr-2"></i>
  66. {{ message }}
  67. </div>
  68. {% endfor %}
  69. </div>
  70. {% endif %}
  71. {% endwith %}
  72. {% block content %}{% endblock %}
  73. </main>
  74. </div>
  75. <script>
  76. async function reloadSquid() {
  77. try {
  78. const response = await fetch('/api/reload-squid', { method: 'POST' });
  79. const data = await response.json();
  80. if (data.status === 'success') {
  81. showNotification(data.message, 'success');
  82. } else {
  83. showNotification(data.message, 'error');
  84. }
  85. } catch (error) {
  86. showNotification('Error al recargar Squid', 'error');
  87. }
  88. }
  89. async function restartSquid() {
  90. if (confirm('¿Está seguro de que desea reiniciar Squid? Esto interrumpirá temporalmente el servicio.')) {
  91. try {
  92. const response = await fetch('/api/restart-squid', { method: 'POST' });
  93. const data = await response.json();
  94. if (data.status === 'success') {
  95. showNotification(data.message, 'success');
  96. } else {
  97. showNotification(data.message, 'error');
  98. }
  99. } catch (error) {
  100. showNotification('Error al reiniciar Squid', 'error');
  101. }
  102. }
  103. }
  104. function showNotification(message, type) {
  105. const notification = document.createElement('div');
  106. notification.className = `fixed top-4 right-4 p-4 rounded-lg shadow-lg z-50 ${
  107. type === 'success' ? 'bg-green-500 text-white' : 'bg-red-500 text-white'
  108. }`;
  109. notification.innerHTML = `
  110. <div class="flex items-center">
  111. <i class="fas fa-${type === 'success' ? 'check-circle' : 'exclamation-triangle'} mr-2"></i>
  112. ${message}
  113. </div>
  114. `;
  115. document.body.appendChild(notification);
  116. setTimeout(() => {
  117. notification.remove();
  118. }, 5000);
  119. }
  120. </script>
  121. </body>
  122. </html>