dashboardAdmin.html 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229
  1. {% extends "admin/base.html" %}
  2. {% block content %}
  3. <div class="space-y-4 sm:space-y-6">
  4. <div class="bg-white rounded-lg shadow-lg p-4 sm:p-6">
  5. <h2 class="text-xl sm:text-2xl font-bold text-gray-800 mb-4 sm:mb-6">{{ _("Dashboard - Resumen del Sistema") }}</h2>
  6. <!-- Stats Cards -->
  7. <div class="grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-4 gap-4 sm:gap-6 mb-6 sm:mb-8">
  8. <!-- ACLs Card -->
  9. <div class="bg-gradient-to-r from-blue-500 to-blue-600 text-white p-6 rounded-lg">
  10. <div class="flex items-center justify-between">
  11. <div>
  12. <p class="text-blue-100">{{ _("Total ACLs") }}</p>
  13. {% if status.errors %}
  14. {% set ns = namespace(shown=False) %}
  15. <div class="space-y-1">
  16. {% for e in status.errors %}
  17. {% if 'ACL' in e or 'acl' in e %}
  18. <div class="bg-red-100 text-red-800 text-sm px-2 py-1 rounded">{{ e }}</div>
  19. {% set ns.shown = True %}
  20. {% endif %}
  21. {% endfor %}
  22. {% if not ns.shown %}
  23. <div class="bg-yellow-100 text-yellow-800 text-sm px-2 py-1 rounded">{{ status.errors[0] }}</div>
  24. {% endif %}
  25. </div>
  26. {% else %}
  27. <p class="text-3xl font-bold">{{ stats.total_acls }}</p>
  28. {% endif %}
  29. </div>
  30. <i class="fas fa-shield-alt text-4xl text-blue-200"></i>
  31. </div>
  32. </div>
  33. <!-- Delay Pools Card -->
  34. <div class="bg-gradient-to-r from-green-500 to-green-600 text-white p-6 rounded-lg">
  35. <div class="flex items-center justify-between">
  36. <div>
  37. <p class="text-green-100">{{ _("Delay Pools") }}</p>
  38. {% if status.errors %}
  39. {% set ns2 = namespace(shown=False) %}
  40. <div class="space-y-1">
  41. {% for e in status.errors %}
  42. {% if 'squid.conf' in e or 'Configuration file' in e or 'read permission' in e or 'write permission' in e or 'read permissions' in e or 'write permissions' in e %}
  43. <div class="bg-red-100 text-red-800 text-sm px-2 py-1 rounded">{{ e }}</div>
  44. {% set ns2.shown = True %}
  45. {% endif %}
  46. {% endfor %}
  47. {% if not ns2.shown %}
  48. <div class="bg-yellow-100 text-yellow-800 text-sm px-2 py-1 rounded">{{ status.errors[0] }}</div>
  49. {% endif %}
  50. </div>
  51. {% else %}
  52. <p class="text-3xl font-bold">{{ stats.total_delay_pools }}</p>
  53. {% endif %}
  54. </div>
  55. <i class="fas fa-tachometer-alt text-4xl text-green-200"></i>
  56. </div>
  57. </div>
  58. <!-- HTTP Rules Card -->
  59. <div class="bg-gradient-to-r from-purple-500 to-purple-600 text-white p-6 rounded-lg">
  60. <div class="flex items-center justify-between">
  61. <div>
  62. <p class="text-purple-100">{{ _("Reglas HTTP") }}</p>
  63. {% if status.errors %}
  64. {% set ns3 = namespace(shown=False) %}
  65. <div class="space-y-1">
  66. {% for e in status.errors %}
  67. {% if 'squid.conf' in e or 'Configuration file' in e or 'read permission' in e or 'write permission' in e or 'not a regular file' in e or 'Expected file named' in e %}
  68. <div class="bg-red-100 text-red-800 text-sm px-2 py-1 rounded">{{ e }}</div>
  69. {% set ns3.shown = True %}
  70. {% endif %}
  71. {% endfor %}
  72. {% if not ns3.shown %}
  73. <div class="bg-yellow-100 text-yellow-800 text-sm px-2 py-1 rounded">{{ status.errors[0] }}</div>
  74. {% endif %}
  75. </div>
  76. {% else %}
  77. <p class="text-3xl font-bold">{{ stats.total_http_rules }}</p>
  78. {% endif %}
  79. </div>
  80. <i class="fas fa-key text-4xl text-purple-200"></i>
  81. </div>
  82. </div>
  83. <!-- SSL Bump Card -->
  84. {% if ssl_bump.enabled %}
  85. <div class="bg-gradient-to-r from-yellow-500 to-orange-500 text-white p-6 rounded-lg">
  86. {% else %}
  87. <div class="bg-gradient-to-r from-gray-400 to-gray-500 text-white p-6 rounded-lg">
  88. {% endif %}
  89. <div class="flex items-center justify-between">
  90. <div>
  91. <p class="{% if ssl_bump.enabled %}text-yellow-100{% else %}text-gray-200{% endif %}">{{ _("SSL Bump") }}</p>
  92. {% if ssl_bump.enabled %}
  93. <p class="text-2xl font-bold">{{ _("Activo") }}</p>
  94. {% if ssl_bump.mode %}
  95. <p class="text-xs mt-1 {% if ssl_bump.enabled %}text-yellow-200{% else %}text-gray-300{% endif %}">{{ ssl_bump.mode }}</p>
  96. {% endif %}
  97. {% else %}
  98. <p class="text-2xl font-bold">{{ _("Inactivo") }}</p>
  99. {% endif %}
  100. </div>
  101. <i class="fas fa-user-secret text-4xl {% if ssl_bump.enabled %}text-yellow-200{% else %}text-gray-300{% endif %}"></i>
  102. </div>
  103. </div>
  104. </div>
  105. <!-- Info cuando todo está en 0 -->
  106. {% if not status.errors and stats.total_acls == 0 and stats.total_delay_pools == 0 and stats.total_http_rules == 0 %}
  107. <div class="bg-yellow-50 border-l-4 border-yellow-400 p-4 sm:p-6 rounded-lg mb-6">
  108. <div class="flex items-start">
  109. <i class="fas fa-exclamation-triangle text-yellow-600 text-2xl mt-1 mr-4"></i>
  110. <div class="flex-1">
  111. <h3 class="text-lg font-semibold text-yellow-900 mb-2">{{ _("No se encontraron configuraciones") }}</h3>
  112. <p class="text-yellow-800 mb-3">{{ _("No se han detectado ACLs, reglas HTTP ni delay pools en tu configuración de Squid.") }}</p>
  113. <div class="bg-white rounded-lg p-4 border border-yellow-200">
  114. <p class="text-sm text-gray-700 mb-2"><strong>{{ _("¿Tu configuración ya está dividida en módulos?") }}</strong></p>
  115. <p class="text-sm text-gray-600 mb-3">{{ _("Si ya tienes tu configuración organizada en archivos separados (por ejemplo: acls.conf, http_access.conf, delay_pools.conf), SquidStats puede leerla directamente sin necesidad de unificarla.") }}</p>
  116. <div class="flex flex-col sm:flex-row gap-2">
  117. <a href="{{ url_for('admin.split_config') }}" class="inline-flex items-center justify-center bg-yellow-500 hover:bg-yellow-600 text-white font-semibold px-4 py-2 rounded-lg transition-colors">
  118. <i class="fas fa-cog mr-2"></i>{{ _("Gestionar Configuración Modular") }}
  119. </a>
  120. <a href="{{ url_for('admin.edit_config') }}" class="inline-flex items-center justify-center bg-blue-500 hover:bg-blue-600 text-white font-semibold px-4 py-2 rounded-lg transition-colors">
  121. <i class="fas fa-edit mr-2"></i>{{ _("Editar squid.conf") }}
  122. </a>
  123. </div>
  124. </div>
  125. </div>
  126. </div>
  127. </div>
  128. {% endif %}
  129. <!-- Quick Actions -->
  130. <div class="bg-gray-50 rounded-lg p-4 sm:p-6">
  131. <h3 class="text-base sm:text-lg font-semibold text-gray-800 mb-4">{{ _("Acciones Rápidas") }}</h3>
  132. <div class="grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-4 gap-4">
  133. {% if status.errors %}
  134. <div class="bg-white p-4 rounded-lg shadow border-l-4 border-blue-300 opacity-60 cursor-not-allowed" title="{{ _("Deshabilitado por errores de configuración") }}">
  135. <i class="fas fa-edit text-blue-300 text-2xl mb-2"></i>
  136. <h4 class="font-semibold text-gray-500">{{ _("Editar Configuración") }}</h4>
  137. <p class="text-sm text-gray-400">{{ _("Modificar archivo squid.conf (deshabilitado)") }}</p>
  138. </div>
  139. <div class="bg-white p-4 rounded-lg shadow border-l-4 border-green-300 opacity-60 cursor-not-allowed" title="{{ _("Deshabilitado por errores de configuración") }}">
  140. <i class="fas fa-plus text-green-300 text-2xl mb-2"></i>
  141. <h4 class="font-semibold text-gray-500">{{ _("Agregar ACL") }}</h4>
  142. <p class="text-sm text-gray-400">{{ _("Crear nueva regla de acceso (deshabilitado)") }}</p>
  143. </div>
  144. {% else %}
  145. <a href="/admin/config/edit" class="bg-white p-4 rounded-lg shadow hover:shadow-md transition-shadow border-l-4 border-blue-500">
  146. <i class="fas fa-edit text-blue-500 text-2xl mb-2"></i>
  147. <h4 class="font-semibold text-gray-800">{{ _("Editar Configuración") }}</h4>
  148. <p class="text-sm text-gray-600">{{ _("Modificar archivo squid.conf") }}</p>
  149. </a>
  150. <a href="/admin/acls" class="bg-white p-4 rounded-lg shadow hover:shadow-md transition-shadow border-l-4 border-green-500">
  151. <i class="fas fa-plus text-green-500 text-2xl mb-2"></i>
  152. <h4 class="font-semibold text-gray-800">{{ _("Agregar ACL") }}</h4>
  153. <p class="text-sm text-gray-600">{{ _("Crear nueva regla de acceso") }}</p>
  154. </a>
  155. {% endif %}
  156. <a href="{{ url_for('admin.view_logs') }}" class="bg-white p-4 rounded-lg shadow hover:shadow-md transition-shadow border-l-4 border-yellow-500">
  157. <i class="fas fa-file-alt text-yellow-500 text-2xl mb-2"></i>
  158. <h4 class="font-semibold text-gray-800">{{ _("Ver Logs") }}</h4>
  159. <p class="text-sm text-gray-600">{{ _("Revisar logs del sistema") }}</p>
  160. </a>
  161. <div class="bg-white p-4 rounded-lg shadow hover:shadow-md transition-shadow border-l-4 border-red-500 cursor-pointer" onclick="restartSquid()">
  162. <i class="fas fa-power-off text-red-500 text-2xl mb-2"></i>
  163. <h4 class="font-semibold text-gray-800">{{ _("Reiniciar Squid") }}</h4>
  164. <p class="text-sm text-gray-600">{{ _("Reiniciar el servicio") }}</p>
  165. </div>
  166. </div>
  167. </div>
  168. <!-- System Status -->
  169. <div class="mt-8 bg-white border rounded-lg p-6">
  170. <h3 class="text-lg font-semibold text-gray-800 mb-4">{{ _("Estado del Sistema") }}</h3>
  171. <div class="space-y-3">
  172. <div class="flex items-center justify-between p-3 bg-green-50 rounded-lg">
  173. <div class="flex items-center">
  174. <i class="fas fa-circle text-green-500 mr-3"></i>
  175. <span class="font-medium">{{ _("Servicio Squid") }}</span>
  176. </div>
  177. <span class="text-green-600 font-semibold">{{ _("Activo") }}</span>
  178. </div>
  179. <div class="flex items-center justify-between p-3 bg-blue-50 rounded-lg">
  180. <div class="flex items-center">
  181. <i class="fas fa-database text-blue-500 mr-3"></i>
  182. <span class="font-medium">{{ _("Configuración") }}</span>
  183. </div>
  184. {% if status.errors %}
  185. <span class="text-red-600 font-semibold">{{ _("No cargada") }}</span>
  186. {% else %}
  187. <span class="text-blue-600 font-semibold">{{ _("Cargada") }}</span>
  188. {% endif %}
  189. </div>
  190. <div class="flex items-center justify-between p-3 {% if ssl_bump.enabled %}bg-yellow-50{% else %}bg-gray-50{% endif %} rounded-lg">
  191. <div class="flex items-center">
  192. <i class="fas fa-user-secret {% if ssl_bump.enabled %}text-yellow-500{% else %}text-gray-400{% endif %} mr-3"></i>
  193. <span class="font-medium">{{ _("SSL Bump (MITM)") }}</span>
  194. </div>
  195. <div class="text-right">
  196. {% if ssl_bump.enabled %}
  197. <span class="text-yellow-600 font-semibold">{{ _("Activo") }}</span>
  198. {% if ssl_bump.mode %}
  199. <span class="ml-2 text-xs bg-yellow-100 text-yellow-800 px-2 py-0.5 rounded-full">{{ ssl_bump.mode }}</span>
  200. {% endif %}
  201. {% if ssl_bump.cert %}
  202. <br><span class="text-xs text-gray-500">{{ _("cert:") }} {{ ssl_bump.cert }}</span>
  203. {% endif %}
  204. {% else %}
  205. <span class="text-gray-500 font-semibold">{{ _("Inactivo") }}</span>
  206. {% endif %}
  207. </div>
  208. </div>
  209. </div>
  210. </div>
  211. </div>
  212. </div>
  213. {% endblock %}