acls_new.html 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177
  1. {% extends "admin/base.html" %}
  2. {% block content %}
  3. <div class="bg-white rounded-lg shadow-lg p-4 sm:p-6">
  4. <div class="flex justify-between items-center mb-4 sm:mb-6">
  5. <div>
  6. <h2 class="text-xl sm:text-2xl font-bold text-gray-800">{{ _("Gestión de Access Control Lists (ACLs)") }}</h2>
  7. <p class="text-sm text-gray-600 mt-1">{{ _("Define condiciones para controlar el acceso al proxy") }}</p>
  8. </div>
  9. <button onclick="showAddModal()" class="bg-blue-600 hover:bg-blue-700 text-white font-semibold px-4 py-2 rounded-lg shadow-md transition-colors">
  10. <i class="fas fa-plus mr-2"></i>{{ _("Agregar ACL") }}
  11. </button>
  12. </div>
  13. <!-- RC -->
  14. <div class="mb-6 bg-red-50 border-2 border-red-300 rounded-lg p-6 flex items-start space-x-4">
  15. <i class="fas fa-exclamation-triangle text-red-600 text-3xl mt-1 animate-pulse"></i>
  16. <div class="flex-1">
  17. <p class="font-bold text-red-800 text-lg">{{ _("¡MUY IMPORTANTE!") }}</p>
  18. <p class="text-red-700 mt-2 font-medium">
  19. {{ _("Esta funcionalidad se encuentra en") }} <strong>{{ _("RC") }}</strong>. Puede contener errores y comportamientos inesperados.
  20. </p>
  21. <p class="text-red-700 mt-2">
  22. <strong>{{ _("Por favor, no la uses en producción de momento. Úsala únicamente en un entorno de prueba.") }}</strong>
  23. </p>
  24. </div>
  25. </div>
  26. {% if acls %}
  27. <div class="mb-4 bg-blue-50 border border-blue-200 rounded-lg p-4">
  28. <div class="flex items-start">
  29. <i class="fas fa-info-circle text-blue-600 mt-1 mr-3"></i>
  30. <div class="text-sm text-gray-700">
  31. <p class="font-semibold text-gray-800 mb-1">{{ _("Acerca de las ACLs:") }}</p>
  32. <ul class="list-disc list-inside space-y-1 ml-2">
  33. <li><span class="font-mono text-xs bg-white px-1 rounded">{{ _("[fast]") }}</span> {{ _("ACLs rápidas - no requieren lookups externos") }}</li>
  34. <li><span class="font-mono text-xs bg-orange-100 px-1 rounded">{{ _("[slow]") }}</span> {{ _("ACLs lentas - pueden requerir DNS o autenticación") }}</li>
  35. <li>{{ _("Usa las ACLs en reglas de http_access, http_reply_access, etc.") }}</li>
  36. <li>{{ _("ACLs predefinidas:") }} <code class="bg-white px-1 rounded">{{ _("all, manager, localhost, to_localhost, to_linklocal, CONNECT") }}</code></li>
  37. </ul>
  38. </div>
  39. </div>
  40. </div>
  41. <div class="space-y-2">
  42. {% for acl in acls %}
  43. <div class="flex flex-col sm:flex-row items-start justify-between p-4 bg-gradient-to-r from-gray-50 to-white rounded-lg border border-gray-200 hover:border-gray-300 transition-all gap-3">
  44. <div class="flex items-start space-x-3 flex-1 min-w-0 w-full">
  45. <div class="flex flex-col items-center space-y-1 flex-shrink-0">
  46. {% if acl.is_predefined %}
  47. <span class="inline-flex px-2 py-1 text-xs font-bold rounded-full bg-purple-100 text-purple-800 border border-purple-300">
  48. <i class="fas fa-star mr-1"></i>{{ _("BUILT-IN") }}
  49. </span>
  50. {% endif %}
  51. {% if acl.category == 'network' %}
  52. <div class="w-10 h-10 rounded-full bg-blue-100 flex items-center justify-center">
  53. <i class="fas fa-network-wired text-blue-600"></i>
  54. </div>
  55. {% elif acl.category == 'domain' %}
  56. <div class="w-10 h-10 rounded-full bg-green-100 flex items-center justify-center">
  57. <i class="fas fa-globe text-green-600"></i>
  58. </div>
  59. {% elif acl.category == 'time' %}
  60. <div class="w-10 h-10 rounded-full bg-orange-100 flex items-center justify-center">
  61. <i class="fas fa-clock text-orange-600"></i>
  62. </div>
  63. {% elif acl.category == 'url' %}
  64. <div class="w-10 h-10 rounded-full bg-indigo-100 flex items-center justify-center">
  65. <i class="fas fa-link text-indigo-600"></i>
  66. </div>
  67. {% elif acl.category == 'port' %}
  68. <div class="w-10 h-10 rounded-full bg-cyan-100 flex items-center justify-center">
  69. <i class="fas fa-plug text-cyan-600"></i>
  70. </div>
  71. {% elif acl.category == 'protocol' %}
  72. <div class="w-10 h-10 rounded-full bg-teal-100 flex items-center justify-center">
  73. <i class="fas fa-exchange-alt text-teal-600"></i>
  74. </div>
  75. {% elif acl.category == 'auth' %}
  76. <div class="w-10 h-10 rounded-full bg-red-100 flex items-center justify-center">
  77. <i class="fas fa-user-lock text-red-600"></i>
  78. </div>
  79. {% elif acl.category == 'content' %}
  80. <div class="w-10 h-10 rounded-full bg-yellow-100 flex items-center justify-center">
  81. <i class="fas fa-file-alt text-yellow-600"></i>
  82. </div>
  83. {% elif acl.category == 'ssl' %}
  84. <div class="w-10 h-10 rounded-full bg-emerald-100 flex items-center justify-center">
  85. <i class="fas fa-lock text-emerald-600"></i>
  86. </div>
  87. {% elif acl.category == 'connection' %}
  88. <div class="w-10 h-10 rounded-full bg-pink-100 flex items-center justify-center">
  89. <i class="fas fa-server text-pink-600"></i>
  90. </div>
  91. {% else %}
  92. <div class="w-10 h-10 rounded-full bg-gray-100 flex items-center justify-center">
  93. <i class="fas fa-cog text-gray-600"></i>
  94. </div>
  95. {% endif %}
  96. </div>
  97. <div class="flex-1 min-w-0">
  98. <div class="flex items-center gap-2 mb-2">
  99. <h3 class="text-lg font-bold text-gray-800">{{ acl.name }}</h3>
  100. <span class="inline-flex px-2 py-0.5 text-xs font-semibold rounded bg-gray-100 text-gray-700 border border-gray-300">
  101. {{ acl.type }}
  102. </span>
  103. {% if acl.is_slow %}
  104. <span class="inline-flex px-2 py-0.5 text-xs font-semibold rounded bg-orange-100 text-orange-700 border border-orange-300">
  105. <i class="fas fa-hourglass-half mr-1"></i>slow
  106. </span>
  107. {% else %}
  108. <span class="inline-flex px-2 py-0.5 text-xs font-semibold rounded bg-green-100 text-green-700 border border-green-300">
  109. <i class="fas fa-bolt mr-1"></i>fast
  110. </span>
  111. {% endif %}
  112. {% for option in acl.options %}
  113. <span class="inline-flex px-2 py-0.5 text-xs font-mono rounded bg-blue-100 text-blue-700 border border-blue-300">
  114. {{ option }}
  115. </span>
  116. {% endfor %}
  117. </div>
  118. <p class="text-sm text-gray-600 mb-2">
  119. <i class="fas fa-info-circle mr-1"></i>{{ acl.type_description }}
  120. </p>
  121. <div class="bg-gray-50 rounded p-2 border border-gray-200">
  122. <div class="flex flex-wrap gap-1">
  123. {% for value in acl.value_list %}
  124. <span class="inline-flex px-2 py-1 text-xs font-mono rounded bg-white text-gray-700 border border-gray-300">
  125. {{ value }}
  126. </span>
  127. {% endfor %}
  128. </div>
  129. </div>
  130. {% if acl.comment %}
  131. <p class="text-xs text-gray-500 mt-2 italic">
  132. <i class="fas fa-comment-alt mr-1"></i>{{ acl.comment }}
  133. </p>
  134. {% endif %}
  135. </div>
  136. </div>
  137. <div class="flex space-x-2 flex-shrink-0 sm:ml-3">
  138. <button onclick='editAcl({{ acl.id }}, "{{ acl.name }}", "{{ acl.type }}", {{ acl.value_list|tojson }}, {{ acl.options|tojson }}, "{{ acl.comment }}")'
  139. class="text-blue-600 hover:text-blue-900 p-2 hover:bg-blue-100 rounded"
  140. title="{{ _("Editar") }}">
  141. <i class="fas fa-edit text-lg"></i>
  142. </button>
  143. <button onclick='deleteAcl({{ acl.id }}, "{{ acl.name }}")'
  144. class="text-red-600 hover:text-red-900 p-2 hover:bg-red-100 rounded"
  145. title="{{ _("Eliminar") }}">
  146. <i class="fas fa-trash text-lg"></i>
  147. </button>
  148. </div>
  149. </div>
  150. {% endfor %}
  151. </div>
  152. {% else %}
  153. <div class="text-center py-12 bg-gray-50 rounded-lg border-2 border-dashed border-gray-300">
  154. <i class="fas fa-shield-alt text-6xl text-gray-300 mb-4"></i>
  155. <p class="text-gray-500 text-lg font-medium">{{ _("No hay ACLs personalizadas configuradas") }}</p>
  156. <p class="text-gray-400 text-sm mt-2">{{ _("Las ACLs predefinidas de Squid siguen disponibles") }}</p>
  157. <button onclick="showAddModal()" class="mt-4 bg-blue-600 hover:bg-blue-700 text-white font-semibold px-6 py-2 rounded-lg shadow-md transition-colors">
  158. <i class="fas fa-plus mr-2"></i>{{ _("Crear primera ACL") }}
  159. </button>
  160. </div>
  161. {% endif %}
  162. </div>
  163. {% include 'admin/acls_modals.html' %}
  164. <script src="{{ url_for('static', filename='js/acls.js') }}"></script>
  165. {% endblock %}