job_history.html 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114
  1. {% extends "base.html" %}
  2. {% block title %}Historique — {{ job.name }}{% endblock %}
  3. {% block content %}
  4. <div class="mb-6 flex items-center gap-4">
  5. <a href="{{ url_for('jobs.index') }}" class="text-gray-400 hover:text-gray-600 text-sm">← Dashboard</a>
  6. <h1 class="text-xl font-bold text-gray-900">{{ job.name }}</h1>
  7. <span class="bg-gray-100 text-gray-600 text-xs px-2 py-0.5 rounded font-mono">{{ job.type }}</span>
  8. <span class="text-gray-400 text-sm font-mono">{{ job.cron_expr }}</span>
  9. </div>
  10. <div class="bg-white rounded-xl border border-gray-200 shadow-sm overflow-hidden">
  11. <div class="px-6 py-4 border-b border-gray-100">
  12. <h2 class="text-sm font-semibold text-gray-700">
  13. Historique des exécutions
  14. <span class="text-gray-400 font-normal">({{ runs | length }} entrées)</span>
  15. </h2>
  16. </div>
  17. {% if not runs %}
  18. <div class="px-6 py-10 text-center text-gray-400 text-sm">
  19. Aucune exécution enregistrée pour ce job.
  20. </div>
  21. {% else %}
  22. <div class="overflow-x-auto">
  23. <table class="w-full text-sm">
  24. <thead>
  25. <tr class="text-xs text-gray-500 uppercase tracking-wide bg-gray-50">
  26. <th class="px-6 py-3 text-left font-medium">Début</th>
  27. <th class="px-6 py-3 text-left font-medium">Fin</th>
  28. <th class="px-6 py-3 text-left font-medium">Durée</th>
  29. <th class="px-6 py-3 text-left font-medium">Statut</th>
  30. <th class="px-6 py-3 text-left font-medium">Archive</th>
  31. <th class="px-6 py-3 text-left font-medium">Taille</th>
  32. <th class="px-6 py-3 text-left font-medium">Log</th>
  33. <th class="px-6 py-3 text-left font-medium">Action</th>
  34. </tr>
  35. </thead>
  36. <tbody class="divide-y divide-gray-100">
  37. {% for run in runs %}
  38. <tr class="hover:bg-gray-50">
  39. <td class="px-6 py-3 text-xs text-gray-700 whitespace-nowrap">
  40. {{ run.started_at.strftime('%d/%m/%Y %H:%M:%S') if run.started_at else '—' }}
  41. </td>
  42. <td class="px-6 py-3 text-xs text-gray-500 whitespace-nowrap">
  43. {{ run.finished_at.strftime('%H:%M:%S') if run.finished_at else '—' }}
  44. </td>
  45. <td class="px-6 py-3 text-xs text-gray-500">
  46. {% if run.duration_seconds is not none %}
  47. {% if run.duration_seconds >= 60 %}
  48. {{ (run.duration_seconds // 60) }}min {{ run.duration_seconds % 60 }}s
  49. {% else %}
  50. {{ run.duration_seconds }}s
  51. {% endif %}
  52. {% else %}
  53. {% endif %}
  54. </td>
  55. <td class="px-6 py-3">
  56. {% if run.status == 'success' %}
  57. <span class="bg-green-100 text-green-700 text-xs font-medium px-2 py-0.5 rounded-full">✓ succès</span>
  58. {% elif run.status == 'error' %}
  59. <span class="bg-red-100 text-red-700 text-xs font-medium px-2 py-0.5 rounded-full">✗ erreur</span>
  60. {% elif run.status == 'running' %}
  61. <span class="bg-blue-100 text-blue-700 text-xs font-medium px-2 py-0.5 rounded-full animate-pulse">⟳ en cours</span>
  62. {% else %}
  63. <span class="text-gray-400 text-xs">{{ run.status or '—' }}</span>
  64. {% endif %}
  65. </td>
  66. <td class="px-6 py-3 text-xs font-mono text-gray-600">
  67. {{ run.archive_name or '—' }}
  68. </td>
  69. <td class="px-6 py-3 text-xs text-gray-500">
  70. {{ run.size_human if run.size_bytes else '—' }}
  71. </td>
  72. <td class="px-6 py-3">
  73. {% if run.log_text %}
  74. <details>
  75. <summary class="cursor-pointer text-xs text-blue-600 hover:underline">Voir</summary>
  76. <pre class="mt-2 text-xs bg-gray-900 text-gray-100 p-3 rounded-lg overflow-x-auto max-w-xl whitespace-pre-wrap">{{ run.log_text }}</pre>
  77. </details>
  78. {% else %}
  79. <span class="text-gray-300 text-xs">—</span>
  80. {% endif %}
  81. </td>
  82. <td class="px-6 py-3">
  83. {% if run.status == 'success' and run.archive_name %}
  84. <div class="flex flex-col gap-1">
  85. <a href="{{ url_for('jobs.archive_restore', archive_name=run.archive_name) }}"
  86. class="text-xs text-orange-600 hover:text-orange-800 hover:underline whitespace-nowrap">
  87. ↩ Restaurer
  88. </a>
  89. {% set destinations = job.destination_id and [job.destination] or [] %}
  90. {% if destinations %}
  91. <form method="post" action="{{ url_for('dest.archive_transfer', archive_name=run.archive_name) }}">
  92. <input type="hidden" name="destination_id" value="{{ job.destination_id }}">
  93. <button type="submit" class="text-xs text-blue-600 hover:text-blue-800 hover:underline whitespace-nowrap text-left">
  94. ↑ Transférer
  95. </button>
  96. </form>
  97. {% endif %}
  98. </div>
  99. {% else %}
  100. <span class="text-gray-300 text-xs">—</span>
  101. {% endif %}
  102. </td>
  103. </tr>
  104. {% endfor %}
  105. </tbody>
  106. </table>
  107. </div>
  108. {% endif %}
  109. </div>
  110. {% endblock %}