base.html 5.9 KB

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