base.html 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128
  1. <!DOCTYPE html>
  2. <html lang="fr" class="h-full bg-gray-50">
  3. <head>
  4. <meta charset="UTF-8">
  5. <meta name="viewport" content="width=device-width, initial-scale=1.0">
  6. <title>{% block title %}Backup Manager{% endblock %} — {{ instance_name }}</title>
  7. <link rel="icon" type="image/png" href="{{ url_for('static', filename='icon.png') }}">
  8. <link rel="apple-touch-icon" href="{{ url_for('static', filename='icon.png') }}">
  9. <script src="https://cdn.tailwindcss.com"></script>
  10. <style type="text/tailwindcss">
  11. @layer components {
  12. /* Bouton principal (créer, lancer, enregistrer) — bleu */
  13. .btn-primary { @apply inline-flex items-center gap-1.5 bg-blue-600 hover:bg-blue-700 text-white font-semibold rounded-full shadow-sm transition; }
  14. /* Bouton secondaire (tester, éditer, sync, historique) — gris ardoise */
  15. .btn-secondary { @apply inline-flex items-center gap-1.5 bg-slate-100 hover:bg-slate-200 text-slate-700 font-medium rounded-full transition; }
  16. /* Bouton action légère (rapatrier, toggle, télécharger) — gris neutre */
  17. .btn-ghost { @apply inline-flex items-center gap-1 bg-gray-100 hover:bg-gray-200 text-gray-600 font-medium rounded-full transition; }
  18. /* Bouton destructeur — rouge */
  19. .btn-danger { @apply inline-flex items-center gap-1 bg-red-100 hover:bg-red-200 text-red-600 font-medium rounded-full transition; }
  20. /* Tailles */
  21. .btn-sm { @apply text-xs px-3 py-1.5; }
  22. .btn-md { @apply text-sm px-5 py-2; }
  23. .btn-icon-sm { @apply text-xs px-2 py-1; }
  24. }
  25. </style>
  26. </head>
  27. <body class="h-full flex flex-col">
  28. <nav class="bg-gray-900 text-white shadow-lg">
  29. <div class="max-w-7xl mx-auto px-6 py-3 flex items-center justify-between">
  30. <div class="flex items-center gap-3">
  31. <img src="{{ url_for('static', filename='icon.png') }}" alt="logo" class="w-7 h-7 rounded">
  32. <a href="{{ url_for('jobs.index') }}" class="text-lg font-bold tracking-tight">Backup Manager</a>
  33. <span class="bg-blue-600 text-xs font-medium px-2 py-0.5 rounded">{{ instance_name }}</span>
  34. </div>
  35. <div class="flex items-center gap-4 text-sm">
  36. <a href="{{ url_for('jobs.index') }}"
  37. class="text-gray-300 hover:text-white transition {% if request.endpoint and request.endpoint.startswith('jobs.') and request.endpoint != 'jobs.job_new' %}text-white font-semibold{% endif %}">
  38. Dashboard
  39. </a>
  40. <a href="{{ url_for('jobs.archives') }}"
  41. class="text-gray-300 hover:text-white transition {% if request.endpoint == 'jobs.archives' %}text-white font-semibold{% endif %}">
  42. Archives
  43. </a>
  44. <a href="{{ url_for('cfg.settings') }}"
  45. class="text-gray-300 hover:text-white transition {% if request.endpoint and request.endpoint.startswith('cfg.') %}text-white font-semibold{% endif %}">
  46. Paramètres
  47. </a>
  48. <a href="{{ url_for('jobs.job_new') }}"
  49. class="bg-blue-600 hover:bg-blue-700 text-white px-3 py-1.5 rounded font-medium transition">
  50. + Nouveau job
  51. </a>
  52. </div>
  53. </div>
  54. </nav>
  55. <!-- Barre d'activité sticky -->
  56. <div id="activity-bar"
  57. class="hidden sticky top-0 z-40 bg-gray-900 border-b border-blue-700 text-white text-xs px-6 py-2 flex items-center gap-3 shadow">
  58. <span class="inline-block w-2 h-2 rounded-full bg-blue-400 animate-pulse shrink-0"></span>
  59. <span class="text-blue-300 font-medium shrink-0">En cours</span>
  60. <div id="activity-list" class="flex gap-4 flex-wrap flex-1 text-gray-200"></div>
  61. </div>
  62. <main class="flex-1 max-w-7xl mx-auto w-full px-6 py-8">
  63. {% with messages = get_flashed_messages(with_categories=true) %}
  64. {% if messages %}
  65. <div class="mb-6 space-y-2">
  66. {% for category, message in messages %}
  67. <div class="px-4 py-3 rounded-lg text-sm font-medium
  68. {% if category == 'error' %}bg-red-50 text-red-800 border border-red-200
  69. {% elif category == 'info' %}bg-blue-50 text-blue-800 border border-blue-200
  70. {% else %}bg-green-50 text-green-800 border border-green-200{% endif %}">
  71. {{ message }}
  72. </div>
  73. {% endfor %}
  74. </div>
  75. {% endif %}
  76. {% endwith %}
  77. {% block content %}{% endblock %}
  78. </main>
  79. <footer class="text-center text-xs text-gray-400 py-4">
  80. Backup Manager — instance <strong>{{ instance_name }}</strong>
  81. </footer>
  82. <script>
  83. (function() {
  84. const bar = document.getElementById('activity-bar');
  85. const list = document.getElementById('activity-list');
  86. const LABELS = { backup: 'Sauvegarde', restore: 'Restauration', push: 'Push', pull: 'Pull' };
  87. function elapsed(isoStr) {
  88. const sec = Math.round((Date.now() - new Date(isoStr).getTime()) / 1000);
  89. if (sec < 60) return sec + 's';
  90. return Math.floor(sec / 60) + 'min' + (sec % 60 ? (sec % 60) + 's' : '');
  91. }
  92. function render(items) {
  93. if (!items || items.length === 0) {
  94. bar.classList.add('hidden');
  95. return;
  96. }
  97. bar.classList.remove('hidden');
  98. list.innerHTML = items.map(it => {
  99. const label = LABELS[it.kind] || it.kind;
  100. const since = it.started_at ? ' · ' + elapsed(it.started_at) : '';
  101. const size = it.size_human ? ' · ' + it.size_human : '';
  102. return `<span class="bg-gray-800 rounded px-2 py-0.5">${label} <strong>${it.name}</strong>${since}${size}</span>`;
  103. }).join('');
  104. }
  105. function poll() {
  106. fetch('{{ url_for("api.api_running") }}', {
  107. headers: { 'X-BackupManager-Key': '{{ api_token }}' }
  108. })
  109. .then(r => r.ok ? r.json() : null)
  110. .then(data => render(data && data.running ? data.running : []))
  111. .catch(() => {});
  112. }
  113. poll();
  114. setInterval(poll, 5000);
  115. })();
  116. </script>
  117. </body>
  118. </html>