blacklist.html 27 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478
  1. {% extends "admin/base.html" %}
  2. {% block content %}
  3. {% include 'components/confirm_modal.html' %}
  4. {% include 'components/loading_spinner.html' %}
  5. <div x-data="{ activeTab: 'pihole' }" class="bg-white rounded-lg shadow-lg p-4 sm:p-6">
  6. <h2 class="text-xl sm:text-2xl font-bold text-gray-800 mb-4 sm:mb-6">{{ _("Blacklist - Gestor de Listas") }}</h2>
  7. <!-- Tabs -->
  8. <div class="flex border-b border-gray-200 flex-wrap">
  9. <button @click="activeTab = 'pihole'" :class="activeTab === 'pihole' ? 'border-blue-500 text-blue-600' : 'border-transparent text-gray-500'" class="py-2 px-4 border-b-2 font-medium text-sm whitespace-nowrap">
  10. {{ _("Pi-hole") }}
  11. </button>
  12. <button @click="activeTab = 'adguard'" :class="activeTab === 'adguard' ? 'border-blue-500 text-blue-600' : 'border-transparent text-gray-500'" class="py-2 px-4 border-b-2 font-medium text-sm whitespace-nowrap">
  13. {{ _("AdGuard") }}
  14. </button>
  15. <button @click="activeTab = 'dnsmasq'" :class="activeTab === 'dnsmasq' ? 'border-blue-500 text-blue-600' : 'border-transparent text-gray-500'" class="py-2 px-4 border-b-2 font-medium text-sm whitespace-nowrap">
  16. {{ _("DNSmasq") }}
  17. </button>
  18. <button @click="activeTab = 'custom'" :class="activeTab === 'custom' ? 'border-blue-500 text-blue-600' : 'border-transparent text-gray-500'" class="py-2 px-4 border-b-2 font-medium text-sm whitespace-nowrap">
  19. {{ _("Personalizada") }}
  20. </button>
  21. <button @click="activeTab = 'blocked_users'" :class="activeTab === 'blocked_users' ? 'border-blue-500 text-blue-600' : 'border-transparent text-gray-500'" class="py-2 px-4 border-b-2 font-medium text-sm whitespace-nowrap">
  22. {{ _("IPs bloqueadas") }}
  23. </button>
  24. <button @click="activeTab = 'import'" :class="activeTab === 'import' ? 'border-blue-500 text-blue-600' : 'border-transparent text-gray-500'" class="py-2 px-4 border-b-2 font-medium text-sm whitespace-nowrap">
  25. {{ _("Importar") }}
  26. </button>
  27. </div>
  28. <!-- Pi-hole Tab -->
  29. <div x-show="activeTab === 'pihole'" class="mt-6">
  30. <h3 class="text-lg font-semibold mb-3 flex items-center gap-2">
  31. {{ _("Integración Pi-hole") }}
  32. <span class="inline-block bg-yellow-200 text-yellow-800 text-xs font-bold px-2 py-0.5 rounded align-middle border border-yellow-300 shadow-sm animate-pulse" title="{{ _("Funcionalidad en Beta") }}">{{ _("BETA") }}</span>
  33. </h3>
  34. <p class="text-sm text-gray-600 mb-4">{{ _("Conecta y sincroniza listas bloqueadas desde un servidor Pi-hole. Aquí puedes configurar conexión y ver el estado.") }}</p>
  35. <form method="POST" action="/admin/blacklist/test-connection" class="grid grid-cols-1 md:grid-cols-2 gap-4">
  36. <input type="hidden" name="csrf_token" value="{{ csrf_token() }}"/>
  37. <div class="bg-gray-50 p-4 rounded border">
  38. <label class="text-sm font-medium text-gray-700">{{ _("Pi-hole Host") }}</label>
  39. <input name="host" type="text" class="w-full mt-2 p-2 border rounded" placeholder="{{ _("192.168.1.2 or example.com") }}" />
  40. </div>
  41. <div class="bg-gray-50 p-4 rounded border">
  42. <label class="text-sm font-medium text-gray-700">{{ _("API Token") }}</label>
  43. <input name="token" type="password" class="w-full mt-2 p-2 border rounded" placeholder="{{ _("Token (opcional)") }}" />
  44. </div>
  45. <div class="md:col-span-2 mt-4 flex gap-2">
  46. <button type="submit" class="bg-blue-500 hover:bg-blue-600 text-white px-4 py-2 rounded">{{ _("Probar Conexión") }}</button>
  47. </form>
  48. <form method="POST" action="/admin/blacklist/sync" class="mt-0">
  49. <input type="hidden" name="csrf_token" value="{{ csrf_token() }}"/>
  50. <button type="submit" class="bg-green-500 hover:bg-green-600 text-white px-4 py-2 rounded">{{ _("Sincronizar Listas") }}</button>
  51. </form>
  52. </div>
  53. </div>
  54. <!-- Blocked IPs Tab -->
  55. <div x-show="activeTab === 'blocked_users'" class="mt-6">
  56. <h3 class="text-lg font-semibold mb-3">{{ _("IPs bloqueadas") }}</h3>
  57. <p class="text-sm text-gray-600 mb-4">{{ _("Lista de IPs que actualmente están bloqueadas en la base de datos.") }}</p>
  58. {% if blocked_users %}
  59. <div class="overflow-x-auto bg-white rounded shadow border" id="blocked-users-table-container">
  60. <table id="blocked-users-table" class="min-w-full text-left text-sm text-gray-700">
  61. <thead class="bg-gray-50 text-xs uppercase text-gray-500">
  62. <tr>
  63. <th class="px-4 py-3">{{ _("Usuario") }}</th>
  64. <th class="px-4 py-3">{{ _("IP") }}</th>
  65. <th class="px-4 py-3">{{ _("Notas") }}</th>
  66. <th class="px-4 py-3">{{ _("Estado") }}</th>
  67. <th class="px-4 py-3">{{ _("Creado") }}</th>
  68. <th class="px-4 py-3">{{ _("Acciones") }}</th>
  69. </tr>
  70. </thead>
  71. <tbody>
  72. {% for user in blocked_users %}
  73. <tr class="border-t last:border-b">
  74. <td class="px-4 py-3">{{ user.username }}</td>
  75. <td class="px-4 py-3 font-mono text-sm text-gray-800">{{ user.ip }}</td>
  76. <td class="px-4 py-3">{{ user.notes or '-' }}</td>
  77. <td class="px-4 py-3">
  78. {% if user.active %}
  79. <span class="inline-flex items-center rounded-full bg-emerald-100 px-2 py-1 text-xs font-semibold text-emerald-700">{{ _("Activo") }}</span>
  80. {% else %}
  81. <span class="inline-flex items-center rounded-full bg-gray-100 px-2 py-1 text-xs font-semibold text-gray-600">{{ _("Inactivo") }}</span>
  82. {% endif %}
  83. </td>
  84. <td class="px-4 py-3">{{ user.created_at.strftime('%Y-%m-%d %H:%M') }}</td>
  85. <td class="px-4 py-3">
  86. <form method="POST" action="/admin/blacklist/delete-blocked-user" class="delete-blocked-user-form inline">
  87. <input type="hidden" name="csrf_token" value="{{ csrf_token() }}"/>
  88. <input type="hidden" name="blocked_user_id" value="{{ user.id }}" />
  89. <input type="hidden" name="username" value="{{ user.username }}" />
  90. <button type="submit" class="bg-red-500 hover:bg-red-600 text-white px-3 py-1.5 rounded text-sm">{{ _("Eliminar") }}</button>
  91. </form>
  92. </td>
  93. </tr>
  94. {% endfor %}
  95. </tbody>
  96. </table>
  97. </div>
  98. {% else %}
  99. <div class="bg-gray-50 p-4 rounded border text-sm text-gray-600">
  100. {{ _("No hay IPs bloqueadas en la base de datos.") }}
  101. </div>
  102. {% endif %}
  103. </div>
  104. <!-- AdGuard Tab -->
  105. <div x-show="activeTab === 'adguard'" class="mt-6">
  106. <h3 class="text-lg font-semibold mb-3">{{ _("Integración AdGuard") }}</h3>
  107. <p class="text-sm text-gray-600 mb-4">{{ _("Soporte para fuentes y listas públicas compatibles con AdGuard.") }}</p>
  108. <form id="importUrlForm" method="POST" action="/admin/blacklist/import" class="bg-gray-50 p-4 rounded border">
  109. <input type="hidden" name="csrf_token" value="{{ csrf_token() }}"/>
  110. <label class="text-sm font-medium text-gray-700">{{ _("URL de la lista") }}</label>
  111. <input name="url" type="text" class="w-full mt-2 p-2 border rounded" placeholder="https://example.com/list.txt" />
  112. <div class="mt-3">
  113. <button type="submit" class="bg-green-500 hover:bg-green-600 text-white px-4 py-2 rounded">{{ _("Agregar Lista") }}</button>
  114. </div>
  115. </form>
  116. {% if url_lists %}
  117. <div class="mt-6">
  118. <h4 class="text-md font-semibold mb-2 text-gray-700">{{ _("Listas importadas") }}</h4>
  119. <ul class="divide-y divide-gray-200 bg-white rounded shadow">
  120. {% for item in url_lists %}
  121. <li class="flex items-center justify-between px-4 py-3 hover:bg-gray-50 gap-3" x-data="{ enforced: {{ 'true' if item.enforced else 'false' }}, loading: false }">
  122. <div class="flex flex-col min-w-0 flex-1">
  123. <span class="font-mono text-blue-700 text-sm truncate max-w-xs md:max-w-md" title="{{ item.source_url }}">{{ item.source_url }}</span>
  124. <div class="flex items-center gap-2 mt-0.5">
  125. <span class="text-xs text-gray-500">{{ item.count }} dominios</span>
  126. <span x-show="enforced" class="inline-flex items-center gap-1 text-xs font-medium text-emerald-700 bg-emerald-50 border border-emerald-200 px-1.5 py-0.5 rounded-full">
  127. <i class="fas fa-shield-alt text-[10px]"></i> {{ _("Activa en Squid") }}
  128. </span>
  129. <span x-show="!enforced" class="inline-flex items-center gap-1 text-xs font-medium text-gray-500 bg-gray-100 border border-gray-200 px-1.5 py-0.5 rounded-full">
  130. <i class="fas fa-ban text-[10px]"></i> {{ _("Inactiva") }}
  131. </span>
  132. </div>
  133. </div>
  134. <div class="flex items-center gap-2 flex-shrink-0">
  135. <!-- Toggle enforcement -->
  136. <button
  137. @click="toggleBlocklist('{{ item.source_url }}', !enforced, $el, (ok) => { if(ok) enforced = !enforced })"
  138. :disabled="loading"
  139. :class="enforced
  140. ? 'bg-emerald-500 hover:bg-emerald-600 focus:ring-emerald-300'
  141. : 'bg-gray-400 hover:bg-gray-500 focus:ring-gray-300'"
  142. class="relative inline-flex h-7 w-12 flex-shrink-0 cursor-pointer rounded-full border-2 border-transparent transition-colors duration-200 ease-in-out focus:outline-none focus:ring-2 focus:ring-offset-1 disabled:opacity-50 disabled:cursor-wait"
  143. role="switch"
  144. :aria-checked="enforced.toString()"
  145. :title="enforced ? 'Desactivar bloqueo en Squid' : 'Activar bloqueo en Squid'"
  146. >
  147. <span
  148. :class="enforced ? 'translate-x-5' : 'translate-x-0'"
  149. class="pointer-events-none inline-block h-6 w-6 transform rounded-full bg-white shadow ring-0 transition duration-200 ease-in-out flex items-center justify-center"
  150. >
  151. <i x-show="loading" class="fas fa-spinner fa-spin text-gray-400 text-xs"></i>
  152. </span>
  153. </button>
  154. <!-- Delete list -->
  155. <form method="POST" action="/admin/blacklist/delete-list" class="delete-list-form">
  156. <input type="hidden" name="csrf_token" value="{{ csrf_token() }}"/>
  157. <input type="hidden" name="source_url" value="{{ item.source_url }}"/>
  158. <button type="submit" class="bg-red-500 hover:bg-red-600 text-white px-3 py-1.5 rounded text-xs font-semibold shadow delete-list-btn" title="{{ _("Eliminar lista y dominios") }}">
  159. <i class="fas fa-trash-alt"></i>
  160. </button>
  161. </form>
  162. </div>
  163. </li>
  164. {% endfor %}
  165. </ul>
  166. </div>
  167. {% endif %}
  168. </div>
  169. <script>
  170. /**
  171. * Toggle Squid enforcement for a blocklist via the API.
  172. *
  173. * @param {string|null} sourceUrl The source_url (null for custom list)
  174. * @param {boolean} enable true = activate, false = deactivate
  175. * @param {HTMLElement} el The toggle button element (for loading state)
  176. * @param {function} callback Called with (true) on success, (false) on error
  177. */
  178. function toggleBlocklist(sourceUrl, enable, el, callback) {
  179. const csrfToken = document.querySelector('meta[name="csrf-token"]').getAttribute('content');
  180. // Disable button while processing
  181. el.disabled = true;
  182. fetch('/admin/api/blocklist/toggle', {
  183. method: 'POST',
  184. headers: {
  185. 'Content-Type': 'application/json',
  186. 'X-CSRFToken': csrfToken
  187. },
  188. body: JSON.stringify({
  189. source_url: sourceUrl,
  190. enable: enable
  191. })
  192. })
  193. .then(function(resp) { return resp.json().then(function(data) { return { ok: resp.ok, data: data }; }); })
  194. .then(function(result) {
  195. el.disabled = false;
  196. if (result.ok && result.data.status === 'success') {
  197. showToast(result.data.message, 'success');
  198. callback(true);
  199. } else {
  200. showToast(result.data.message || 'Error al cambiar estado', 'error');
  201. callback(false);
  202. }
  203. })
  204. .catch(function(err) {
  205. el.disabled = false;
  206. showToast('Error de conexión al servidor', 'error');
  207. callback(false);
  208. });
  209. }
  210. /**
  211. * Lightweight toast notification.
  212. */
  213. function showToast(message, type) {
  214. var container = document.getElementById('toastContainer');
  215. if (!container) {
  216. container = document.createElement('div');
  217. container.id = 'toastContainer';
  218. container.className = 'fixed top-4 right-4 z-[60] flex flex-col gap-2 max-w-sm';
  219. document.body.appendChild(container);
  220. }
  221. var colorClasses = type === 'success'
  222. ? 'bg-emerald-600 text-white'
  223. : type === 'error'
  224. ? 'bg-red-600 text-white'
  225. : 'bg-gray-700 text-white';
  226. var icon = type === 'success' ? 'fa-check-circle' : type === 'error' ? 'fa-exclamation-circle' : 'fa-info-circle';
  227. var toast = document.createElement('div');
  228. toast.className = 'flex items-center gap-2 px-4 py-3 rounded-lg shadow-lg text-sm font-medium transform translate-x-full transition-transform duration-300 ' + colorClasses;
  229. toast.innerHTML = '<i class="fas ' + icon + '"></i><span>' + message + '</span>';
  230. container.appendChild(toast);
  231. // Animate in
  232. requestAnimationFrame(function() {
  233. toast.classList.remove('translate-x-full');
  234. toast.classList.add('translate-x-0');
  235. });
  236. // Auto-dismiss
  237. setTimeout(function() {
  238. toast.classList.remove('translate-x-0');
  239. toast.classList.add('translate-x-full');
  240. setTimeout(function() { toast.remove(); }, 300);
  241. }, 4000);
  242. }
  243. // Reutiliza el modal de confirmación global
  244. document.addEventListener('DOMContentLoaded', function() {
  245. function showImportLoading(title, subtitle) {
  246. const overlay = document.getElementById('importLoadingOverlay');
  247. const loadingTitle = document.getElementById('importLoadingTitle');
  248. const loadingSubtitle = document.getElementById('importLoadingSubtitle');
  249. if (loadingTitle && title) loadingTitle.textContent = title;
  250. if (loadingSubtitle && subtitle) loadingSubtitle.textContent = subtitle;
  251. if (overlay) {
  252. overlay.classList.remove('hidden');
  253. overlay.classList.add('flex');
  254. }
  255. }
  256. let pendingDeleteForm = null;
  257. document.querySelectorAll('.delete-list-form').forEach(function(form) {
  258. form.addEventListener('submit', function(e) {
  259. e.preventDefault();
  260. pendingDeleteForm = form;
  261. const url = form.querySelector('input[name="source_url"]').value;
  262. showCustomConfirm(
  263. `¿Estás seguro de que deseas eliminar la siguiente lista?\n\nURL: ${url}\n\nEsta acción es irreversible y eliminará todos los dominios asociados.`,
  264. function() {
  265. if (pendingDeleteForm) {
  266. pendingDeleteForm.submit();
  267. pendingDeleteForm = null;
  268. }
  269. }
  270. );
  271. });
  272. });
  273. const deleteBlockedUserConfirmTemplate = {{ _('¿Estás seguro de que deseas eliminar el usuario bloqueado %s de la base de datos? Esta acción también actualizará el archivo de IPs bloqueadas.')|tojson }};
  274. const deleteBlockedUserErrorText = {{ _('Error al eliminar usuario bloqueado')|tojson }};
  275. const deleteBlockedUserConnectionErrorText = {{ _('Error de conexión al servidor')|tojson }};
  276. document.querySelectorAll('.delete-blocked-user-form').forEach(function(form) {
  277. form.addEventListener('submit', function(e) {
  278. e.preventDefault();
  279. pendingDeleteForm = form;
  280. const username = form.querySelector('input[name="username"]').value;
  281. const confirmMessage = deleteBlockedUserConfirmTemplate.replace('%s', username);
  282. showCustomConfirm(
  283. confirmMessage,
  284. function() {
  285. if (!pendingDeleteForm) {
  286. return;
  287. }
  288. const blockedUserId = pendingDeleteForm.querySelector('input[name="blocked_user_id"]').value;
  289. const csrfToken = pendingDeleteForm.querySelector('input[name="csrf_token"]').value;
  290. fetch('/admin/blacklist/delete-blocked-user', {
  291. method: 'POST',
  292. headers: {
  293. 'Content-Type': 'application/json',
  294. 'X-CSRFToken': csrfToken,
  295. },
  296. body: JSON.stringify({ blocked_user_id: blockedUserId }),
  297. })
  298. .then(function(resp) { return resp.json().then(function(data) { return { ok: resp.ok, data: data }; }); })
  299. .then(function(result) {
  300. if (result.ok && result.data.status === 'success') {
  301. showToast(result.data.message, 'success');
  302. const row = pendingDeleteForm.closest('tr');
  303. if (row) {
  304. row.remove();
  305. }
  306. const tbody = document.querySelector('#blocked-users-table tbody');
  307. if (tbody && tbody.querySelectorAll('tr').length === 0) {
  308. const container = document.getElementById('blocked-users-table-container');
  309. if (container) {
  310. const emptyText = {{ _('No hay IPs bloqueadas en la base de datos.')|tojson }};
  311. container.innerHTML = `
  312. <div class="bg-gray-50 p-4 rounded border text-sm text-gray-600">
  313. ${emptyText}
  314. </div>
  315. `;
  316. }
  317. }
  318. } else {
  319. showToast(result.data.message || deleteBlockedUserErrorText, 'error');
  320. }
  321. })
  322. .catch(function() {
  323. showToast(deleteBlockedUserConnectionErrorText, 'error');
  324. })
  325. .finally(function() {
  326. pendingDeleteForm = null;
  327. });
  328. }
  329. );
  330. });
  331. });
  332. // Validación para evitar agregar listas duplicadas
  333. const addListForm = document.getElementById('importUrlForm');
  334. if (addListForm) {
  335. addListForm.addEventListener('submit', function(e) {
  336. const input = addListForm.querySelector('input[name="url"]');
  337. if (!input) return;
  338. const newUrl = input.value.trim();
  339. if (!newUrl) return;
  340. // Recolectar URLs ya existentes
  341. const existingUrls = Array.from(document.querySelectorAll('input[name="source_url"]'))
  342. .map(el => el.value.trim());
  343. if (existingUrls.includes(newUrl)) {
  344. showCustomConfirm(
  345. 'La lista ya existe en el sistema. No puedes agregar la misma URL dos veces.',
  346. function() {}, // Solo cerrar
  347. { onlyClose: true }
  348. );
  349. e.preventDefault();
  350. return;
  351. }
  352. showImportLoading(
  353. 'Importando lista desde URL',
  354. 'Validando enlace y procesando dominios...'
  355. );
  356. });
  357. }
  358. const importFileForm = document.getElementById('importFileForm');
  359. if (importFileForm) {
  360. importFileForm.addEventListener('submit', function() {
  361. showImportLoading(
  362. 'Importando archivo de listas',
  363. 'Leyendo archivo y aplicando reglas de bloqueo...'
  364. );
  365. });
  366. }
  367. window.addEventListener('pageshow', function() {
  368. const overlay = document.getElementById('importLoadingOverlay');
  369. if (overlay) {
  370. overlay.classList.add('hidden');
  371. overlay.classList.remove('flex');
  372. }
  373. });
  374. });
  375. </script>
  376. <!-- DNSmasq Tab -->
  377. <div x-show="activeTab === 'dnsmasq'" class="mt-6">
  378. <h3 class="text-lg font-semibold mb-3 flex items-center gap-2">
  379. {{ _("DNSmasq") }}
  380. <span class="inline-block bg-yellow-200 text-yellow-800 text-xs font-bold px-2 py-0.5 rounded align-middle border border-yellow-300 shadow-sm animate-pulse" title="{{ _("Funcionalidad en Beta") }}">{{ _("BETA") }}</span>
  381. </h3>
  382. <p class="text-sm text-gray-600 mb-4">{{ _("Exporta o importa reglas en formato compatible con dnsmasq.") }}</p>
  383. <div class="bg-gray-50 p-4 rounded border">
  384. <button class="bg-blue-500 hover:bg-blue-600 text-white px-4 py-2 rounded">{{ _("Exportar archivo hosts") }}</button>
  385. </div>
  386. </div>
  387. <!-- Custom Tab -->
  388. <div x-show="activeTab === 'custom'" x-data="{ customEnforced: {{ 'true' if custom_enforced else 'false' }}, customLoading: false }" class="mt-6">
  389. <div class="flex items-center justify-between mb-3">
  390. <div>
  391. <h3 class="text-lg font-semibold">{{ _("Lista Personalizada") }}</h3>
  392. <p class="text-sm text-gray-600">{{ _("Añade dominios manualmente o pega una lista separada por comas/lineas.") }}</p>
  393. </div>
  394. <div class="flex items-center gap-3 flex-shrink-0">
  395. <div class="flex items-center gap-2">
  396. <span x-show="customEnforced" class="inline-flex items-center gap-1 text-xs font-medium text-emerald-700 bg-emerald-50 border border-emerald-200 px-2 py-1 rounded-full">
  397. <i class="fas fa-shield-alt text-[10px]"></i> {{ _("Activa en Squid") }}
  398. </span>
  399. <span x-show="!customEnforced" class="inline-flex items-center gap-1 text-xs font-medium text-gray-500 bg-gray-100 border border-gray-200 px-2 py-1 rounded-full">
  400. <i class="fas fa-ban text-[10px]"></i> {{ _("Inactiva") }}
  401. </span>
  402. </div>
  403. <button
  404. @click="toggleBlocklist(null, !customEnforced, $el, (ok) => { if(ok) customEnforced = !customEnforced })"
  405. :disabled="customLoading"
  406. :class="customEnforced
  407. ? 'bg-emerald-500 hover:bg-emerald-600 focus:ring-emerald-300'
  408. : 'bg-gray-400 hover:bg-gray-500 focus:ring-gray-300'"
  409. class="relative inline-flex h-7 w-12 flex-shrink-0 cursor-pointer rounded-full border-2 border-transparent transition-colors duration-200 ease-in-out focus:outline-none focus:ring-2 focus:ring-offset-1 disabled:opacity-50 disabled:cursor-wait"
  410. role="switch"
  411. :aria-checked="customEnforced.toString()"
  412. :title="customEnforced ? 'Desactivar bloqueo en Squid' : 'Activar bloqueo en Squid'"
  413. >
  414. <span
  415. :class="customEnforced ? 'translate-x-5' : 'translate-x-0'"
  416. class="pointer-events-none inline-block h-6 w-6 transform rounded-full bg-white shadow ring-0 transition duration-200 ease-in-out flex items-center justify-center"
  417. >
  418. <i x-show="customLoading" class="fas fa-spinner fa-spin text-gray-400 text-xs"></i>
  419. </span>
  420. </button>
  421. </div>
  422. </div>
  423. <form method="POST" action="/admin/blacklist/save-custom" class="grid grid-cols-1 gap-4">
  424. <input type="hidden" name="csrf_token" value="{{ csrf_token() }}"/>
  425. <textarea name="custom_list" rows="6" class="w-full p-3 border rounded" placeholder="{{ _("example.com
  426. example.org") }}">{{ blacklist }}</textarea>
  427. <div class="flex gap-2">
  428. <button type="submit" class="bg-green-500 hover:bg-green-600 text-white px-4 py-2 rounded">{{ _("Guardar") }}</button>
  429. <button type="button" class="bg-gray-200 hover:bg-gray-300 px-4 py-2 rounded">{{ _("Cancelar") }}</button>
  430. </div>
  431. </form>
  432. </div>
  433. <!-- Import Tab -->
  434. <div x-show="activeTab === 'import'" class="mt-6">
  435. <h3 class="text-lg font-semibold mb-3">{{ _("Importar listas") }}</h3>
  436. <p class="text-sm text-gray-600 mb-4">{{ _("Importa desde archivos locales o pega URLs de listas públicas.") }}</p>
  437. <form id="importFileForm" method="POST" action="/admin/blacklist/import" enctype="multipart/form-data" class="bg-gray-50 p-4 rounded border">
  438. <input type="hidden" name="csrf_token" value="{{ csrf_token() }}"/>
  439. <label class="text-sm font-medium text-gray-700">{{ _("Subir archivo") }}</label>
  440. <input name="file" type="file" class="w-full mt-2" />
  441. <div class="mt-3">
  442. <button type="submit" class="bg-blue-500 hover:bg-blue-600 text-white px-4 py-2 rounded">{{ _("Importar") }}</button>
  443. </div>
  444. </form>
  445. </div>
  446. </div>
  447. {% endblock %}