From c48d5beae0e652401c931205cfda03345d58fb96 Mon Sep 17 00:00:00 2001 From: yoannmultigaming Date: Mon, 23 Nov 2026 03:06:08 +0100 Subject: [PATCH] =?UTF-8?q?AP=20manageur=20V1.2=20(B=C3=AAta)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- index.html | 127 +++++++++++++++++++++++++++++++++++++++++++++++++++ version.json | 4 +- 2 files changed, 129 insertions(+), 2 deletions(-) diff --git a/index.html b/index.html index c9db556..17df156 100644 --- a/index.html +++ b/index.html @@ -9384,6 +9384,133 @@ ${vpnBadgeTopo} ? (rate ? ` (${Math.round(rate)} Mbps)` : ` (~)`) : ` (${val} dBm)`; const tip = isEst + ? (rate ? `Estimé via lien Wi-Fi ${rate} MBit/s (pilote Raspberry Pi brcmfmac)` : `Qualité estimée via les statistiques de paquets (pilote Raspberry Pi brcmfmac)`) + : `${val} dBm`; + if (val >= -50) return `${t('signal_excellent', 'Excellent')}${suffix}`; + if (val >= -60) return `${t('signal_good', 'Bon')}${suffix}`; + if (val >= -70) return `${t('signal_fair', 'Moyen')}${suffix}`; + return `${t('signal_weak', 'Faible')}${suffix}`; + } + + function cleanQrBox(box) { + if (!box) return; + const canvas = box.querySelector('canvas'); + const img = box.querySelector('img'); + if (!canvas && !img) return; + if (img && img.src && img.src.startsWith('data:image')) { + img.style.display = 'block'; img.style.width = '100%'; img.style.height = '100%'; + if (canvas) canvas.remove(); + return; + } + if (canvas) { + try { + const dataUrl = canvas.toDataURL('image/png'); + if (dataUrl && dataUrl.length > 50) { + if (img) { + img.src = dataUrl; img.style.display = 'block'; img.style.width = '100%'; img.style.height = '100%'; + canvas.remove(); return; + } + } + } catch (_) { } + canvas.style.display = 'block'; canvas.style.width = '100%'; canvas.style.height = '100%'; + if (img) img.remove(); + return; + } + if (img) { img.style.display = 'block'; img.style.width = '100%'; img.style.height = '100%' } + } + + let currentSettingsTab = 'wifi'; + let currentNotifSubTab = sessionStorage.getItem('apNotifSubTab') || 'services'; + function selectNotifSubTab(subTab) { + currentNotifSubTab = subTab; + sessionStorage.setItem('apNotifSubTab', subTab); + const isServices = subTab === 'services'; + const isAlerts = subTab === 'alerts'; + const ts = $('tabNotifServices'), ta = $('tabNotifAlerts'); + if (ts) { ts.classList.toggle('active', isServices); ts.setAttribute('aria-selected', isServices); } + if (ta) { ta.classList.toggle('active', isAlerts); ta.setAttribute('aria-selected', isAlerts); } + const ps = $('panelNotifServices'), pa = $('panelNotifAlerts'); + if (ps) ps.style.display = isServices ? 'block' : 'none'; + if (pa) pa.style.display = isAlerts ? 'block' : 'none'; + } + + function selectSettingsTab(tabKey) { + if (tabKey === '2fa') tabKey = 'admin'; + currentSettingsTab = tabKey; + const tabs = ['wifi', 'admin', 'vpn', 'proxy', 'notif', 'custom', 'backup', 'danger']; + tabs.forEach(k => { + const btnId = 'tabSettings' + k.charAt(0).toUpperCase() + k.slice(1); + const panelId = 'panelSettings' + k.charAt(0).toUpperCase() + k.slice(1); + const btn = $(btnId); const panel = $(panelId); + if (btn) { + btn.classList.toggle('active', k === tabKey); + btn.setAttribute('aria-selected', k === tabKey ? 'true' : 'false'); + } + if (panel) { + panel.style.display = (k === tabKey) ? 'block' : 'none'; + panel.classList.toggle('active', k === tabKey); + } + }); + if (tabKey === 'admin') { if (typeof loadAdminUser === 'function') loadAdminUser(); if (typeof loadSessions === 'function') loadSessions(); if (typeof loadPasskeysList === 'function') loadPasskeysList(); if (typeof loadApiKeys === 'function') loadApiKeys(); } + if (tabKey === 'vpn') { + if (typeof loadVpnProfiles === 'function') loadVpnProfiles(); + if (typeof loadVpnClients === 'function') loadVpnClients(); + startVpnTabRefresh(); + } + if (tabKey === 'proxy') { + if (typeof loadReverseProxySettings === 'function') loadReverseProxySettings(); + } + if (tabKey === 'notif') { + if (typeof selectNotifSubTab === 'function') selectNotifSubTab(currentNotifSubTab || 'services'); + if (typeof loadNotificationSettings === 'function') loadNotificationSettings(); + } + if (tabKey === 'custom') { + if (typeof loadDeviceTypes === 'function') loadDeviceTypes(); + if (typeof loadUpdateSettings === 'function') loadUpdateSettings(); + } + if (tabKey === 'backup') { + if (typeof loadBackupsTab === 'function') loadBackupsTab(); + } + } + + let vpnTabRefreshTimer = null; + function startVpnTabRefresh() { + if (vpnTabRefreshTimer) clearInterval(vpnTabRefreshTimer); + vpnTabRefreshTimer = setInterval(() => { + if (authToken && currentTab === 'settings' && currentSettingsTab === 'vpn') { + if (typeof loadVpnProfiles === 'function') loadVpnProfiles(); + if (typeof loadVpnClients === 'function') loadVpnClients(); + } else { + clearInterval(vpnTabRefreshTimer); + vpnTabRefreshTimer = null; + } + }, 3000); + } + + function qr() { + if (!status.ssid || !status.password) return; + let box = $('qrcode'); let signature = status.ssid + '\u0000' + status.password; + if (signature === qrSignature) return; + $('qrPassword').value = status.password; box.replaceChildren(); + new QRCode(box, { text: `WIFI:T:WPA;S:${esc(status.ssid)};P:${esc(status.password)};;`, width: 190, height: 190 }); + cleanQrBox(box); + setTimeout(() => cleanQrBox(box), 50); + setTimeout(() => cleanQrBox(box), 200); + qrSignature = signature; + } + + async function controlAp(action) { + return runAction(async () => { + try { + const response = await apiFetch('/api/ap/control', { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify({ action }) }); + const data = await response.json(); if (!response.ok) throw Error(data.error || 'Action refusée'); + await new Promise(resolve => setTimeout(resolve, 1000)); await load(); + } catch (e) { alert(tErr(e.message)) } + }); + } + + function updateApButtons() { + const active = !!status.active, configured = !!status.configured; if ($('dashboardView')) $('dashboardView').classList.toggle('active', currentTab === 'dashboard'); if ($('statsView')) $('statsView').classList.toggle('active', configured && currentTab === 'stats'); if ($('devicesView')) $('devicesView').classList.toggle('active', configured && currentTab === 'devices'); diff --git a/version.json b/version.json index 325ef0d..dc6037b 100644 --- a/version.json +++ b/version.json @@ -1,5 +1,5 @@ { "version": "V1.2 (Bêta)", - "commit": "44c2048d3b501f41a2d9a36f56250b897d13258e", - "build_date": "2026-11-23T01:26:27Z" + "commit": "9b86c11a24a29494d9ab541d856e66573c572469", + "build_date": "2026-11-23T01:52:05Z" } \ No newline at end of file