AP manageur V1.2 (Bêta)

This commit is contained in:
yoannmultigaming committed 2026-11-23 13:30:16 +01:00
1 parent c48d5beae0
commit 188497ae79
7 files changed
+604 -75

No files matched your search

+220 -34
View File
@@ -7295,6 +7295,81 @@
</div>
</div>
<!-- 12. Modal Progression Restauration des données -->
<div id="modalRestoreProgress" class="modal-overlay" style="z-index:999999;backdrop-filter:blur(6px);background:rgba(0,0,0,0.85)">
<div class="modal-card" style="max-width:480px;width:92%;padding:28px 24px;border:1px solid rgba(56,189,248,0.4);box-shadow:0 16px 40px rgba(0,0,0,0.6), 0 0 30px rgba(56,189,248,0.2);border-radius:18px;display:flex;flex-direction:column;align-items:center;gap:18px">
<!-- Icône animée -->
<div style="position:relative;width:68px;height:68px;display:flex;align-items:center;justify-content:center">
<div style="position:absolute;inset:0;border-radius:50%;border:2px solid rgba(56,189,248,0.35);animation:radarPulse 2s ease-out infinite"></div>
<div id="restoreProgressIcon" style="font-size:34px;z-index:1;animation:iconFloat 2s ease-in-out infinite">📦</div>
</div>
<!-- Titre et sous-titre -->
<div style="text-align:center">
<h2 style="margin:0;font-size:18px;letter-spacing:-0.3px;color:var(--text)" data-i18n="restore_progress_title">Restauration des données</h2>
<div style="margin-top:6px;display:inline-flex;align-items:center;gap:6px;background:rgba(56,189,248,0.12);border:1px solid rgba(56,189,248,0.3);color:var(--blue);padding:3px 12px;border-radius:20px;font-size:12px;font-weight:600">
<span id="restoreProgressBadgeIcon" style="display:inline-flex;align-items:center;justify-content:center;animation:spin 1.5s linear infinite">⚙️</span>
<span id="restoreProgressBadgeText" data-i18n="restore_progress_badge">Restauration en cours…</span>
</div>
</div>
<!-- Barre de progression -->
<div class="loader-progress-box" style="width:100%;margin-top:4px">
<div style="display:flex;justify-content:space-between;align-items:center;margin-bottom:6px;font-size:12px">
<span id="restoreProgressStepLabel" style="font-weight:600;color:var(--text)" data-i18n="restore_step_label">Étape 1 / 5</span>
<span id="restoreProgressPercent" style="font-weight:700;color:var(--blue);font-family:monospace">0%</span>
</div>
<div class="loader-bar-bg" style="height:10px;border-radius:8px;background:var(--panel2);border:1px solid var(--line);overflow:hidden">
<div id="restoreProgressBar" class="loader-bar-fill" style="width:0%;height:100%;background:linear-gradient(90deg, #0284c7, #38bdf8);box-shadow:0 0 12px rgba(56,189,248,0.5);border-radius:8px;transition:width .35s ease"></div>
</div>
</div>
<!-- Libellés d'état dynamique -->
<div style="text-align:center;min-height:44px;width:100%">
<div id="restoreProgressStatusText" style="font-weight:700;font-size:14px;color:var(--text)" data-i18n="restore_starting">Démarrage de la restauration…</div>
<div id="restoreProgressDetails" class="muted" style="font-size:12px;margin-top:3px" data-i18n="restore_preparing">Inspection du fichier et validation du format…</div>
</div>
<!-- Checklist visuelle des étapes -->
<div class="loader-checklist" style="display:grid;grid-template-columns:1fr;gap:7px;width:100%;margin-top:4px;border-top:1px solid var(--line);padding-top:12px">
<div id="restoreStepCheck" class="loader-step active" style="display:flex;align-items:center;gap:8px;padding:7px 12px;background:var(--panel2);border-radius:8px;border:1px solid rgba(56,189,248,0.4);font-size:12.5px">
<span class="step-icon">📦</span>
<span class="step-name" style="flex:1" data-i18n="restore_step1_check">Analyse &amp; vérification de l'archive</span>
<span class="step-state" id="restoreStepCheckState" style="font-weight:700;color:var(--blue)">↻</span>
</div>
<div id="restoreStepPrefs" class="loader-step" style="display:flex;align-items:center;gap:8px;padding:7px 12px;background:var(--panel2);border-radius:8px;border:1px solid transparent;font-size:12.5px">
<span class="step-icon">⚙️</span>
<span class="step-name" style="flex:1" data-i18n="restore_step2_prefs">Restauration des réglages &amp; préférences</span>
<span class="step-state" id="restoreStepPrefsState">⏳</span>
</div>
<div id="restoreStepDevices" class="loader-step" style="display:flex;align-items:center;gap:8px;padding:7px 12px;background:var(--panel2);border-radius:8px;border:1px solid transparent;font-size:12.5px">
<span class="step-icon">📱</span>
<span class="step-name" style="flex:1" data-i18n="restore_step3_dev">Restauration des équipements &amp; quotas</span>
<span class="step-state" id="restoreStepDevicesState">⏳</span>
</div>
<div id="restoreStepVpn" class="loader-step" style="display:flex;align-items:center;gap:8px;padding:7px 12px;background:var(--panel2);border-radius:8px;border:1px solid transparent;font-size:12.5px">
<span class="step-icon">🛡️</span>
<span class="step-name" style="flex:1" data-i18n="restore_step4_vpn">Restauration des profils VPN &amp; routages</span>
<span class="step-state" id="restoreStepVpnState">⏳</span>
</div>
<div id="restoreStepSync" class="loader-step" style="display:flex;align-items:center;gap:8px;padding:7px 12px;background:var(--panel2);border-radius:8px;border:1px solid transparent;font-size:12.5px">
<span class="step-icon">📶</span>
<span class="step-name" style="flex:1" data-i18n="restore_step5_sync">Reconfiguration Wi-Fi &amp; synchronisation finale</span>
<span class="step-state" id="restoreStepSyncState">⏳</span>
</div>
</div>
<div id="restoreProgressErrorBox" style="display:none;width:100%;margin-top:8px;padding:10px;background:rgba(239,68,68,0.15);border:1px solid var(--red);border-radius:8px;color:var(--red);font-size:12px;text-align:center">
<span id="restoreProgressErrorText"></span>
<div style="margin-top:8px">
<button type="button" class="secondary" style="padding:4px 10px;font-size:12px" onclick="closeRestoreProgressModal()">Fermer</button>
</div>
</div>
</div>
</div>
</main>
<script src="https://cdnjs.cloudflare.com/ajax/libs/qrcodejs/1.0.0/qrcode.min.js" defer></script>
@@ -12319,9 +12394,6 @@ ${vpnBadgeTopo}
alert(t('backup_no_pending', "Aucune donnée de sauvegarde en attente."));
return;
}
const btn = $('btnConfirmImportAction');
const msg = $('importModalMsg');
const mainMsg = $('backupActionMsg');
const options = {
restore_vpn: $('chkRestoreVpn') ? $('chkRestoreVpn').checked : true,
@@ -12341,52 +12413,161 @@ ${vpnBadgeTopo}
return;
}
if (btn) { btn.disabled = true; btn.textContent = t('backup_restoring', 'Restauration en cours…'); }
if (msg) {
msg.style.display = 'block';
msg.style.background = 'rgba(56,189,248,0.12)';
msg.style.color = 'var(--blue)';
msg.textContent = t('backup_applying_to_db', 'Application de la sauvegarde dans la base de données…');
}
const backupPayload = pendingBackupData;
const modal = $('modalImportBackup');
if (modal) modal.style.display = 'none';
pendingBackupData = null;
const progressModal = $('modalRestoreProgress');
if (progressModal) progressModal.classList.add('active');
$('restoreProgressBar').style.width = '20%';
$('restoreProgressPercent').textContent = '20%';
$('restoreProgressStepLabel').textContent = (t('restore_step_label', 'Étape {step} / {total}') || 'Étape {step} / {total}').replace('{step}', '1').replace('{total}', '5');
$('restoreProgressBadgeText').textContent = t('restore_progress_badge', 'Restauration en cours…');
$('restoreProgressBadgeIcon').textContent = '⚙️';
$('restoreProgressBadgeIcon').style.animation = 'spin 1.5s linear infinite';
$('restoreProgressIcon').textContent = '📦';
$('restoreProgressStatusText').textContent = t('restore_step1_check', 'Analyse & vérification de l\'archive…');
$('restoreProgressDetails').textContent = t('restore_preparing', 'Inspection du fichier et validation du format…');
if ($('restoreProgressErrorBox')) $('restoreProgressErrorBox').style.display = 'none';
const restoreStepPills = [
{ id: 'restoreStepCheck', stateId: 'restoreStepCheckState' },
{ id: 'restoreStepPrefs', stateId: 'restoreStepPrefsState' },
{ id: 'restoreStepDevices', stateId: 'restoreStepDevicesState' },
{ id: 'restoreStepVpn', stateId: 'restoreStepVpnState' },
{ id: 'restoreStepSync', stateId: 'restoreStepSyncState' }
];
restoreStepPills.forEach((s, idx) => {
const el = $(s.id);
const st = $(s.stateId);
if (!el || !st) return;
if (idx === 0) {
el.className = 'loader-step active';
el.style.borderColor = 'rgba(56,189,248,0.4)';
st.textContent = '↻';
st.style.color = 'var(--blue)';
} else {
el.className = 'loader-step';
el.style.borderColor = 'transparent';
st.textContent = '⏳';
st.style.color = 'inherit';
}
});
let restorePollInterval = null;
let isDone = false;
const doPollRestore = async () => {
if (isDone) return;
try {
const res = await fetch(API_URL + '/api/backup/restore/progress', { cache: 'no-store' });
if (!res.ok) return;
const p = await res.json();
if (!p) return;
const pct = Math.min(100, Math.max(0, p.percent || 0));
$('restoreProgressBar').style.width = pct + '%';
$('restoreProgressPercent').textContent = pct + '%';
if (p.step) {
$('restoreProgressStepLabel').textContent = (t('restore_step_label', 'Étape {step} / {total}') || 'Étape {step} / {total}')
.replace('{step}', p.step).replace('{total}', p.total_steps || 5);
}
if (p.message) {
$('restoreProgressStatusText').textContent = tMsg(p.message);
}
if (p.details) {
$('restoreProgressDetails').textContent = tMsg(p.details);
}
const curStep = p.step || 1;
restoreStepPills.forEach((s, idx) => {
const stepNum = idx + 1;
const el = $(s.id);
const st = $(s.stateId);
if (!el || !st) return;
if (curStep > stepNum || (p.done && curStep >= stepNum && !p.error)) {
el.className = 'loader-step done';
el.style.borderColor = 'rgba(34,197,94,0.3)';
st.textContent = '✓';
st.style.color = 'var(--green)';
} else if (curStep === stepNum && !p.done) {
el.className = 'loader-step active';
el.style.borderColor = 'rgba(56,189,248,0.4)';
st.textContent = '↻';
st.style.color = 'var(--blue)';
} else {
el.className = 'loader-step';
el.style.borderColor = 'transparent';
st.textContent = '⏳';
st.style.color = 'inherit';
}
});
if (p.error) {
if (restorePollInterval) clearInterval(restorePollInterval);
if ($('restoreProgressErrorBox')) {
$('restoreProgressErrorBox').style.display = 'block';
$('restoreProgressErrorText').textContent = tErr(p.error);
}
$('restoreProgressBadgeText').textContent = t('error', 'Erreur');
$('restoreProgressBadgeIcon').textContent = '⚠️';
$('restoreProgressBadgeIcon').style.animation = 'none';
$('restoreProgressIcon').textContent = '⚠️';
return;
}
if (p.done && !isDone) {
isDone = true;
if (restorePollInterval) clearInterval(restorePollInterval);
$('restoreProgressBar').style.width = '100%';
$('restoreProgressPercent').textContent = '100%';
$('restoreProgressBadgeText').textContent = t('done', 'Terminé !');
$('restoreProgressBadgeIcon').textContent = '✅';
$('restoreProgressBadgeIcon').style.animation = 'none';
$('restoreProgressIcon').textContent = '✅';
$('restoreProgressStatusText').textContent = t('restore_complete_title', 'Sauvegarde restaurée avec succès !');
$('restoreProgressDetails').textContent = t('restore_reloading', 'Rechargement de l’interface en cours…');
setTimeout(() => {
window.location.reload();
}, 1200);
}
} catch (_) {}
};
restorePollInterval = setInterval(doPollRestore, 200);
try {
const res = await apiFetch('/api/backup/import', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({
backup: pendingBackupData,
backup: backupPayload,
options: options
})
});
const d = await res.json();
if (!res.ok) throw new Error(d.error || 'Erreur lors de la restauration');
closeImportBackupModal();
if (mainMsg) {
mainMsg.style.display = 'block';
mainMsg.style.background = 'rgba(50,213,131,0.15)';
mainMsg.style.color = 'var(--green)';
mainMsg.textContent = '✓ ' + tMsg(d.message || 'Sauvegarde restaurée avec succès !');
setTimeout(() => { if (mainMsg) mainMsg.style.display = 'none'; }, 8000);
if (!isDone) {
await doPollRestore();
}
// Rafraîchir les données
try { await load(); } catch (_) { }
try { if (typeof loadVpnProfiles === 'function') await loadVpnProfiles(); } catch (_) { }
try { if (typeof loadDevices === 'function') await loadDevices(); } catch (_) { }
try { if (typeof loadDeviceTypesList === 'function') await loadDeviceTypesList(); } catch (_) { }
try { if (typeof loadBlocked === 'function') await loadBlocked(); } catch (_) { }
} catch (e) {
if (msg) {
msg.style.display = 'block';
msg.style.background = 'rgba(239,68,68,0.15)';
msg.style.color = 'var(--red)';
msg.textContent = tErr(e.message);
if (!isDone) {
if (restorePollInterval) clearInterval(restorePollInterval);
if ($('restoreProgressErrorBox')) {
$('restoreProgressErrorBox').style.display = 'block';
$('restoreProgressErrorText').textContent = tErr(e.message);
}
$('restoreProgressBadgeText').textContent = t('error', 'Erreur');
$('restoreProgressBadgeIcon').textContent = '⚠️';
$('restoreProgressBadgeIcon').style.animation = 'none';
$('restoreProgressIcon').textContent = '⚠️';
}
} finally {
if (btn) { btn.disabled = false; btn.textContent = 'Confirmer et restaurer'; }
}
}
@@ -13331,6 +13512,11 @@ ${vpnBadgeTopo}
if (modal) modal.classList.remove('active');
};
window.closeRestoreProgressModal = function() {
const modal = $('modalRestoreProgress');
if (modal) modal.classList.remove('active');
};
$('clearAllData').onclick = () => runAction(async () => {
if (!confirm(t('confirm_delete_all_data', '⚠️ ATTENTION : Voulez-vous vraiment supprimer toutes les données de l’application ?'))) return;
const modal = $('modalClearAllProgress');