Просмотр исходного кода

fix+feat: navbar sticky fonctionnelle, auto-remplissage nom de job

- Fix sticky : h-full → min-h-screen sur body (h-full bloquait le scroll du document)
- Auto-remplissage du nom depuis app_id / dossier source / nom de base selon le type

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Cédric Hansen 1 месяц назад
Родитель
Сommit
5e96d9dcf8
2 измененных файлов с 40 добавлено и 4 удалено
  1. 2 2
      sources/templates/base.html
  2. 38 2
      sources/templates/job_form.html

+ 2 - 2
sources/templates/base.html

@@ -1,5 +1,5 @@
 <!DOCTYPE html>
-<html lang="fr" class="h-full bg-gray-50">
+<html lang="fr" class="bg-gray-50">
 <head>
   <meta charset="UTF-8">
   <meta name="viewport" content="width=device-width, initial-scale=1.0">
@@ -24,7 +24,7 @@
     }
   </style>
 </head>
-<body class="h-full flex flex-col">
+<body class="min-h-screen flex flex-col">
 
   <div class="sticky top-0 z-50">
   <nav class="bg-gray-900 text-white shadow-lg">

+ 38 - 2
sources/templates/job_form.html

@@ -43,7 +43,7 @@
       <div id="cfg-ynh_app" class="type-cfg space-y-3">
         <div>
           <label class="block text-sm font-medium text-gray-700 mb-1">Application YunoHost</label>
-          <select name="app_id"
+          <select name="app_id" id="app_id"
                   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">
             {% set current_app_id = (job.config_json | fromjson).get('app_id', '') if job and job.config_json else '' %}
             {% for ynh_app in ynh_apps %}
@@ -371,7 +371,43 @@
     document.getElementById('retention-help').textContent = retentionHelp[mode] || '';
   }
 
-  document.getElementById('job-type').addEventListener('change', showTypeConfig);
+  // Auto-remplissage du nom si le champ est vide
+  const nameInput = document.querySelector('[name=name]');
+  function suggestName() {
+    if (nameInput.value.trim()) return; // ne pas écraser si déjà renseigné
+    const type = document.getElementById('job-type').value;
+    let suggestion = '';
+    if (type === 'ynh_app') {
+      const sel = document.getElementById('app_id');
+      suggestion = sel ? sel.value : '';
+    } else if (type === 'ynh_system') {
+      suggestion = 'Système YunoHost';
+    } else if (type === 'mysql') {
+      const sel = document.getElementById('db-select-mysql');
+      suggestion = sel ? sel.value : '';
+    } else if (type === 'postgresql') {
+      const sel = document.getElementById('db-select-postgresql');
+      suggestion = sel ? sel.value : '';
+    } else if (type === 'custom_dir') {
+      const src = document.querySelector('[name=source_path]');
+      if (src && src.value.trim()) {
+        const parts = src.value.trim().replace(/\/+$/, '').split('/');
+        suggestion = parts[parts.length - 1] || '';
+      }
+    }
+    if (suggestion) nameInput.value = suggestion;
+  }
+
+  document.getElementById('job-type').addEventListener('change', function() { showTypeConfig(); suggestName(); });
+  const appSel = document.getElementById('app_id');
+  if (appSel) appSel.addEventListener('change', suggestName);
+  ['db-select-mysql', 'db-select-postgresql'].forEach(id => {
+    const el = document.getElementById(id);
+    if (el) el.addEventListener('change', suggestName);
+  });
+  const srcPath = document.querySelector('[name=source_path]');
+  if (srcPath) srcPath.addEventListener('input', suggestName);
+
   document.querySelector('[name=retention_mode]').addEventListener('change', updateRetentionHelp);
   showTypeConfig();
   updateRetentionHelp();