settings.html 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138
  1. {% extends "base.html" %}
  2. {% block title %}Paramètres{% endblock %}
  3. {% block content %}
  4. <div class="max-w-xl">
  5. <h1 class="text-xl font-bold text-gray-900 mb-6">Paramètres</h1>
  6. <div class="bg-white rounded-xl border border-gray-200 p-6 space-y-3 mb-6">
  7. <h2 class="text-sm font-semibold text-gray-700 uppercase tracking-wide">API — Token d'accès</h2>
  8. <p class="text-xs text-gray-500">
  9. Communiquez ce token aux autres instances BackupManager pour qu'elles puissent se connecter à celle-ci.
  10. </p>
  11. <div class="flex items-center gap-2">
  12. <input type="text" id="api-token" readonly value="{{ api_token }}"
  13. class="flex-1 border border-gray-200 bg-gray-50 rounded-lg px-3 py-2 text-sm font-mono text-gray-700 focus:outline-none select-all">
  14. <button type="button" onclick="copyToken()"
  15. class="shrink-0 bg-gray-100 hover:bg-gray-200 text-gray-700 text-xs px-3 py-2 rounded-lg border border-gray-200 transition">
  16. Copier
  17. </button>
  18. </div>
  19. {% if instance_url %}
  20. <p class="text-xs text-gray-400">
  21. URL de cette instance : <span class="font-mono">{{ instance_url }}</span>
  22. </p>
  23. {% endif %}
  24. </div>
  25. <form method="post" class="space-y-6">
  26. <div class="bg-white rounded-xl border border-gray-200 p-6 space-y-4">
  27. <h2 class="text-sm font-semibold text-gray-700 uppercase tracking-wide">Serveur SMTP</h2>
  28. <div class="grid grid-cols-3 gap-3">
  29. <div class="col-span-2">
  30. <label class="block text-sm font-medium text-gray-700 mb-1">Hôte SMTP</label>
  31. <input type="text" name="smtp_host" value="{{ cfg.smtp_host }}"
  32. placeholder="smtp.exemple.fr"
  33. class="w-full border border-gray-300 rounded-lg px-3 py-2 text-sm font-mono focus:outline-none focus:ring-2 focus:ring-blue-500">
  34. </div>
  35. <div>
  36. <label class="block text-sm font-medium text-gray-700 mb-1">Port</label>
  37. <input type="number" name="smtp_port" min="1" max="65535"
  38. value="{{ cfg.smtp_port or 587 }}"
  39. class="w-full border border-gray-300 rounded-lg px-3 py-2 text-sm font-mono focus:outline-none focus:ring-2 focus:ring-blue-500">
  40. </div>
  41. </div>
  42. <div class="grid grid-cols-2 gap-3">
  43. <div>
  44. <label class="block text-sm font-medium text-gray-700 mb-1">Utilisateur</label>
  45. <input type="text" name="smtp_user" value="{{ cfg.smtp_user }}"
  46. placeholder="user@exemple.fr"
  47. class="w-full border border-gray-300 rounded-lg px-3 py-2 text-sm font-mono focus:outline-none focus:ring-2 focus:ring-blue-500">
  48. </div>
  49. <div>
  50. <label class="block text-sm font-medium text-gray-700 mb-1">Mot de passe</label>
  51. <input type="password" name="smtp_password" value="{{ cfg.smtp_password }}"
  52. placeholder="••••••••"
  53. class="w-full border border-gray-300 rounded-lg px-3 py-2 text-sm focus:outline-none focus:ring-2 focus:ring-blue-500">
  54. </div>
  55. </div>
  56. <div class="grid grid-cols-2 gap-3">
  57. <div>
  58. <label class="block text-sm font-medium text-gray-700 mb-1">Expéditeur (From)</label>
  59. <input type="email" name="smtp_from" value="{{ cfg.smtp_from }}"
  60. placeholder="backup@exemple.fr"
  61. class="w-full border border-gray-300 rounded-lg px-3 py-2 text-sm font-mono focus:outline-none focus:ring-2 focus:ring-blue-500">
  62. <p class="text-xs text-gray-400 mt-1">Si vide, utilise l'utilisateur SMTP.</p>
  63. </div>
  64. <div>
  65. <label class="block text-sm font-medium text-gray-700 mb-1">Destinataire (To)</label>
  66. <input type="email" name="smtp_to" value="{{ cfg.smtp_to }}"
  67. placeholder="admin@exemple.fr"
  68. class="w-full border border-gray-300 rounded-lg px-3 py-2 text-sm font-mono focus:outline-none focus:ring-2 focus:ring-blue-500">
  69. </div>
  70. </div>
  71. <div class="flex items-center gap-6">
  72. <label class="flex items-center gap-2">
  73. <input type="checkbox" name="smtp_tls" value="1"
  74. {% if cfg.smtp_tls == '1' %}checked{% endif %}
  75. class="rounded border-gray-300 text-blue-600">
  76. <span class="text-sm font-medium text-gray-700">STARTTLS</span>
  77. </label>
  78. <label class="flex items-center gap-2">
  79. <input type="checkbox" name="smtp_ssl" value="1"
  80. {% if cfg.smtp_ssl == '1' %}checked{% endif %}
  81. class="rounded border-gray-300 text-blue-600">
  82. <span class="text-sm font-medium text-gray-700">SSL/TLS direct (port 465)</span>
  83. </label>
  84. </div>
  85. </div>
  86. <div class="bg-white rounded-xl border border-gray-200 p-6 space-y-3">
  87. <h2 class="text-sm font-semibold text-gray-700 uppercase tracking-wide">Déclenchement</h2>
  88. <label class="flex items-center gap-2">
  89. <input type="checkbox" name="notify_on_error" value="1"
  90. {% if cfg.notify_on_error != '0' %}checked{% endif %}
  91. class="rounded border-gray-300 text-blue-600">
  92. <span class="text-sm font-medium text-gray-700">Notifier en cas d'erreur</span>
  93. </label>
  94. <label class="flex items-center gap-2">
  95. <input type="checkbox" name="notify_on_success" value="1"
  96. {% if cfg.notify_on_success == '1' %}checked{% endif %}
  97. class="rounded border-gray-300 text-blue-600">
  98. <span class="text-sm font-medium text-gray-700">Notifier en cas de succès</span>
  99. </label>
  100. </div>
  101. <div class="flex gap-3 flex-wrap">
  102. <button type="submit" name="action" value="save"
  103. class="bg-blue-600 hover:bg-blue-700 text-white px-5 py-2 rounded-lg font-medium text-sm transition">
  104. Enregistrer
  105. </button>
  106. <button type="submit" name="action" value="test_smtp"
  107. class="bg-white hover:bg-gray-50 text-gray-700 border border-gray-300 px-5 py-2 rounded-lg font-medium text-sm transition">
  108. Envoyer un email de test
  109. </button>
  110. </div>
  111. </form>
  112. </div>
  113. <script>
  114. function copyToken() {
  115. const input = document.getElementById('api-token');
  116. navigator.clipboard.writeText(input.value).then(() => {
  117. const btn = event.target;
  118. btn.textContent = 'Copié !';
  119. setTimeout(() => btn.textContent = 'Copier', 2000);
  120. });
  121. }
  122. </script>
  123. {% endblock %}