APmanageur Wi-Fi V1.0

This commit is contained in:
yoannmultigaming committed 2026-11-18 16:41:17 +01:00
1 parent 49240da546
commit ca3cf6a55c
1 file changed
+20 -39
+20 -39
View File
@@ -1105,14 +1105,8 @@
</p> </p>
</div> </div>
<label style="display:flex;align-items:center;gap:10px;cursor:pointer;margin-bottom:18px;user-select:none">
<input type="checkbox" id="notifEnabledSwitch" style="width:auto;margin:0" onchange="onNotifToggle()">
<strong style="font-size:15px" data-i18n="step4_enable_label">Activer les notifications
automatiques</strong>
</label>
<div id="notifChannelsBox" <div id="notifChannelsBox"
style="display:none;background:var(--panel2);border:1px solid var(--line);border-radius:12px;padding:16px;margin-bottom:16px"> style="display:block;background:var(--panel2);border:1px solid var(--line);border-radius:12px;padding:16px;margin-bottom:16px">
<p class="muted" style="font-size:13px;margin:0 0 14px" data-i18n="step4_channels_hint"> <p class="muted" style="font-size:13px;margin:0 0 14px" data-i18n="step4_channels_hint">
Renseignez au moins un canal ci-dessous (vous pourrez aussi le faire plus tard dans les Réglages) : Renseignez au moins un canal ci-dessous (vous pourrez aussi le faire plus tard dans les Réglages) :
</p> </p>
@@ -2800,12 +2794,8 @@
} }
function onNotifToggle() { function onNotifToggle() {
const isEnabled = $('notifEnabledSwitch') && $('notifEnabledSwitch').checked;
if ($('notifChannelsBox')) $('notifChannelsBox').style.display = isEnabled ? 'block' : 'none';
if (isEnabled) {
toggleNotifFields(); toggleNotifFields();
initStatsReportTimeSelects(); initStatsReportTimeSelects();
}
updateStep4ContinueState(); updateStep4ContinueState();
} }
@@ -3154,11 +3144,6 @@
if ($('notifWebhookMethod') && wh.method) $('notifWebhookMethod').value = wh.method; if ($('notifWebhookMethod') && wh.method) $('notifWebhookMethod').value = wh.method;
if ($('notifWebhookHeaders') && wh.headers) $('notifWebhookHeaders').value = wh.headers; if ($('notifWebhookHeaders') && wh.headers) $('notifWebhookHeaders').value = wh.headers;
const anyChannelEnabled = !!(em.enabled || got.enabled || dis.enabled || ntf.enabled || pb.enabled || po.enabled || sl.enabled || tg.enabled || wh.enabled);
if (anyChannelEnabled && $('notifEnabledSwitch')) {
$('notifEnabledSwitch').checked = true;
onNotifToggle();
}
toggleNotifFields(); toggleNotifFields();
} catch (_) { } } catch (_) { }
} }
@@ -3348,7 +3333,7 @@
} }
// Notifications // Notifications
const notifOn = $('notifEnabledSwitch') && $('notifEnabledSwitch').checked; const notifSt = getStep4NotificationStatus();
const channels = [ const channels = [
{ id: 'notifEmailEnabled', name: 'Email' }, { id: 'notifEmailEnabled', name: 'Email' },
{ id: 'notifGotifyEnabled', name: 'Gotify' }, { id: 'notifGotifyEnabled', name: 'Gotify' },
@@ -3361,16 +3346,14 @@
{ id: 'notifWebhookEnabled', name: 'Webhook' } { id: 'notifWebhookEnabled', name: 'Webhook' }
]; ];
let activeChannels = []; let activeChannels = [];
if (notifOn) { if (notifSt.anyConfigured) {
channels.forEach(c => { channels.forEach(c => {
if ($(c.id) && $(c.id).checked) activeChannels.push(c.name); if ($(c.id) && $(c.id).checked) activeChannels.push(c.name);
}); });
} }
if ($('recapNotif')) { if ($('recapNotif')) {
if (notifOn && activeChannels.length) { if (activeChannels.length) {
$('recapNotif').textContent = activeChannels.join(', '); $('recapNotif').textContent = activeChannels.join(', ');
} else if (notifOn) {
$('recapNotif').textContent = isEn ? 'Enabled (pending setup)' : 'Activées (à configurer)';
} else { } else {
$('recapNotif').textContent = isEn ? 'Disabled' : 'Désactivées'; $('recapNotif').textContent = isEn ? 'Disabled' : 'Désactivées';
} }
@@ -3415,7 +3398,7 @@
if (stepNum < 1 || stepNum > 6) return; if (stepNum < 1 || stepNum > 6) return;
if (currentStep === 4 && stepNum > 4) { if (currentStep === 4 && stepNum > 4) {
const st = getStep4NotificationStatus(); const st = getStep4NotificationStatus();
if (st.enabled && !st.anyConfigured) { if (st.anyChecked && !st.anyConfigured) {
updateStep4ContinueState(); updateStep4ContinueState();
selectSetupNotifSubTab('services'); selectSetupNotifSubTab('services');
return; return;
@@ -3512,8 +3495,6 @@
} }
function getStep4NotificationStatus() { function getStep4NotificationStatus() {
const notifOn = !!($('notifEnabledSwitch') && $('notifEnabledSwitch').checked);
if (!notifOn) return { enabled: false, anyChecked: false, anyConfigured: false };
const p = getNotificationFormPayload(); const p = getNotificationFormPayload();
const checks = [ const checks = [
{ en: p.email.enabled, ok: !!(p.email.smtp_host && p.email.to_addr) }, { en: p.email.enabled, ok: !!(p.email.smtp_host && p.email.to_addr) },
@@ -3527,7 +3508,6 @@
{ en: p.webhook.enabled, ok: !!p.webhook.url } { en: p.webhook.enabled, ok: !!p.webhook.url }
]; ];
return { return {
enabled: true,
anyChecked: checks.some(c => c.en), anyChecked: checks.some(c => c.en),
anyConfigured: checks.some(c => c.en && c.ok) anyConfigured: checks.some(c => c.en && c.ok)
}; };
@@ -3539,7 +3519,7 @@
const st = getStep4NotificationStatus(); const st = getStep4NotificationStatus();
const isEn = currentLanguage.startsWith('en'); const isEn = currentLanguage.startsWith('en');
if (st.enabled && !st.anyConfigured) { if (!st.anyConfigured) {
if (btn) { if (btn) {
btn.disabled = true; btn.disabled = true;
btn.style.opacity = '0.5'; btn.style.opacity = '0.5';
@@ -3547,11 +3527,11 @@
} }
const msg = st.anyChecked const msg = st.anyChecked
? (isEn ? (isEn
? '⚠️ Please fill in the required fields for the enabled notification service (URL, token, recipient...) or disable automatic notifications to continue.' ? '⚠️ Please fill in the required fields for the enabled notification service (URL, token, recipient...) to continue, or click "Skip".'
: '⚠️ Veuillez compléter les champs obligatoires du service de notification activé (URL, jeton, destinataire...) ou désactiver les notifications automatiques pour continuer.') : '⚠️ Veuillez compléter les champs obligatoires du service de notification activé (URL, jeton, destinataire...) pour continuer, ou cliquez sur « Ignorer ».')
: (isEn : (isEn
? '⚠️ Please enable and configure at least one notification service (or disable automatic notifications) to continue.' ? '⚠️ Please enable and configure at least one notification service to continue, or click "Skip".'
: '⚠️ Veuillez activer et configurer au moins un service de notification (ou désactiver les notifications automatiques) pour continuer.'); : '⚠️ Veuillez activer et configurer au moins un service de notification pour continuer, ou cliquez sur « Ignorer ».');
showError(errEl, msg); showError(errEl, msg);
} else { } else {
if (btn) { if (btn) {
@@ -3564,17 +3544,19 @@
} }
function skipStep4() { function skipStep4() {
if ($('notifEnabledSwitch')) { ['Email', 'Gotify', 'Discord', 'Ntfy', 'Pushbullet', 'Pushover', 'Slack', 'Telegram', 'Webhook'].forEach(cap => {
$('notifEnabledSwitch').checked = false; const chk = $('notif' + cap + 'Enabled');
onNotifToggle(); if (chk) chk.checked = false;
} });
toggleNotifFields();
if ($('step4Error')) $('step4Error').style.display = 'none';
goToStep(5); goToStep(5);
} }
function validateStep4() { function validateStep4() {
updateStep4ContinueState(); updateStep4ContinueState();
const st = getStep4NotificationStatus(); const st = getStep4NotificationStatus();
if (st.enabled && !st.anyConfigured) { if (!st.anyConfigured) {
selectSetupNotifSubTab('services'); selectSetupNotifSubTab('services');
return; return;
} }
@@ -3809,7 +3791,7 @@
if (!password || password !== confirmation) { goToStep(2); return validateStep2(); } if (!password || password !== confirmation) { goToStep(2); return validateStep2(); }
if (!adminUser || !adminPass) { goToStep(3); return validateStep3(); } if (!adminUser || !adminPass) { goToStep(3); return validateStep3(); }
const notifSt = getStep4NotificationStatus(); const notifSt = getStep4NotificationStatus();
if (notifSt.enabled && !notifSt.anyConfigured) { goToStep(4); return validateStep4(); } if (notifSt.anyChecked && !notifSt.anyConfigured) { goToStep(4); return validateStep4(); }
isConfiguring = true; isConfiguring = true;
btn.disabled = true; btn.disabled = true;
@@ -3898,9 +3880,8 @@
} }
} }
// E. Enregistrement des notifications (si activées) // E. Enregistrement des notifications (si au moins un service configuré)
const notifOn = $('notifEnabledSwitch') && $('notifEnabledSwitch').checked; if (notifSt.anyConfigured) {
if (notifOn) {
msg.textContent = isEn ? '4/5 Saving notification channels & alert events…' : '4/5 Enregistrement des alertes et notifications…'; msg.textContent = isEn ? '4/5 Saving notification channels & alert events…' : '4/5 Enregistrement des alertes et notifications…';
if (progBar) progBar.style.width = '80%'; if (progBar) progBar.style.width = '80%';
try { try {