job_history.html 5.9 KB

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