dashboard_local.html 7.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140
  1. {% extends "base.html" %}
  2. {% block title %}Dashboard{% endblock %}
  3. {% block content %}
  4. {# ── Statistiques rapides ─────────────────────────────────────────────────── #}
  5. {% set total = jobs | length %}
  6. {% set enabled_count = jobs | selectattr('enabled') | list | length %}
  7. {% set recent_runs = last_runs.values() | select | list %}
  8. {% set success_count = recent_runs | selectattr('status', 'equalto', 'success') | list | length %}
  9. {% set error_count = recent_runs | selectattr('status', 'equalto', 'error') | list | length %}
  10. {% set running_count = recent_runs | selectattr('status', 'equalto', 'running') | list | length %}
  11. <div class="grid grid-cols-2 sm:grid-cols-4 gap-4 mb-8">
  12. <div class="bg-white rounded-xl border border-gray-200 px-5 py-4">
  13. <p class="text-xs text-gray-500 uppercase tracking-wide">Jobs</p>
  14. <p class="text-3xl font-bold text-gray-800 mt-1">{{ total }}</p>
  15. <p class="text-xs text-gray-400 mt-1">{{ enabled_count }} actifs</p>
  16. </div>
  17. <div class="bg-white rounded-xl border border-gray-200 px-5 py-4">
  18. <p class="text-xs text-gray-500 uppercase tracking-wide">Succès</p>
  19. <p class="text-3xl font-bold text-green-600 mt-1">{{ success_count }}</p>
  20. <p class="text-xs text-gray-400 mt-1">dernière exécution</p>
  21. </div>
  22. <div class="bg-white rounded-xl border border-gray-200 px-5 py-4">
  23. <p class="text-xs text-gray-500 uppercase tracking-wide">Erreurs</p>
  24. <p class="text-3xl font-bold {% if error_count > 0 %}text-red-600{% else %}text-gray-400{% endif %} mt-1">
  25. {{ error_count }}
  26. </p>
  27. <p class="text-xs text-gray-400 mt-1">dernière exécution</p>
  28. </div>
  29. <div class="bg-white rounded-xl border border-gray-200 px-5 py-4">
  30. <p class="text-xs text-gray-500 uppercase tracking-wide">En cours</p>
  31. <p class="text-3xl font-bold {% if running_count > 0 %}text-blue-600{% else %}text-gray-400{% endif %} mt-1">
  32. {{ running_count }}
  33. </p>
  34. <p class="text-xs text-gray-400 mt-1">actuellement</p>
  35. </div>
  36. </div>
  37. {# ── Table des jobs ───────────────────────────────────────────────────────── #}
  38. <div class="bg-white rounded-xl border border-gray-200 shadow-sm overflow-hidden">
  39. <div class="px-6 py-4 border-b border-gray-100 flex items-center justify-between">
  40. <h2 class="text-base font-semibold text-gray-800">Jobs de sauvegarde</h2>
  41. </div>
  42. {% if not jobs %}
  43. <div class="px-6 py-12 text-center text-gray-400">
  44. <p class="text-lg">Aucun job configuré.</p>
  45. <a href="{{ url_for('jobs.job_new') }}" class="mt-3 inline-block text-blue-600 hover:underline text-sm">
  46. Créer le premier job →
  47. </a>
  48. </div>
  49. {% else %}
  50. <div class="overflow-x-auto">
  51. <table class="w-full text-sm">
  52. <thead>
  53. <tr class="text-xs text-gray-500 uppercase tracking-wide bg-gray-50">
  54. <th class="px-6 py-3 text-left font-medium">Nom</th>
  55. <th class="px-6 py-3 text-left font-medium">Type</th>
  56. <th class="px-6 py-3 text-left font-medium">Planification</th>
  57. <th class="px-6 py-3 text-left font-medium">Transfert</th>
  58. <th class="px-6 py-3 text-left font-medium">Dernière exéc.</th>
  59. <th class="px-6 py-3 text-left font-medium">Statut</th>
  60. <th class="px-6 py-3 text-left font-medium">Taille</th>
  61. <th class="px-6 py-3 text-right font-medium">Actions</th>
  62. </tr>
  63. </thead>
  64. <tbody class="divide-y divide-gray-100">
  65. {% for job in jobs %}
  66. {% set run = last_runs.get(job.id) %}
  67. <tr class="hover:bg-gray-50 {% if not job.enabled %}opacity-50{% endif %}">
  68. <td class="px-6 py-4 font-medium text-gray-900">{{ job.name }}</td>
  69. <td class="px-6 py-4">
  70. <span class="bg-gray-100 text-gray-600 text-xs px-2 py-0.5 rounded font-mono">
  71. {{ job.type }}
  72. </span>
  73. </td>
  74. <td class="px-6 py-4 font-mono text-xs text-gray-600">{{ job.cron_expr }}</td>
  75. <td class="px-6 py-4">
  76. {% if job.destination %}
  77. <span class="bg-violet-50 text-violet-700 text-xs px-2 py-0.5 rounded font-medium">{{ job.destination.name }}</span>
  78. {% else %}
  79. <span class="bg-gray-100 text-gray-500 text-xs px-2 py-0.5 rounded">Local</span>
  80. {% endif %}
  81. </td>
  82. <td class="px-6 py-4 text-xs text-gray-500">
  83. {% if run and run.started_at %}
  84. {{ run.started_at.strftime('%d/%m/%Y %H:%M') }}
  85. {% else %}
  86. <span class="text-gray-300">Jamais</span>
  87. {% endif %}
  88. </td>
  89. <td class="px-6 py-4">
  90. {% if run %}
  91. {% if run.status == 'success' %}
  92. <span class="bg-green-100 text-green-700 text-xs font-medium px-2 py-0.5 rounded-full">✓ succès</span>
  93. {% elif run.status == 'error' %}
  94. <span class="bg-red-100 text-red-700 text-xs font-medium px-2 py-0.5 rounded-full">✗ erreur</span>
  95. {% elif run.status == 'running' %}
  96. <span class="bg-blue-100 text-blue-700 text-xs font-medium px-2 py-0.5 rounded-full animate-pulse">⟳ en cours</span>
  97. {% endif %}
  98. {% else %}
  99. <span class="text-gray-300 text-xs">—</span>
  100. {% endif %}
  101. </td>
  102. <td class="px-6 py-4 text-xs text-gray-500">
  103. {% if run and run.size_bytes %}{{ run.size_human }}{% else %}—{% endif %}
  104. </td>
  105. <td class="px-6 py-4 text-right">
  106. <div class="flex items-center justify-end gap-2">
  107. <form method="post" action="{{ url_for('jobs.job_run_now', job_id=job.id) }}"
  108. onsubmit="return confirm('Lancer « {{ job.name }} » maintenant ?')">
  109. <button type="submit" class="btn-primary btn-sm">▶ Lancer</button>
  110. </form>
  111. <a href="{{ url_for('jobs.job_history', job_id=job.id) }}"
  112. class="btn-secondary btn-sm">Historique</a>
  113. <a href="{{ url_for('jobs.job_edit', job_id=job.id) }}"
  114. class="btn-secondary btn-sm">Éditer</a>
  115. <form method="post" action="{{ url_for('jobs.job_toggle', job_id=job.id) }}">
  116. <button type="submit" class="btn-ghost btn-icon-sm"
  117. title="{{ 'Désactiver' if job.enabled else 'Activer' }}">
  118. {{ '⏸' if job.enabled else '▶' }}
  119. </button>
  120. </form>
  121. <form method="post" action="{{ url_for('jobs.job_delete', job_id=job.id) }}"
  122. onsubmit="return confirm('Supprimer définitivement « {{ job.name }} » et son historique ?')">
  123. <button type="submit" class="btn-danger btn-icon-sm">✕</button>
  124. </form>
  125. </div>
  126. </td>
  127. </tr>
  128. {% endfor %}
  129. </tbody>
  130. </table>
  131. </div>
  132. {% endif %}
  133. </div>
  134. {% endblock %}