AP manageur V1.2 (Bêta)

This commit is contained in:
yoannmultigaming committed 2026-11-23 17:27:07 +01:00
1 parent 9d17156a97
commit 2b4e6570bf
5 files changed
+441 -6

No files matched your search

+424 -1
View File
@@ -2230,6 +2230,13 @@
coupé)</span></label>
<label class="check" style="margin:0"><input id="notifEvtQuotaExceeded" type="checkbox" checked><span
data-i18n="notif_evt_quota_exceeded">⚖️ Quota de données dépassé par un appareil</span></label>
<label class="check" style="margin:0"><input id="notifEvtBackupSuccess" type="checkbox" checked><span
data-i18n="notif_evt_backup_success">💾 Sauvegarde créée avec succès</span></label>
<label class="check" style="margin:0"><input id="notifEvtBackupRemoteSuccess" type="checkbox"
checked><span data-i18n="notif_evt_backup_remote_success">☁️ Sauvegarde envoyée sur l’hôte distant (si
configuré)</span></label>
<label class="check" style="margin:0"><input id="notifEvtUpdateAvailable" type="checkbox" checked><span
data-i18n="notif_evt_update_available">🚀 Mise à jour disponible pour AP Manageur</span></label>
<label class="check"
style="margin:0;grid-column:1/-1;background:var(--panel2);padding:10px 14px;border-radius:10px;border:1px solid var(--line);font-weight:600">
<input id="notifEvtStatsReport" type="checkbox" onchange="toggleStatsReportSchedule(this.checked)">
@@ -2412,6 +2419,126 @@
</div>
</div>
<!-- Section Recherche de mise à jour automatique -->
<div style="margin-top:22px;padding-top:18px;border-top:1px solid var(--line)">
<div
style="display:flex;align-items:center;justify-content:space-between;margin-bottom:10px;flex-wrap:wrap;gap:8px">
<div>
<h3 style="margin:0;font-size:15px;display:flex;align-items:center;gap:8px">
<span>🚀</span>
<span data-i18n="step5_update_title">Recherche de mise à jour automatique</span>
<span class="pill" style="font-size:11px" data-i18n="optional_badge">Optionnel</span>
</h3>
<p class="muted" style="font-size:12px;margin:3px 0 0" data-i18n="step5_update_desc">
Vérifie périodiquement si de nouvelles fonctionnalités ou des correctifs de sécurité sont disponibles pour AP Manageur.
</p>
</div>
</div>
<div style="background:var(--panel2);border:1px solid var(--line);border-radius:12px;padding:16px;margin-top:10px">
<label class="check" style="margin:0;font-size:14px;font-weight:600">
<input type="checkbox" id="setupUpdateCheckerEnabled" checked onchange="onToggleSetupUpdateChecker(this.checked)">
<span data-i18n="adv_update_enable_chk">Activer la recherche automatique de mises à jour</span>
</label>
<p class="muted" style="font-size:12px;margin:4px 0 12px 28px" data-i18n="adv_update_enable_hint">
Lorsque cette option est désactivée, aucune requête n’est envoyée vers Gitea et le bouton de mise à jour reste masqué.
</p>
<div id="setupUpdateIntervalGroup" style="margin-top:8px">
<label class="label" for="setupUpdateInterval" data-i18n="adv_update_interval_label" style="font-weight:600;font-size:13px">
Fréquence de vérification automatique
</label>
<select id="setupUpdateInterval" style="width:100%;max-width:360px;margin-top:6px;padding:9px 12px;border-radius:8px;font-size:13px">
<option value="300" data-i18n="interval_5m">Toutes les 5 minutes</option>
<option value="900" data-i18n="interval_15m">Toutes les 15 minutes</option>
<option value="1800" selected data-i18n="interval_30m">Toutes les 30 minutes (Recommandé)</option>
<option value="3600" data-i18n="interval_1h">Toutes les heures</option>
<option value="7200" data-i18n="interval_2h">Toutes les 2 heures</option>
<option value="21600" data-i18n="interval_6h">Toutes les 6 heures</option>
<option value="43200" data-i18n="interval_12h">Toutes les 12 heures</option>
<option value="86400" data-i18n="interval_24h">Une fois par jour (24 heures)</option>
</select>
<p class="muted" style="font-size:12px;margin-top:6px" data-i18n="adv_update_interval_hint">
Définit l’intervalle entre chaque analyse en arrière-plan par le serveur.
</p>
</div>
</div>
</div>
<!-- Section Sauvegardes automatiques (Backup) -->
<div style="margin-top:22px;padding-top:18px;border-top:1px solid var(--line)">
<div
style="display:flex;align-items:center;justify-content:space-between;margin-bottom:10px;flex-wrap:wrap;gap:8px">
<div>
<h3 style="margin:0;font-size:15px;display:flex;align-items:center;gap:8px">
<span>💾</span>
<span data-i18n="step5_backup_title">Sauvegardes automatiques (Backup)</span>
<span class="pill" style="font-size:11px" data-i18n="optional_badge">Optionnel</span>
</h3>
<p class="muted" style="font-size:12px;margin:3px 0 0" data-i18n="step5_backup_desc">
Planifiez des sauvegardes régulières de la configuration, des utilisateurs et des règles pour prévenir toute perte de données.
</p>
</div>
</div>
<div style="background:var(--panel2);border:1px solid var(--line);border-radius:12px;padding:16px;margin-top:10px">
<label class="check" style="margin:0;font-size:14px;font-weight:600">
<input type="checkbox" id="setupBackupCronEnabled" onchange="onToggleSetupBackupCron(this.checked)">
<span data-i18n="backup_cron_enable">Activer la planification des sauvegardes automatiques</span>
</label>
<div id="setupBackupCronBody" style="display:none;margin-top:14px">
<div style="display:grid;grid-template-columns:repeat(auto-fit,minmax(170px,1fr));gap:12px">
<div>
<label class="label" for="setupBackupCronDay" data-i18n="backup_cron_day_label">Fréquence / Jour</label>
<select id="setupBackupCronDay" onchange="syncSetupBackupCronFromSelects()">
<option value="*" selected data-i18n="stats_cron_day_all_short">Tous les jours</option>
<option value="1-5" data-i18n="stats_cron_day_workdays_short">Jours ouvrés (Lun-Ven)</option>
<option value="6,7" data-i18n="stats_cron_day_weekend_short">Week-end (Sam-Dim)</option>
<option value="1" data-i18n="stats_cron_day_mon">Chaque Lundi</option>
<option value="2" data-i18n="stats_cron_day_tue">Chaque Mardi</option>
<option value="3" data-i18n="stats_cron_day_wed">Chaque Mercredi</option>
<option value="4" data-i18n="stats_cron_day_thu">Chaque Jeudi</option>
<option value="5" data-i18n="stats_cron_day_fri">Chaque Vendredi</option>
<option value="6" data-i18n="stats_cron_day_sat">Chaque Samedi</option>
<option value="0" data-i18n="stats_cron_day_sun">Chaque Dimanche</option>
</select>
</div>
<div>
<label class="label" for="setupBackupCronHour" data-i18n="backup_cron_hour_label">Heure</label>
<select id="setupBackupCronHour" onchange="syncSetupBackupCronFromSelects()"></select>
</div>
<div>
<label class="label" for="setupBackupCronMinute" data-i18n="backup_cron_min_label">Minute</label>
<select id="setupBackupCronMinute" onchange="syncSetupBackupCronFromSelects()"></select>
</div>
<div>
<label class="label" for="setupBackupCronRetention" data-i18n="backup_cron_retention_label">Rétention (0 = illimité)</label>
<input id="setupBackupCronRetention" type="number" min="0" max="365" value="7">
</div>
</div>
<div style="margin-top:12px">
<label class="label" for="setupBackupCronExpr" data-i18n="backup_cron_expr_label">Expression Cron</label>
<input id="setupBackupCronExpr" type="text" value="0 3 * * *" placeholder="0 3 * * *"
style="font-family:monospace;margin-bottom:0" oninput="updateSetupBackupCronSummary()">
</div>
<div style="display:flex;align-items:center;justify-content:space-between;flex-wrap:wrap;gap:8px;margin-top:10px">
<div style="display:flex;align-items:center;gap:6px;flex-wrap:wrap">
<span id="setupBackupCronHuman" class="pill pill-blue pill-no-dot" style="font-size:12px">📅 Tous les jours à 03:00</span>
<button type="button" class="secondary" style="padding:3px 9px;font-size:11px"
onclick="applySetupBackupCronPreset('0 3 * * *','*',3,0)" data-i18n="backup_preset_daily">Chaque nuit 03:00</button>
<button type="button" class="secondary" style="padding:3px 9px;font-size:11px"
onclick="applySetupBackupCronPreset('0 4 * * 0','0',4,0)" data-i18n="backup_preset_weekly">Dimanche 04:00</button>
<button type="button" class="secondary" style="padding:3px 9px;font-size:11px"
onclick="applySetupBackupCronPreset('0 */6 * * *','*','*',0)" data-i18n="backup_preset_6h">Toutes les 6h</button>
</div>
</div>
</div>
</div>
</div>
<div class="step-actions">
<button type="button" class="secondary" onclick="goToStep(4)" data-i18n="btn_prev">← Précédent</button>
<div class="step-actions-right">
@@ -2473,6 +2600,8 @@
<div class="recap-box-val" id="recapTheme">Auto (Système)</div>
<div class="recap-box-sub" id="recapAutoconnect" data-i18n="recap_auto_start_yes">Démarrage auto : Oui
</div>
<div class="recap-box-sub" id="recapUpdateChecker">Mise à jour auto : Toutes les 30 min</div>
<div class="recap-box-sub" id="recapBackupSchedule">Sauvegardes : Désactivées</div>
</div>
</div>
@@ -3092,6 +3221,35 @@
'step5_vpn_desc': 'Importez ou configurez dès maintenant des tunnels VPN pour router le trafic de vos appareils.',
'step5_vpn_add_btn': 'Ajouter un profil VPN',
'step5_vpn_empty': 'Aucun profil VPN ajouté pour le moment. Vous pourrez également en ajouter ultérieurement dans les Réglages.',
'notif_evt_backup_success': '💾 Sauvegarde créée avec succès',
'notif_evt_backup_remote_success': '☁️ Sauvegarde envoyée sur l’hôte distant (si configuré)',
'notif_evt_update_available': '🚀 Mise à jour disponible pour AP Manageur',
'step5_update_title': 'Recherche de mise à jour automatique',
'step5_update_desc': 'Vérifie périodiquement si de nouvelles fonctionnalités ou des correctifs de sécurité sont disponibles pour AP Manageur.',
'adv_update_enable_chk': 'Activer la recherche automatique de mises à jour',
'adv_update_enable_hint': 'Lorsque cette option est désactivée, aucune requête n’est envoyée vers Gitea et le bouton de mise à jour reste masqué.',
'adv_update_interval_label': 'Fréquence de vérification automatique',
'adv_update_interval_hint': 'Définit l’intervalle entre chaque analyse en arrière-plan par le serveur.',
'interval_5m': 'Toutes les 5 minutes',
'interval_15m': 'Toutes les 15 minutes',
'interval_30m': 'Toutes les 30 minutes (Recommandé)',
'interval_1h': 'Toutes les heures',
'interval_2h': 'Toutes les 2 heures',
'interval_6h': 'Toutes les 6 heures',
'interval_12h': 'Toutes les 12 heures',
'interval_24h': 'Une fois par jour (24 heures)',
'step5_backup_title': 'Sauvegardes automatiques (Backup)',
'step5_backup_desc': 'Planifiez des sauvegardes régulières de la configuration, des utilisateurs et des règles pour prévenir toute perte de données.',
'backup_cron_enable': 'Activer la planification des sauvegardes automatiques',
'backup_cron_day_label': 'Fréquence / Jour',
'backup_cron_hour_label': 'Heure',
'backup_cron_min_label': 'Minute',
'backup_cron_retention_label': 'Rétention (0 = illimité)',
'backup_cron_expr_label': 'Expression Cron',
'backup_cron_invalid': 'Expression Cron invalide (5 champs requis)',
'backup_preset_daily': 'Chaque nuit 03:00',
'backup_preset_weekly': 'Dimanche 04:00',
'backup_preset_6h': 'Toutes les 6h',
'optional_badge': 'Optionnel',
'btn_see_recap': 'Voir le récapitulatif →',
@@ -3259,6 +3417,35 @@
'step5_vpn_desc': 'Import or configure VPN tunnels right now to route device network traffic.',
'step5_vpn_add_btn': 'Add VPN Profile',
'step5_vpn_empty': 'No VPN profiles added yet. You can also configure them later in Settings.',
'notif_evt_backup_success': '💾 Backup created successfully',
'notif_evt_backup_remote_success': '☁️ Backup uploaded to remote storage (if configured)',
'notif_evt_update_available': '🚀 Update available for AP Manageur',
'step5_update_title': 'Automatic Update Check',
'step5_update_desc': 'Periodically checks if new features or security patches are available for AP Manageur.',
'adv_update_enable_chk': 'Enable automatic update check',
'adv_update_enable_hint': 'When disabled, no requests are sent to Gitea and update alerts remain hidden.',
'adv_update_interval_label': 'Automatic check frequency',
'adv_update_interval_hint': 'Defines the background check interval performed by the server.',
'interval_5m': 'Every 5 minutes',
'interval_15m': 'Every 15 minutes',
'interval_30m': 'Every 30 minutes (Recommended)',
'interval_1h': 'Every hour',
'interval_2h': 'Every 2 hours',
'interval_6h': 'Every 6 hours',
'interval_12h': 'Every 12 hours',
'interval_24h': 'Once a day (24 hours)',
'step5_backup_title': 'Automatic Backups (Backup)',
'step5_backup_desc': 'Schedule regular backups of configuration, users, and rules to prevent data loss.',
'backup_cron_enable': 'Enable automated scheduled backups',
'backup_cron_day_label': 'Frequency / Day',
'backup_cron_hour_label': 'Hour',
'backup_cron_min_label': 'Minute',
'backup_cron_retention_label': 'Retention (0 = unlimited)',
'backup_cron_expr_label': 'Cron Expression',
'backup_cron_invalid': 'Invalid Cron expression (5 fields required)',
'backup_preset_daily': 'Every night 03:00',
'backup_preset_weekly': 'Sunday 04:00',
'backup_preset_6h': 'Every 6h',
'optional_badge': 'Optional',
'btn_see_recap': 'View Summary →',
@@ -3426,6 +3613,35 @@
'step5_vpn_desc': 'Import or configure VPN tunnels right now to route device network traffic.',
'step5_vpn_add_btn': 'Add VPN Profile',
'step5_vpn_empty': 'No VPN profiles added yet. You can also configure them later in Settings.',
'notif_evt_backup_success': '💾 Backup created successfully',
'notif_evt_backup_remote_success': '☁️ Backup uploaded to remote storage (if configured)',
'notif_evt_update_available': '🚀 Update available for AP Manageur',
'step5_update_title': 'Automatic Update Check',
'step5_update_desc': 'Periodically checks if new features or security patches are available for AP Manageur.',
'adv_update_enable_chk': 'Enable automatic update check',
'adv_update_enable_hint': 'When disabled, no requests are sent to Gitea and update alerts remain hidden.',
'adv_update_interval_label': 'Automatic check frequency',
'adv_update_interval_hint': 'Defines the background check interval performed by the server.',
'interval_5m': 'Every 5 minutes',
'interval_15m': 'Every 15 minutes',
'interval_30m': 'Every 30 minutes (Recommended)',
'interval_1h': 'Every hour',
'interval_2h': 'Every 2 hours',
'interval_6h': 'Every 6 hours',
'interval_12h': 'Every 12 hours',
'interval_24h': 'Once a day (24 hours)',
'step5_backup_title': 'Automatic Backups (Backup)',
'step5_backup_desc': 'Schedule regular backups of configuration, users, and rules to prevent data loss.',
'backup_cron_enable': 'Enable automated scheduled backups',
'backup_cron_day_label': 'Frequency / Day',
'backup_cron_hour_label': 'Hour',
'backup_cron_min_label': 'Minute',
'backup_cron_retention_label': 'Retention (0 = unlimited)',
'backup_cron_expr_label': 'Cron Expression',
'backup_cron_invalid': 'Invalid Cron expression (5 fields required)',
'backup_preset_daily': 'Every night 03:00',
'backup_preset_weekly': 'Sunday 04:00',
'backup_preset_6h': 'Every 6h',
'optional_badge': 'Optional',
'btn_see_recap': 'View Summary →',
@@ -3894,6 +4110,9 @@
vpn_profile_connected: $('notifEvtVpnProfileConnected')?.checked || false,
vpn_profile_disconnected: $('notifEvtVpnProfileDisconnected')?.checked || false,
quota_exceeded: $('notifEvtQuotaExceeded')?.checked ?? true,
backup_success: $('notifEvtBackupSuccess')?.checked ?? true,
backup_remote_success: $('notifEvtBackupRemoteSuccess')?.checked ?? true,
update_available: $('notifEvtUpdateAvailable')?.checked ?? true,
stats_report: $('notifEvtStatsReport')?.checked || false
},
stats_report_schedule: {
@@ -4079,6 +4298,9 @@
if ($('notifEvtVpnProfileConnected') && evts.vpn_profile_connected !== undefined) $('notifEvtVpnProfileConnected').checked = !!evts.vpn_profile_connected;
if ($('notifEvtVpnProfileDisconnected') && evts.vpn_profile_disconnected !== undefined) $('notifEvtVpnProfileDisconnected').checked = !!evts.vpn_profile_disconnected;
if ($('notifEvtQuotaExceeded') && evts.quota_exceeded !== undefined) $('notifEvtQuotaExceeded').checked = !!evts.quota_exceeded;
if ($('notifEvtBackupSuccess')) $('notifEvtBackupSuccess').checked = evts.backup_success !== undefined ? !!evts.backup_success : true;
if ($('notifEvtBackupRemoteSuccess')) $('notifEvtBackupRemoteSuccess').checked = evts.backup_remote_success !== undefined ? !!evts.backup_remote_success : true;
if ($('notifEvtUpdateAvailable')) $('notifEvtUpdateAvailable').checked = evts.update_available !== undefined ? !!evts.update_available : true;
const sched = cfg.stats_report_schedule || {};
const isStatsRep = !!(evts.stats_report || sched.enabled);
@@ -4372,7 +4594,7 @@
if ($('recapNotifSub')) {
if (notifOn && activeChannels.length) {
let evCount = 0;
const evIds = ['notifEvtNewDevice', 'notifEvtDeviceConnected', 'notifEvtDeviceDisconnected', 'notifEvtAdminLogin', 'notifEvtAdminLoginFailed', 'notifEvtDeviceBlocked', 'notifEvtSettingsChanged', 'notifEvtVpnClientConnected', 'notifEvtVpnClientDisconnected', 'notifEvtVpnProfileConnected', 'notifEvtVpnProfileDisconnected', 'notifEvtQuotaExceeded', 'notifEvtStatsReport'];
const evIds = ['notifEvtNewDevice', 'notifEvtDeviceConnected', 'notifEvtDeviceDisconnected', 'notifEvtAdminLogin', 'notifEvtAdminLoginFailed', 'notifEvtDeviceBlocked', 'notifEvtSettingsChanged', 'notifEvtVpnClientConnected', 'notifEvtVpnClientDisconnected', 'notifEvtVpnProfileConnected', 'notifEvtVpnProfileDisconnected', 'notifEvtQuotaExceeded', 'notifEvtBackupSuccess', 'notifEvtBackupRemoteSuccess', 'notifEvtUpdateAvailable', 'notifEvtStatsReport'];
evIds.forEach(eid => { if ($(eid) && $(eid).checked) evCount++; });
$('recapNotifSub').textContent = isEn ? `${activeChannels.length} channel(s) • ${evCount} alert event(s)` : `${activeChannels.length} canal(aux) • ${evCount} événement(s) d’alerte`;
} else {
@@ -4403,6 +4625,173 @@
if ($('recapAutoconnect')) {
$('recapAutoconnect').textContent = isEn ? ('Autostart: ' + (autoOn ? 'Yes' : 'No')) : ('Démarrage auto : ' + (autoOn ? 'Oui' : 'Non'));
}
// Mise à jour automatique
if ($('recapUpdateChecker')) {
const updOn = $('setupUpdateCheckerEnabled') && $('setupUpdateCheckerEnabled').checked;
const updInterval = $('setupUpdateInterval') ? $('setupUpdateInterval').value : '1800';
const intervalLabelsFr = {
'300': 'Toutes les 5 min', '900': 'Toutes les 15 min', '1800': 'Toutes les 30 min',
'3600': 'Toutes les heures', '7200': 'Toutes les 2 h', '21600': 'Toutes les 6 h',
'43200': 'Toutes les 12 h', '86400': 'Toutes les 24 h'
};
const intervalLabelsEn = {
'300': 'Every 5 min', '900': 'Every 15 min', '1800': 'Every 30 min',
'3600': 'Every hour', '7200': 'Every 2 hours', '21600': 'Every 6 hours',
'43200': 'Every 12 hours', '86400': 'Every 24 hours'
};
const intDict = isEn ? intervalLabelsEn : intervalLabelsFr;
const intervalTxt = intDict[updInterval] || (isEn ? 'Every 30 min' : 'Toutes les 30 min');
$('recapUpdateChecker').textContent = isEn
? ('Auto update check: ' + (updOn ? intervalTxt : 'Disabled'))
: ('Mise à jour auto : ' + (updOn ? intervalTxt : 'Désactivée'));
}
// Sauvegardes
if ($('recapBackupSchedule')) {
const bkOn = $('setupBackupCronEnabled') && $('setupBackupCronEnabled').checked;
const bkSummary = $('setupBackupCronHuman') ? $('setupBackupCronHuman').textContent.replace(/^[📅⚠️]\s*/, '') : '';
const bkRet = $('setupBackupCronRetention')?.value || '7';
if (bkOn) {
$('recapBackupSchedule').textContent = isEn
? `Backups: Enabled (${bkSummary}, retention ${bkRet}d)`
: `Sauvegardes : Activées (${bkSummary}, rétention ${bkRet}j)`;
} else {
$('recapBackupSchedule').textContent = isEn ? 'Backups: Disabled' : 'Sauvegardes : Désactivées';
}
}
}
function onToggleSetupUpdateChecker(enabled) {
const group = $('setupUpdateIntervalGroup');
const select = $('setupUpdateInterval');
if (select) select.disabled = !enabled;
if (group) group.style.opacity = enabled ? '1' : '0.45';
}
function initSetupBackupTimeSelects() {
const hSel = $('setupBackupCronHour');
const mSel = $('setupBackupCronMinute');
if (hSel && hSel.options.length <= 1) {
let hHtml = '<option value="*">' + t('stats_cron_day_all', 'Toutes les heures (*)') + '</option>';
for (let i = 0; i < 24; i++) {
const v = String(i).padStart(2, '0');
const sel = (i === 3) ? ' selected' : '';
hHtml += `<option value="${i}"${sel}>${v}h (${v}:00)</option>`;
}
hSel.innerHTML = hHtml;
}
if (mSel && mSel.options.length <= 1) {
let mHtml = '';
for (let i = 0; i < 60; i++) {
const v = String(i).padStart(2, '0');
const sel = (i === 0) ? ' selected' : '';
mHtml += `<option value="${i}"${sel}>${v} min (:${v})</option>`;
}
mSel.innerHTML = mHtml;
}
syncSetupBackupCronFromSelects();
}
function onToggleSetupBackupCron(enabled) {
const body = $('setupBackupCronBody');
if (body) body.style.display = enabled ? 'block' : 'none';
if (enabled) {
initSetupBackupTimeSelects();
updateSetupBackupCronSummary();
}
}
function syncSetupBackupCronFromSelects() {
const d = $('setupBackupCronDay')?.value || '*';
const h = $('setupBackupCronHour')?.value ?? '3';
const m = $('setupBackupCronMinute')?.value ?? '0';
const expr = `${m} ${h} * * ${d}`;
if ($('setupBackupCronExpr')) $('setupBackupCronExpr').value = expr;
updateSetupBackupCronSummary();
}
function applySetupBackupCronPreset(expr, day, hour, minute) {
initSetupBackupTimeSelects();
if ($('setupBackupCronDay')) $('setupBackupCronDay').value = String(day);
if ($('setupBackupCronHour')) $('setupBackupCronHour').value = String(hour);
if ($('setupBackupCronMinute')) $('setupBackupCronMinute').value = String(minute);
if ($('setupBackupCronExpr')) $('setupBackupCronExpr').value = expr;
updateSetupBackupCronSummary();
}
function updateSetupBackupCronSummary() {
const badge = $('setupBackupCronHuman');
if (!badge) return;
const expr = ($('setupBackupCronExpr')?.value || '').trim();
const parts = expr.split(/\s+/);
if (parts.length !== 5) {
badge.textContent = '⚠️ ' + t('backup_cron_invalid', 'Expression Cron invalide (5 champs requis)');
return;
}
const [minPart, hourPart, domPart, monthPart, dowPart] = parts;
if (domPart !== '*' || monthPart !== '*' || hourPart.includes('/') || minPart.includes('/')) {
badge.textContent = '⚙️ Cron : ' + expr;
return;
}
const daysMap = {
'*': t('stats_cron_day_all_short', 'Tous les jours'),
'1-5': t('stats_cron_day_workdays_short', 'Jours ouvrés (Lun-Ven)'),
'6,7': t('stats_cron_day_weekend_short', 'Week-end (Sam-Dim)'),
'1': t('stats_cron_day_mon', 'Chaque Lundi'),
'2': t('stats_cron_day_tue', 'Chaque Mardi'),
'3': t('stats_cron_day_wed', 'Chaque Mercredi'),
'4': t('stats_cron_day_thu', 'Chaque Jeudi'),
'5': t('stats_cron_day_fri', 'Chaque Vendredi'),
'6': t('stats_cron_day_sat', 'Chaque Samedi'),
'0': t('stats_cron_day_sun', 'Chaque Dimanche'),
'7': t('stats_cron_day_sun', 'Chaque Dimanche')
};
const dStr = daysMap[dowPart] || (t('stats_cron_day_prefix', 'Jour ') + dowPart);
let timeStr = '';
if (hourPart === '*') {
timeStr = t('stats_cron_hourly_at', 'toutes les heures à :{min}').replace('{min}', String(minPart).padStart(2, '0'));
} else {
timeStr = t('stats_cron_at_time', 'à {time}').replace('{time}', `${String(hourPart).padStart(2, '0')}:${String(minPart).padStart(2, '0')}`);
}
badge.textContent = `📅 ${dStr} ${timeStr}`;
}
async function loadStep5SettingsInSetup() {
try {
const resUpd = await fetch(API_URL + '/api/system/update/settings', {
headers: getSetupAuthHeaders('', false)
});
if (resUpd.ok) {
const dUpd = await resUpd.json();
const isUpdEn = dUpd.enabled !== undefined ? !!dUpd.enabled : true;
if ($('setupUpdateCheckerEnabled')) $('setupUpdateCheckerEnabled').checked = isUpdEn;
if ($('setupUpdateInterval')) $('setupUpdateInterval').value = String(dUpd.interval || 1800);
onToggleSetupUpdateChecker(isUpdEn);
}
} catch (_) { }
try {
const resBk = await fetch(API_URL + '/api/backups/schedule', {
headers: getSetupAuthHeaders('', false)
});
if (resBk.ok) {
const dBk = await resBk.json();
const sched = dBk.schedule || dBk;
if (sched) {
const isBkEn = !!sched.enabled;
if ($('setupBackupCronEnabled')) $('setupBackupCronEnabled').checked = isBkEn;
if ($('setupBackupCronRetention') && sched.retention !== undefined) $('setupBackupCronRetention').value = sched.retention;
initSetupBackupTimeSelects();
if ($('setupBackupCronDay') && sched.day) $('setupBackupCronDay').value = sched.day;
if ($('setupBackupCronHour') && sched.hour !== undefined) $('setupBackupCronHour').value = String(sched.hour);
if ($('setupBackupCronMinute') && sched.minute !== undefined) $('setupBackupCronMinute').value = String(sched.minute);
if ($('setupBackupCronExpr') && sched.cron_expr) $('setupBackupCronExpr').value = sched.cron_expr;
onToggleSetupBackupCron(isBkEn);
}
}
} catch (_) { }
}
}
function goToStep(stepNum) {
@@ -5331,7 +5720,9 @@
setSetupLanguage(currentLanguage);
setSetupTheme(currentTheme);
initStatsReportTimeSelects();
initSetupBackupTimeSelects();
loadNotificationSettingsInSetup();
loadStep5SettingsInSetup();
initSetupDropZone();
checkDetectedServerBackups();
const notifBox = $('notifChannelsBox');
@@ -5523,6 +5914,38 @@
});
} catch (_) { }
// G. Enregistrement recherche de mise à jour & planification des sauvegardes
try {
const updEnabled = $('setupUpdateCheckerEnabled') ? $('setupUpdateCheckerEnabled').checked : true;
const updInterval = $('setupUpdateInterval') ? parseInt($('setupUpdateInterval').value, 10) : 1800;
await fetch(API_URL + '/api/system/update/settings', {
method: 'POST',
headers: headers,
body: JSON.stringify({ enabled: updEnabled, interval: updInterval })
});
} catch (_) { }
try {
const bkEnabled = !!($('setupBackupCronEnabled') && $('setupBackupCronEnabled').checked);
const bkDay = $('setupBackupCronDay')?.value || '*';
const bkHour = $('setupBackupCronHour')?.value ?? '3';
const bkMin = $('setupBackupCronMinute')?.value ?? '0';
const bkRet = $('setupBackupCronRetention') ? parseInt($('setupBackupCronRetention').value, 10) : 7;
const bkExpr = ($('setupBackupCronExpr')?.value || `${bkMin} ${bkHour} * * ${bkDay}`).trim();
await fetch(API_URL + '/api/backups/schedule', {
method: 'POST',
headers: headers,
body: JSON.stringify({
enabled: bkEnabled,
day: bkDay,
hour: bkHour,
minute: bkMin,
retention: bkRet,
cron_expr: bkExpr
})
});
} catch (_) { }
if (progBar) progBar.style.width = '100%';
msg.style.color = 'var(--green)';
msg.textContent = isEn ? '✅ Configuration complete! Redirecting to dashboard…' : '✅ Configuration réussie ! Redirection vers le tableau de bord…';