job_history.html 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115
  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 == 'warning' %}
  59. <span class="bg-amber-100 text-amber-700 text-xs font-medium px-2 py-0.5 rounded-full">⚠ transfert partiel</span>
  60. {% elif run.status == 'error' %}
  61. <span class="bg-red-100 text-red-700 text-xs font-medium px-2 py-0.5 rounded-full">✗ erreur</span>
  62. {% elif run.status == 'running' %}
  63. <span class="bg-blue-100 text-blue-700 text-xs font-medium px-2 py-0.5 rounded-full animate-pulse">⟳ en cours</span>
  64. {% else %}
  65. <span class="text-gray-400 text-xs">{{ run.status or '—' }}</span>
  66. {% endif %}
  67. </td>
  68. <td class="px-6 py-3 text-xs font-mono text-gray-600">
  69. {{ run.archive_name or '—' }}
  70. </td>
  71. <td class="px-6 py-3 text-xs text-gray-500">
  72. {{ run.size_human if run.size_bytes else '—' }}
  73. </td>
  74. <td class="px-6 py-3">
  75. {% if run.log_text %}
  76. <details>
  77. <summary class="cursor-pointer text-xs text-blue-600 hover:underline">Voir</summary>
  78. <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>
  79. </details>
  80. {% else %}
  81. <span class="text-gray-300 text-xs">—</span>
  82. {% endif %}
  83. </td>
  84. <td class="px-6 py-3">
  85. {% if run.status in ('success', 'warning') and run.archive_name %}
  86. <div class="flex flex-col gap-1">
  87. <a href="{{ url_for('jobs.archive_restore', archive_name=run.archive_name) }}"
  88. class="text-xs text-orange-600 hover:text-orange-800 hover:underline whitespace-nowrap">
  89. ↩ Restaurer
  90. </a>
  91. {% for jd in job.job_destinations if jd.dest_type == 'ssh' %}
  92. <form method="post" action="{{ url_for('dest.archive_transfer', archive_name=run.archive_name) }}">
  93. <input type="hidden" name="destination_id" value="{{ jd.dest_id }}">
  94. <button type="submit" class="text-xs text-blue-600 hover:text-blue-800 hover:underline whitespace-nowrap text-left">
  95. ↑ {{ jd.label }}
  96. </button>
  97. </form>
  98. {% endfor %}
  99. </div>
  100. {% else %}
  101. <span class="text-gray-300 text-xs">—</span>
  102. {% endif %}
  103. </td>
  104. </tr>
  105. {% endfor %}
  106. </tbody>
  107. </table>
  108. </div>
  109. {% endif %}
  110. </div>
  111. {% endblock %}