|
|
@@ -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();
|