AP manageur V1.1 (Bêta)
This commit is contained in:
1 parent
d047c137af
commit
c35a2fcfa3
4 files changed
+67
-23
No files matched your search
+61
-23
@@ -14056,6 +14056,7 @@ ${vpnBadgeTopo}
|
|||||||
if ($('rememberUser').checked) { localStorage.setItem('apRememberedUser', $('authUsername').value.trim()); }
|
if ($('rememberUser').checked) { localStorage.setItem('apRememberedUser', $('authUsername').value.trim()); }
|
||||||
else { localStorage.removeItem('apRememberedUser'); }
|
else { localStorage.removeItem('apRememberedUser'); }
|
||||||
$('authOtp').value = '';
|
$('authOtp').value = '';
|
||||||
|
showLoaderScreen();
|
||||||
try {
|
try {
|
||||||
await initializeAndShowDashboard(true);
|
await initializeAndShowDashboard(true);
|
||||||
} catch (_) {
|
} catch (_) {
|
||||||
@@ -14645,6 +14646,7 @@ ${vpnBadgeTopo}
|
|||||||
msgEl.style.color = 'var(--green)';
|
msgEl.style.color = 'var(--green)';
|
||||||
msgEl.textContent = verData.message ? tMsg(verData.message) : t('passkey_auth_success', 'Authentification Passkey réussie !');
|
msgEl.textContent = verData.message ? tMsg(verData.message) : t('passkey_auth_success', 'Authentification Passkey réussie !');
|
||||||
}
|
}
|
||||||
|
showLoaderScreen();
|
||||||
try {
|
try {
|
||||||
await initializeAndShowDashboard(true);
|
await initializeAndShowDashboard(true);
|
||||||
} catch (_) {
|
} catch (_) {
|
||||||
@@ -15500,11 +15502,27 @@ ${vpnBadgeTopo}
|
|||||||
// 1. Initialisation de l'API & statut session
|
// 1. Initialisation de l'API & statut session
|
||||||
updateLoaderProgress(15, mainTitle, t('loader_step1_conn', "Connexion à l’API et vérification des accès…"), 1);
|
updateLoaderProgress(15, mainTitle, t('loader_step1_conn', "Connexion à l’API et vérification des accès…"), 1);
|
||||||
let statusData = null;
|
let statusData = null;
|
||||||
try {
|
for (let sAttempt = 1; !statusData || statusData.is_starting; sAttempt++) {
|
||||||
const resStatus = await apiFetch('/api/status');
|
if (!authToken || loaderSkipped) break;
|
||||||
if (resStatus.ok) statusData = await resStatus.json();
|
try {
|
||||||
} catch (e) {
|
const resStatus = await apiFetch('/api/status');
|
||||||
console.warn("Statut initial :", e);
|
if (resStatus.ok) {
|
||||||
|
const parsed = await resStatus.json();
|
||||||
|
if (parsed) {
|
||||||
|
statusData = parsed;
|
||||||
|
if (!parsed.is_starting) break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} catch (e) {
|
||||||
|
console.warn("Statut initial (tentative " + sAttempt + "):", e);
|
||||||
|
}
|
||||||
|
if (sAttempt >= 60) {
|
||||||
|
console.warn("Délai d'attente dépassé pour is_starting, continuation...");
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
const p = Math.min(26, 15 + Math.floor(sAttempt * 0.3));
|
||||||
|
updateLoaderProgress(p, mainTitle, t('loader_api_initializing', "Initialisation des services et de l'API…"), 1);
|
||||||
|
await new Promise(r => setTimeout(r, 1000));
|
||||||
}
|
}
|
||||||
if (!authToken) {
|
if (!authToken) {
|
||||||
hideLoaderScreen();
|
hideLoaderScreen();
|
||||||
@@ -15663,12 +15681,17 @@ ${vpnBadgeTopo}
|
|||||||
// 4. Chargement final et synchronisation du tableau de bord
|
// 4. Chargement final et synchronisation du tableau de bord
|
||||||
if (skipBtn) skipBtn.style.display = 'none';
|
if (skipBtn) skipBtn.style.display = 'none';
|
||||||
updateLoaderProgress(90, mainTitle, t('loader_step4_sync', "Synchronisation des équipements, tunnels et métriques…"), 4);
|
updateLoaderProgress(90, mainTitle, t('loader_step4_sync', "Synchronisation des équipements, tunnels et métriques…"), 4);
|
||||||
try {
|
let loadSuccess = false;
|
||||||
await load();
|
for (let lAttempt = 1; lAttempt <= 4 && !loadSuccess && !loaderSkipped; lAttempt++) {
|
||||||
if (typeof loadVpnProfiles === 'function') await loadVpnProfiles();
|
try {
|
||||||
if (typeof loadVpnClients === 'function') await loadVpnClients();
|
await load();
|
||||||
} catch (e) {
|
if (typeof loadVpnProfiles === 'function') await loadVpnProfiles();
|
||||||
console.warn("Load error:", e);
|
if (typeof loadVpnClients === 'function') await loadVpnClients();
|
||||||
|
loadSuccess = true;
|
||||||
|
} catch (e) {
|
||||||
|
console.warn("Load attempt " + lAttempt + " error:", e);
|
||||||
|
if (lAttempt < 4) await new Promise(r => setTimeout(r, 800));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
updateLoaderProgress(96, mainTitle, t('loader_step4_inventory', "Inventaire des appareils réseau…"), 4);
|
updateLoaderProgress(96, mainTitle, t('loader_step4_inventory', "Inventaire des appareils réseau…"), 4);
|
||||||
try {
|
try {
|
||||||
@@ -15710,10 +15733,12 @@ ${vpnBadgeTopo}
|
|||||||
(async () => {
|
(async () => {
|
||||||
applyProjectTitle();
|
applyProjectTitle();
|
||||||
applyLanguage(currentLanguage, false);
|
applyLanguage(currentLanguage, false);
|
||||||
|
showLoaderScreen();
|
||||||
try {
|
try {
|
||||||
let data = null;
|
let data = null;
|
||||||
let serverWasDown = false;
|
let serverWasDown = false;
|
||||||
for (let attempt = 1; !data; attempt++) {
|
let isCompletelyLoaded = false;
|
||||||
|
for (let attempt = 1; !isCompletelyLoaded; attempt++) {
|
||||||
try {
|
try {
|
||||||
let controller, timer;
|
let controller, timer;
|
||||||
let fetchOpts = { cache: 'no-store' };
|
let fetchOpts = { cache: 'no-store' };
|
||||||
@@ -15725,20 +15750,31 @@ ${vpnBadgeTopo}
|
|||||||
const response = await fetch(API_URL + '/api/auth/status', fetchOpts);
|
const response = await fetch(API_URL + '/api/auth/status', fetchOpts);
|
||||||
if (timer) clearTimeout(timer);
|
if (timer) clearTimeout(timer);
|
||||||
if (!response.ok) throw Error('HTTP ' + response.status);
|
if (!response.ok) throw Error('HTTP ' + response.status);
|
||||||
data = await response.json();
|
const resData = await response.json();
|
||||||
|
data = resData;
|
||||||
|
|
||||||
|
// Si le backend indique que le démarrage interne est toujours en cours
|
||||||
|
if (resData.is_starting) {
|
||||||
|
serverWasDown = true;
|
||||||
|
showLoaderScreen();
|
||||||
|
if ($('loaderBadgeText')) $('loaderBadgeText').textContent = t('loader_starting_badge', 'Démarrage en cours');
|
||||||
|
if ($('loaderBadgeIcon')) $('loaderBadgeIcon').innerHTML = ICON_GEAR;
|
||||||
|
const p = Math.min(25, 10 + Math.floor(attempt * 1.2));
|
||||||
|
updateLoaderProgress(p, t('loader_starting', 'Démarrage en cours…'), t('loader_api_initializing', "Initialisation des services et de l'API…"), 1);
|
||||||
|
await new Promise(resolve => setTimeout(resolve, 1000));
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
// L'API a répondu et son initialisation est terminée
|
||||||
|
isCompletelyLoaded = true;
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
serverWasDown = true;
|
serverWasDown = true;
|
||||||
showLoaderScreen();
|
showLoaderScreen();
|
||||||
if ($('loaderBadgeText')) $('loaderBadgeText').textContent = 'Démarrage en cours';
|
if ($('loaderBadgeText')) $('loaderBadgeText').textContent = t('loader_starting_badge', 'Démarrage en cours');
|
||||||
if ($('loaderBadgeIcon')) $('loaderBadgeIcon').innerHTML = ICON_GEAR;
|
if ($('loaderBadgeIcon')) $('loaderBadgeIcon').innerHTML = ICON_GEAR;
|
||||||
updateLoaderProgress(5, "Démarrage en cours…", `Attente du serveur API (${attempt}/4) dans 1.5s…`, 1);
|
const p = Math.min(20, 5 + Math.floor(attempt * 0.8));
|
||||||
if (attempt >= 4) {
|
updateLoaderProgress(p, t('loader_starting', 'Démarrage en cours…'), `${t('loader_waiting_api', "Attente du serveur API")} (${attempt})…`, 1);
|
||||||
console.warn("API indisponible après 4 tentatives, arrêt du loader et affichage de l'interface");
|
await new Promise(resolve => setTimeout(resolve, 1200));
|
||||||
hideLoaderScreen();
|
|
||||||
showAuth(false);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
await new Promise(resolve => setTimeout(resolve, 1500));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
authConfigured = !!data.configured; authTwoFactor = !!data.two_factor;
|
authConfigured = !!data.configured; authTwoFactor = !!data.two_factor;
|
||||||
@@ -15780,7 +15816,9 @@ ${vpnBadgeTopo}
|
|||||||
localStorage.setItem('apBootTime', String(currentBootTime));
|
localStorage.setItem('apBootTime', String(currentBootTime));
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// Utilisateur non connecté : masquer le loader et afficher l'écran de connexion
|
// Utilisateur non connecté et API complètement chargée : transition fluide vers l'écran de connexion
|
||||||
|
updateLoaderProgress(100, t('loader_step4_ready', "Système prêt !"), t('loader_login_ready', "API prête, ouverture de la connexion…"), 1);
|
||||||
|
await new Promise(r => setTimeout(r, 200));
|
||||||
hideLoaderScreen();
|
hideLoaderScreen();
|
||||||
showAuth(!authConfigured);
|
showAuth(!authConfigured);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -246,10 +246,12 @@ window.I18N['en-gb'] = {
|
|||||||
"header_lang_tooltip": "Language settings",
|
"header_lang_tooltip": "Language settings",
|
||||||
"last_activity": "Last activity:",
|
"last_activity": "Last activity:",
|
||||||
"limits_dev_name_label": "Device Name",
|
"limits_dev_name_label": "Device Name",
|
||||||
|
"loader_api_initializing": "Initializing services and API…",
|
||||||
"loader_connecting": "connecting…",
|
"loader_connecting": "connecting…",
|
||||||
"loader_finished": "Startup complete!",
|
"loader_finished": "Startup complete!",
|
||||||
"loader_finished_badge": "Startup complete",
|
"loader_finished_badge": "Startup complete",
|
||||||
"loader_ip_pending": "fetching IP…",
|
"loader_ip_pending": "fetching IP…",
|
||||||
|
"loader_login_ready": "API ready, opening login…",
|
||||||
"loader_no_vpn_needed": "No automatic VPN tunnel required",
|
"loader_no_vpn_needed": "No automatic VPN tunnel required",
|
||||||
"loader_ready": "System ready!",
|
"loader_ready": "System ready!",
|
||||||
"loader_ready_badge": "System ready",
|
"loader_ready_badge": "System ready",
|
||||||
|
|||||||
@@ -246,10 +246,12 @@ window.I18N['en-us'] = {
|
|||||||
"header_lang_tooltip": "Language settings",
|
"header_lang_tooltip": "Language settings",
|
||||||
"last_activity": "Last activity:",
|
"last_activity": "Last activity:",
|
||||||
"limits_dev_name_label": "Device Name",
|
"limits_dev_name_label": "Device Name",
|
||||||
|
"loader_api_initializing": "Initializing services and API…",
|
||||||
"loader_connecting": "connecting…",
|
"loader_connecting": "connecting…",
|
||||||
"loader_finished": "Startup complete!",
|
"loader_finished": "Startup complete!",
|
||||||
"loader_finished_badge": "Startup complete",
|
"loader_finished_badge": "Startup complete",
|
||||||
"loader_ip_pending": "fetching IP…",
|
"loader_ip_pending": "fetching IP…",
|
||||||
|
"loader_login_ready": "API ready, opening login…",
|
||||||
"loader_no_vpn_needed": "No automatic VPN tunnel required",
|
"loader_no_vpn_needed": "No automatic VPN tunnel required",
|
||||||
"loader_ready": "System ready!",
|
"loader_ready": "System ready!",
|
||||||
"loader_ready_badge": "System ready",
|
"loader_ready_badge": "System ready",
|
||||||
|
|||||||
@@ -246,10 +246,12 @@ window.I18N['fr'] = {
|
|||||||
"header_lang_tooltip": "Paramètres de langue",
|
"header_lang_tooltip": "Paramètres de langue",
|
||||||
"last_activity": "Dernière activité :",
|
"last_activity": "Dernière activité :",
|
||||||
"limits_dev_name_label": "Nom de l'appareil",
|
"limits_dev_name_label": "Nom de l'appareil",
|
||||||
|
"loader_api_initializing": "Initialisation des services et de l'API…",
|
||||||
"loader_connecting": "connexion…",
|
"loader_connecting": "connexion…",
|
||||||
"loader_finished": "Démarrage terminé !",
|
"loader_finished": "Démarrage terminé !",
|
||||||
"loader_finished_badge": "Démarrage terminé",
|
"loader_finished_badge": "Démarrage terminé",
|
||||||
"loader_ip_pending": "IP en cours…",
|
"loader_ip_pending": "IP en cours…",
|
||||||
|
"loader_login_ready": "API prête, ouverture de la connexion…",
|
||||||
"loader_no_vpn_needed": "Aucun tunnel VPN automatique requis",
|
"loader_no_vpn_needed": "Aucun tunnel VPN automatique requis",
|
||||||
"loader_ready": "Système prêt !",
|
"loader_ready": "Système prêt !",
|
||||||
"loader_ready_badge": "Système prêt",
|
"loader_ready_badge": "Système prêt",
|
||||||
|
|||||||
Reference in new issue
Block a user