conexiones.html 29 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552
  1. {% from 'macros.html' import format_bandwidth %}
  2. <div class="w-full space-y-6">
  3. {# ── Barra de estado de proxies (solo visible si multi_proxy) ── #}
  4. {% if multi_proxy and proxy_statuses %}
  5. <div class="flex flex-wrap gap-2 items-center bg-white rounded-lg shadow px-4 py-2 border border-gray-100">
  6. <span class="text-xs font-semibold text-gray-500 uppercase tracking-wide mr-2">{{ _("Proxies:") }}</span>
  7. {% for ps in proxy_statuses %}
  8. <span class="inline-flex items-center gap-1.5 px-2.5 py-1 rounded-full text-xs font-semibold
  9. {% if ps.ok %}bg-green-100 text-green-800{% else %}bg-red-100 text-red-700{% endif %}">
  10. <i class="fas {% if ps.ok %}fa-circle-check{% else %}fa-circle-xmark{% endif %} text-[10px]"></i>
  11. {{ ps.label }}
  12. </span>
  13. {% endfor %}
  14. </div>
  15. {% endif %}
  16. {# ── Filtro por proxy (solo si multi_proxy) ── #}
  17. {% if multi_proxy and proxy_statuses %}
  18. <div class="flex flex-wrap gap-2 items-center">
  19. <button type="button"
  20. class="proxy-filter-btn px-3 py-1.5 rounded-full text-xs font-semibold bg-indigo-600 text-white shadow"
  21. data-proxy="all">{{ _("Todos") }}</button>
  22. {% for ps in proxy_statuses %}
  23. {% if ps.ok %}
  24. <button type="button"
  25. class="proxy-filter-btn px-3 py-1.5 rounded-full text-xs font-semibold bg-gray-100 text-gray-700 hover:bg-indigo-100 transition-colors"
  26. data-proxy="{{ ps.label }}">{{ ps.label }}</button>
  27. {% endif %}
  28. {% endfor %}
  29. </div>
  30. <script>
  31. (function(){
  32. document.addEventListener("click", function(e){
  33. const btn = e.target.closest(".proxy-filter-btn");
  34. if(!btn) return;
  35. const chosen = btn.dataset.proxy;
  36. document.querySelectorAll(".proxy-filter-btn").forEach(b=>{
  37. b.classList.toggle("bg-indigo-600", b.dataset.proxy === chosen);
  38. b.classList.toggle("text-white", b.dataset.proxy === chosen);
  39. b.classList.toggle("bg-gray-100", b.dataset.proxy !== chosen);
  40. b.classList.toggle("text-gray-700", b.dataset.proxy !== chosen);
  41. });
  42. document.querySelectorAll(".user-accordion[data-proxy]").forEach(el=>{
  43. el.style.display = (chosen === "all" || el.dataset.proxy === chosen) ? "" : "none";
  44. });
  45. });
  46. })();
  47. </script>
  48. {% endif %}
  49. {# Tarjetas de estadísticas #}
  50. <div class="flex justify-center mb-8">
  51. <div class="grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4 2xl:grid-cols-4 gap-3 w-full">
  52. {# Tarjeta de información del Servidor Squid #}
  53. <div class="bg-white p-3 rounded-lg shadow flex items-center transition-all duration-300 ease-in-out hover:shadow-lg hover:-translate-y-0.5 min-w-0">
  54. <div class="w-10 h-10 rounded-full bg-indigo-100 flex items-center justify-center mr-3 flex-shrink-0">
  55. <i class="fas fa-server text-indigo-500 text-lg"></i>
  56. </div>
  57. <div class="min-w-0 flex-1">
  58. <p class="text-gray-500 text-xs truncate">
  59. {{ _("Servidor Squid:") }}
  60. </p>
  61. <p class="text-lg font-bold truncate" title="{{ squid_version }}">
  62. {{ squid_version }}
  63. </p>
  64. </div>
  65. </div>
  66. {# Tarjeta de Bandwidth Total #}
  67. <div class="bg-white p-3 rounded-lg shadow flex items-center transition-all duration-300 ease-in-out hover:shadow-lg hover:-translate-y-0.5 min-w-0">
  68. <div class="w-10 h-10 rounded-full bg-teal-100 flex items-center justify-center mr-3 flex-shrink-0">
  69. <i class="fas fa-tachometer-alt text-teal-500 text-lg"></i>
  70. </div>
  71. <div class="min-w-0 flex-1">
  72. <p class="text-gray-500 text-xs">{{ _("Total Bandwidth") }}</p>
  73. <p class="text-lg font-bold truncate">
  74. {% set total_bw = namespace(value=0) %}
  75. {% for user_data in valid_users.values() %}
  76. {% for connection in user_data.connections %}
  77. {% if connection.bandwidth_kbps is defined %}
  78. {% set total_bw.value = total_bw.value + (connection.bandwidth_kbps|float) %}
  79. {% endif %}
  80. {% endfor %}
  81. {% endfor %}
  82. {{ format_bandwidth(total_bw.value) }}
  83. </p>
  84. </div>
  85. </div>
  86. {# Tarjeta de Usuarios Activos #}
  87. <div class="bg-white p-3 rounded-lg shadow flex items-center transition-all duration-300 ease-in-out hover:shadow-lg hover:-translate-y-0.5 min-w-0">
  88. <div class="w-10 h-10 rounded-full bg-blue-100 flex items-center justify-center mr-3 flex-shrink-0">
  89. <i class="fas fa-users text-blue-500 text-lg"></i>
  90. </div>
  91. <div class="min-w-0 flex-1">
  92. <p class="text-gray-500 text-xs">{{ _("Usuarios Activos") }}</p>
  93. <p class="text-lg font-bold">{{ valid_users|length }}</p>
  94. </div>
  95. </div>
  96. {# Tarjeta de Conexiones Totales #}
  97. <div class="bg-white p-3 rounded-lg shadow flex items-center transition-all duration-300 ease-in-out hover:shadow-lg hover:-translate-y-0.5 min-w-0">
  98. <div class="w-10 h-10 rounded-full bg-green-100 flex items-center justify-center mr-3 flex-shrink-0">
  99. <i class="fas fa-exchange-alt text-green-500 text-lg"></i>
  100. </div>
  101. <div class="min-w-0 flex-1">
  102. <p class="text-gray-500 text-xs">{{ _("Conexiones Totales") }}</p>
  103. <p class="text-lg font-bold">
  104. {% set total = namespace(value=0) %}
  105. {% for user_data in valid_users.values() %}
  106. {% set total.value = total.value + user_data.connections|length %}
  107. {% endfor %}
  108. {{ total.value }}
  109. </p>
  110. </div>
  111. </div>
  112. {# Tiempo de Actividad de Squid #}
  113. {% if squid_info_stats and squid_info_stats.elapsed_hours %}
  114. <div class="bg-white p-3 rounded-lg shadow flex items-center transition-all duration-300 ease-in-out hover:shadow-lg hover:-translate-y-0.5 min-w-0">
  115. <div class="w-10 h-10 rounded-full bg-purple-100 flex items-center justify-center mr-3 flex-shrink-0">
  116. <i class="fas fa-clock text-purple-500 text-lg"></i>
  117. </div>
  118. <div class="min-w-0 flex-1">
  119. <p class="text-gray-500 text-xs">{{ _("Tiempo Activo") }}</p>
  120. <p class="text-lg font-bold">
  121. {{ squid_info_stats.elapsed_hours }}h
  122. </p>
  123. </div>
  124. </div>
  125. {% endif %}
  126. {# Peticiones HTTP Totales #}
  127. {% if squid_info_stats and squid_info_stats.requests_received %}
  128. <div class="bg-white p-3 rounded-lg shadow flex items-center transition-all duration-300 ease-in-out hover:shadow-lg hover:-translate-y-0.5 min-w-0">
  129. <div class="w-10 h-10 rounded-full bg-red-100 flex items-center justify-center mr-3 flex-shrink-0">
  130. <i class="fas fa-globe text-red-500 text-lg"></i>
  131. </div>
  132. <div class="min-w-0 flex-1">
  133. <p class="text-gray-500 text-xs">{{ _("Peticiones HTTP") }}</p>
  134. <p class="text-lg font-bold">
  135. {{ squid_info_stats.requests_received | int }}
  136. </p>
  137. </div>
  138. </div>
  139. {% endif %}
  140. {# Promedio de Peticiones por Minuto #}
  141. {% if squid_info_stats and squid_info_stats.avg_requests_per_minute %}
  142. <div class="bg-white p-3 rounded-lg shadow flex items-center transition-all duration-300 ease-in-out hover:shadow-lg hover:-translate-y-0.5 min-w-0">
  143. <div class="w-10 h-10 rounded-full bg-teal-100 flex items-center justify-center mr-3 flex-shrink-0">
  144. <i class="fas fa-chart-line text-teal-500 text-lg"></i>
  145. </div>
  146. <div class="min-w-0 flex-1">
  147. <p class="text-gray-500 text-xs">{{ _("Peticiones/Min") }}</p>
  148. <p class="text-lg font-bold">
  149. {{ squid_info_stats.avg_requests_per_minute|round(1) }}
  150. </p>
  151. </div>
  152. </div>
  153. {% endif %}
  154. {# Estado de Conexión de Squid (oculto en modo multi-proxy, que ya muestra estado por proxy) #}
  155. {% if squid_info_stats and not multi_proxy %}
  156. <div class="bg-white p-3 rounded-lg shadow flex items-center transition-all duration-300 ease-in-out hover:shadow-lg hover:-translate-y-0.5 min-w-0">
  157. <div class="w-10 h-10 rounded-full {% if squid_info_stats.connection_status == 'connected' %}bg-green-100{% else %}bg-red-100{% endif %} flex items-center justify-center mr-3 flex-shrink-0">
  158. <i class="fas {% if squid_info_stats.connection_status == 'connected' %}fa-check-circle text-green-500{% else %}fa-exclamation-triangle text-red-500{% endif %} text-lg"></i>
  159. </div>
  160. <div class="min-w-0 flex-1">
  161. <p class="text-gray-500 text-xs">{{ _("Estado Squid") }}</p>
  162. <p class="text-sm font-bold {% if squid_info_stats.connection_status == 'connected' %}text-green-600{% else %}text-red-600{% endif %} truncate">
  163. {% if squid_info_stats.connection_status == 'connected' %}{{ _("Conectado") }}
  164. {% elif squid_info_stats.connection_status == 'connected_but_parse_error' %}{{ _("Error Parsing") }}
  165. {% elif squid_info_stats.connection_status == 'timeout' %}{{ _("Timeout") }}
  166. {% elif squid_info_stats.connection_status == 'connection_refused' %}{{ _("Rechazado") }}
  167. {% elif squid_info_stats.connection_status == 'dns_error' %}{{ _("Error DNS") }}
  168. {% else %}{{ _("Error") }}
  169. {% endif %}
  170. </p>
  171. </div>
  172. </div>
  173. {% endif %}
  174. {# Tarjeta de Tipo de Sistema #}
  175. <div class="bg-white p-3 rounded-lg shadow flex items-center transition-all duration-300 ease-in-out hover:shadow-lg hover:-translate-y-0.5 min-w-0">
  176. <div class="w-10 h-10 rounded-full bg-orange-100 flex items-center justify-center mr-3 flex-shrink-0">
  177. <i class="fas fa-desktop text-orange-500 text-lg"></i>
  178. </div>
  179. <div class="min-w-0 flex-1">
  180. <p class="text-gray-500 text-xs">{{ _("Tipo de Sistema") }}</p>
  181. <p class="text-lg font-bold truncate" title="{{ system_type }}">
  182. {{ system_type }}
  183. </p>
  184. </div>
  185. </div>
  186. </div>
  187. </div>
  188. {# El resto del código permanece igual #}
  189. {% if valid_users|length > 0 %}
  190. <div class="flex justify-end mb-4">
  191. <button id="toggle-all-button" class="bg-blue-500 hover:bg-blue-600 text-white font-bold py-2 px-4 rounded-lg transition-colors duration-300">
  192. {{ _("Ver Resumen") }}
  193. </button>
  194. </div>
  195. {% endif %}
  196. <div id="user-accordion-group">
  197. {% for user, user_data in valid_users.items() %}
  198. {% set connections = user_data.connections %}
  199. {% set client_ip = user_data.client_ip %}
  200. {# Determine the proxy label for this user (from first connection) #}
  201. {% set user_proxy = connections[0].proxy_host if connections and connections[0].proxy_host is defined else '' %}
  202. <div class="user-accordion bg-white rounded-lg shadow-md mb-3" {% if user_proxy %}data-proxy="{{ user_proxy }}"{% endif %}>
  203. <div class="w-full text-left p-4 border-b bg-white rounded-t-lg" id="header-{{ loop.index }}">
  204. <div class="flex flex-col sm:flex-row sm:items-center sm:justify-between">
  205. <div class="flex items-center mb-3 sm:mb-0">
  206. <div class="w-10 h-10 rounded-full bg-blue-100 flex items-center justify-center mr-3 flex-shrink-0">
  207. <i class="fas fa-user text-blue-600"></i>
  208. </div>
  209. <div class="min-w-0">
  210. <h2 class="text-lg font-bold text-gray-800 truncate" title="{{ user }}">{{ user }}</h2>
  211. {% if multi_proxy and user_proxy %}
  212. <span class="inline-flex items-center gap-1 mt-0.5 px-2 py-0.5 rounded-full text-[10px] font-semibold bg-indigo-100 text-indigo-700">
  213. <i class="fas fa-network-wired text-[9px]"></i> {{ user_proxy }}
  214. </span>
  215. {% endif %}
  216. </div>
  217. </div>
  218. <div class="flex flex-wrap items-center gap-x-4 gap-y-2">
  219. <div class="flex items-center text-sm text-gray-600" title="{{ _("IP del Cliente") }}">
  220. <i class="fas fa-network-wired mr-1.5 text-gray-500"></i>
  221. <span class="truncate max-w-[120px]">{{ client_ip }}</span>
  222. </div>
  223. <div class="flex items-center text-sm text-gray-600" title="{{ _("Conexiones totales de este usuario") }}">
  224. <i class="fas fa-link mr-1.5 text-blue-500"></i>
  225. <span>{{ connections|length }} conexiones</span>
  226. </div>
  227. {% set user_bw = namespace(value=0) %}
  228. {% for connection in connections %}
  229. {% if connection.bandwidth_kbps is defined %}
  230. {% set user_bw.value = user_bw.value + (connection.bandwidth_kbps|float) %}
  231. {% endif %}
  232. {% endfor %}
  233. <div class="flex items-center text-sm text-gray-600" title="{{ _("Total de velocidad del usuario") }}">
  234. <i class="fas fa-tachometer-alt mr-1.5 text-teal-500"></i>
  235. <span class="truncate max-w-[100px]">
  236. {{ format_bandwidth(user_bw.value) }}
  237. </span>
  238. </div>
  239. {% set total_data = namespace(value=0) %}
  240. {% set total_requests = namespace(value=0) %}
  241. {% for connection in connections %}
  242. {% if connection.fd_total != "N/A" %}
  243. {% set total_data.value = total_data.value + connection.fd_total %}
  244. {% endif %}
  245. {% set total_requests.value = total_requests.value + connection.nrequests %}
  246. {% endfor %}
  247. <div class="hidden md:flex items-center text-sm text-gray-600" title="{{ _("Total de datos transferidos") }}">
  248. <i class="fas fa-database mr-1.5 text-green-500"></i>
  249. <span>{{ (total_data.value / 1024 / 1024)|round(2) }} {{ _("MB") }}</span>
  250. </div>
  251. <div class="hidden lg:flex items-center text-sm text-gray-600" title="{{ _("Total de solicitudes") }}">
  252. <i class="fas fa-bullhorn mr-1.5 text-purple-500"></i>
  253. <span>{{ total_requests.value }} solicitudes</span>
  254. </div>
  255. <div class="relative">
  256. <button type="button" data-actions-toggle="{{ loop.index }}" class="inline-flex items-center px-3 py-1.5 rounded-full bg-slate-100 text-slate-700 text-sm font-semibold border border-slate-200 hover:bg-slate-200 transition-colors duration-200">
  257. {{ _("Acciones") }}
  258. <span class="ml-2 rounded-full bg-indigo-100 text-indigo-700 text-[10px] font-semibold uppercase px-2 py-0.5">{{ _("Beta") }}</span>
  259. <i class="fas fa-chevron-down ml-2 text-xs"></i>
  260. </button>
  261. <div data-actions-menu="{{ loop.index }}" class="hidden absolute right-0 mt-2 w-52 bg-white border border-gray-200 rounded-xl shadow-lg z-20 overflow-hidden py-1">
  262. <div class="px-3 py-1.5 text-xs font-semibold text-gray-400 uppercase tracking-wide border-b border-gray-100">{{ _("Acciones") }}
  263. <span class="ml-1 rounded-full bg-indigo-100 text-indigo-700 text-[10px] font-semibold uppercase px-2 py-0.5">{{ _("Beta") }}</span>
  264. </div>
  265. <button type="button"
  266. data-action="throttle" data-user="{{ user }}" data-ip="{{ client_ip }}"
  267. class="w-full text-left flex items-center gap-2 px-4 py-2 text-sm text-amber-700 hover:bg-amber-50 transition-colors duration-150">
  268. <i class="fas fa-tachometer-alt text-amber-500 w-4"></i> {{ _("Reducir velocidad") }}
  269. </button>
  270. <button type="button"
  271. data-action="unthrottle" data-user="{{ user }}" data-ip="{{ client_ip }}"
  272. class="w-full text-left flex items-center gap-2 px-4 py-2 text-sm text-green-700 hover:bg-green-50 transition-colors duration-150">
  273. <i class="fas fa-gauge-high text-green-500 w-4"></i> {{ _("Restaurar velocidad") }}
  274. </button>
  275. <div class="border-t border-gray-100 my-1"></div>
  276. <button type="button"
  277. data-action="block" data-user="{{ user }}" data-ip="{{ client_ip }}"
  278. class="w-full text-left flex items-center gap-2 px-4 py-2 text-sm text-red-700 hover:bg-red-50 transition-colors duration-150">
  279. <i class="fas fa-ban text-red-500 w-4"></i> {{ _("Bloquear") }}
  280. </button>
  281. <button type="button"
  282. data-action="unblock" data-user="{{ user }}" data-ip="{{ client_ip }}"
  283. class="w-full text-left flex items-center gap-2 px-4 py-2 text-sm text-blue-700 hover:bg-blue-50 transition-colors duration-150">
  284. <i class="fas fa-circle-check text-blue-500 w-4"></i> {{ _("Desbloquear") }}
  285. </button>
  286. <div class="border-t border-gray-100 my-1"></div>
  287. <button type="button"
  288. data-action="reset" data-user="{{ user }}" data-ip="{{ client_ip }}"
  289. class="w-full text-left flex items-center gap-2 px-4 py-2 text-sm text-orange-700 hover:bg-orange-50 transition-colors duration-150">
  290. <i class="fas fa-rotate text-orange-500 w-4"></i> {{ _("Resetear conexiones") }}
  291. </button>
  292. </div>
  293. </div>
  294. <button type="button" data-accordion-btn="{{ loop.index }}" class="w-6 text-center cursor-pointer">
  295. <i class="fas fa-chevron-down transition-transform duration-300 rotate-180" id="icon-{{ loop.index }}"></i>
  296. </button>
  297. </div>
  298. </div>
  299. </div>
  300. <div data-accordion-content data-user='{{ user|tojson }}' id="content-{{ loop.index }}" class="rounded-b-lg overflow-hidden">
  301. <div class="overflow-x-auto">
  302. <table class="min-w-full divide-y divide-gray-200">
  303. <thead class="bg-gray-50">
  304. <tr>
  305. <th class="px-4 py-2 text-left text-xs font-medium text-gray-500 uppercase">
  306. {{ _("Duración") }}
  307. </th>
  308. <th class="px-4 py-2 text-left text-xs font-medium text-gray-500 uppercase">
  309. {{ _("Método") }}
  310. </th>
  311. <th class="px-4 py-2 text-left text-xs font-medium text-gray-500 uppercase">
  312. {{ _("URL") }}
  313. </th>
  314. <th class="px-4 py-2 text-left text-xs font-medium text-gray-500 uppercase">
  315. {{ _("Datos") }}
  316. </th>
  317. <th class="px-4 py-2 text-left text-xs font-medium text-gray-500 uppercase">
  318. {{ _("Velocidad") }}
  319. </th>
  320. <th class="px-4 py-2 text-left text-xs font-medium text-gray-500 uppercase">
  321. {{ _("Delay Pool") }}
  322. </th>
  323. <th class="px-4 py-2 text-left text-xs font-medium text-gray-500 uppercase">
  324. {{ _("Solicitudes") }}
  325. </th>
  326. <th class="px-4 py-2 text-left text-xs font-medium text-gray-500 uppercase">
  327. {{ _("Dir. Remota") }}
  328. </th>
  329. {% if multi_proxy %}
  330. <th class="px-4 py-2 text-left text-xs font-medium text-gray-500 uppercase">
  331. {{ _("Proxy") }}
  332. </th>
  333. {% endif %}
  334. </tr>
  335. </thead>
  336. <tbody class="divide-y divide-gray-200">
  337. {% for connection in connections %}
  338. <tr class="transition-colors duration-200 ease-in-out hover:bg-gray-50">
  339. <td class="px-4 py-3 whitespace-nowrap text-sm text-gray-500">
  340. {% set seconds = connection.elapsed_time|float %}
  341. {% if seconds >= 3600 %}{{ "%.2f"|format(seconds/3600) }} h
  342. {% elif seconds >= 60 %}{{ "%.2f"|format(seconds/60) }} min {% else %}
  343. {{ "%.2f"|format(seconds) }} seg
  344. {% endif %}
  345. </td>
  346. <td class="px-4 py-3 whitespace-nowrap">
  347. {% set method = connection.logType|lower %}
  348. <span class="px-2 py-1 rounded-full text-xs font-semibold ... {% if method == 'connect' or method == 'tcp_tunnel' %}bg-green-100 text-green-800 ... {% endif %}">
  349. {{ connection.logType }}
  350. </span>
  351. </td>
  352. <td class="px-4 py-3 max-w-xs">
  353. <div class="truncate text-sm transition-colors duration-200 hover:text-blue-600"
  354. title="{{ connection.uri }}">
  355. {{ connection.uri }}
  356. </div>
  357. </td>
  358. <td class="px-4 py-3 whitespace-nowrap text-sm">
  359. {% if connection.fd_total != "N/A" %}
  360. {{ (connection.fd_total / 1024 / 1024)|round(2) }} {{ _("MB") }}
  361. {% else %}{{ _("N/A") }}
  362. {% endif %}
  363. </td>
  364. <td class="px-4 py-3 whitespace-nowrap text-sm">
  365. {{ format_bandwidth(connection.bandwidth_kbps) }}
  366. </td>
  367. <td class="px-4 py-3 whitespace-nowrap">
  368. {% if connection.delay_pool != "N/A" %}
  369. {% set pool = connection.delay_pool|string %}
  370. <span class="px-2 py-1 rounded-full text-xs font-semibold ... {% if pool == '0' %}bg-sky-100 text-sky-800 ... {% endif %}">
  371. {{ _("Pool") }} {{ connection.delay_pool }}
  372. </span>
  373. {% endif %}
  374. </td>
  375. <td class="px-4 py-3 whitespace-nowrap text-sm font-medium">
  376. {{ connection.nrequests }}
  377. </td>
  378. <td class="px-4 py-3 whitespace-nowrap text-sm font-mono ... hover:text-blue-600">
  379. {{ connection.proxy_local_ip }}
  380. </td>
  381. {% if multi_proxy %}
  382. <td class="px-4 py-3 whitespace-nowrap">
  383. <span class="px-2 py-1 rounded-full text-[10px] font-semibold bg-indigo-100 text-indigo-700">
  384. {{ connection.proxy_host if connection.proxy_host is defined else '—' }}
  385. </span>
  386. </td>
  387. {% endif %}
  388. </tr>
  389. {% endfor %}
  390. </tbody>
  391. </table>
  392. </div>
  393. </div>
  394. </div>
  395. {% endfor %}
  396. </div>
  397. </div>
  398. <!-- ============================================================
  399. MODALES DE ACCIONES
  400. ============================================================ -->
  401. <!-- Modal: Resetear conexiones -->
  402. <div id="modal-reset" class="hidden fixed inset-0 z-50 flex items-center justify-center p-4 bg-black/40 backdrop-blur-sm">
  403. <div class="bg-white rounded-2xl shadow-2xl w-full max-w-md p-6">
  404. <div class="flex items-center gap-3 mb-4">
  405. <div class="w-10 h-10 rounded-full bg-orange-100 flex items-center justify-center flex-shrink-0">
  406. <i class="fas fa-rotate text-orange-500"></i>
  407. </div>
  408. <div>
  409. <h3 class="text-lg font-bold text-gray-800">{{ _("Resetear conexiones") }}</h3>
  410. <p id="modal-reset-subtitle" class="text-sm text-gray-500"></p>
  411. </div>
  412. </div>
  413. <p class="text-sm text-gray-600 mb-6">{{ _("Se cerrarán los estados de red activos asociados a esta IP. Las nuevas conexiones podrán establecerse inmediatamente.") }}</p>
  414. <div class="flex justify-end gap-3">
  415. <button type="button" data-modal-cancel class="px-4 py-2 rounded-lg border border-gray-200 text-gray-600 text-sm hover:bg-gray-50 transition-colors">{{ _("Cancelar") }}</button>
  416. <button type="button" data-modal-confirm="reset" class="px-4 py-2 rounded-lg bg-orange-500 hover:bg-orange-600 text-white text-sm font-semibold transition-colors">
  417. <i class="fas fa-rotate mr-1.5"></i> {{ _("Resetear") }}
  418. </button>
  419. </div>
  420. </div>
  421. </div>
  422. <!-- Modal: Bloquear usuario -->
  423. <div id="modal-block" class="hidden fixed inset-0 z-50 flex items-center justify-center p-4 bg-black/40 backdrop-blur-sm">
  424. <div class="bg-white rounded-2xl shadow-2xl w-full max-w-md p-6 animate-fade-in">
  425. <div class="flex items-center gap-3 mb-4">
  426. <div class="w-10 h-10 rounded-full bg-red-100 flex items-center justify-center flex-shrink-0">
  427. <i class="fas fa-ban text-red-500"></i>
  428. </div>
  429. <div>
  430. <h3 class="text-lg font-bold text-gray-800">{{ _("Bloquear usuario") }}</h3>
  431. <p id="modal-block-subtitle" class="text-sm text-gray-500"></p>
  432. </div>
  433. </div>
  434. <p class="text-sm text-gray-600 mb-6">
  435. {{ _("Esta acción bloqueará todo el tráfico del usuario. Se añadirá") }}
  436. <code class="bg-gray-100 px-1 rounded text-xs">{{ _("http_access deny") }}</code>
  437. {{ _("en Squid y se guardará en la base de datos para persistencia.") }}
  438. </p>
  439. <div class="flex justify-end gap-3">
  440. <button type="button" data-modal-cancel class="px-4 py-2 rounded-lg border border-gray-200 text-gray-600 text-sm hover:bg-gray-50 transition-colors">{{ _("Cancelar") }}</button>
  441. <button type="button" data-modal-confirm="block" class="px-4 py-2 rounded-lg bg-red-500 hover:bg-red-600 text-white text-sm font-semibold transition-colors">
  442. <i class="fas fa-ban mr-1.5"></i> {{ _("Confirmar bloqueo") }}
  443. </button>
  444. </div>
  445. </div>
  446. </div>
  447. <!-- Modal: Desbloquear usuario -->
  448. <div id="modal-unblock" class="hidden fixed inset-0 z-50 flex items-center justify-center p-4 bg-black/40 backdrop-blur-sm">
  449. <div class="bg-white rounded-2xl shadow-2xl w-full max-w-md p-6">
  450. <div class="flex items-center gap-3 mb-4">
  451. <div class="w-10 h-10 rounded-full bg-blue-100 flex items-center justify-center flex-shrink-0">
  452. <i class="fas fa-circle-check text-blue-500"></i>
  453. </div>
  454. <div>
  455. <h3 class="text-lg font-bold text-gray-800">{{ _("Desbloquear usuario") }}</h3>
  456. <p id="modal-unblock-subtitle" class="text-sm text-gray-500"></p>
  457. </div>
  458. </div>
  459. <p class="text-sm text-gray-600 mb-6">{{ _("Se eliminará el bloqueo activo para esta IP y se recargará la configuración de Squid.") }}</p>
  460. <div class="flex justify-end gap-3">
  461. <button type="button" data-modal-cancel class="px-4 py-2 rounded-lg border border-gray-200 text-gray-600 text-sm hover:bg-gray-50 transition-colors">{{ _("Cancelar") }}</button>
  462. <button type="button" data-modal-confirm="unblock" class="px-4 py-2 rounded-lg bg-blue-500 hover:bg-blue-600 text-white text-sm font-semibold transition-colors">
  463. <i class="fas fa-circle-check mr-1.5"></i> {{ _("Confirmar") }}
  464. </button>
  465. </div>
  466. </div>
  467. </div>
  468. <!-- Modal: Reducir velocidad -->
  469. <div id="modal-throttle" class="hidden fixed inset-0 z-50 flex items-center justify-center p-4 bg-black/40 backdrop-blur-sm">
  470. <div class="bg-white rounded-2xl shadow-2xl w-full max-w-md p-6">
  471. <div class="flex items-center gap-3 mb-4">
  472. <div class="w-10 h-10 rounded-full bg-amber-100 flex items-center justify-center flex-shrink-0">
  473. <i class="fas fa-tachometer-alt text-amber-500"></i>
  474. </div>
  475. <div>
  476. <h3 class="text-lg font-bold text-gray-800">{{ _("Reducir velocidad") }}</h3>
  477. <p id="modal-throttle-subtitle" class="text-sm text-gray-500"></p>
  478. </div>
  479. </div>
  480. <p class="text-sm text-gray-600 mb-4">
  481. {{ _("Asigna la IP del usuario a un") }} <strong>{{ _("delay pool") }}</strong> {{ _("existente. Sus conexiones estarán sujetas a los límites de ancho de banda configurados en ese pool.") }}
  482. </p>
  483. <label class="block text-sm font-medium text-gray-700 mb-1">{{ _("Selecciona el delay pool") }}</label>
  484. <select id="throttle-pool-select" class="w-full border border-gray-200 rounded-lg px-3 py-2 text-sm text-gray-700 focus:outline-none focus:ring-2 focus:ring-amber-300 mb-6">
  485. <option value="">{{ _("Cargando pools...") }}</option>
  486. </select>
  487. <div class="flex justify-end gap-3">
  488. <button type="button" data-modal-cancel class="px-4 py-2 rounded-lg border border-gray-200 text-gray-600 text-sm hover:bg-gray-50 transition-colors">{{ _("Cancelar") }}</button>
  489. <button type="button" data-modal-confirm="throttle" class="px-4 py-2 rounded-lg bg-amber-500 hover:bg-amber-600 text-white text-sm font-semibold transition-colors">
  490. <i class="fas fa-tachometer-alt mr-1.5"></i> {{ _("Aplicar") }}
  491. </button>
  492. </div>
  493. </div>
  494. </div>
  495. <!-- Modal: Restaurar velocidad -->
  496. <div id="modal-unthrottle" class="hidden fixed inset-0 z-50 flex items-center justify-center p-4 bg-black/40 backdrop-blur-sm">
  497. <div class="bg-white rounded-2xl shadow-2xl w-full max-w-md p-6">
  498. <div class="flex items-center gap-3 mb-4">
  499. <div class="w-10 h-10 rounded-full bg-green-100 flex items-center justify-center flex-shrink-0">
  500. <i class="fas fa-gauge-high text-green-500"></i>
  501. </div>
  502. <div>
  503. <h3 class="text-lg font-bold text-gray-800">{{ _("Restaurar velocidad") }}</h3>
  504. <p id="modal-unthrottle-subtitle" class="text-sm text-gray-500"></p>
  505. </div>
  506. </div>
  507. <p class="text-sm text-gray-600 mb-6">{{ _("Se eliminará la restricción de velocidad activa para esta IP y se recargará la configuración de Squid.") }}</p>
  508. <div class="flex justify-end gap-3">
  509. <button type="button" data-modal-cancel class="px-4 py-2 rounded-lg border border-gray-200 text-gray-600 text-sm hover:bg-gray-50 transition-colors">{{ _("Cancelar") }}</button>
  510. <button type="button" data-modal-confirm="unthrottle" class="px-4 py-2 rounded-lg bg-green-500 hover:bg-green-600 text-white text-sm font-semibold transition-colors">
  511. <i class="fas fa-gauge-high mr-1.5"></i> {{ _("Confirmar") }}
  512. </button>
  513. </div>
  514. </div>
  515. </div>
  516. <!-- Toast de notificación -->
  517. <div id="action-toast"
  518. class="hidden fixed top-20 right-6 z-50 flex items-center gap-3 px-4 py-3 rounded-xl shadow-lg text-sm font-medium transition-all duration-300 max-w-sm">
  519. <i id="action-toast-icon" class="text-lg"></i>
  520. <span id="action-toast-message"></span>
  521. </div>