archives_overview.html 7.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174
  1. {% extends "base.html" %}
  2. {% block title %}Vue globale des archives{% endblock %}
  3. {% block content %}
  4. <div class="space-y-8">
  5. <div class="flex items-center justify-between">
  6. <div>
  7. <h1 class="text-2xl font-bold text-gray-900">Vue globale des archives</h1>
  8. <p class="text-sm text-gray-500 mt-1">Toutes les destinations — local, SSH et instances fédérées</p>
  9. </div>
  10. <a href="{{ url_for('overview.overview') }}" class="btn-ghost btn-sm">
  11. ↻ Rafraîchir
  12. </a>
  13. </div>
  14. {% for loc in locations %}
  15. <div class="bg-white rounded-xl shadow-sm border border-gray-200 overflow-hidden">
  16. {# En-tête de la section #}
  17. <div class="px-6 py-4 bg-gray-50 border-b border-gray-200 flex items-center gap-3">
  18. {% if loc.type == "local" %}
  19. <span class="inline-flex items-center gap-1 bg-blue-100 text-blue-700 text-xs font-semibold px-2.5 py-1 rounded-full">
  20. Local
  21. </span>
  22. {% elif loc.type == "ssh" %}
  23. <span class="inline-flex items-center gap-1 bg-slate-100 text-slate-700 text-xs font-semibold px-2.5 py-1 rounded-full">
  24. SSH
  25. </span>
  26. {% else %}
  27. <span class="inline-flex items-center gap-1 bg-purple-100 text-purple-700 text-xs font-semibold px-2.5 py-1 rounded-full">
  28. Instance
  29. </span>
  30. {% endif %}
  31. <span class="font-semibold text-gray-800">{{ loc.label }}</span>
  32. {% if loc.type == "instance" and loc.instance_url is defined %}
  33. <span class="text-xs text-gray-400">{{ loc.instance_url }}</span>
  34. {% endif %}
  35. </div>
  36. {# Erreur de connexion #}
  37. {% if loc.error %}
  38. <div class="px-6 py-5 flex items-start gap-3 text-sm text-red-700 bg-red-50">
  39. <span class="text-base shrink-0">⚠</span>
  40. <span>{{ loc.error }}</span>
  41. </div>
  42. {% else %}
  43. {# Groupes par job #}
  44. {% set ns = namespace(has_content=false) %}
  45. {% for group in loc.groups %}
  46. {% if group.archives %}
  47. {% set ns.has_content = true %}
  48. {% endif %}
  49. {% endfor %}
  50. {% if loc.orphaned %}{% set ns.has_content = true %}{% endif %}
  51. {% if not ns.has_content %}
  52. <div class="px-6 py-8 text-center text-sm text-gray-400">
  53. Aucune archive sur cette destination.
  54. </div>
  55. {% else %}
  56. <div class="divide-y divide-gray-100">
  57. {% for group in loc.groups %}
  58. {% if group.archives %}
  59. <div class="px-6 py-4">
  60. {# En-tête du groupe #}
  61. <div class="flex items-center justify-between mb-3">
  62. <div class="flex items-center gap-2">
  63. <span class="font-medium text-gray-800">{{ group.job.name }}</span>
  64. <span class="text-xs bg-gray-100 text-gray-500 px-2 py-0.5 rounded-full">
  65. {{ group.job.type }}
  66. </span>
  67. <span class="text-xs bg-green-50 text-green-700 border border-green-200 px-2 py-0.5 rounded-full">
  68. rétention : {{ group.retention_label }}
  69. </span>
  70. </div>
  71. <form method="post" action="{{ url_for('overview.overview_retention') }}"
  72. onsubmit="return confirm('Appliquer la rétention pour « {{ group.job.name }} » sur cette destination ?')">
  73. <input type="hidden" name="job_id" value="{{ group.job.id }}">
  74. <input type="hidden" name="loc_type" value="{{ loc.type }}">
  75. {% if loc.type == "ssh" %}<input type="hidden" name="dest_id" value="{{ loc.dest_id }}">{% endif %}
  76. {% if loc.type == "instance" %}<input type="hidden" name="instance_id" value="{{ loc.instance_id }}">{% endif %}
  77. <button type="submit" class="btn-secondary btn-sm">
  78. ↺ Appliquer la rétention
  79. </button>
  80. </form>
  81. </div>
  82. {# Table des archives #}
  83. <div class="rounded-lg border border-gray-100 overflow-hidden">
  84. <table class="w-full text-sm">
  85. <thead class="bg-gray-50 text-xs text-gray-500 uppercase tracking-wide">
  86. <tr>
  87. <th class="text-left px-4 py-2 font-medium">Archive</th>
  88. <th class="text-right px-4 py-2 font-medium">Taille</th>
  89. <th class="text-right px-4 py-2 font-medium">Date</th>
  90. <th class="px-4 py-2"></th>
  91. </tr>
  92. </thead>
  93. <tbody class="divide-y divide-gray-50">
  94. {% for arch in group.archives %}
  95. <tr class="hover:bg-gray-50 transition">
  96. <td class="px-4 py-2.5 font-mono text-xs text-gray-700">{{ arch.name }}</td>
  97. <td class="px-4 py-2.5 text-right text-gray-500 tabular-nums">{{ arch.size_human }}</td>
  98. <td class="px-4 py-2.5 text-right text-gray-500 tabular-nums">{{ arch.date_str }}</td>
  99. <td class="px-4 py-2.5 text-right">
  100. <form method="post" action="{{ url_for('overview.overview_delete') }}"
  101. onsubmit="return confirm('Supprimer « {{ arch.name }} » ?')">
  102. <input type="hidden" name="name" value="{{ arch.name }}">
  103. <input type="hidden" name="loc_type" value="{{ loc.type }}">
  104. {% if loc.type == "ssh" %}<input type="hidden" name="dest_id" value="{{ loc.dest_id }}">{% endif %}
  105. {% if loc.type == "instance" %}<input type="hidden" name="instance_id" value="{{ loc.instance_id }}">{% endif %}
  106. <button type="submit" class="btn-danger btn-icon-sm">✕</button>
  107. </form>
  108. </td>
  109. </tr>
  110. {% endfor %}
  111. </tbody>
  112. </table>
  113. </div>
  114. </div>
  115. {% endif %}
  116. {% endfor %}
  117. {# Archives orphelines (ne correspondent à aucun job) #}
  118. {% if loc.orphaned %}
  119. <div class="px-6 py-4">
  120. <div class="flex items-center gap-2 mb-3">
  121. <span class="font-medium text-gray-500">Sans job associé</span>
  122. <span class="text-xs bg-yellow-50 text-yellow-700 border border-yellow-200 px-2 py-0.5 rounded-full">
  123. {{ loc.orphaned | length }} archive(s)
  124. </span>
  125. </div>
  126. <div class="rounded-lg border border-gray-100 overflow-hidden">
  127. <table class="w-full text-sm">
  128. <tbody class="divide-y divide-gray-50">
  129. {% for arch in loc.orphaned %}
  130. <tr class="hover:bg-gray-50 transition">
  131. <td class="px-4 py-2.5 font-mono text-xs text-gray-700">{{ arch.name }}</td>
  132. <td class="px-4 py-2.5 text-right text-gray-500 tabular-nums">{{ arch.size_human }}</td>
  133. <td class="px-4 py-2.5 text-right text-gray-500 tabular-nums">{{ arch.date_str }}</td>
  134. <td class="px-4 py-2.5 text-right">
  135. <form method="post" action="{{ url_for('overview.overview_delete') }}"
  136. onsubmit="return confirm('Supprimer « {{ arch.name }} » ?')">
  137. <input type="hidden" name="name" value="{{ arch.name }}">
  138. <input type="hidden" name="loc_type" value="{{ loc.type }}">
  139. {% if loc.type == "ssh" %}<input type="hidden" name="dest_id" value="{{ loc.dest_id }}">{% endif %}
  140. {% if loc.type == "instance" %}<input type="hidden" name="instance_id" value="{{ loc.instance_id }}">{% endif %}
  141. <button type="submit" class="btn-danger btn-icon-sm">✕</button>
  142. </form>
  143. </td>
  144. </tr>
  145. {% endfor %}
  146. </tbody>
  147. </table>
  148. </div>
  149. </div>
  150. {% endif %}
  151. </div>
  152. {% endif %}
  153. {% endif %}
  154. </div>
  155. {% endfor %}
  156. </div>
  157. {% endblock %}