index.twig 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. {% extends 'layout.twig' %}
  2. {% block title %}Policies — IRDB{% endblock %}
  3. {% block content %}
  4. {% import 'partials/sort.twig' as sort %}
  5. <div class="mx-auto max-w-5xl">
  6. <div class="flex items-center justify-between">
  7. <h1 class="text-2xl font-semibold tracking-tight">Policies</h1>
  8. <span class="text-sm text-slate-500 dark:text-slate-400">{{ list.total|default(0) }} total</span>
  9. </div>
  10. {% if can_write %}
  11. <section class="mt-6 rounded-2xl border border-slate-200 bg-white p-5 shadow-sm dark:border-slate-800 dark:bg-slate-900">
  12. <h2 class="text-sm font-semibold uppercase tracking-wider text-slate-500 dark:text-slate-400">New policy</h2>
  13. <form method="post" action="/app/policies" class="mt-3 grid grid-cols-1 gap-3 md:grid-cols-3 text-sm">
  14. <input type="hidden" name="csrf_token" value="{{ csrf_token }}">
  15. <div>
  16. <label for="p-name" class="block text-xs font-medium text-slate-600 dark:text-slate-400">Name</label>
  17. <input type="text" id="p-name" name="name" required
  18. class="mt-1 w-full rounded-md border border-slate-300 bg-white px-2 py-1.5 font-mono dark:border-slate-700 dark:bg-slate-950">
  19. </div>
  20. <div class="md:col-span-2">
  21. <label for="p-desc" class="block text-xs font-medium text-slate-600 dark:text-slate-400">Description</label>
  22. <input type="text" id="p-desc" name="description"
  23. class="mt-1 w-full rounded-md border border-slate-300 bg-white px-2 py-1.5 dark:border-slate-700 dark:bg-slate-950">
  24. </div>
  25. <div class="md:col-span-3 flex items-center justify-between">
  26. <label class="flex items-center gap-2 text-xs text-slate-600 dark:text-slate-400">
  27. <input type="checkbox" name="include_manual_blocks" value="1" checked> include manual blocks
  28. </label>
  29. <button type="submit" class="rounded-md bg-indigo-600 px-3 py-1.5 text-sm font-medium text-white hover:bg-indigo-500">Create</button>
  30. </div>
  31. <p class="md:col-span-3 text-xs text-slate-400">Thresholds are configured on the policy edit page after creation.</p>
  32. </form>
  33. </section>
  34. {% endif %}
  35. <section class="mt-6 overflow-hidden rounded-2xl border border-slate-200 bg-white shadow-sm dark:border-slate-800 dark:bg-slate-900">
  36. <table class="w-full text-sm" data-sortable-table="policies-index">
  37. <thead class="border-b border-slate-200 bg-slate-50 text-left text-xs uppercase tracking-wider text-slate-500 dark:border-slate-800 dark:bg-slate-950 dark:text-slate-400">
  38. <tr>
  39. {{ sort.th('Name', 'name') }}
  40. {{ sort.th('Description', 'description') }}
  41. {{ sort.th('Categories', 'categories', 'number', 'right') }}
  42. {{ sort.th('Manual blocks', 'manual_blocks') }}
  43. {% if can_write %}<th class="px-4 py-2 text-right font-medium">Actions</th>{% endif %}
  44. </tr>
  45. </thead>
  46. <tbody class="divide-y divide-slate-100 dark:divide-slate-800">
  47. {% for p in list.items|default([]) %}
  48. <tr>
  49. <td class="px-4 py-2" data-sort-value="{{ p.name }}"><a href="/app/policies/{{ p.id }}" class="font-mono text-indigo-600 hover:underline dark:text-indigo-400">{{ p.name }}</a></td>
  50. <td class="px-4 py-2 text-slate-600 dark:text-slate-300" data-sort-value="{{ p.description|default('') }}">{{ p.description|default('—') }}</td>
  51. <td class="px-4 py-2 text-right font-mono" data-sort-value="{{ p.thresholds|length }}">{{ p.thresholds|length }}</td>
  52. <td class="px-4 py-2 text-slate-500 dark:text-slate-400" data-sort-value="{{ p.include_manual_blocks ? 'yes' : 'no' }}">{{ p.include_manual_blocks ? 'yes' : 'no' }}</td>
  53. {% if can_write %}
  54. <td class="px-4 py-2 text-right">
  55. <a href="/app/policies/{{ p.id }}" class="mr-2 text-xs text-indigo-600 hover:underline dark:text-indigo-400">Edit</a>
  56. {% include 'partials/confirm_form.twig' with {
  57. action: '/app/policies/' ~ p.id ~ '/delete',
  58. label: 'Delete',
  59. description: 'Delete this policy. Refused if any consumer references it.',
  60. } only %}
  61. </td>
  62. {% endif %}
  63. </tr>
  64. {% else %}
  65. <tr><td colspan="5" class="px-4 py-6 text-center text-slate-400">No policies.</td></tr>
  66. {% endfor %}
  67. </tbody>
  68. </table>
  69. </section>
  70. </div>
  71. {% endblock %}