diff --git a/index.html b/index.html
index 962cc56..4e7871a 100644
--- a/index.html
+++ b/index.html
@@ -9535,13 +9535,26 @@ ${vpnBadgeTopo}
}
try { loadPreferences(); } catch (_) { }
+ let apActionInProgress = null;
+
function setActionBusy(busy) {
actionBusy = busy;
- document.querySelectorAll('button').forEach(button => { button.disabled = busy; button.style.opacity = busy ? '0.55' : ''; button.style.cursor = busy ? 'wait' : '' });
+ document.querySelectorAll('button').forEach(button => {
+ if (button.id === 'apControl' || button.id === 'apRestart') return;
+ button.disabled = busy;
+ button.style.opacity = busy ? '0.55' : '';
+ button.style.cursor = busy ? 'wait' : '';
+ });
}
async function runAction(action) {
- if (actionBusy) return; setActionBusy(true);
- try { return await action() } finally { setActionBusy(false) }
+ if (actionBusy) return;
+ setActionBusy(true);
+ try {
+ return await action();
+ } finally {
+ setActionBusy(false);
+ updateApButtons();
+ }
}
function uptime(s) {
@@ -9675,40 +9688,42 @@ ${vpnBadgeTopo}
}
async function controlAp(action) {
+ if (action === 'stop') {
+ const confirmMsg = t('confirm_stop_ap', "Êtes-vous sûr de vouloir arrêter le point d’accès Wi-Fi ?\n\nTous les appareils connectés seront déconnectés.\nCette opération peut prendre plusieurs minutes.");
+ if (!confirm(confirmMsg)) return;
+ } else if (action === 'restart') {
+ const confirmMsg = t('confirm_restart_ap', "Êtes-vous sûr de vouloir redémarrer le point d’accès Wi-Fi ?\n\nTous les appareils connectés seront temporairement déconnectés.\nCette opération peut prendre plusieurs minutes.");
+ if (!confirm(confirmMsg)) return;
+ }
+
return runAction(async () => {
- const apBtn = $('apControl');
- const rstBtn = $('apRestart');
- const origApText = apBtn ? apBtn.textContent : '';
- const origRstText = rstBtn ? rstBtn.textContent : '';
- if (action === 'start' && apBtn) {
- apBtn.innerHTML = `⚙️ ${escapeHtml(t('btn_starting', 'Démarrage…'))}`;
- } else if (action === 'stop' && apBtn) {
- apBtn.innerHTML = `⚙️ ${escapeHtml(t('btn_stopping', 'Arrêt…'))}`;
- } else if (action === 'restart' && rstBtn) {
- rstBtn.innerHTML = `⚙️ ${escapeHtml(t('btn_restarting', 'Redémarrage…'))}`;
- }
+ 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 data = await response.json(); if (!response.ok) throw Error(data.error || 'Action refusée');
- for (let attempt = 0; attempt < 6; attempt++) {
- await new Promise(resolve => setTimeout(resolve, 600));
+ const data = await response.json();
+ if (!response.ok) throw Error(data.error || 'Action refusée');
+
+ for (let attempt = 0; attempt < 12; attempt++) {
+ await new Promise(resolve => setTimeout(resolve, 800));
await load();
if (action === 'start' && status && status.active) break;
if (action === 'stop' && status && !status.active) break;
- if (action === 'restart' && status && status.active) break;
+ if (action === 'restart') {
+ if (attempt >= 1 && status && status.active) break;
+ }
}
} catch (e) {
alert(tErr(e.message));
} finally {
- if (apBtn && origApText) apBtn.textContent = origApText;
- if (rstBtn && origRstText) rstBtn.textContent = origRstText;
+ apActionInProgress = null;
updateApButtons();
}
});
}
function updateApButtons() {
- const active = !!status.active, configured = !!status.configured;
+ const active = !!(status && status.active), configured = !!(status && 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');
@@ -9724,19 +9739,61 @@ ${vpnBadgeTopo}
if ($('settingsTab')) $('settingsTab').style.display = configured ? '' : 'none';
if ($('logsTab')) $('logsTab').style.display = configured ? '' : 'none';
if ($('blockedTab')) $('blockedTab').style.display = configured ? '' : 'none';
+
if ($('apControl')) {
$('apControl').style.display = configured ? '' : 'none';
- $('apControl').textContent = active ? t('btn_stop', 'Arrêter') : t('btn_start', 'Démarrer');
- $('apControl').style.background = active ? 'var(--red)' : 'var(--blue)';
- $('apControl').style.color = active ? 'white' : 'var(--blue-text, #071326)';
+ if (apActionInProgress === 'start') {
+ $('apControl').innerHTML = `⚙️ ${escapeHtml(t('btn_starting', 'Démarrage…'))}`;
+ $('apControl').disabled = true;
+ $('apControl').style.opacity = '0.7';
+ $('apControl').style.cursor = 'wait';
+ $('apControl').style.background = 'var(--blue)';
+ $('apControl').style.color = 'var(--blue-text, #071326)';
+ } else if (apActionInProgress === 'stop') {
+ $('apControl').innerHTML = `⚙️ ${escapeHtml(t('btn_stopping', 'Arrêt…'))}`;
+ $('apControl').disabled = true;
+ $('apControl').style.opacity = '0.7';
+ $('apControl').style.cursor = 'wait';
+ $('apControl').style.background = 'var(--red)';
+ $('apControl').style.color = 'white';
+ } else if (apActionInProgress === 'restart') {
+ $('apControl').disabled = true;
+ $('apControl').style.opacity = '0.55';
+ $('apControl').style.cursor = 'not-allowed';
+ $('apControl').textContent = active ? t('btn_stop', 'Arrêter') : t('btn_start', 'Démarrer');
+ $('apControl').style.background = active ? 'var(--red)' : 'var(--blue)';
+ $('apControl').style.color = active ? 'white' : 'var(--blue-text, #071326)';
+ } else {
+ $('apControl').disabled = false;
+ $('apControl').textContent = active ? t('btn_stop', 'Arrêter') : t('btn_start', 'Démarrer');
+ $('apControl').style.background = active ? 'var(--red)' : 'var(--blue)';
+ $('apControl').style.color = active ? 'white' : 'var(--blue-text, #071326)';
+ $('apControl').style.opacity = '';
+ $('apControl').style.cursor = 'pointer';
+ }
}
+
if ($('apRestart')) {
$('apRestart').style.display = configured ? '' : 'none';
- $('apRestart').disabled = !active;
- $('apRestart').style.opacity = active ? '1' : '0.4';
- $('apRestart').style.cursor = active ? 'pointer' : 'not-allowed';
- $('apRestart').title = active ? t('btn_restart', 'Redémarrer') : t('ap_stopped_no_restart', "L'AP est arrêtée (démarrage requis)");
+ if (apActionInProgress === 'restart') {
+ $('apRestart').innerHTML = `⚙️ ${escapeHtml(t('btn_restarting', 'Redémarrage…'))}`;
+ $('apRestart').disabled = true;
+ $('apRestart').style.opacity = '0.7';
+ $('apRestart').style.cursor = 'wait';
+ } else if (apActionInProgress) {
+ $('apRestart').disabled = true;
+ $('apRestart').style.opacity = '0.4';
+ $('apRestart').style.cursor = 'not-allowed';
+ $('apRestart').textContent = t('btn_restart', 'Redémarrer');
+ } else {
+ $('apRestart').disabled = !active;
+ $('apRestart').style.opacity = active ? '1' : '0.4';
+ $('apRestart').style.cursor = active ? 'pointer' : 'not-allowed';
+ $('apRestart').title = active ? t('btn_restart', 'Redémarrer') : t('ap_stopped_no_restart', "L'AP est arrêtée (démarrage requis)");
+ $('apRestart').textContent = t('btn_restart', 'Redémarrer');
+ }
}
+
if ($('refresh')) $('refresh').style.display = configured ? '' : 'none';
const updateInfo = (status && status.update) ? status.update : null;
if (updateInfo) lastUpdateData = updateInfo;
diff --git a/lang/en-gb.js b/lang/en-gb.js
index 00cd5ae..164daa7 100644
--- a/lang/en-gb.js
+++ b/lang/en-gb.js
@@ -1457,5 +1457,7 @@ window.I18N['en-gb'] = {
"setup_launch_redirecting": "Redirecting to dashboard…",
"btn_starting": "Starting…",
"btn_stopping": "Stopping…",
- "btn_restarting": "Restarting…"
+ "btn_restarting": "Restarting…",
+ "confirm_stop_ap": "Are you sure you want to stop the Wi-Fi access point?\n\nAll connected devices will be disconnected.\nThis operation may take several minutes.",
+ "confirm_restart_ap": "Are you sure you want to restart the Wi-Fi access point?\n\nAll connected devices will be temporarily disconnected.\nThis operation may take several minutes."
};
diff --git a/lang/en-us.js b/lang/en-us.js
index 3e6bd4d..c00e6ad 100644
--- a/lang/en-us.js
+++ b/lang/en-us.js
@@ -1457,5 +1457,7 @@ window.I18N['en-us'] = {
"setup_launch_redirecting": "Redirecting to dashboard…",
"btn_starting": "Starting…",
"btn_stopping": "Stopping…",
- "btn_restarting": "Restarting…"
+ "btn_restarting": "Restarting…",
+ "confirm_stop_ap": "Are you sure you want to stop the Wi-Fi access point?\n\nAll connected devices will be disconnected.\nThis operation may take several minutes.",
+ "confirm_restart_ap": "Are you sure you want to restart the Wi-Fi access point?\n\nAll connected devices will be temporarily disconnected.\nThis operation may take several minutes."
};
diff --git a/lang/fr.js b/lang/fr.js
index c6ba987..eb2069e 100644
--- a/lang/fr.js
+++ b/lang/fr.js
@@ -1457,5 +1457,7 @@ window.I18N['fr'] = {
"setup_launch_redirecting": "Redirection vers le tableau de bord…",
"btn_starting": "Démarrage…",
"btn_stopping": "Arrêt…",
- "btn_restarting": "Redémarrage…"
+ "btn_restarting": "Redémarrage…",
+ "confirm_stop_ap": "Êtes-vous sûr de vouloir arrêter le point d’accès Wi-Fi ?\n\nTous les appareils connectés seront déconnectés.\nCette opération peut prendre plusieurs minutes.",
+ "confirm_restart_ap": "Êtes-vous sûr de vouloir redémarrer le point d’accès Wi-Fi ?\n\nTous les appareils connectés seront temporairement déconnectés.\nCette opération peut prendre plusieurs minutes."
};