remote_instances.html 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  1. {% extends "base.html" %}
  2. {% block title %}Instances distantes{% endblock %}
  3. {% block content %}
  4. <div class="flex items-center justify-between mb-6">
  5. <h1 class="text-xl font-bold text-gray-900">Instances distantes</h1>
  6. <a href="{{ url_for('network.remote_instance_new') }}"
  7. class="bg-blue-600 hover:bg-blue-700 text-white px-4 py-2 rounded-lg text-sm font-medium transition">
  8. + Ajouter une instance
  9. </a>
  10. </div>
  11. {% if not instances %}
  12. <div class="bg-white rounded-xl border border-gray-200 px-6 py-12 text-center text-gray-400">
  13. <p class="text-lg">Aucune instance distante configurée.</p>
  14. <p class="text-sm mt-2">Ajoutez une instance pour voir son état et déclencher des sauvegardes à distance.</p>
  15. <a href="{{ url_for('network.remote_instance_new') }}" class="mt-4 inline-block text-blue-600 hover:underline text-sm">
  16. Ajouter une première instance →
  17. </a>
  18. </div>
  19. {% else %}
  20. <div class="space-y-4">
  21. {% for inst in instances %}
  22. {% set status_color = {
  23. 'online': 'bg-green-100 text-green-700',
  24. 'error': 'bg-red-100 text-red-700',
  25. 'offline': 'bg-gray-100 text-gray-500',
  26. }.get(inst.status, 'bg-gray-100 text-gray-400') %}
  27. <div class="bg-white rounded-xl border border-gray-200 shadow-sm p-5">
  28. <div class="flex items-start justify-between gap-4">
  29. <div class="space-y-2 min-w-0 flex-1">
  30. <div class="flex items-center gap-2 flex-wrap">
  31. <span class="font-semibold text-gray-900">{{ inst.name }}</span>
  32. <span class="text-xs px-2 py-0.5 rounded-full font-medium {{ status_color }}">
  33. {{ inst.status or 'unknown' }}
  34. </span>
  35. {% if inst.last_seen %}
  36. <span class="text-xs text-gray-400">
  37. vu {{ inst.last_seen.strftime('%d/%m %H:%M') }}
  38. </span>
  39. {% endif %}
  40. </div>
  41. <p class="text-sm font-mono text-gray-500">{{ inst.url_display }}</p>
  42. {% if inst.remote_runs %}
  43. <div class="mt-3 border-t border-gray-100 pt-3">
  44. <p class="text-xs font-semibold text-gray-500 uppercase tracking-wide mb-2">
  45. Jobs ({{ inst.remote_runs | length }})
  46. </p>
  47. <div class="grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 gap-2">
  48. {% for rr in inst.remote_runs %}
  49. {% set run_color = {
  50. 'success': 'text-green-600',
  51. 'error': 'text-red-600',
  52. 'running': 'text-blue-600',
  53. }.get(rr.last_status, 'text-gray-400') %}
  54. <div class="text-xs bg-gray-50 rounded-lg px-3 py-2 space-y-0.5">
  55. <p class="font-medium text-gray-800 truncate">{{ rr.job_name }}</p>
  56. <p class="text-gray-400">{{ rr.job_type }}</p>
  57. {% if rr.last_run_at %}
  58. <p class="{{ run_color }} font-medium">
  59. {{ rr.last_status }} — {{ rr.last_run_at.strftime('%d/%m %H:%M') }}
  60. </p>
  61. {% else %}
  62. <p class="text-gray-300">jamais exécuté</p>
  63. {% endif %}
  64. {% if rr.last_size_bytes %}
  65. <p class="text-gray-400">{{ rr.last_size_human }}</p>
  66. {% endif %}
  67. </div>
  68. {% endfor %}
  69. </div>
  70. </div>
  71. {% endif %}
  72. </div>
  73. <div class="flex items-center gap-2 shrink-0 flex-wrap justify-end">
  74. <form method="post" action="{{ url_for('network.remote_instance_test', inst_id=inst.id) }}">
  75. <button type="submit"
  76. class="bg-gray-50 hover:bg-gray-100 text-gray-700 text-xs px-3 py-1.5 rounded border border-gray-200 transition">
  77. Tester
  78. </button>
  79. </form>
  80. <form method="post" action="{{ url_for('network.remote_instance_sync', inst_id=inst.id) }}">
  81. <button type="submit"
  82. class="bg-gray-50 hover:bg-gray-100 text-gray-700 text-xs px-3 py-1.5 rounded border border-gray-200 transition">
  83. Synchroniser
  84. </button>
  85. </form>
  86. <a href="{{ url_for('network.remote_instance_edit', inst_id=inst.id) }}"
  87. class="bg-gray-50 hover:bg-gray-100 text-gray-700 text-xs px-3 py-1.5 rounded border border-gray-200 transition">
  88. Éditer
  89. </a>
  90. <form method="post" action="{{ url_for('network.remote_instance_delete', inst_id=inst.id) }}"
  91. onsubmit="return confirm('Supprimer l\'instance « {{ inst.name }} » ?')">
  92. <button type="submit"
  93. class="text-red-300 hover:text-red-600 text-xs px-2 py-1.5 rounded hover:bg-red-50 transition">
  94. </button>
  95. </form>
  96. </div>
  97. </div>
  98. </div>
  99. {% endfor %}
  100. </div>
  101. {% endif %}
  102. {% endblock %}