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
+22 -41
+22 -41
View File
@@ -1105,14 +1105,8 @@
</p>
</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"
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">
Renseignez au moins un canal ci-dessous (vous pourrez aussi le faire plus tard dans les Réglages) :
</p>
@@ -2800,12 +2794,8 @@
}
function onNotifToggle() {
const isEnabled = $('notifEnabledSwitch') && $('notifEnabledSwitch').checked;
if ($('notifChannelsBox')) $('notifChannelsBox').style.display = isEnabled ? 'block' : 'none';
if (isEnabled) {
toggleNotifFields();
initStatsReportTimeSelects();
}
toggleNotifFields();
initStatsReportTimeSelects();
updateStep4ContinueState();
}
@@ -3154,11 +3144,6 @@
if ($('notifWebhookMethod') && wh.method) $('notifWebhookMethod').value = wh.method;
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();
} catch (_) { }
}
@@ -3348,7 +3333,7 @@
}
// Notifications
const notifOn = $('notifEnabledSwitch') && $('notifEnabledSwitch').checked;
const notifSt = getStep4NotificationStatus();
const channels = [
{ id: 'notifEmailEnabled', name: 'Email' },
{ id: 'notifGotifyEnabled', name: 'Gotify' },
@@ -3361,16 +3346,14 @@
{ id: 'notifWebhookEnabled', name: 'Webhook' }
];
let activeChannels = [];
if (notifOn) {
if (notifSt.anyConfigured) {
channels.forEach(c => {
if ($(c.id) && $(c.id).checked) activeChannels.push(c.name);
});
}
if ($('recapNotif')) {
if (notifOn && activeChannels.length) {
if (activeChannels.length) {
$('recapNotif').textContent = activeChannels.join(', ');
} else if (notifOn) {
$('recapNotif').textContent = isEn ? 'Enabled (pending setup)' : 'Activées (à configurer)';
} else {
$('recapNotif').textContent = isEn ? 'Disabled' : 'Désactivées';
}
@@ -3415,7 +3398,7 @@
if (stepNum < 1 || stepNum > 6) return;
if (currentStep === 4 && stepNum > 4) {
const st = getStep4NotificationStatus();
if (st.enabled && !st.anyConfigured) {
if (st.anyChecked && !st.anyConfigured) {
updateStep4ContinueState();
selectSetupNotifSubTab('services');
return;
@@ -3512,8 +3495,6 @@
}
function getStep4NotificationStatus() {
const notifOn = !!($('notifEnabledSwitch') && $('notifEnabledSwitch').checked);
if (!notifOn) return { enabled: false, anyChecked: false, anyConfigured: false };
const p = getNotificationFormPayload();
const checks = [
{ 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 }
];
return {
enabled: true,
anyChecked: checks.some(c => c.en),
anyConfigured: checks.some(c => c.en && c.ok)
};
@@ -3539,7 +3519,7 @@
const st = getStep4NotificationStatus();
const isEn = currentLanguage.startsWith('en');
if (st.enabled && !st.anyConfigured) {
if (!st.anyConfigured) {
if (btn) {
btn.disabled = true;
btn.style.opacity = '0.5';
@@ -3547,11 +3527,11 @@
}
const msg = st.anyChecked
? (isEn
? '⚠️ Please fill in the required fields for the enabled notification service (URL, token, recipient...) or disable automatic notifications to continue.'
: '⚠️ Veuillez compléter les champs obligatoires du service de notification activé (URL, jeton, destinataire...) ou désactiver les notifications automatiques pour continuer.')
? '⚠️ 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...) pour continuer, ou cliquez sur « Ignorer ».')
: (isEn
? '⚠️ Please enable and configure at least one notification service (or disable automatic notifications) to continue.'
: '⚠️ Veuillez activer et configurer au moins un service de notification (ou désactiver les notifications automatiques) pour continuer.');
? '⚠️ Please enable and configure at least one notification service to continue, or click "Skip".'
: '⚠️ Veuillez activer et configurer au moins un service de notification pour continuer, ou cliquez sur « Ignorer ».');
showError(errEl, msg);
} else {
if (btn) {
@@ -3564,17 +3544,19 @@
}
function skipStep4() {
if ($('notifEnabledSwitch')) {
$('notifEnabledSwitch').checked = false;
onNotifToggle();
}
['Email', 'Gotify', 'Discord', 'Ntfy', 'Pushbullet', 'Pushover', 'Slack', 'Telegram', 'Webhook'].forEach(cap => {
const chk = $('notif' + cap + 'Enabled');
if (chk) chk.checked = false;
});
toggleNotifFields();
if ($('step4Error')) $('step4Error').style.display = 'none';
goToStep(5);
}
function validateStep4() {
updateStep4ContinueState();
const st = getStep4NotificationStatus();
if (st.enabled && !st.anyConfigured) {
if (!st.anyConfigured) {
selectSetupNotifSubTab('services');
return;
}
@@ -3809,7 +3791,7 @@
if (!password || password !== confirmation) { goToStep(2); return validateStep2(); }
if (!adminUser || !adminPass) { goToStep(3); return validateStep3(); }
const notifSt = getStep4NotificationStatus();
if (notifSt.enabled && !notifSt.anyConfigured) { goToStep(4); return validateStep4(); }
if (notifSt.anyChecked && !notifSt.anyConfigured) { goToStep(4); return validateStep4(); }
isConfiguring = true;
btn.disabled = true;
@@ -3898,9 +3880,8 @@
}
}
// E. Enregistrement des notifications (si activées)
const notifOn = $('notifEnabledSwitch') && $('notifEnabledSwitch').checked;
if (notifOn) {
// E. Enregistrement des notifications (si au moins un service configuré)
if (notifSt.anyConfigured) {
msg.textContent = isEn ? '4/5 Saving notification channels & alert events…' : '4/5 Enregistrement des alertes et notifications…';
if (progBar) progBar.style.width = '80%';
try {