AP manageur V1.1 (Bêta)
This commit is contained in:
1 parent
25934624ea
commit
cf611c584c
5 files changed
+268
-153
No files matched your search
+67
-45
@@ -9700,7 +9700,7 @@ ${vpnBadgeTopo}
|
||||
apActionInProgress = action;
|
||||
updateApButtons();
|
||||
try {
|
||||
const response = await apiFetch('/api/ap/control', { method: 'POST', timeout: 60000, headers: { 'Content-Type': 'application/json' }, body: JSON.stringify({ action }) });
|
||||
const response = await apiFetch('/api/ap/control', { method: 'POST', timeout: 90000, headers: { 'Content-Type': 'application/json' }, body: JSON.stringify({ action }) });
|
||||
const data = await response.json();
|
||||
if (!response.ok) throw Error(data.error || 'Action refusée');
|
||||
|
||||
@@ -14013,7 +14013,7 @@ ${vpnBadgeTopo}
|
||||
try {
|
||||
const sMode = document.querySelector('input[name="setupMode"]:checked')?.value || 'ap';
|
||||
const sEth = $('setupBridgeEth')?.value || '';
|
||||
const response = await apiFetch('/api/setup', { method: 'POST', timeout: 60000, headers: { 'Content-Type': 'application/json' }, body: JSON.stringify({ ssid: $('setupSsid').value, password: password, security: $('setupSecurity').value, mode: sMode, bridge_eth: sEth, max_clients: parseInt($('setupMaxClients') ? $('setupMaxClients').value : 0, 10) || 0 }) });
|
||||
const response = await apiFetch('/api/setup', { method: 'POST', timeout: 90000, headers: { 'Content-Type': 'application/json' }, body: JSON.stringify({ ssid: $('setupSsid').value, password: password, security: $('setupSecurity').value, mode: sMode, bridge_eth: sEth, max_clients: parseInt($('setupMaxClients') ? $('setupMaxClients').value : 0, 10) || 0 }) });
|
||||
const data = await response.json(); if (!response.ok) throw Error(data.error || 'Configuration refusée');
|
||||
message.textContent = data.message; currentTab = 'dashboard'; sessionStorage.setItem('apDashboardTab', 'dashboard');
|
||||
await new Promise(resolve => setTimeout(resolve, 500)); await load();
|
||||
@@ -14071,50 +14071,72 @@ ${vpnBadgeTopo}
|
||||
if (panel) panel.style.cursor = disabled ? 'wait' : '';
|
||||
}
|
||||
|
||||
$('saveSettings').onclick = () => runAction(async () => {
|
||||
let m = $('message');
|
||||
if (settingsMessageTimer) {
|
||||
clearTimeout(settingsMessageTimer);
|
||||
settingsMessageTimer = null;
|
||||
}
|
||||
setSettingsWifiInputsDisabled(true);
|
||||
m.style.color = 'var(--muted)';
|
||||
m.textContent = t('loading', 'Enregistrement…');
|
||||
try {
|
||||
const setMode = document.querySelector('input[name="settingsMode"]:checked')?.value || 'ap';
|
||||
const setEth = $('settingsBridgeEth')?.value || '';
|
||||
let r = await apiFetch('/api/settings', {
|
||||
method: 'POST',
|
||||
timeout: 60000,
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
body: JSON.stringify({
|
||||
ssid: $('settingsSsid').value,
|
||||
password: $('settingsPassword').value,
|
||||
security: $('settingsSecurity').value,
|
||||
mode: setMode,
|
||||
bridge_eth: setEth,
|
||||
max_clients: parseInt($('settingsMaxClients') ? $('settingsMaxClients').value : 0, 10) || 0,
|
||||
autoconnect: $('settingsAutoconnect').checked
|
||||
})
|
||||
});
|
||||
let d = await r.json();
|
||||
if (!r.ok) throw Error(d.error);
|
||||
m.style.color = 'var(--green)';
|
||||
m.textContent = tMsg(d.message);
|
||||
await new Promise(resolve => setTimeout(resolve, 1000));
|
||||
await load();
|
||||
} catch (e) {
|
||||
m.style.color = 'var(--red)';
|
||||
m.textContent = tErr(e.message);
|
||||
} finally {
|
||||
setSettingsWifiInputsDisabled(false);
|
||||
if (settingsMessageTimer) clearTimeout(settingsMessageTimer);
|
||||
settingsMessageTimer = setTimeout(() => {
|
||||
if (m) m.textContent = '';
|
||||
$('saveSettings').onclick = () => {
|
||||
const confirmMsg = t('confirm_save_settings_restart', "La modification des réglages Wi-Fi va redémarrer le point d’accès.\n\nTous les appareils connectés seront temporairement déconnectés.\nCette opération peut durer plusieurs minutes.\n\nSouhaitez-vous continuer ?");
|
||||
if (!confirm(confirmMsg)) return;
|
||||
|
||||
return runAction(async () => {
|
||||
let m = $('message');
|
||||
if (settingsMessageTimer) {
|
||||
clearTimeout(settingsMessageTimer);
|
||||
settingsMessageTimer = null;
|
||||
}, 4000);
|
||||
}
|
||||
});
|
||||
}
|
||||
apActionInProgress = 'restart';
|
||||
updateApButtons();
|
||||
setSettingsWifiInputsDisabled(true);
|
||||
if (m) {
|
||||
m.style.color = 'var(--blue)';
|
||||
m.innerHTML = `<span style="display:inline-flex;animation:spin 1s linear infinite;margin-right:6px">⚙️</span> <span>${escapeHtml(t('settings_restarting_warning', "Redémarrage : cette opération peut durer plusieurs minutes…"))}</span>`;
|
||||
}
|
||||
try {
|
||||
const setMode = document.querySelector('input[name="settingsMode"]:checked')?.value || 'ap';
|
||||
const setEth = $('settingsBridgeEth')?.value || '';
|
||||
let r = await apiFetch('/api/settings', {
|
||||
method: 'POST',
|
||||
timeout: 90000,
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
body: JSON.stringify({
|
||||
ssid: $('settingsSsid').value,
|
||||
password: $('settingsPassword').value,
|
||||
security: $('settingsSecurity').value,
|
||||
mode: setMode,
|
||||
bridge_eth: setEth,
|
||||
max_clients: parseInt($('settingsMaxClients') ? $('settingsMaxClients').value : 0, 10) || 0,
|
||||
autoconnect: $('settingsAutoconnect').checked
|
||||
})
|
||||
});
|
||||
let d = await r.json();
|
||||
if (!r.ok) throw Error(d.error || 'Erreur lors de l’enregistrement');
|
||||
|
||||
for (let attempt = 0; attempt < 25; attempt++) {
|
||||
await new Promise(resolve => setTimeout(resolve, 800));
|
||||
try {
|
||||
await load();
|
||||
} catch (_) {}
|
||||
if (attempt >= 2 && status && status.active) break;
|
||||
}
|
||||
|
||||
if (m) {
|
||||
m.style.color = 'var(--green)';
|
||||
m.textContent = '✅ ' + tMsg(d.message || t('settings_saved_restarted', 'Réglages enregistrés et point d’accès redémarré avec succès !'));
|
||||
}
|
||||
} catch (e) {
|
||||
if (m) {
|
||||
m.style.color = 'var(--red)';
|
||||
m.textContent = '❌ ' + tErr(e.message);
|
||||
}
|
||||
} finally {
|
||||
apActionInProgress = null;
|
||||
updateApButtons();
|
||||
setSettingsWifiInputsDisabled(false);
|
||||
if (settingsMessageTimer) clearTimeout(settingsMessageTimer);
|
||||
settingsMessageTimer = setTimeout(() => {
|
||||
if (m) m.textContent = '';
|
||||
settingsMessageTimer = null;
|
||||
}, 5000);
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
$('logout').onclick = logout;
|
||||
|
||||
|
||||
Reference in new issue
Block a user