| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152 |
- {% extends "base.html" %}
- {% block title %}Dashboard{% endblock %}
- {% block content %}
- {# ── Statistiques rapides ─────────────────────────────────────────────────── #}
- {% set total = jobs | length %}
- {% set enabled_count = jobs | selectattr('enabled') | list | length %}
- {% set recent_runs = last_runs.values() | select | list %}
- {% set success_count = recent_runs | selectattr('status', 'equalto', 'success') | list | length %}
- {% set error_count = recent_runs | selectattr('status', 'equalto', 'error') | list | length %}
- {% set running_count = recent_runs | selectattr('status', 'equalto', 'running') | list | length %}
- <div class="grid grid-cols-2 sm:grid-cols-4 gap-4 mb-8">
- <div class="bg-white rounded-xl border border-gray-200 px-5 py-4">
- <p class="text-xs text-gray-500 uppercase tracking-wide">Jobs</p>
- <p class="text-3xl font-bold text-gray-800 mt-1">{{ total }}</p>
- <p class="text-xs text-gray-400 mt-1">{{ enabled_count }} actifs</p>
- </div>
- <div class="bg-white rounded-xl border border-gray-200 px-5 py-4">
- <p class="text-xs text-gray-500 uppercase tracking-wide">Succès</p>
- <p class="text-3xl font-bold text-green-600 mt-1">{{ success_count }}</p>
- <p class="text-xs text-gray-400 mt-1">dernière exécution</p>
- </div>
- <div class="bg-white rounded-xl border border-gray-200 px-5 py-4">
- <p class="text-xs text-gray-500 uppercase tracking-wide">Erreurs</p>
- <p class="text-3xl font-bold {% if error_count > 0 %}text-red-600{% else %}text-gray-400{% endif %} mt-1">
- {{ error_count }}
- </p>
- <p class="text-xs text-gray-400 mt-1">dernière exécution</p>
- </div>
- <div class="bg-white rounded-xl border border-gray-200 px-5 py-4">
- <p class="text-xs text-gray-500 uppercase tracking-wide">En cours</p>
- <p class="text-3xl font-bold {% if running_count > 0 %}text-blue-600{% else %}text-gray-400{% endif %} mt-1">
- {{ running_count }}
- </p>
- <p class="text-xs text-gray-400 mt-1">actuellement</p>
- </div>
- </div>
- {# ── Table des jobs ───────────────────────────────────────────────────────── #}
- <div class="bg-white rounded-xl border border-gray-200 shadow-sm overflow-hidden">
- <div class="px-6 py-4 border-b border-gray-100 flex items-center justify-between">
- <h2 class="text-base font-semibold text-gray-800">Jobs de sauvegarde</h2>
- </div>
- {% if not jobs %}
- <div class="px-6 py-12 text-center text-gray-400">
- <p class="text-lg">Aucun job configuré.</p>
- <a href="{{ url_for('job_new') }}" class="mt-3 inline-block text-blue-600 hover:underline text-sm">
- Créer le premier job →
- </a>
- </div>
- {% else %}
- <div class="overflow-x-auto">
- <table class="w-full text-sm">
- <thead>
- <tr class="text-xs text-gray-500 uppercase tracking-wide bg-gray-50">
- <th class="px-6 py-3 text-left font-medium">Nom</th>
- <th class="px-6 py-3 text-left font-medium">Type</th>
- <th class="px-6 py-3 text-left font-medium">Planification</th>
- <th class="px-6 py-3 text-left font-medium">Prochaine exéc.</th>
- <th class="px-6 py-3 text-left font-medium">Dernière exéc.</th>
- <th class="px-6 py-3 text-left font-medium">Statut</th>
- <th class="px-6 py-3 text-left font-medium">Taille</th>
- <th class="px-6 py-3 text-right font-medium">Actions</th>
- </tr>
- </thead>
- <tbody class="divide-y divide-gray-100">
- {% for job in jobs %}
- {% set run = last_runs.get(job.id) %}
- <tr class="hover:bg-gray-50 {% if not job.enabled %}opacity-50{% endif %}">
- <td class="px-6 py-4 font-medium text-gray-900">{{ job.name }}</td>
- <td class="px-6 py-4">
- <span class="bg-gray-100 text-gray-600 text-xs px-2 py-0.5 rounded font-mono">
- {{ job.type }}
- </span>
- </td>
- <td class="px-6 py-4 font-mono text-xs text-gray-600">{{ job.cron_expr }}</td>
- <td class="px-6 py-4 text-xs text-gray-500">
- {% set next = job.next_run() %}
- {% if next and job.enabled %}
- {{ next.strftime('%d/%m %H:%M') }}
- {% else %}
- <span class="text-gray-300">—</span>
- {% endif %}
- </td>
- <td class="px-6 py-4 text-xs text-gray-500">
- {% if run and run.started_at %}
- {{ run.started_at.strftime('%d/%m/%Y %H:%M') }}
- {% else %}
- <span class="text-gray-300">Jamais</span>
- {% endif %}
- </td>
- <td class="px-6 py-4">
- {% if run %}
- {% if run.status == 'success' %}
- <span class="bg-green-100 text-green-700 text-xs font-medium px-2 py-0.5 rounded-full">✓ succès</span>
- {% elif run.status == 'error' %}
- <span class="bg-red-100 text-red-700 text-xs font-medium px-2 py-0.5 rounded-full">✗ erreur</span>
- {% elif run.status == 'running' %}
- <span class="bg-blue-100 text-blue-700 text-xs font-medium px-2 py-0.5 rounded-full animate-pulse">⟳ en cours</span>
- {% endif %}
- {% else %}
- <span class="text-gray-300 text-xs">—</span>
- {% endif %}
- </td>
- <td class="px-6 py-4 text-xs text-gray-500">
- {% if run and run.size_bytes %}{{ run.size_human }}{% else %}—{% endif %}
- </td>
- <td class="px-6 py-4 text-right">
- <div class="flex items-center justify-end gap-2">
- <form method="post" action="{{ url_for('job_run_now', job_id=job.id) }}"
- onsubmit="return confirm('Lancer « {{ job.name }} » maintenant ?')">
- <button type="submit"
- class="bg-blue-50 hover:bg-blue-100 text-blue-700 text-xs font-medium px-2.5 py-1 rounded transition">
- ▶ Lancer
- </button>
- </form>
- <a href="{{ url_for('job_history', job_id=job.id) }}"
- class="text-gray-400 hover:text-gray-700 text-xs px-2 py-1 rounded hover:bg-gray-100 transition">
- Historique
- </a>
- <a href="{{ url_for('job_edit', job_id=job.id) }}"
- class="text-gray-400 hover:text-gray-700 text-xs px-2 py-1 rounded hover:bg-gray-100 transition">
- Éditer
- </a>
- <form method="post" action="{{ url_for('job_toggle', job_id=job.id) }}">
- <button type="submit"
- class="text-gray-400 hover:text-gray-700 text-xs px-2 py-1 rounded hover:bg-gray-100 transition"
- title="{{ 'Désactiver' if job.enabled else 'Activer' }}">
- {{ '⏸' if job.enabled else '▶' }}
- </button>
- </form>
- <form method="post" action="{{ url_for('job_delete', job_id=job.id) }}"
- onsubmit="return confirm('Supprimer définitivement « {{ job.name }} » et son historique ?')">
- <button type="submit"
- class="text-red-300 hover:text-red-600 text-xs px-2 py-1 rounded hover:bg-red-50 transition">
- ✕
- </button>
- </form>
- </div>
- </td>
- </tr>
- {% endfor %}
- </tbody>
- </table>
- </div>
- {% endif %}
- </div>
- {% endblock %}
|