destination_form.html 4.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  1. {% extends "base.html" %}
  2. {% block title %}{{ 'Éditer' if dest else 'Nouvelle destination' }}{% endblock %}
  3. {% block content %}
  4. <div class="max-w-xl">
  5. <div class="mb-6">
  6. <a href="{{ url_for('cfg.settings') + '?tab=destinations' }}" class="text-gray-400 hover:text-gray-600 text-sm">← Destinations</a>
  7. </div>
  8. <h1 class="text-xl font-bold text-gray-900 mb-6">
  9. {{ 'Éditer « ' + dest.name + ' »' if dest else 'Nouvelle destination rsync SSH' }}
  10. </h1>
  11. <form method="post" class="space-y-5">
  12. <div class="bg-white rounded-xl border border-gray-200 p-6 space-y-4">
  13. <h2 class="text-sm font-semibold text-gray-700 uppercase tracking-wide">Connexion SSH</h2>
  14. <div>
  15. <label class="block text-sm font-medium text-gray-700 mb-1">Nom</label>
  16. <input type="text" name="name" required
  17. value="{{ dest.name if dest else '' }}"
  18. placeholder="ex: VPS Hetzner"
  19. 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">
  20. </div>
  21. <div class="grid grid-cols-3 gap-3">
  22. <div class="col-span-2">
  23. <label class="block text-sm font-medium text-gray-700 mb-1">Hôte</label>
  24. <input type="text" name="host" required
  25. value="{{ dest.host if dest else '' }}"
  26. placeholder="backup.exemple.fr"
  27. 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">
  28. </div>
  29. <div>
  30. <label class="block text-sm font-medium text-gray-700 mb-1">Port</label>
  31. <input type="number" name="port" min="1" max="65535"
  32. value="{{ dest.port if dest else 22 }}"
  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. <div>
  37. <label class="block text-sm font-medium text-gray-700 mb-1">Utilisateur SSH</label>
  38. <input type="text" name="user"
  39. value="{{ dest.user if dest else 'root' }}"
  40. placeholder="root"
  41. 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">
  42. </div>
  43. <div>
  44. <label class="block text-sm font-medium text-gray-700 mb-1">Chemin distant</label>
  45. <input type="text" name="remote_path"
  46. value="{{ dest.remote_path if dest else '/home/yunohost.backup/archives' }}"
  47. placeholder="/home/yunohost.backup/archives"
  48. 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">
  49. <p class="text-xs text-gray-400 mt-1">
  50. Répertoire de destination sur le serveur distant. Doit exister et être accessible par l'utilisateur SSH.
  51. </p>
  52. </div>
  53. <div class="flex items-center gap-2">
  54. <input type="checkbox" name="enabled" value="1" id="dest_enabled"
  55. {% if not dest or dest.enabled %}checked{% endif %}
  56. class="rounded border-gray-300 text-blue-600">
  57. <label for="dest_enabled" class="text-sm font-medium text-gray-700">Destination activée</label>
  58. </div>
  59. </div>
  60. {% if pub_key %}
  61. <div class="bg-white rounded-xl border border-gray-200 p-6 space-y-3">
  62. <h2 class="text-sm font-semibold text-gray-700 uppercase tracking-wide">Clé publique SSH</h2>
  63. <p class="text-xs text-gray-500">
  64. Copiez cette clé dans <code class="bg-gray-100 px-1 rounded">~{{ dest.user }}/.ssh/authorized_keys</code>
  65. sur <strong>{{ dest.host }}</strong> pour autoriser le transfert.
  66. </p>
  67. <div class="relative">
  68. <pre id="pubkey" class="bg-gray-900 text-green-400 text-xs p-3 rounded-lg overflow-x-auto whitespace-pre-wrap break-all select-all">{{ pub_key }}</pre>
  69. <button type="button" onclick="navigator.clipboard.writeText(document.getElementById('pubkey').textContent)"
  70. class="absolute top-2 right-2 bg-gray-700 hover:bg-gray-600 text-gray-300 text-xs px-2 py-1 rounded transition">
  71. Copier
  72. </button>
  73. </div>
  74. </div>
  75. {% elif dest %}
  76. <div class="bg-amber-50 border border-amber-200 rounded-xl p-4 text-sm text-amber-800">
  77. ⚠ La clé SSH sera générée lors de l'enregistrement.
  78. </div>
  79. {% endif %}
  80. <div class="flex gap-3">
  81. <button type="submit" class="btn-primary btn-md">
  82. {{ 'Enregistrer' if dest else 'Créer la destination' }}
  83. </button>
  84. <a href="{{ url_for('cfg.settings') + '?tab=destinations' }}" class="btn-secondary btn-md">Annuler</a>
  85. </div>
  86. </form>
  87. </div>
  88. {% endblock %}