http_access.html 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478
  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">{{ _("Reglas de Acceso HTTP") }}</h2>
  7. <p class="text-sm text-gray-600 mt-1">{{ _("Las reglas se evalúan en orden. La primera coincidencia determina el acceso.") }}</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 Regla") }}
  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 rules %}
  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">{{ _("Importante sobre el orden:") }}</p>
  32. <ul class="list-disc list-inside space-y-1 ml-2">
  33. <li>{{ _("Las reglas se procesan de arriba hacia abajo") }}</li>
  34. <li>{{ _("La primera regla que coincida se aplica (allow o deny)") }}</li>
  35. <li>{{ _("Si ninguna regla coincide, se aplica el comportamiento contrario a la última regla") }}</li>
  36. <li>{{ _("Se recomienda terminar con \"deny all\" para evitar confusión") }}</li>
  37. </ul>
  38. </div>
  39. </div>
  40. </div>
  41. <div class="space-y-2">
  42. {% for rule in rules %}
  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 items-center space-x-2 flex-shrink-0">
  46. <span class="text-xs font-mono text-gray-400">#{{ loop.index }}</span>
  47. {% if rule.action == 'allow' %}
  48. <span class="inline-flex px-3 py-1 text-xs font-bold rounded-full bg-green-100 text-green-800 border border-green-300">
  49. <i class="fas fa-check mr-1"></i>{{ _("ALLOW") }}
  50. </span>
  51. {% else %}
  52. <span class="inline-flex px-3 py-1 text-xs font-bold rounded-full bg-red-100 text-red-800 border border-red-300">
  53. <i class="fas fa-times mr-1"></i>{{ _("DENY") }}
  54. </span>
  55. {% endif %}
  56. </div>
  57. <div class="flex-1 min-w-0">
  58. <div class="flex flex-wrap items-center gap-2">
  59. {% for acl in rule.acls %}
  60. {% if acl.startswith('!') %}
  61. <span class="inline-flex items-center px-2 py-1 rounded bg-orange-100 text-orange-800 text-xs font-mono border border-orange-300">
  62. <i class="fas fa-exclamation-circle mr-1"></i>{{ acl }}
  63. </span>
  64. {% elif acl in ['localhost', 'manager', 'all'] %}
  65. <span class="inline-flex items-center px-2 py-1 rounded bg-purple-100 text-purple-800 text-xs font-mono border border-purple-300">
  66. <i class="fas fa-star mr-1"></i>{{ acl }}
  67. </span>
  68. {% elif 'ports' in acl.lower() %}
  69. <span class="inline-flex items-center px-2 py-1 rounded bg-blue-100 text-blue-800 text-xs font-mono border border-blue-300">
  70. <i class="fas fa-plug mr-1"></i>{{ acl }}
  71. </span>
  72. {% elif acl == 'CONNECT' %}
  73. <span class="inline-flex items-center px-2 py-1 rounded bg-indigo-100 text-indigo-800 text-xs font-mono border border-indigo-300">
  74. <i class="fas fa-link mr-1"></i>{{ acl }}
  75. </span>
  76. {% else %}
  77. <span class="inline-flex items-center px-2 py-1 rounded bg-gray-100 text-gray-800 text-xs font-mono border border-gray-300">
  78. {{ acl }}
  79. </span>
  80. {% endif %}
  81. {% endfor %}
  82. </div>
  83. {% if rule.description %}
  84. <p class="text-xs text-gray-500 mt-2 italic">
  85. <i class="fas fa-comment-alt mr-1"></i>{{ rule.description }}
  86. </p>
  87. {% endif %}
  88. {% if rule.is_negative %}
  89. <p class="text-xs text-orange-600 mt-1">
  90. <i class="fas fa-info-circle mr-1"></i>{{ _("Contiene negación (!) - se aplica cuando NO coincide con la ACL") }}
  91. </p>
  92. {% endif %}
  93. </div>
  94. </div>
  95. <div class="flex space-x-2 flex-shrink-0 sm:ml-3">
  96. <button onclick='moveRuleUp({{ loop.index0 }})'
  97. class="text-gray-600 hover:text-gray-900 p-2 hover:bg-gray-100 rounded"
  98. title="{{ _("Mover arriba") }}"
  99. {% if loop.first %}disabled class="opacity-30 cursor-not-allowed"{% endif %}>
  100. <i class="fas fa-arrow-up"></i>
  101. </button>
  102. <button onclick='moveRuleDown({{ loop.index0 }})'
  103. class="text-gray-600 hover:text-gray-900 p-2 hover:bg-gray-100 rounded"
  104. title="{{ _("Mover abajo") }}"
  105. {% if loop.last %}disabled class="opacity-30 cursor-not-allowed"{% endif %}>
  106. <i class="fas fa-arrow-down"></i>
  107. </button>
  108. <button onclick='editRule({{ loop.index0 }}, "{{ rule.action }}", "{{ rule.acl_string }}", "{{ rule.description }}")'
  109. class="text-blue-600 hover:text-blue-900 p-2 hover:bg-blue-100 rounded"
  110. title="{{ _("Editar") }}">
  111. <i class="fas fa-edit"></i>
  112. </button>
  113. <button onclick='deleteRule({{ loop.index0 }}, "{{ rule.action }} {{ rule.acl_string }}")'
  114. class="text-red-600 hover:text-red-900 p-2 hover:bg-red-100 rounded"
  115. title="{{ _("Eliminar") }}">
  116. <i class="fas fa-trash"></i>
  117. </button>
  118. </div>
  119. </div>
  120. {% endfor %}
  121. </div>
  122. {% else %}
  123. <div class="text-center py-12 bg-gray-50 rounded-lg border-2 border-dashed border-gray-300">
  124. <i class="fas fa-shield-alt text-6xl text-gray-300 mb-4"></i>
  125. <p class="text-gray-500 text-lg font-medium">{{ _("No hay reglas HTTP access configuradas") }}</p>
  126. <p class="text-gray-400 text-sm mt-2">{{ _("⚠️ Sin reglas, el acceso será DENEGADO por defecto") }}</p>
  127. <div class="mt-4 bg-blue-50 border border-blue-200 rounded-lg p-4 max-w-md mx-auto">
  128. <div class="flex items-start">
  129. <i class="fas fa-info-circle text-blue-600 mt-1 mr-3"></i>
  130. <div class="text-left text-sm">
  131. <p class="font-semibold text-blue-900 mb-1">{{ _("¿Ya tienes reglas configuradas?") }}</p>
  132. <p class="text-blue-800 mb-2">{{ _("Si tu squid.conf aún no está dividido, puedes") }} <a href="{{ url_for('admin.split_config') }}" class="underline hover:text-blue-600 font-semibold">{{ _("dividir tu configuración") }}</a> {{ _("para una mejor gestión modular.") }}</p>
  133. <p class="text-blue-800">{{ _("Si ya está dividido, verifica que los archivos estén en el directorio correcto o edítalos directamente desde") }} <a href="{{ url_for('admin.view_config') }}" class="underline hover:text-blue-600 font-semibold">{{ _("Configuración") }}</a>.</p>
  134. </div>
  135. </div>
  136. </div>
  137. <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">
  138. <i class="fas fa-plus mr-2"></i>{{ _("Crear primera regla") }}
  139. </button>
  140. </div>
  141. {% endif %}
  142. </div>
  143. <!-- Add Modal -->
  144. <div id="addModal" class="hidden fixed inset-0 bg-black bg-opacity-50 z-50 flex items-center justify-center p-4">
  145. <div class="bg-white rounded-lg shadow-xl max-w-2xl w-full p-6 max-h-[90vh] overflow-y-auto">
  146. <h3 class="text-2xl font-bold text-gray-800 mb-4">
  147. <i class="fas fa-plus-circle text-blue-600 mr-2"></i>{{ _("Agregar Regla HTTP Access") }}
  148. </h3>
  149. <form id="addForm" method="POST" action="/admin/http-access/add">
  150. <input type="hidden" name="csrf_token" value="{{ csrf_token() }}">
  151. <div class="mb-4">
  152. <label class="block text-gray-700 font-semibold mb-2">{{ _("Acción:") }}</label>
  153. <div class="grid grid-cols-2 gap-3">
  154. <label class="flex items-center justify-center p-4 border-2 border-gray-300 rounded-lg cursor-pointer hover:border-green-500 hover:bg-green-50 transition-all">
  155. <input type="radio" name="action" value="allow" class="mr-3 w-4 h-4" required>
  156. <div class="text-center">
  157. <i class="fas fa-check-circle text-green-600 text-2xl mb-1"></i>
  158. <p class="font-semibold text-gray-800">{{ _("ALLOW") }}</p>
  159. <p class="text-xs text-gray-600">{{ _("Permitir acceso") }}</p>
  160. </div>
  161. </label>
  162. <label class="flex items-center justify-center p-4 border-2 border-gray-300 rounded-lg cursor-pointer hover:border-red-500 hover:bg-red-50 transition-all">
  163. <input type="radio" name="action" value="deny" class="mr-3 w-4 h-4" required>
  164. <div class="text-center">
  165. <i class="fas fa-times-circle text-red-600 text-2xl mb-1"></i>
  166. <p class="font-semibold text-gray-800">{{ _("DENY") }}</p>
  167. <p class="text-xs text-gray-600">{{ _("Denegar acceso") }}</p>
  168. </div>
  169. </label>
  170. </div>
  171. </div>
  172. <div class="mb-4">
  173. <label class="block text-gray-700 font-semibold mb-2">{{ _("ACLs:") }}</label>
  174. <div id="addAclsList" class="space-y-2 mb-2">
  175. <!-- ACLs se agregarán dinámicamente -->
  176. </div>
  177. <button type="button" onclick="addAclInput('add')" class="text-blue-600 hover:text-blue-800 text-sm font-medium">
  178. <i class="fas fa-plus-circle mr-1"></i>{{ _("Agregar ACL") }}
  179. </button>
  180. </div>
  181. <div class="mb-4">
  182. <label class="block text-gray-700 font-semibold mb-2">
  183. <i class="fas fa-star text-yellow-500 mr-1"></i>{{ _("ACLs Comunes (opcional):") }}
  184. </label>
  185. <div class="grid grid-cols-2 sm:grid-cols-3 gap-2">
  186. <button type="button" onclick="addCommonAcl('add', 'localhost')" class="px-3 py-2 bg-purple-100 hover:bg-purple-200 text-purple-800 rounded text-sm border border-purple-300">
  187. localhost
  188. </button>
  189. <button type="button" onclick="addCommonAcl('add', 'manager')" class="px-3 py-2 bg-purple-100 hover:bg-purple-200 text-purple-800 rounded text-sm border border-purple-300">
  190. manager
  191. </button>
  192. <button type="button" onclick="addCommonAcl('add', 'all')" class="px-3 py-2 bg-purple-100 hover:bg-purple-200 text-purple-800 rounded text-sm border border-purple-300">
  193. all
  194. </button>
  195. <button type="button" onclick="addCommonAcl('add', '!Safe_ports')" class="px-3 py-2 bg-orange-100 hover:bg-orange-200 text-orange-800 rounded text-sm border border-orange-300">
  196. {{ _("!Safe_ports") }}
  197. </button>
  198. <button type="button" onclick="addCommonAcl('add', '!SSL_ports')" class="px-3 py-2 bg-orange-100 hover:bg-orange-200 text-orange-800 rounded text-sm border border-orange-300">
  199. {{ _("!SSL_ports") }}
  200. </button>
  201. <button type="button" onclick="addCommonAcl('add', 'CONNECT')" class="px-3 py-2 bg-indigo-100 hover:bg-indigo-200 text-indigo-800 rounded text-sm border border-indigo-300">
  202. {{ _("CONNECT") }}
  203. </button>
  204. </div>
  205. <p class="text-xs text-gray-500 mt-2">
  206. <i class="fas fa-info-circle mr-1"></i>{{ _("Haz clic en estas ACLs predefinidas para agregarlas rápidamente") }}
  207. </p>
  208. </div>
  209. <div class="mb-4 bg-yellow-50 border border-yellow-200 rounded-lg p-3">
  210. <p class="text-sm text-gray-700">
  211. <i class="fas fa-lightbulb text-yellow-600 mr-2"></i>
  212. <strong>{{ _("Tip:") }}</strong> {{ _("Usa") }} <code class="bg-white px-1 rounded">!</code> {{ _("antes del nombre de una ACL para negación. Ej:") }} <code class="bg-white px-1 rounded">{{ _("!Safe_ports") }}</code> {{ _("coincide cuando NO es un puerto seguro.") }}
  213. </p>
  214. </div>
  215. <div class="mb-4">
  216. <label class="block text-gray-700 font-semibold mb-2">{{ _("Descripción (opcional):") }}</label>
  217. <input type="text" name="description" placeholder="{{ _("Ej: Permitir acceso desde la red local") }}"
  218. class="w-full px-4 py-2 border border-gray-300 rounded-lg focus:ring-2 focus:ring-blue-500 focus:border-transparent text-sm">
  219. <p class="text-xs text-gray-500 mt-1">{{ _("Se agregará como comentario antes de la regla") }}</p>
  220. </div>
  221. <div class="flex space-x-2 justify-end mt-6 pt-4 border-t">
  222. <button type="button" onclick="closeAddModal()" class="px-5 py-2 bg-gray-300 hover:bg-gray-400 text-gray-800 rounded-lg transition-colors font-medium">
  223. {{ _("Cancelar") }}
  224. </button>
  225. <button type="submit" class="px-5 py-2 bg-blue-600 hover:bg-blue-700 text-white rounded-lg transition-colors font-medium">
  226. <i class="fas fa-save mr-2"></i>{{ _("Crear Regla") }}
  227. </button>
  228. </div>
  229. </form>
  230. </div>
  231. </div>
  232. <!-- Edit Modal -->
  233. <div id="editModal" class="hidden fixed inset-0 bg-black bg-opacity-50 z-50 flex items-center justify-center p-4">
  234. <div class="bg-white rounded-lg shadow-xl max-w-2xl w-full p-6 max-h-[90vh] overflow-y-auto">
  235. <h3 class="text-2xl font-bold text-gray-800 mb-4">
  236. <i class="fas fa-edit text-blue-600 mr-2"></i>{{ _("Editar Regla HTTP Access") }}
  237. </h3>
  238. <form id="editForm" method="POST" action="/admin/http-access/edit">
  239. <input type="hidden" name="csrf_token" value="{{ csrf_token() }}">
  240. <input type="hidden" name="index" id="editIndex">
  241. <div class="mb-4">
  242. <label class="block text-gray-700 font-semibold mb-2">{{ _("Acción:") }}</label>
  243. <div class="grid grid-cols-2 gap-3">
  244. <label class="flex items-center justify-center p-4 border-2 border-gray-300 rounded-lg cursor-pointer hover:border-green-500 hover:bg-green-50 transition-all">
  245. <input type="radio" name="action" value="allow" id="editActionAllow" class="mr-3 w-4 h-4" required>
  246. <div class="text-center">
  247. <i class="fas fa-check-circle text-green-600 text-2xl mb-1"></i>
  248. <p class="font-semibold text-gray-800">{{ _("ALLOW") }}</p>
  249. </div>
  250. </label>
  251. <label class="flex items-center justify-center p-4 border-2 border-gray-300 rounded-lg cursor-pointer hover:border-red-500 hover:bg-red-50 transition-all">
  252. <input type="radio" name="action" value="deny" id="editActionDeny" class="mr-3 w-4 h-4" required>
  253. <div class="text-center">
  254. <i class="fas fa-times-circle text-red-600 text-2xl mb-1"></i>
  255. <p class="font-semibold text-gray-800">{{ _("DENY") }}</p>
  256. </div>
  257. </label>
  258. </div>
  259. </div>
  260. <div class="mb-4">
  261. <label class="block text-gray-700 font-semibold mb-2">{{ _("ACLs:") }}</label>
  262. <div id="editAclsList" class="space-y-2 mb-2">
  263. <!-- ACLs se llenarán dinámicamente -->
  264. </div>
  265. <button type="button" onclick="addAclInput('edit')" class="text-blue-600 hover:text-blue-800 text-sm font-medium">
  266. <i class="fas fa-plus-circle mr-1"></i>{{ _("Agregar ACL") }}
  267. </button>
  268. </div>
  269. <div class="mb-4">
  270. <label class="block text-gray-700 font-semibold mb-2">{{ _("Descripción (opcional):") }}</label>
  271. <input type="text" name="description" id="editDescription" placeholder="{{ _("Ej: Permitir acceso desde la red local") }}"
  272. class="w-full px-4 py-2 border border-gray-300 rounded-lg focus:ring-2 focus:ring-blue-500 focus:border-transparent text-sm">
  273. </div>
  274. <div class="flex space-x-2 justify-end mt-6 pt-4 border-t">
  275. <button type="button" onclick="closeEditModal()" class="px-5 py-2 bg-gray-300 hover:bg-gray-400 text-gray-800 rounded-lg transition-colors font-medium">
  276. {{ _("Cancelar") }}
  277. </button>
  278. <button type="submit" class="px-5 py-2 bg-blue-600 hover:bg-blue-700 text-white rounded-lg transition-colors font-medium">
  279. <i class="fas fa-save mr-2"></i>{{ _("Guardar Cambios") }}
  280. </button>
  281. </div>
  282. </form>
  283. </div>
  284. </div>
  285. <script>
  286. let addAclCounter = 0;
  287. let editAclCounter = 0;
  288. function showAddModal() {
  289. document.getElementById('addModal').classList.remove('hidden');
  290. document.getElementById('addForm').reset();
  291. document.getElementById('addAclsList').innerHTML = '';
  292. addAclCounter = 0;
  293. // Add one initial ACL input
  294. addAclInput('add');
  295. }
  296. function closeAddModal() {
  297. document.getElementById('addModal').classList.add('hidden');
  298. }
  299. function editRule(index, action, aclString, description) {
  300. document.getElementById('editIndex').value = index;
  301. // Set action radio button
  302. if (action === 'allow') {
  303. document.getElementById('editActionAllow').checked = true;
  304. } else {
  305. document.getElementById('editActionDeny').checked = true;
  306. }
  307. // Set description
  308. document.getElementById('editDescription').value = description || '';
  309. // Parse ACLs and fill inputs
  310. const acls = aclString.split(' ');
  311. const aclsContainer = document.getElementById('editAclsList');
  312. aclsContainer.innerHTML = '';
  313. editAclCounter = 0;
  314. acls.forEach(acl => {
  315. if (acl.trim()) {
  316. addAclInput('edit', acl.trim());
  317. }
  318. });
  319. // If no ACLs were added, add one empty input
  320. if (editAclCounter === 0) {
  321. addAclInput('edit');
  322. }
  323. document.getElementById('editModal').classList.remove('hidden');
  324. }
  325. function closeEditModal() {
  326. document.getElementById('editModal').classList.add('hidden');
  327. }
  328. function addAclInput(mode, value = '') {
  329. const container = document.getElementById(mode + 'AclsList');
  330. const counter = mode === 'add' ? addAclCounter++ : editAclCounter++;
  331. const aclDiv = document.createElement('div');
  332. aclDiv.className = 'flex items-center space-x-2';
  333. aclDiv.id = mode + 'Acl' + counter;
  334. aclDiv.innerHTML = `
  335. <input type="text" name="acls[]" value="${value}" placeholder="Nombre de ACL (ej: localhost, !Safe_ports)"
  336. class="flex-1 px-3 py-2 border border-gray-300 rounded-lg text-sm font-mono focus:ring-2 focus:ring-blue-500" required>
  337. <button type="button" onclick="removeAclInput('${mode}', ${counter})"
  338. class="text-red-600 hover:text-red-800 p-2">
  339. <i class="fas fa-times"></i>
  340. </button>
  341. `;
  342. container.appendChild(aclDiv);
  343. }
  344. function removeAclInput(mode, counter) {
  345. const aclDiv = document.getElementById(mode + 'Acl' + counter);
  346. if (aclDiv) {
  347. // Only allow removal if there's more than one ACL input
  348. const container = document.getElementById(mode + 'AclsList');
  349. if (container.children.length > 1) {
  350. aclDiv.remove();
  351. } else {
  352. alert('Debe haber al menos una ACL en la regla');
  353. }
  354. }
  355. }
  356. function addCommonAcl(mode, aclName) {
  357. addAclInput(mode, aclName);
  358. }
  359. function deleteRule(index, rule) {
  360. if (confirm('¿Estás seguro de que quieres eliminar la regla:\nhttp_access ' + rule + '?\n\nEsto puede afectar el acceso al proxy.')) {
  361. const form = document.createElement('form');
  362. form.method = 'POST';
  363. form.action = '/admin/http-access/delete';
  364. const indexInput = document.createElement('input');
  365. indexInput.type = 'hidden';
  366. indexInput.name = 'index';
  367. indexInput.value = index;
  368. const csrfInput = document.createElement('input');
  369. csrfInput.type = 'hidden';
  370. csrfInput.name = 'csrf_token';
  371. csrfInput.value = '{{ csrf_token() }}';
  372. form.appendChild(indexInput);
  373. form.appendChild(csrfInput);
  374. document.body.appendChild(form);
  375. form.submit();
  376. }
  377. }
  378. function moveRuleUp(index) {
  379. if (index === 0) return;
  380. const form = document.createElement('form');
  381. form.method = 'POST';
  382. form.action = '/admin/http-access/move';
  383. const indexInput = document.createElement('input');
  384. indexInput.type = 'hidden';
  385. indexInput.name = 'index';
  386. indexInput.value = index;
  387. const directionInput = document.createElement('input');
  388. directionInput.type = 'hidden';
  389. directionInput.name = 'direction';
  390. directionInput.value = 'up';
  391. const csrfInput = document.createElement('input');
  392. csrfInput.type = 'hidden';
  393. csrfInput.name = 'csrf_token';
  394. csrfInput.value = '{{ csrf_token() }}';
  395. form.appendChild(indexInput);
  396. form.appendChild(directionInput);
  397. form.appendChild(csrfInput);
  398. document.body.appendChild(form);
  399. form.submit();
  400. }
  401. function moveRuleDown(index) {
  402. const form = document.createElement('form');
  403. form.method = 'POST';
  404. form.action = '/admin/http-access/move';
  405. const indexInput = document.createElement('input');
  406. indexInput.type = 'hidden';
  407. indexInput.name = 'index';
  408. indexInput.value = index;
  409. const directionInput = document.createElement('input');
  410. directionInput.type = 'hidden';
  411. directionInput.name = 'direction';
  412. directionInput.value = 'down';
  413. const csrfInput = document.createElement('input');
  414. csrfInput.type = 'hidden';
  415. csrfInput.name = 'csrf_token';
  416. csrfInput.value = '{{ csrf_token() }}';
  417. form.appendChild(indexInput);
  418. form.appendChild(directionInput);
  419. form.appendChild(csrfInput);
  420. document.body.appendChild(form);
  421. form.submit();
  422. }
  423. </script>
  424. {% endblock %}