Files
apmanageur/setup.html
T

5549 lines
268 KiB
HTML
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
<!DOCTYPE html>
<html lang="fr" data-theme="dark">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta http-equiv="Cache-Control" content="no-cache, no-store, must-revalidate">
<meta http-equiv="Pragma" content="no-cache">
<meta http-equiv="Expires" content="0">
<title data-i18n="page_title">Configuration initiale - AP Manageur</title>
<link rel="icon" type="image/png" href="/images/favicon.png">
<link rel="shortcut icon" href="/images/favicon.png">
<link rel="apple-touch-icon" href="/images/favicon.png">
<script src="/lang/fr.js"></script>
<script src="/lang/en-us.js"></script>
<script src="/lang/en-gb.js"></script>
<script>
(function () {
// Masquer le nom de fichier dans la barre d'adresse
try {
if (/\/(setup\.html|Setup\.HTML|Setup\.html)$/i.test(window.location.pathname)) {
var cleanSetupUrl = window.location.pathname.replace(/\/(setup\.html|Setup\.HTML|Setup\.html)$/i, '/setup') + window.location.search + window.location.hash;
window.history.replaceState(null, '', cleanSetupUrl);
}
} catch (_) { }
// Thème automatique par défaut
function setT(t) {
if (!t) return;
var m = window.matchMedia('(prefers-color-scheme: light)');
var resolved = t === 'auto' ? (m.matches ? 'light' : 'dark') : t;
document.documentElement.dataset.theme = resolved;
if (t === 'macos') {
document.documentElement.dataset.macosMode = m.matches ? 'light' : 'dark';
} else {
delete document.documentElement.dataset.macosMode;
}
}
try {
var explicitTheme = sessionStorage.getItem('setupExplicitTheme');
var t = explicitTheme || 'auto';
setT(t);
window.matchMedia('(prefers-color-scheme: light)').addEventListener('change', function (e) {
var cur = sessionStorage.getItem('setupExplicitTheme') || 'auto';
if (cur === 'auto') {
document.documentElement.dataset.theme = e.matches ? 'light' : 'dark';
}
});
} catch (_) { }
// Détection de la langue du navigateur : si la langue n'existe pas dans le programme, repli sur l'anglais britannique (en-gb)
function detectBrowserLanguage() {
var raw = (navigator.language || (navigator.languages && navigator.languages[0]) || '').toLowerCase().trim();
if (raw.indexOf('fr') === 0) return 'fr';
if (raw === 'en-us' || raw.indexOf('en-us') === 0) return 'en-us';
return 'en-gb';
}
try {
var explicit = sessionStorage.getItem('setupExplicitLang');
var curLang = (explicit && ['fr', 'en-us', 'en-gb'].indexOf(explicit) !== -1) ? explicit : detectBrowserLanguage();
document.documentElement.lang = curLang === 'en-us' ? 'en-US' : (curLang === 'en-gb' ? 'en-GB' : 'fr');
} catch (_) { }
try {
var params = new URLSearchParams(window.location.search);
var isForced = params.has('force') || params.has('reconfigure');
if (!isForced) {
fetch('/api/auth/status', { cache: 'no-store' })
.then(function (r) { return r.json(); })
.then(function (d) {
if (d) {
if (d.version) {
document.querySelectorAll('.app-version').forEach(function (el) { el.textContent = d.version; });
}
var alreadyConfigured = !!(d.configured || d.setup_completed);
if (alreadyConfigured) {
window.location.replace('/');
}
}
})
.catch(function () { });
}
} catch (_) { }
})();
</script>
<style>
* {
box-sizing: border-box;
}
html,
body {
overflow-x: hidden;
max-width: 100%;
}
body {
margin: 0;
font-family: system-ui, -apple-system, sans-serif;
background: var(--bg);
color: var(--text);
transition: background .2s, color .2s;
min-height: 100vh;
display: flex;
flex-direction: column;
}
.wrap {
max-width: 1080px;
margin: 0 auto;
padding: 26px 20px 60px;
width: 100%;
}
header {
display: flex;
justify-content: space-between;
align-items: center;
margin-bottom: 22px;
gap: 12px;
flex-wrap: wrap;
}
h1 {
margin: 0;
font-size: 24px;
display: flex;
align-items: center;
gap: 10px;
}
.sub {
color: var(--muted);
font-size: 14px;
margin-top: 4px;
}
/* Layout 2 colonnes avec Stepper à gauche */
.setup-layout {
display: grid;
grid-template-columns: 280px 1fr;
gap: 24px;
align-items: start;
}
@media (max-width: 820px) {
.setup-layout {
grid-template-columns: 1fr;
gap: 16px;
}
}
.setup-sidebar {
background: var(--panel);
border: 1px solid var(--line);
border-radius: 14px;
padding: 20px 16px;
box-shadow: 0 4px 20px rgba(0, 0, 0, 0.12);
position: sticky;
top: 20px;
}
.sidebar-title {
font-size: 13px;
font-weight: 700;
text-transform: uppercase;
letter-spacing: .6px;
color: var(--muted);
margin-bottom: 14px;
padding-bottom: 10px;
border-bottom: 1px solid var(--line);
display: flex;
align-items: center;
justify-content: space-between;
}
.stepper-nav {
display: flex;
flex-direction: column;
gap: 8px;
position: relative;
}
@media (max-width: 820px) {
.stepper-nav {
flex-direction: row;
overflow-x: auto;
padding-bottom: 4px;
-webkit-overflow-scrolling: touch;
}
.setup-sidebar {
position: static;
padding: 12px 14px;
}
.sidebar-title {
display: none;
}
}
.step-item {
display: flex;
align-items: center;
gap: 12px;
padding: 10px 12px;
border-radius: 10px;
cursor: default;
transition: all .18s ease;
border: 1px solid transparent;
user-select: none;
position: relative;
pointer-events: none;
}
.step-item.active {
background: rgba(92, 167, 255, 0.14);
border-color: rgba(92, 167, 255, 0.4);
}
.step-item.completed {
opacity: 0.95;
}
.step-badge {
width: 28px;
height: 28px;
border-radius: 50%;
display: flex;
align-items: center;
justify-content: center;
font-weight: 700;
font-size: 13px;
background: var(--panel2);
border: 1px solid var(--line);
color: var(--muted);
flex-shrink: 0;
transition: all .2s;
}
.step-item.active .step-badge {
background: var(--blue);
color: var(--blue-text);
border-color: var(--blue);
box-shadow: 0 0 10px rgba(92, 167, 255, 0.45);
}
.step-item.completed .step-badge {
background: var(--green);
color: #ffffff;
border-color: var(--green);
}
.step-info {
display: flex;
flex-direction: column;
min-width: 0;
}
.step-label {
font-size: 11px;
text-transform: uppercase;
letter-spacing: .4px;
color: var(--muted);
font-weight: 600;
}
.step-title-text {
font-size: 13px;
font-weight: 600;
color: var(--text);
line-height: 1.25;
word-break: normal;
}
.step-item.active .step-title-text {
color: var(--blue);
font-weight: 700;
}
@media (max-width: 820px) {
.step-item {
flex-shrink: 0;
padding: 6px 10px;
gap: 6px;
}
.step-info {
display: none;
}
}
/* Carte principale */
.card {
background: var(--panel);
border: 1px solid var(--line);
border-radius: 14px;
padding: 26px;
box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
}
.step-panel {
display: none;
animation: stepSlideInNext .28s cubic-bezier(0.22, 1, 0.36, 1);
}
.step-panel.active {
display: block;
}
.step-panel.slide-prev {
animation: stepSlideInPrev .28s cubic-bezier(0.22, 1, 0.36, 1);
}
@keyframes fadeIn {
from {
opacity: 0;
transform: translateY(3px);
}
to {
opacity: 1;
transform: translateY(0);
}
}
@keyframes stepSlideInNext {
from {
opacity: 0;
transform: translateX(18px) translateY(2px);
}
to {
opacity: 1;
transform: translateX(0) translateY(0);
}
}
@keyframes stepSlideInPrev {
from {
opacity: 0;
transform: translateX(-18px) translateY(2px);
}
to {
opacity: 1;
transform: translateX(0) translateY(0);
}
}
@keyframes fieldReveal {
from {
opacity: 0;
transform: translateY(-6px);
}
to {
opacity: 1;
transform: translateY(0);
}
}
@keyframes eyePop {
0% {
transform: scale(1);
}
40% {
transform: scale(1.22) rotate(-8deg);
}
75% {
transform: scale(0.92) rotate(4deg);
}
100% {
transform: scale(1) rotate(0);
}
}
@keyframes badgePop {
0% {
transform: scale(0.82);
}
60% {
transform: scale(1.14);
}
100% {
transform: scale(1);
}
}
@keyframes errShake {
0%, 100% {
transform: translateX(0);
}
20% {
transform: translateX(-5px);
}
40% {
transform: translateX(5px);
}
60% {
transform: translateX(-3px);
}
80% {
transform: translateX(3px);
}
}
@keyframes modalPop {
from {
opacity: 0;
transform: scale(0.94) translateY(10px);
}
to {
opacity: 1;
transform: scale(1) translateY(0);
}
}
.pwd-eye-btn {
transition: transform .18s ease, background .18s ease, border-color .18s ease, box-shadow .18s ease;
}
.pwd-eye-btn:hover {
transform: scale(1.06);
border-color: var(--blue);
}
.pwd-eye-btn.eye-pop {
animation: eyePop .32s cubic-bezier(0.34, 1.56, 0.64, 1);
}
.pwd-eye-btn.is-visible {
border-color: var(--blue);
box-shadow: 0 0 0 2px rgba(92, 167, 255, 0.22);
}
.step-item.active .step-badge,
.step-item.completed .step-badge {
animation: badgePop .3s cubic-bezier(0.34, 1.56, 0.64, 1);
}
.lang-card,
.theme-card,
.mode-card,
.recap-box {
transition: transform .2s cubic-bezier(0.22, 1, 0.36, 1), border-color .2s ease, box-shadow .2s ease, background .2s ease;
}
.lang-card:hover,
.theme-card:hover,
.mode-card:hover {
transform: translateY(-2px);
box-shadow: 0 6px 18px rgba(0, 0, 0, 0.18);
}
.lang-card:active,
.theme-card:active,
.mode-card:active {
transform: translateY(0) scale(0.98);
}
.field-reveal {
animation: fieldReveal .24s cubic-bezier(0.22, 1, 0.36, 1);
}
.err-shake {
animation: errShake .34s ease;
}
#modalSetupVpn > div,
#modalSetupBackup > div,
#modalSetupBackupPicker > div {
animation: modalPop .24s cubic-bezier(0.22, 1, 0.36, 1);
}
.setup-backup-tab.active {
border-bottom-color: var(--accent) !important;
color: var(--text) !important;
}
.setup-prov-btn {
transition: all .15s ease;
}
.setup-prov-btn:hover {
border-color: var(--accent) !important;
}
.setup-prov-btn.active {
border-color: var(--accent) !important;
background: var(--accent) !important;
color: #fff !important;
}
#setupDropZone:hover {
border-color: var(--accent) !important;
background: var(--panel3) !important;
}
@media (prefers-reduced-motion: reduce) {
.step-panel,
.step-panel.slide-prev,
.pwd-eye-btn.eye-pop,
.step-item.active .step-badge,
.step-item.completed .step-badge,
.field-reveal,
.err-shake,
#modalSetupVpn > div,
#modalSetupBackup > div,
#modalSetupBackupPicker > div {
animation: none !important;
}
.pwd-eye-btn,
.lang-card,
.theme-card,
.mode-card,
.recap-box {
transition: none !important;
}
}
.panel-header {
margin-bottom: 20px;
padding-bottom: 14px;
border-bottom: 1px solid var(--line);
}
.panel-title {
font-size: 20px;
margin: 0 0 6px;
display: flex;
align-items: center;
gap: 10px;
}
.panel-desc {
color: var(--muted);
font-size: 14px;
margin: 0;
line-height: 1.5;
}
.notice {
background: var(--panel2);
border: 1px solid var(--line);
border-left: 4px solid var(--blue);
border-radius: 8px;
padding: 12px 14px;
font-size: 13px;
color: var(--text);
line-height: 1.5;
margin-bottom: 16px;
}
.label {
display: block;
margin-bottom: 6px;
font-size: 13px;
font-weight: 600;
color: var(--text);
}
input,
select,
button,
textarea {
font-family: inherit;
}
input[type="text"],
input[type="password"],
input[type="number"],
input[type="url"],
input[type="email"],
select,
textarea {
width: 100%;
padding: 11px 12px;
background: var(--panel2);
color: var(--text);
border: 1px solid var(--line);
border-radius: 8px;
font-size: 14px;
margin-bottom: 16px;
outline: none;
transition: border-color .15s;
}
input:focus,
select:focus,
textarea:focus {
border-color: var(--blue);
}
button {
padding: 10px 18px;
background: var(--blue);
color: var(--blue-text);
border: none;
border-radius: 8px;
font-weight: 700;
cursor: pointer;
display: inline-flex;
align-items: center;
justify-content: center;
gap: 8px;
transition: opacity .15s, transform .1s;
font-size: 14px;
}
button:hover {
opacity: .92;
}
button:active {
transform: scale(0.98);
}
button.secondary {
background: var(--panel2);
color: var(--text);
border: 1px solid var(--line);
}
button.secondary:hover {
border-color: var(--blue);
}
.pill {
display: inline-block;
padding: 2px 8px;
border-radius: 999px;
border: 1px solid var(--line);
font-size: 12px;
color: var(--muted);
background: var(--panel2);
}
.muted {
color: var(--muted);
}
.check {
display: flex;
align-items: center;
gap: 8px;
margin-top: 10px;
cursor: pointer;
font-size: 14px;
user-select: none;
}
.check input[type="radio"] {
width: auto !important;
margin: 0 !important;
flex-shrink: 0;
}
/* Windows 11 Fluent Design Toggle Switch pour les checkboxes */
input[type="checkbox"] {
appearance: none !important;
-webkit-appearance: none !important;
position: relative !important;
display: inline-block !important;
width: 40px !important;
height: 20px !important;
min-width: 40px !important;
max-width: 40px !important;
border-radius: 9999px !important;
background-color: rgba(255, 255, 255, 0.08) !important;
border: 1px solid var(--line, rgba(255, 255, 255, 0.35)) !important;
cursor: pointer !important;
outline: none !important;
vertical-align: middle !important;
margin: 0 !important;
flex-shrink: 0 !important;
box-sizing: border-box !important;
transition: background-color 0.2s cubic-bezier(0.4, 0, 0.2, 1),
border-color 0.2s cubic-bezier(0.4, 0, 0.2, 1),
box-shadow 0.2s cubic-bezier(0.4, 0, 0.2, 1) !important;
}
input[type="checkbox"]::before {
content: "" !important;
position: absolute !important;
top: 3px !important;
left: 3px !important;
width: 12px !important;
height: 12px !important;
border-radius: 50% !important;
background-color: var(--muted, #9aa8c5) !important;
transition: transform 0.2s cubic-bezier(0.2, 0.8, 0.4, 1),
width 0.15s ease,
background-color 0.2s ease !important;
}
/* Hover état désactivé */
input[type="checkbox"]:hover {
background-color: rgba(255, 255, 255, 0.14) !important;
border-color: rgba(255, 255, 255, 0.55) !important;
}
input[type="checkbox"]:hover::before {
background-color: var(--text, #ffffff) !important;
}
/* Clic maintenu (effet d'étirement Fluent Win11) */
input[type="checkbox"]:active::before {
width: 15px !important;
}
/* État Activé (Checked) */
input[type="checkbox"]:checked {
background-color: var(--blue, #38bdf8) !important;
border-color: var(--blue, #38bdf8) !important;
}
input[type="checkbox"]:checked::before {
transform: translateX(20px) !important;
background-color: #000000 !important;
}
input[type="checkbox"]:checked:hover {
filter: brightness(1.08) !important;
}
input[type="checkbox"]:checked:active::before {
transform: translateX(17px) !important;
width: 15px !important;
}
/* Focus navigation clavier */
input[type="checkbox"]:focus-visible {
box-shadow: 0 0 0 2px var(--bg, #071326), 0 0 0 4px var(--blue, #38bdf8) !important;
}
/* Disabled */
input[type="checkbox"]:disabled {
opacity: 0.4 !important;
cursor: not-allowed !important;
}
/* Adaptation thème clair */
html[data-theme="light"] input[type="checkbox"] {
background-color: rgba(0, 0, 0, 0.06) !important;
border-color: rgba(0, 0, 0, 0.28) !important;
}
html[data-theme="light"] input[type="checkbox"]::before {
background-color: #5c5c5c !important;
}
html[data-theme="light"] input[type="checkbox"]:hover {
background-color: rgba(0, 0, 0, 0.1) !important;
border-color: rgba(0, 0, 0, 0.45) !important;
}
html[data-theme="light"] input[type="checkbox"]:checked {
background-color: var(--blue, #0066da) !important;
border-color: var(--blue, #0066da) !important;
}
html[data-theme="light"] input[type="checkbox"]:checked::before {
background-color: #ffffff !important;
}
.settings-nav {
display: flex;
flex-wrap: wrap;
gap: 8px;
margin-bottom: 16px;
align-items: center;
}
.settings-nav-btn {
background: var(--panel);
border: 1px solid var(--line);
color: var(--muted);
font-size: 13px;
font-weight: 600;
padding: 7px 14px;
border-radius: 8px;
cursor: pointer;
white-space: nowrap;
flex-shrink: 0;
transition: all .18s ease;
user-select: none;
display: inline-flex;
align-items: center;
gap: 6px;
}
.settings-nav-btn:hover:not(.active) {
background: var(--panel2);
color: var(--text);
border-color: var(--blue);
}
.settings-nav-btn.active {
background: var(--blue) !important;
color: var(--blue-text, #071326) !important;
border-color: var(--blue) !important;
font-weight: 700 !important;
box-shadow: 0 2px 8px rgba(92, 167, 255, .3);
}
.pill-blue {
background: rgba(92, 167, 255, .16) !important;
color: var(--blue) !important;
border: 1px solid rgba(92, 167, 255, .38) !important;
font-weight: 600;
display: inline-flex;
align-items: center;
gap: 6px;
}
.pill-no-dot {
padding: 3px 10px;
}
/* Grille de sélection de mode réseau */
.mode-selector-grid {
display: grid;
grid-template-columns: 1fr 1fr;
gap: 12px;
margin-bottom: 16px;
}
@media (max-width: 650px) {
.mode-selector-grid {
grid-template-columns: 1fr;
}
}
.mode-card {
background: var(--panel2);
border: 1px solid var(--line);
border-radius: 10px;
padding: 14px;
cursor: pointer;
transition: all .2s;
display: flex;
align-items: flex-start;
gap: 10px;
}
.mode-card:hover {
border-color: var(--blue);
}
.mode-card.selected {
border-color: var(--blue);
background: rgba(92, 167, 255, 0.08);
}
.step-actions {
display: flex;
align-items: center;
justify-content: space-between;
gap: 12px;
margin-top: 24px;
padding-top: 18px;
border-top: 1px solid var(--line);
flex-wrap: wrap;
}
.step-actions-right {
display: flex;
gap: 10px;
margin-left: auto;
flex-wrap: wrap;
}
/* Grille de sélection de thèmes */
.theme-grid {
display: grid;
grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
gap: 10px;
margin-bottom: 20px;
}
.theme-card {
background: var(--panel2);
border: 1px solid var(--line);
border-radius: 9px;
padding: 12px 10px;
text-align: center;
cursor: pointer;
transition: all .18s;
user-select: none;
}
.theme-card:hover {
border-color: var(--blue);
}
.theme-card.active {
border-color: var(--blue);
background: rgba(92, 167, 255, 0.15);
font-weight: 700;
box-shadow: 0 0 0 1px var(--blue);
}
.theme-icon {
font-size: 22px;
margin-bottom: 4px;
}
/* Grille des Langues avec vrais drapeaux SVG */
.lang-grid {
display: grid;
grid-template-columns: repeat(3, 1fr);
gap: 12px;
margin-bottom: 20px;
}
@media (max-width: 650px) {
.lang-grid {
grid-template-columns: 1fr;
}
}
.lang-card {
background: var(--panel2);
border: 1px solid var(--line);
border-radius: 10px;
padding: 14px 14px;
display: flex;
align-items: center;
gap: 12px;
cursor: pointer;
transition: all .18s;
user-select: none;
}
.lang-card:hover {
border-color: var(--blue);
transform: translateY(-1px);
}
.lang-card.active {
border-color: var(--blue);
background: rgba(92, 167, 255, 0.15);
box-shadow: 0 0 0 1px var(--blue);
}
.flag-icon {
width: 36px;
height: 26px;
border-radius: 4px;
box-shadow: 0 2px 5px rgba(0, 0, 0, 0.28);
flex-shrink: 0;
display: block;
border: 1px solid rgba(255, 255, 255, 0.18);
}
/* Récapitulatif Final */
.recap-grid {
display: grid;
grid-template-columns: 1fr 1fr;
gap: 14px;
margin-bottom: 20px;
}
@media (max-width: 650px) {
.recap-grid {
grid-template-columns: 1fr;
}
}
.recap-box {
background: var(--panel2);
border: 1px solid var(--line);
border-radius: 10px;
padding: 14px 16px;
}
.recap-box-title {
font-size: 12px;
font-weight: 700;
text-transform: uppercase;
letter-spacing: .5px;
color: var(--muted);
margin-bottom: 6px;
display: flex;
align-items: center;
gap: 6px;
}
.recap-box-val {
font-size: 15px;
font-weight: 700;
color: var(--text);
word-break: break-all;
}
.recap-box-sub {
font-size: 12px;
color: var(--muted);
margin-top: 2px;
}
/* Barre de progression d'installation */
.progress-bar-container {
width: 100%;
height: 8px;
background: var(--panel2);
border-radius: 4px;
overflow: hidden;
margin: 16px 0 10px;
display: none;
}
.progress-bar-fill {
height: 100%;
width: 0%;
background: linear-gradient(90deg, var(--blue), var(--green));
transition: width .3s ease;
}
/* Carte de profil VPN dans la liste */
.vpn-profile-item {
display: flex;
align-items: center;
justify-content: space-between;
gap: 10px;
background: var(--panel2);
border: 1px solid var(--line);
border-radius: 8px;
padding: 10px 14px;
}
@keyframes radarPulse {
0% { transform: scale(0.9); opacity: 0.8; }
50% { transform: scale(1.4); opacity: 0.2; }
100% { transform: scale(1.8); opacity: 0; }
}
@keyframes iconFloat {
0%, 100% { transform: translateY(0); }
50% { transform: translateY(-4px); }
}
@keyframes spin {
0% { transform: rotate(0deg); }
100% { transform: rotate(360deg); }
}
.loader-step {
display: flex;
align-items: center;
gap: 8px;
padding: 7px 12px;
background: var(--panel2);
border-radius: 8px;
border: 1px solid transparent;
font-size: 12.5px;
transition: all .25s ease;
}
.loader-step.active {
border-color: rgba(56, 189, 248, 0.4);
}
.loader-step.done {
border-color: rgba(34, 197, 94, 0.3);
}
</style>
<link rel="stylesheet" href="/themes/dark.css">
<link rel="stylesheet" href="/themes/light.css">
<link rel="stylesheet" href="/themes/winxp.css">
<link rel="stylesheet" href="/themes/futuristic.css">
<link rel="stylesheet" href="/themes/macos.css">
<link rel="stylesheet" href="/themes/hacker.css">
</head>
<body>
<div class="wrap">
<header>
<div>
<h1>
<img src="/images/favicon.png" alt="Logo" width="30" height="30"
style="vertical-align:middle;border-radius:7px;box-shadow:0 2px 6px rgba(0,0,0,0.3)"
onerror="this.style.display='none'">
<span class="app-title" data-i18n="app_title">Administration de l’AP Wi‑Fi</span>
</h1>
<div class="sub">
<span class="app-short-title">AP Manageur</span>
<span class="pill app-version" style="margin-left:6px;font-size:11px">V1.2 (Bêta)</span>
<span class="pill" style="margin-left:4px;font-size:11px;color:var(--blue);border-color:var(--blue)"
data-i18n="app_badge_setup">Configuration initiale</span>
</div>
</div>
</header>
<!-- Message si le point d'accès est déjà configuré -->
<div id="alreadyConfiguredAlert" class="card" style="display:none;margin-bottom:20px;border-color:var(--green)">
<div>
<div style="display:flex;align-items:center;gap:8px;font-weight:700;color:var(--green);font-size:16px">
<span>✅</span> <span>Point d'accès déjà configuré</span>
</div>
<div class="muted" style="margin-top:4px;font-size:13px" id="alreadyConfiguredDetails">
Votre point d'accès Wi-Fi est opérationnel.
</div>
</div>
</div>
<!-- Layout Stepper à gauche + Contenu à droite -->
<div class="setup-layout">
<!-- Stepper latéral gauche -->
<aside class="setup-sidebar">
<div class="sidebar-title">
<span data-i18n="sidebar_title">Étapes d'installation</span>
<span id="sidebarProgressText" style="color:var(--blue);font-size:12px;text-transform:none">1 / 6</span>
</div>
<nav class="stepper-nav" aria-label="Étapes de configuration">
<!-- Étape 1 -->
<div class="step-item active" id="stepNav1">
<div class="step-badge" id="stepBadge1">1</div>
<div class="step-info">
<span class="step-label" data-i18n="step_label_1">Étape 1</span>
<span class="step-title-text" data-i18n="step_name_1">Bienvenue</span>
</div>
</div>
<!-- Étape 2 -->
<div class="step-item" id="stepNav2">
<div class="step-badge" id="stepBadge2">2</div>
<div class="step-info">
<span class="step-label" data-i18n="step_label_2">Étape 2</span>
<span class="step-title-text" data-i18n="step_name_2">Configuration du réseau Wifi</span>
</div>
</div>
<!-- Étape 3 -->
<div class="step-item" id="stepNav3">
<div class="step-badge" id="stepBadge3">3</div>
<div class="step-info">
<span class="step-label" data-i18n="step_label_3">Étape 3</span>
<span class="step-title-text" data-i18n="step_name_3">Création du compte administrateur</span>
</div>
</div>
<!-- Étape 4 -->
<div class="step-item" id="stepNav4">
<div class="step-badge" id="stepBadge4">4</div>
<div class="step-info">
<span class="step-label" data-i18n="step_label_4">Étape 4</span>
<span class="step-title-text" data-i18n="step_name_4">Notification</span>
</div>
</div>
<!-- Étape 5 -->
<div class="step-item" id="stepNav5">
<div class="step-badge" id="stepBadge5">5</div>
<div class="step-info">
<span class="step-label" data-i18n="step_label_5">Étape 5</span>
<span class="step-title-text" data-i18n="step_name_5">Option facultatif</span>
</div>
</div>
<!-- Étape 6 -->
<div class="step-item" id="stepNav6">
<div class="step-badge" id="stepBadge6">6</div>
<div class="step-info">
<span class="step-label" data-i18n="step_label_6">Étape 6</span>
<span class="step-title-text" data-i18n="step_name_6">Fin de configuration</span>
</div>
</div>
</nav>
</aside>
<!-- Contenu principal à droite -->
<main class="card setup-main">
<!-- ============================================== -->
<!-- ÉTAPE 1 : BIENVENUE -->
<!-- ============================================== -->
<section class="step-panel active" id="panelStep1">
<div class="panel-header">
<h2 class="panel-title"><span>👋</span> <span data-i18n="step1_title">Bienvenue sur AP Manageur</span></h2>
<p class="panel-desc" data-i18n="step1_desc">
Cet assistant vous accompagne pas à pas pour initialiser votre point d'accès Wi-Fi et sécuriser l'accès à
votre tableau de bord.
</p>
</div>
<div class="notice">
<strong data-i18n="step1_guide_title">🚀 Mise en route en 6 étapes simples :</strong>
<ul style="margin:8px 0 0;padding-left:20px;line-height:1.6">
<li data-i18n="step1_guide_1">Définition du nom (SSID) et du mot de passe de votre réseau sans fil</li>
<li data-i18n="step1_guide_2">Création du compte administrateur du tableau de bord</li>
<li data-i18n="step1_guide_3">Paramétrage des alertes et notifications (optionnel)</li>
<li data-i18n="step1_guide_4">Personnalisation du thème, des profils VPN et des préférences (optionnel)
</li>
</ul>
</div>
<div style="margin-top:16px">
<label class="label" data-i18n="step1_choose_lang">Choisissez la langue de l'interface :</label>
<div class="lang-grid">
<!-- France -->
<div class="lang-card" id="langCard_fr" onclick="setSetupLanguage('fr', true)">
<svg class="flag-icon" viewBox="0 0 3 2">
<rect width="1" height="2" fill="#002654" />
<rect x="1" width="1" height="2" fill="#ffffff" />
<rect x="2" width="1" height="2" fill="#ce1126" />
</svg>
<div>
<div style="font-weight:700" data-i18n="lang_fr_name">Français</div>
<div class="muted" style="font-size:11px" data-i18n="lang_fr_sub">France</div>
</div>
</div>
<!-- USA -->
<div class="lang-card" id="langCard_en-us" onclick="setSetupLanguage('en-us', true)">
<svg class="flag-icon" viewBox="0 0 60 38">
<rect width="60" height="38" fill="#b22234" />
<path d="M0,2.92h60 M0,8.77h60 M0,14.62h60 M0,20.46h60 M0,26.31h60 M0,32.15h60" stroke="#fff"
stroke-width="2.92" />
<rect width="25" height="20.5" fill="#3c3b6e" />
<g fill="#fff">
<circle cx="4" cy="3.5" r="1.1" />
<circle cx="9" cy="3.5" r="1.1" />
<circle cx="14" cy="3.5" r="1.1" />
<circle cx="19" cy="3.5" r="1.1" />
<circle cx="6.5" cy="7" r="1.1" />
<circle cx="11.5" cy="7" r="1.1" />
<circle cx="16.5" cy="7" r="1.1" />
<circle cx="21.5" cy="7" r="1.1" />
<circle cx="4" cy="10.5" r="1.1" />
<circle cx="9" cy="10.5" r="1.1" />
<circle cx="14" cy="10.5" r="1.1" />
<circle cx="19" cy="10.5" r="1.1" />
<circle cx="6.5" cy="14" r="1.1" />
<circle cx="11.5" cy="14" r="1.1" />
<circle cx="16.5" cy="14" r="1.1" />
<circle cx="21.5" cy="14" r="1.1" />
<circle cx="4" cy="17.5" r="1.1" />
<circle cx="9" cy="17.5" r="1.1" />
<circle cx="14" cy="17.5" r="1.1" />
<circle cx="19" cy="17.5" r="1.1" />
</g>
</svg>
<div>
<div style="font-weight:700" data-i18n="lang_en_us_name">English (US)</div>
<div class="muted" style="font-size:11px" data-i18n="lang_en_us_sub">United States</div>
</div>
</div>
<!-- UK -->
<div class="lang-card" id="langCard_en-gb" onclick="setSetupLanguage('en-gb', true)">
<svg class="flag-icon" viewBox="0 0 60 38">
<clipPath id="uk-flag-clip">
<rect width="60" height="38" rx="2" />
</clipPath>
<g clip-path="url(#uk-flag-clip)">
<rect width="60" height="38" fill="#012169" />
<path d="M0,0 L60,38 M60,0 L0,38" stroke="#fff" stroke-width="7" />
<path d="M0,0 L60,38 M60,0 L0,38" stroke="#c8102e" stroke-width="4" />
<path d="M30,0 v38 M0,19 h60" stroke="#fff" stroke-width="12" />
<path d="M30,0 v38 M0,19 h60" stroke="#c8102e" stroke-width="7" />
</g>
</svg>
<div>
<div style="font-weight:700" data-i18n="lang_en_gb_name">English (UK)</div>
<div class="muted" style="font-size:11px" data-i18n="lang_en_gb_sub">United Kingdom</div>
</div>
</div>
</div>
</div>
<!-- Bannière de détection de sauvegardes existantes -->
<div id="setupDetectedBackupsBanner"
style="display:none;margin-top:16px;padding:14px 16px;background:rgba(92,167,255,0.08);border:1px solid rgba(92,167,255,0.28);border-radius:10px;align-items:center;justify-content:space-between;gap:12px;flex-wrap:wrap">
<div style="display:flex;align-items:center;gap:12px">
<span style="font-size:24px">💾</span>
<div>
<div style="font-weight:700;font-size:14px" id="setupDetectedBackupsTitle" data-i18n="setup_detected_backups_title">Sauvegardes existantes détectées</div>
<div class="muted" style="font-size:12px;margin-top:2px" id="setupDetectedBackupsDesc" data-i18n="setup_detected_backups_desc">Des sauvegardes ont été trouvées sur le serveur. Vous pouvez restaurer votre configuration immédiatement.</div>
</div>
</div>
<button type="button" onclick="openSetupBackupPickerModal('server')"
style="display:inline-flex;align-items:center;gap:6px;padding:7px 14px;font-size:13px;white-space:nowrap">
<span>📂</span> <span data-i18n="btn_view_detected_backups">Voir les sauvegardes</span>
</button>
</div>
<!-- Input masqué pour importer une sauvegarde -->
<input type="file" id="setupBackupFileInput" accept=".json,.zip,.sqlite,.sqlite3" style="display:none"
onchange="handleSetupBackupFile(event)">
<div class="step-actions">
<div class="muted" style="font-size:13px" id="step1CounterText" data-i18n="step1_counter">Étape 1 sur 6
</div>
<div class="step-actions-right">
<button type="button" class="secondary" onclick="openSetupBackupPickerModal()"
style="display:flex;align-items:center;gap:6px">
<span>📦</span> <span data-i18n="btn_import_backup">Importer une sauvegarde</span>
</button>
<button type="button" onclick="goToStep(2)" style="display:flex;align-items:center;gap:6px">
<span data-i18n="btn_start_config">Commencer la configuration</span> <span>→</span>
</button>
</div>
</div>
</section>
<!-- ============================================== -->
<!-- ÉTAPE 2 : CONFIGURATION DU RÉSEAU WIFI -->
<!-- ============================================== -->
<section class="step-panel" id="panelStep2">
<div class="panel-header">
<h2 class="panel-title"><span>📶</span> <span data-i18n="step2_title">Configuration du réseau Wi-Fi</span>
</h2>
<p class="panel-desc" data-i18n="step2_desc">
Configurez le nom de diffusion (SSID), la clé de sécurité et le mode de routage.
</p>
</div>
<label class="label" for="setupSsid" data-i18n="step2_ssid_label">Nom du réseau (SSID) *</label>
<input id="setupSsid" type="text" maxlength="32" placeholder="Ex: Mon-WiFi-Maison" value="Mon-WiFi-AP">
<p class="muted" style="font-size:12px;margin:-10px 0 16px" data-i18n="step2_ssid_hint">1 à 32 caractères
visibles par vos téléphones, PC et équipements.</p>
<label class="label" for="setupPassword" data-i18n="step2_pwd_label">Mot de passe Wi-Fi (Clé de sécurité WPA)
*</label>
<div style="display:flex;gap:8px;margin-bottom:6px">
<input id="setupPassword" type="password" minlength="8" maxlength="63" placeholder="8 caractères minimum"
data-i18n-placeholder="step2_pwd_ph" style="margin:0">
<button class="secondary pwd-eye-btn" type="button" onclick="togglePasswordVisibility('setupPassword', this)"
title="Afficher" aria-label="Afficher" data-i18n-title="toggle_pwd_show"
data-i18n-aria-label="toggle_pwd_show">👁️</button>
</div>
<div id="pwdStrengthWrap_setupWifi" style="margin:0 0 16px;display:none">
<div style="display:flex;align-items:center;justify-content:space-between;margin-bottom:4px;font-size:11.5px">
<span class="muted" data-i18n="pwd_strength_label">Force du mot de passe :</span>
<span id="pwdStrengthText_setupWifi" style="font-weight:700"></span>
</div>
<div style="height:4px;background:var(--line);border-radius:4px;overflow:hidden">
<div id="pwdStrengthBar_setupWifi" style="height:100%;width:0%;border-radius:4px;transition:width .25s ease, background-color .25s ease"></div>
</div>
</div>
<label class="label" for="setupPasswordConfirm" data-i18n="step2_pwd_confirm_label">Confirmation du mot de
passe Wi-Fi *</label>
<div style="display:flex;gap:8px;margin-bottom:6px">
<input id="setupPasswordConfirm" type="password" minlength="8" maxlength="63"
placeholder="Confirmation identique" data-i18n-placeholder="step2_pwd_confirm_ph" style="margin:0">
<button class="secondary pwd-eye-btn" type="button" onclick="togglePasswordVisibility('setupPasswordConfirm', this)"
title="Afficher" aria-label="Afficher" data-i18n-title="toggle_pwd_show"
data-i18n-aria-label="toggle_pwd_show">👁️</button>
</div>
<div id="pwdStrengthWrap_setupWifiConfirm" style="margin:0 0 16px;display:none">
<div style="display:flex;align-items:center;justify-content:space-between;margin-bottom:4px;font-size:11.5px">
<span class="muted" data-i18n="pwd_strength_label">Force du mot de passe :</span>
<div style="display:flex;align-items:center;gap:6px">
<span id="pwdMatchText_setupWifiConfirm" style="font-size:11px;font-weight:600"></span>
<span id="pwdStrengthText_setupWifiConfirm" style="font-weight:700"></span>
</div>
</div>
<div style="height:4px;background:var(--line);border-radius:4px;overflow:hidden">
<div id="pwdStrengthBar_setupWifiConfirm" style="height:100%;width:0%;border-radius:4px;transition:width .25s ease, background-color .25s ease"></div>
</div>
</div>
<label class="label" for="setupSecurity" data-i18n="step2_sec_label">Type de sécurité Wi-Fi</label>
<select id="setupSecurity">
<option value="wpa2" selected data-i18n="step2_sec_wpa2">WPA2-Personal (Recommandé - compatible tous
appareils)</option>
<option value="wpa3" data-i18n="step2_sec_wpa3">WPA3-Personal (Sécurité maximale - appareils récents)
</option>
<option value="wpa1" data-i18n="step2_sec_wpa1">WPA/WPA2 Mixte (Équipements anciens)</option>
</select>
<label class="label" data-i18n="step2_mode_label">Mode de fonctionnement réseau</label>
<div class="mode-selector-grid">
<label class="mode-card selected" id="cardModeAp">
<input type="radio" name="setupMode" id="setupModeAp" value="ap" checked
style="width:auto;margin:3px 0 0 0" onchange="onModeChange()">
<div>
<strong data-i18n="step2_mode_ap_title">Mode AP (Routeur / NAT)</strong>
<div class="muted" style="font-size:12px;margin-top:2px" data-i18n="step2_mode_ap_desc">
Serveur DHCP interne (10.42.0.x). Réseau Wi-Fi autonome et sécurisé.
</div>
</div>
</label>
<label class="mode-card" id="cardModeBridge">
<input type="radio" name="setupMode" id="setupModeBridge" value="bridge"
style="width:auto;margin:3px 0 0 0" onchange="onModeChange()">
<div>
<strong data-i18n="step2_mode_bridge_title">Mode Bridge (Pont transparent)</strong>
<div class="muted" style="font-size:12px;margin-top:2px" data-i18n="step2_mode_bridge_desc">
Les appareils Wi-Fi reçoivent leur IP directement de votre box Internet.
</div>
</div>
</label>
</div>
<div id="setupBridgeBlock" style="display:none;margin-bottom:16px">
<label class="label" for="setupBridgeEth" data-i18n="step2_bridge_eth_label">Interface Ethernet reliée à la
box (Pont)</label>
<select id="setupBridgeEth" style="margin-bottom:8px"></select>
<p class="muted" style="font-size:12px;margin:0" data-i18n="step2_bridge_eth_hint">
L'interface réseau physique qui transmet les paquets vers votre réseau local.
</p>
</div>
<label class="label" for="setupMaxClients" data-i18n="step2_max_clients_label">Limite d'appareils simultanés
(0 = illimité)</label>
<input id="setupMaxClients" type="number" min="0" max="250" value="0" placeholder="0 pour illimité">
<div id="step2Error" class="muted"
style="color:var(--red);font-weight:600;font-size:13px;display:none;margin-top:8px"></div>
<div class="step-actions">
<button type="button" class="secondary" onclick="goToStep(1)" data-i18n="btn_prev">← Précédent</button>
<div class="step-actions-right">
<button type="button" onclick="validateStep2()" data-i18n="btn_continue">
<span>Continuer</span> <span>→</span>
</button>
</div>
</div>
</section>
<!-- ============================================== -->
<!-- ÉTAPE 3 : CRÉATION DU COMPTE ADMINISTRATEUR -->
<!-- ============================================== -->
<section class="step-panel" id="panelStep3">
<div class="panel-header">
<h2 class="panel-title"><span>🛡️</span> <span data-i18n="step3_title">Création du compte
administrateur</span></h2>
<p class="panel-desc" data-i18n="step3_desc">
Définissez le compte d'administration qui protégera l'accès au tableau de bord.
</p>
</div>
<div id="adminAlreadySetMsg" style="display:none" class="notice" style="border-color:var(--green)">
✅ Un compte administrateur est déjà enregistré. Vous pouvez conserver le compte actuel ou saisir de nouveaux
identifiants.
</div>
<label class="label" for="setupAdminUser" data-i18n="step3_user_label">Nom d'utilisateur administrateur
*</label>
<input id="setupAdminUser" type="text" maxlength="32" placeholder="admin" value="admin">
<label class="label" for="setupAdminPassword" data-i18n="step3_pwd_label">Mot de passe administrateur
*</label>
<div style="display:flex;gap:8px;margin-bottom:6px">
<input id="setupAdminPassword" type="password" minlength="4" maxlength="128"
placeholder="Mot de passe robuste" data-i18n-placeholder="step3_pwd_ph" style="margin:0">
<button class="secondary pwd-eye-btn" type="button" onclick="togglePasswordVisibility('setupAdminPassword', this)"
title="Afficher" aria-label="Afficher" data-i18n-title="toggle_pwd_show"
data-i18n-aria-label="toggle_pwd_show">👁️</button>
</div>
<div id="pwdStrengthWrap_setupAdmin" style="margin:0 0 16px;display:none">
<div style="display:flex;align-items:center;justify-content:space-between;margin-bottom:4px;font-size:11.5px">
<span class="muted" data-i18n="pwd_strength_label">Force du mot de passe :</span>
<span id="pwdStrengthText_setupAdmin" style="font-weight:700"></span>
</div>
<div style="height:4px;background:var(--line);border-radius:4px;overflow:hidden">
<div id="pwdStrengthBar_setupAdmin" style="height:100%;width:0%;border-radius:4px;transition:width .25s ease, background-color .25s ease"></div>
</div>
</div>
<label class="label" for="setupAdminPasswordConfirm" data-i18n="step3_pwd_confirm_label">Confirmation du mot
de passe *</label>
<div style="display:flex;gap:8px;margin-bottom:6px">
<input id="setupAdminPasswordConfirm" type="password" minlength="4" maxlength="128"
placeholder="Ressaisissez le mot de passe" data-i18n-placeholder="step3_pwd_confirm_ph" style="margin:0">
<button class="secondary pwd-eye-btn" type="button"
onclick="togglePasswordVisibility('setupAdminPasswordConfirm', this)"
title="Afficher" aria-label="Afficher" data-i18n-title="toggle_pwd_show"
data-i18n-aria-label="toggle_pwd_show">👁️</button>
</div>
<div id="pwdStrengthWrap_setupAdminConfirm" style="margin:0 0 16px;display:none">
<div style="display:flex;align-items:center;justify-content:space-between;margin-bottom:4px;font-size:11.5px">
<span class="muted" data-i18n="pwd_strength_label">Force du mot de passe :</span>
<div style="display:flex;align-items:center;gap:6px">
<span id="pwdMatchText_setupAdminConfirm" style="font-size:11px;font-weight:600"></span>
<span id="pwdStrengthText_setupAdminConfirm" style="font-weight:700"></span>
</div>
</div>
<div style="height:4px;background:var(--line);border-radius:4px;overflow:hidden">
<div id="pwdStrengthBar_setupAdminConfirm" style="height:100%;width:0%;border-radius:4px;transition:width .25s ease, background-color .25s ease"></div>
</div>
</div>
<div class="notice" style="margin-top:8px" data-i18n-html="step3_security_note">
🔐 <strong>Sécurité renforcée</strong> : Une fois le compte créé, vous pourrez activer l'authentification à
double facteur (2FA TOTP) et enregistrer des clés Passkeys (WebAuthn / Empreinte) dans les Paramètres.
</div>
<div id="step3Error" class="muted"
style="color:var(--red);font-weight:600;font-size:13px;display:none;margin-top:8px"></div>
<div class="step-actions">
<button type="button" class="secondary" onclick="goToStep(2)" data-i18n="btn_prev">← Précédent</button>
<div class="step-actions-right">
<button type="button" onclick="validateStep3()" data-i18n="btn_continue">
<span>Continuer</span> <span>→</span>
</button>
</div>
</div>
</section>
<!-- ============================================== -->
<!-- ÉTAPE 4 : NOTIFICATION -->
<!-- ============================================== -->
<section class="step-panel" id="panelStep4">
<div class="panel-header">
<h2 class="panel-title"><span>🔔</span> <span data-i18n="step4_title">Notifications & Alertes</span></h2>
<p class="panel-desc" data-i18n="step4_desc">
Configurez des alertes en temps réel lors des connexions, déconnexions ou blocages d'appareils.
</p>
</div>
<div id="notifChannelsBox"
style="display:block;background:var(--panel2);border:1px solid var(--line);border-radius:12px;padding:16px;margin-bottom:16px">
<p class="muted" style="font-size:13px;margin:0 0 14px" data-i18n="step4_channels_hint">
Renseignez au moins un canal ci-dessous (vous pourrez aussi le faire plus tard dans les Réglages) :
</p>
<div class="settings-nav" role="tablist"
style="margin:0 0 16px;border-bottom:1px solid var(--line);padding-bottom:12px">
<button id="btnSubTabNotifServices" class="settings-nav-btn active" type="button" role="tab"
aria-selected="true" onclick="selectSetupNotifSubTab('services')">
<span>📡</span> <span data-i18n="settings_notif_tab_services">Services de notification (9)</span>
</button>
<button id="btnSubTabNotifAlerts" class="settings-nav-btn" type="button" role="tab" aria-selected="false"
onclick="selectSetupNotifSubTab('alerts')">
<span>⚡</span> <span data-i18n="notif_events_title">Événements déclencheurs d’alerte</span>
</button>
</div>
<div id="setupNotifTestDetails"></div>
<!-- Sous-onglet 1 : Services de notification (9 canaux) -->
<div id="panelSetupNotifServices" style="display:block">
<!-- Canal 1 : Email (SMTP) -->
<div
style="background:var(--panel);border:1px solid var(--line);border-radius:12px;padding:16px;margin-bottom:16px">
<div
style="display:flex;justify-content:space-between;align-items:center;flex-wrap:wrap;gap:10px;margin-bottom:12px">
<div style="display:flex;align-items:center;gap:10px">
<div
style="width:32px;height:32px;flex-shrink:0;display:flex;align-items:center;justify-content:center">
<svg width="28" height="28" viewBox="0 0 24 24" fill="none">
<rect width="24" height="24" rx="6" fill="#2563EB" />
<path
d="M4 7.5A2.5 2.5 0 0 1 6.5 5h11A2.5 2.5 0 0 1 20 7.5v9a2.5 2.5 0 0 1-2.5 2.5h-11A2.5 2.5 0 0 1 4 16.5v-9zm2.2-.5a1 1 0 0 0-.7 1.7l6 5a1 1 0 0 0 1.3 0l6-5a1 1 0 0 0-.7-1.7H6.2z"
fill="#FFFFFF" />
</svg>
</div>
<div>
<strong style="font-size:15px" data-i18n="notif_email_title">Notification par Email
(SMTP)</strong>
<div class="muted" style="font-size:12px" data-i18n="notif_email_desc">Envoi direct via votre
serveur de messagerie</div>
</div>
</div>
<label class="check" style="margin:0;font-weight:700">
<input id="notifEmailEnabled" type="checkbox" onchange="toggleNotifFields('email')">
<span data-i18n="notif_email_enable">Activer Email</span>
</label>
</div>
<div id="notifEmailFields" style="display:none;padding-top:10px;border-top:1px solid var(--line)">
<div style="display:grid;grid-template-columns:2fr 1fr;gap:10px">
<div>
<label class="label" for="notifEmailHost" style="margin-top:4px"
data-i18n="notif_email_host_label">Hôte SMTP</label>
<input id="notifEmailHost" type="text" placeholder="smtp.gmail.com">
</div>
<div>
<label class="label" for="notifEmailPort" style="margin-top:4px"
data-i18n="notif_email_port_label">Port SMTP</label>
<input id="notifEmailPort" type="number" placeholder="587" value="587">
</div>
</div>
<div style="display:grid;grid-template-columns:1fr 1fr;gap:10px">
<div>
<label class="label" for="notifEmailSecure" data-i18n="notif_email_sec_label">Sécurité</label>
<select id="notifEmailSecure"
style="display:block;width:100%;margin:7px 0 16px;padding:12px;border-radius:9px;border:1px solid var(--line);background:var(--panel2);color:var(--text);font-size:14px">
<option value="starttls" data-i18n="notif_email_starttls_hint">STARTTLS (recommandé port 587)
</option>
<option value="ssl" data-i18n="notif_email_sec_ssl_465">SSL / TLS (port 465)</option>
<option value="none" data-i18n="notif_email_none_hint">Aucune (port 25 non chiffré)</option>
</select>
</div>
<div>
<label class="label" for="notifEmailUser" data-i18n="notif_email_user_label">Identifiant
SMTP</label>
<input id="notifEmailUser" type="text" placeholder="utilisateur@exemple.com">
</div>
</div>
<label class="label" for="notifEmailPass" data-i18n="notif_email_pass_label">Mot de passe SMTP</label>
<div style="display:flex;gap:8px;margin:7px 0 16px">
<input id="notifEmailPass" type="password" placeholder="Mot de passe ou mot de passe d’application"
data-i18n-placeholder="placeholder_email_pass" style="margin:0">
<button id="toggleNotifEmailPass" class="secondary pwd-eye-btn" type="button"
aria-label="Afficher" title="Afficher" data-i18n-title="toggle_pwd_show"
data-i18n-aria-label="toggle_pwd_show"
onclick="togglePasswordVisibility('notifEmailPass', this)">👁️</button>
</div>
<div style="display:grid;grid-template-columns:1fr 1fr;gap:10px">
<div>
<label class="label" for="notifEmailFrom" data-i18n="notif_email_from_full">Expéditeur
(From)</label>
<input id="notifEmailFrom" type="text" placeholder="AP Manageur &lt;alerte@exemple.com&gt;">
</div>
<div>
<label class="label" for="notifEmailTo" data-i18n="notif_email_to_label">Destinataire(s)
(To)</label>
<input id="notifEmailTo" type="text" placeholder="destinataire@exemple.com">
</div>
</div>
<div style="display:flex;justify-content:flex-end;margin-top:8px">
<button type="button" class="secondary" onclick="testSetupNotification('email')"
style="font-size:13px;padding:6px 14px" data-i18n="notif_email_test_btn">Tester l’envoi
Email</button>
</div>
</div>
</div>
<!-- Canal 2 : Gotify -->
<div
style="background:var(--panel);border:1px solid var(--line);border-radius:12px;padding:16px;margin-bottom:16px">
<div
style="display:flex;justify-content:space-between;align-items:center;flex-wrap:wrap;gap:10px;margin-bottom:12px">
<div style="display:flex;align-items:center;gap:10px">
<div
style="width:32px;height:32px;flex-shrink:0;display:flex;align-items:center;justify-content:center">
<svg width="32" height="32" viewBox="46.6 113.46 377.2 307.81" fill="none"
xmlns="http://www.w3.org/2000/svg">
<style>
.gtf-paw {
fill: #ddcba2;
stroke: #000;
stroke-width: 2;
stroke-linecap: round;
stroke-miterlimit: 10
}
.gtf-body {
fill: #71caee;
stroke: #000;
stroke-width: 2;
stroke-linecap: round;
stroke-miterlimit: 10
}
.gtf-white {
fill: #fff;
stroke: #000;
stroke-width: 2;
stroke-linecap: round;
stroke-miterlimit: 10
}
.gtf-env {
fill: #f0f0f0;
stroke: #000;
stroke-width: 2;
stroke-linecap: round;
stroke-miterlimit: 10
}
.gtf-none {
fill: none;
stroke: #000;
stroke-width: 2;
stroke-linecap: round;
stroke-miterlimit: 10
}
</style>
<path
d="M317.7 376.2c6.2-1.7 15.8 0 19.5 3.2 5.5 4.8 4.9 20.9 1.1 29-.8 1.7-1.8 3.4-3.2 4.4s-3.4 1.2-4.7 0-1.7-3.3-1.9-5.2c-.2-3.1-.2-6.2.3-9.2.2-1.3.2-2.9-.2-4.2-.6-2.2-2.5-3.1-4.5-3.5-3.4-.8-14.3-.7-19.5-.7-.8 0 1.5-9.1 2-9.7 2.6-2.9 7.5-3.1 11.1-4.1z"
class="gtf-paw" />
<path
d="m258.9 119.7-9-2.7c-4.6-1.4-9.2-2.8-14-2.5-2.8.2-6.1 1.3-6.9 4-.6 2-1.6 7.3-1.3 7.9 1.5 3.4 13.9 6.7 18.3 6.7"
class="gtf-body" />
<path
d="M392.6 177.9c-1.4 1.4-2.2 3.5-2.5 5.5-.2 1.4-.1 3 .5 4.3s1.8 2.3 3.1 3c1.3.6 2.8.9 4.3.9 1.1 0 2.3-.1 3.1-.9.6-.7.8-1.6.9-2.5.2-2.3-.1-4.7-.9-6.9-.4-1.1-.9-2.3-1.8-3.1-1.7-1.8-4.5-2.2-6.4-.5-.1 0-.2.1-.3.2"
fill="#000" />
<path
d="M358.5 164.2c-1-1 0-2.7 1-3.7 5.8-5.2 15.1-4.6 21.8-.6 10.9 6.6 15.6 19.9 17.2 32.5.6 5.2.9 10.6-.5 15.7s-4.6 9.9-9.3 12.1c-1.1.5-2.3.9-3.4.5s-1.9-1.8-1.2-2.8c-9.4-13.6-19-26.8-20.9-43.2-.5-4.1-1.8-7.4-4.7-10.5z"
class="gtf-white" />
<path
d="M134.7 328.4c-5.1-3.1-9.9-6.6-14.3-10.6-1.3-1.2-2.6-2.5-2.6-4.3 0-1.2.6-2.2 1.2-3.2.8-1.4 1.7-2.8 2.5-4.1 1.1-1.8 2.9-3.9 4.9-3.2.9.3 1.5 1.1 2 1.8 2.4 3.3 4.9 6.6 7.3 9.8 1.5 2 3.7 4.3 6.1 3.5"
class="gtf-body" />
<path
d="M209.6 133c33.2-18 77.8-19.6 111.5-8.7 24.3 7.9 43.4 26.7 53.3 50 8.7 20.6 10.5 43.6 8.1 65.7-4.4 40.2-20.2 77.9-40.3 112.6-11.1 19-21.8 36-40.5 48.5-36.8 24.6-87.2 22.1-128.4 11.5-19.9-5.1-39.7-17.3-47.2-37.3-4.8-12.8-4.2-27.6 1.5-40 11.6-24.8 43.2-38.4 45.6-67.9.7-8.7-1.6-17.3-3.6-25.7-5.6-23.4-8.9-45.8 1.4-68.7 8.1-17.7 21.9-31 38.6-40z"
class="gtf-body" />
<path
d="M189.8 151.4c-5.4-5.2-11.9-8.8-19-10.3-2.2-.5-4.7-.7-6.9.7-1.8 1.2-3.1 3.3-4.2 5.3-1.6 3-3 6.2-4.1 9.4-.4 1.2-.6 2.5 0 3.5.3.6.9.9 1.5 1.2 8.1 4.2 16.8 7.1 25.5 9.8"
class="gtf-body" />
<path d="M183.7 158.7c-2.5-1.8-16.8-12.1-18.7-4.8-.4 1.6.5 3.9 1.5 4.8" class="gtf-body" />
<path
d="M264.5 174.9c-.5.5-.9 1-1.3 1.6-9 11.6-12 27.9-9.3 42.1 1.7 9 5.9 17.9 13.2 23.4 19.3 14.6 51.5 13.5 68.4-1.5 24.4-21.7 13-67.6-14-78.8-17.6-7.2-43.7-1.6-57 13.2zm117.6 62.2c1.4-.1 2.9-.1 4.3.1.3 0 .7.1 1 .4.2.3.4.7.5 1.1 1 3.9.5 8.2.1 12.4-.1.9-.2 1.8-.6 2.6-1 2.1-3.1 2.7-4.7 2.7-.1 0-.2 0-.3-.1-.3-.2-.3-.7-.2-1.2.3-5.9-.1-11.9-.1-18q0 .15 0 0z"
class="gtf-white" />
<path
d="M378.7 236.8c-1.4.4-2.5 2-2.8 4.4-.5 4.4-.7 8.9-.5 13.4 0 .9.1 1.9.5 2.4.2.3.5.4.8.4 1.6.3 4.1-.6 5.6-1 0 0 0-5.2-.1-8s-.1-6.1-.2-8.9v-2.2c.1-.7-2.6-.7-3.3-.5z"
class="gtf-white" />
<path
d="M358.3 231.8c-.3 2.2.1 4.7 1.7 7.4 2.6 4.4 7 6.1 11.9 5.8 8.9-.6 25.3-5.4 27.5-15.7.6-3-.3-6.1-2.2-8.5-6.2-7.8-17.8-5.7-25.6-2-5.9 2.7-12.4 7-13.3 13z"
class="gtf-paw" />
<path
d="M386.4 208.6c2.2 1.4 3.7 3.8 4 7 .3 3.6-1.4 7.5-5 8.8-2.9 1.1-6.2.6-9.1-.4s-5.8-2.8-6.8-5.7c-.7-2-.3-4.3.7-6.1 1.1-1.8 2.8-3.2 4.7-4.1 3.9-1.8 8.4-1.6 11.5.5z"
fill="#888e93" stroke="#000" stroke-width="2" stroke-linecap="round" stroke-miterlimit="10" />
<path
d="M414.7 262.6c2.4.6 4.8 2.1 5.6 4.4s.1 4.9-1.6 6.7-4.2 2.5-6.6 2.5c-.8 0-1.7-.1-2.4-.5-2.5-1.1-3.5-4-4.2-6.6-1.8-6.8 3.6-7.8 9.2-6.5z"
class="gtf-paw" />
<path
d="M267.1 284.7c2.3-4.5 141.3-36.2 144.7-31.6 3.4 4.5 15.8 88.2 9 90.4-6.8 2.3-119.8 37.3-126.6 35s-29.4-89.3-27.1-93.8z"
class="gtf-env" />
<path d="M294.2 378.5s54.3-74.6 59.9-76.9c5.7-2.3 67.3 41.3 67.3 41.3" class="gtf-none" />
<path d="M267 287.7s86 38.8 91.6 36.6c5.7-2.3 53.1-71.2 53.1-71.2" class="gtf-env" />
<path
d="M132.8 375.6c-3.5 3.8-7.3 7.8-13 9.2-4.6 1.2-10 .2-13.6-2.3-1.4-1-2.6-2.2-4-3.2-1.5-1-3.4-1.7-5.3-1.3-2.7.5-4.1 3.1-3.6 5.3 2 8.8 17 15.6 27.5 15.5 9 0 19-4.6 21.4-11.8"
class="gtf-paw" />
<path
d="M261.9 283.5c-.1 4.2 4.3 7.3 8.4 7.6s8.2-1.3 12.2-2.6c1.4-.4 2.9-.8 4.2-.2 1.8.9 2.7 4.1 1.8 5.9s-3.4 3.5-5.3 4.4c-6.5 3-12.9 3.6-19.9 2-5.3-1.2-11.3-4.3-13-13.5"
class="gtf-paw" />
<path
d="M318.4 198.4c-2-.3-4.1.1-5.9 1.3-3.2 2.1-4.7 6.2-4.7 9.9 0 1.9.4 3.8 1.4 5.3 1.2 1.7 3.1 2.9 5.2 3.4 3.4.8 8.2.7 10.5-2.5 1-1.5 1.4-3.3 1.5-5.1.5-5.7-1.8-11.4-8-12.3"
fill="#000" />
<path
d="M320.4 203.3c.9.3 1.7.8 2.1 1.7.4.8.4 1.7.3 2.5-.1 1-.6 2-1.5 2.7-.7.5-1.7.7-2.6.5s-1.7-.8-2.2-1.6c-1.1-1.6-.9-4.4.9-5.5.9-.4 2-.6 3-.3"
fill="#fff" />
<path d="M81.6 222.4s56.5 68.4 123.9 42.4l6.6-29.7C150 272.2 82.8 214.3 82.8 214.3z"
fill="#575756" opacity="0.3" />
<path d="M64.2 234.9s63.1 101.5 157.8 78.9l14.2-38.5c-89.5 38.3-168.9-51-168.9-51z"
fill="#575756" opacity="0.3" />
<path d="M46.6 251.5s61.1 130.9 178 117.5l22.6-44.2c-113 33-195.3-85.7-195.3-85.7z"
fill="#575756" opacity="0.3" />
</svg>
</div>
<div>
<strong style="font-size:15px" data-i18n="notif_gotify_title">Notification Gotify</strong>
<div class="muted" style="font-size:12px" data-i18n="notif_gotify_desc">Serveur de push
auto-hébergé léger et instantané (Compatible Gotify v2 &amp; v3.1.1+)</div>
</div>
</div>
<label class="check" style="margin:0;font-weight:700">
<input id="notifGotifyEnabled" type="checkbox" onchange="toggleNotifFields('gotify')">
<span data-i18n="notif_gotify_enable">Activer Gotify</span>
</label>
</div>
<div id="notifGotifyFields" style="display:none;padding-top:10px;border-top:1px solid var(--line)">
<label class="label" for="notifGotifyUrl" style="margin-top:4px"
data-i18n="notif_gotify_url_label">URL du serveur Gotify</label>
<input id="notifGotifyUrl" type="text"
placeholder="http://192.168.1.50:8080 ou https://gotify.mon-domaine.fr">
<div style="display:grid;grid-template-columns:2fr 1fr;gap:10px">
<div>
<label class="label" for="notifGotifyToken" data-i18n="notif_gotify_token_apps">Jeton
d’application (Token APPS)</label>
<div style="display:flex;gap:8px;margin:7px 0 16px">
<input id="notifGotifyToken" type="password" placeholder="gtfya.xxxx ou Axxxx" style="margin:0">
<button id="toggleNotifGotifyToken" class="secondary pwd-eye-btn" type="button"
aria-label="Afficher" title="Afficher" data-i18n-title="toggle_pwd_show"
data-i18n-aria-label="toggle_pwd_show"
onclick="togglePasswordVisibility('notifGotifyToken', this)">👁️</button>
</div>
</div>
<div>
<label class="label" for="notifGotifyPriority" data-i18n="notif_gotify_priority_range">Priorité (1
- 10)</label>
<input id="notifGotifyPriority" type="number" min="1" max="10" placeholder="5" value="5">
</div>
</div>
<div
style="font-size:12px;color:var(--muted);background:var(--panel2);border:1px solid var(--line);border-radius:8px;padding:10px 12px;margin-bottom:12px;line-height:1.5"
data-i18n-html="notif_gotify_alert_box">
⚠️ <strong>Important pour Gotify 3.1.1 :</strong> Le jeton doit provenir de l'onglet
<strong>APPS</strong> de Gotify (commençant par <code>gtfya...</code> en v3 ou <code>A...</code> en
v2). Les jetons de l'onglet <strong>CLIENTS</strong> ne permettent pas de publier des alertes. Le
HTTPS avec certificat auto-signé est supporté.
</div>
<div style="display:flex;justify-content:flex-end;margin-top:8px">
<button type="button" class="secondary" onclick="testSetupNotification('gotify')"
style="font-size:13px;padding:6px 14px" data-i18n="notif_gotify_test_btn">Tester Gotify</button>
</div>
</div>
</div>
<!-- Canal 3 : Discord Webhook -->
<div
style="background:var(--panel);border:1px solid var(--line);border-radius:12px;padding:16px;margin-bottom:16px">
<div
style="display:flex;justify-content:space-between;align-items:center;flex-wrap:wrap;gap:10px;margin-bottom:12px">
<div style="display:flex;align-items:center;gap:10px">
<div
style="width:32px;height:32px;flex-shrink:0;display:flex;align-items:center;justify-content:center">
<svg width="28" height="28" viewBox="0 0 24 24" fill="none">
<rect width="24" height="24" rx="6" fill="#5865F2" />
<path
d="M18.8 6.5A14.2 14.2 0 0 0 15.3 5.4a.2.2 0 0 0-.2.1 9.9 9.9 0 0 0-.4.9 13.1 13.1 0 0 0-5.4 0 10.1 10.1 0 0 0-.4-.9.2.2 0 0 0-.2-.1A14.2 14.2 0 0 0 5.2 6.5a.2.2 0 0 0-.1.1C3.3 9.4 2.8 12.2 3.1 15a.2.2 0 0 0 .1.1 14.3 14.3 0 0 0 4.3 2.2.2.2 0 0 0 .2-.1 10.2 10.2 0 0 0 .9-1.4.2.2 0 0 0-.1-.2 9.3 9.3 0 0 1-1.3-.6.2.2 0 0 1 0-.3c.1-.1.2-.1.3-.2a10.2 10.2 0 0 0 9 0c.1.1.2.1.3.2a.2.2 0 0 1 0 .3 9.3 9.3 0 0 1-1.3.6.2.2 0 0 0-.1.2c.3.5.6 1 .9 1.4a.2.2 0 0 0 .2.1 14.3 14.3 0 0 0 4.3-2.2.2.2 0 0 0 .1-.1c.3-3.3-.6-6.1-2.2-8.4a.2.2 0 0 0-.1-.1zM9.5 13.1c-.8 0-1.5-.7-1.5-1.6s.7-1.6 1.5-1.6 1.5.7 1.5 1.6-.7 1.6-1.5 1.6zm5 0c-.8 0-1.5-.7-1.5-1.6s.7-1.6 1.5-1.6 1.5.7 1.5 1.6-.7 1.6-1.5 1.6z"
fill="#FFFFFF" />
</svg>
</div>
<div>
<strong style="font-size:15px" data-i18n="notif_discord_title">Notification Discord</strong>
<div class="muted" style="font-size:12px" data-i18n="notif_discord_desc">Envoi direct sur un canal
de salon via Webhook</div>
</div>
</div>
<label class="check" style="margin:0;font-weight:700">
<input id="notifDiscordEnabled" type="checkbox" onchange="toggleNotifFields('discord')">
<span data-i18n="notif_discord_enable">Activer Discord</span>
</label>
</div>
<div id="notifDiscordFields" style="display:none;padding-top:10px;border-top:1px solid var(--line)">
<label class="label" for="notifDiscordWebhook" style="margin-top:4px"
data-i18n="notif_discord_url_label">URL du Webhook Discord</label>
<input id="notifDiscordWebhook" type="text"
placeholder="https://discord.com/api/webhooks/123456789/abcdef...">
<label class="label" for="notifDiscordBotName" data-i18n="notif_discord_bot_label">Nom du Bot
(optionnel)</label>
<input id="notifDiscordBotName" type="text" placeholder="AP Manageur" value="AP Manageur">
<div style="display:flex;justify-content:flex-end;margin-top:8px">
<button type="button" class="secondary" onclick="testSetupNotification('discord')"
style="font-size:13px;padding:6px 14px" data-i18n="notif_discord_test_btn">Tester Discord</button>
</div>
</div>
</div>
<!-- Canal 4 : ntfy.sh -->
<div
style="background:var(--panel);border:1px solid var(--line);border-radius:12px;padding:16px;margin-bottom:16px">
<div
style="display:flex;justify-content:space-between;align-items:center;flex-wrap:wrap;gap:10px;margin-bottom:12px">
<div style="display:flex;align-items:center;gap:10px">
<div
style="width:32px;height:32px;flex-shrink:0;display:flex;align-items:center;justify-content:center">
<svg width="28" height="28" viewBox="0 0 24 24" fill="none">
<rect width="24" height="24" rx="6" fill="#1E40AF" />
<path
d="M12 4a5 5 0 0 0-5 5v3.2L5.6 14.8A1 1 0 0 0 6.4 16h11.2a1 1 0 0 0 .8-1.2L17 12.2V9a5 5 0 0 0-5-5zm-2 13a2 2 0 0 0 4 0h-4z"
fill="#FFFFFF" />
</svg>
</div>
<div>
<strong style="font-size:15px" data-i18n="notif_ntfy_title">Notification ntfy.sh</strong>
<div class="muted" style="font-size:12px" data-i18n="notif_ntfy_desc">Notifications push via
ntfy.sh ou serveur auto-hébergé</div>
</div>
</div>
<label class="check" style="margin:0;font-weight:700">
<input id="notifNtfyEnabled" type="checkbox" onchange="toggleNotifFields('ntfy')">
<span data-i18n="notif_ntfy_enable">Activer ntfy</span>
</label>
</div>
<div id="notifNtfyFields" style="display:none;padding-top:10px;border-top:1px solid var(--line)">
<div style="display:grid;grid-template-columns:2fr 1fr;gap:10px">
<div>
<label class="label" for="notifNtfyUrl" style="margin-top:4px"
data-i18n="notif_ntfy_server_label">Serveur ntfy</label>
<input id="notifNtfyUrl" type="text" placeholder="https://ntfy.sh" value="https://ntfy.sh">
</div>
<div>
<label class="label" for="notifNtfyTopic" style="margin-top:4px"
data-i18n="notif_ntfy_topic_label">Topic (sujet)</label>
<input id="notifNtfyTopic" type="text" placeholder="mon_topic_secret">
</div>
</div>
<div style="display:grid;grid-template-columns:2fr 1fr;gap:10px">
<div>
<label class="label" for="notifNtfyToken" data-i18n="notif_ntfy_token_opt">Jeton / Mot de passe
(optionnel pour topic privé)</label>
<div style="display:flex;gap:8px;margin:7px 0 16px">
<input id="notifNtfyToken" type="password" placeholder="tk_xxxxxxxxxxxx" style="margin:0">
<button id="toggleNotifNtfyToken" class="secondary pwd-eye-btn" type="button" aria-label="Afficher"
title="Afficher" data-i18n-title="toggle_pwd_show" data-i18n-aria-label="toggle_pwd_show"
onclick="togglePasswordVisibility('notifNtfyToken', this)">👁️</button>
</div>
</div>
<div>
<label class="label" for="notifNtfyPriority" data-i18n="notif_ntfy_priority_range">Priorité (1 -
5)</label>
<input id="notifNtfyPriority" type="number" min="1" max="5" placeholder="3" value="3">
</div>
</div>
<div style="display:flex;justify-content:flex-end;margin-top:8px">
<button type="button" class="secondary" onclick="testSetupNotification('ntfy')"
style="font-size:13px;padding:6px 14px" data-i18n="notif_ntfy_test_btn">Tester ntfy</button>
</div>
</div>
</div>
<!-- Canal 5 : Pushbullet -->
<div
style="background:var(--panel);border:1px solid var(--line);border-radius:12px;padding:16px;margin-bottom:16px">
<div
style="display:flex;justify-content:space-between;align-items:center;flex-wrap:wrap;gap:10px;margin-bottom:12px">
<div style="display:flex;align-items:center;gap:10px">
<div
style="width:32px;height:32px;flex-shrink:0;display:flex;align-items:center;justify-content:center">
<svg width="28" height="28" viewBox="0 0 24 24" fill="none">
<rect width="24" height="24" rx="6" fill="#4AB367" />
<path
d="M12 4.5A7.5 7.5 0 0 0 4.5 12 7.5 7.5 0 0 0 12 19.5 7.5 7.5 0 0 0 19.5 12 7.5 7.5 0 0 0 12 4.5zm-3.5 4h4a3.5 3.5 0 1 1 0 7h-1.5v2h-2.5v-9zm2.5 2v3h1.5a1.5 1.5 0 0 0 0-3H11z"
fill="#FFFFFF" />
</svg>
</div>
<div>
<strong style="font-size:15px" data-i18n="notif_pushbullet_title">Notification Pushbullet</strong>
<div class="muted" style="font-size:12px" data-i18n="notif_pushbullet_desc">Push instantané sur
téléphones, tablettes et navigateurs</div>
</div>
</div>
<label class="check" style="margin:0;font-weight:700">
<input id="notifPushbulletEnabled" type="checkbox" onchange="toggleNotifFields('pushbullet')">
<span data-i18n="notif_pushbullet_enable">Activer Pushbullet</span>
</label>
</div>
<div id="notifPushbulletFields" style="display:none;padding-top:10px;border-top:1px solid var(--line)">
<label class="label" for="notifPushbulletToken" style="margin-top:4px"
data-i18n="notif_pushbullet_token_label">Jeton d’accès (Access Token)</label>
<div style="display:flex;gap:8px;margin:7px 0 16px">
<input id="notifPushbulletToken" type="password" placeholder="o.xxxxxxxxxxxxxxxxxxxxxxxxxxxx"
style="margin:0">
<button id="toggleNotifPushbulletToken" class="secondary pwd-eye-btn" type="button"
aria-label="Afficher" title="Afficher" data-i18n-title="toggle_pwd_show"
data-i18n-aria-label="toggle_pwd_show"
onclick="togglePasswordVisibility('notifPushbulletToken', this)">👁️</button>
</div>
<label class="label" for="notifPushbulletDevice" data-i18n="notif_pushbullet_device_iden">ID de
l’appareil (Device Iden, optionnel — laisser vide pour tous)</label>
<input id="notifPushbulletDevice" type="text" placeholder="ujpah72o0sjAoStArDw">
<div style="display:flex;justify-content:flex-end;margin-top:8px">
<button type="button" class="secondary" onclick="testSetupNotification('pushbullet')"
style="font-size:13px;padding:6px 14px" data-i18n="notif_pushbullet_test_btn">Tester
Pushbullet</button>
</div>
</div>
</div>
<!-- Canal 6 : Pushover -->
<div
style="background:var(--panel);border:1px solid var(--line);border-radius:12px;padding:16px;margin-bottom:16px">
<div
style="display:flex;justify-content:space-between;align-items:center;flex-wrap:wrap;gap:10px;margin-bottom:12px">
<div style="display:flex;align-items:center;gap:10px">
<div
style="width:32px;height:32px;flex-shrink:0;display:flex;align-items:center;justify-content:center">
<svg width="28" height="28" viewBox="0 0 24 24" fill="none">
<rect width="24" height="24" rx="6" fill="#0A85B5" />
<path
d="M7.5 5h5.2c3 0 5.3 1.8 5.3 4.5 0 3-2.4 4.8-5.5 4.8H9.8L8.2 19H5.8L7.5 5zm2.8 2.2L9.2 12.1h3c1.7 0 3.2-.9 3.2-2.5 0-1.5-1.2-2.4-2.8-2.4h-2.3z"
fill="#FFFFFF" />
</svg>
</div>
<div>
<strong style="font-size:15px" data-i18n="notif_pushover_title">Notification Pushover</strong>
<div class="muted" style="font-size:12px" data-i18n="notif_pushover_desc">Push pour Android, iOS
et Desktop</div>
</div>
</div>
<label class="check" style="margin:0;font-weight:700">
<input id="notifPushoverEnabled" type="checkbox" onchange="toggleNotifFields('pushover')">
<span data-i18n="notif_pushover_enable">Activer Pushover</span>
</label>
</div>
<div id="notifPushoverFields" style="display:none;padding-top:10px;border-top:1px solid var(--line)">
<div style="display:grid;grid-template-columns:1fr 1fr;gap:10px">
<div>
<label class="label" for="notifPushoverUser" style="margin-top:4px"
data-i18n="notif_pushover_user_label">Clé utilisateur (User Key)</label>
<div style="display:flex;gap:8px;margin:7px 0 16px">
<input id="notifPushoverUser" type="password" placeholder="uQiRzpo4DXghDmr9Qnoxf5p6Bp3..."
style="margin:0">
<button id="toggleNotifPushoverUser" class="secondary pwd-eye-btn" type="button"
aria-label="Afficher" title="Afficher" data-i18n-title="toggle_pwd_show"
data-i18n-aria-label="toggle_pwd_show"
onclick="togglePasswordVisibility('notifPushoverUser', this)">👁️</button>
</div>
</div>
<div>
<label class="label" for="notifPushoverToken" style="margin-top:4px"
data-i18n="notif_pushover_token_label">Jeton d’application (API Token)</label>
<div style="display:flex;gap:8px;margin:7px 0 16px">
<input id="notifPushoverToken" type="password" placeholder="azGDORePK8gMaC0QOYAMyEEuzJ3..."
style="margin:0">
<button id="toggleNotifPushoverToken" class="secondary pwd-eye-btn" type="button"
aria-label="Afficher" title="Afficher" data-i18n-title="toggle_pwd_show"
data-i18n-aria-label="toggle_pwd_show"
onclick="togglePasswordVisibility('notifPushoverToken', this)">👁️</button>
</div>
</div>
</div>
<label class="label" for="notifPushoverPriority" data-i18n="notif_pushover_priority_label">Priorité
(-2 à 2 : 0 = Normal, 1 = Élevée)</label>
<input id="notifPushoverPriority" type="number" min="-2" max="2" placeholder="0" value="0">
<div style="display:flex;justify-content:flex-end;margin-top:8px">
<button type="button" class="secondary" onclick="testSetupNotification('pushover')"
style="font-size:13px;padding:6px 14px" data-i18n="notif_pushover_test_btn">Tester
Pushover</button>
</div>
</div>
</div>
<!-- Canal 7 : Slack -->
<div
style="background:var(--panel);border:1px solid var(--line);border-radius:12px;padding:16px;margin-bottom:16px">
<div
style="display:flex;justify-content:space-between;align-items:center;flex-wrap:wrap;gap:10px;margin-bottom:12px">
<div style="display:flex;align-items:center;gap:10px">
<div
style="width:32px;height:32px;flex-shrink:0;display:flex;align-items:center;justify-content:center">
<svg width="28" height="28" viewBox="0 0 24 24" fill="none">
<rect width="24" height="24" rx="6" fill="#4A154B" />
<path
d="M6 10.5a1.5 1.5 0 1 1 0-3 1.5 1.5 0 0 1 0 3zm2.5 0a1.5 1.5 0 0 1-1.5-1.5V5.5a1.5 1.5 0 1 1 3 0V9a1.5 1.5 0 0 1-1.5 1.5z"
fill="#36C5F0" />
<path
d="M10.5 18a1.5 1.5 0 1 1-3 0 1.5 1.5 0 0 1 3 0zm0-2.5a1.5 1.5 0 0 1-1.5 1.5H5.5a1.5 1.5 0 1 1 0-3H9a1.5 1.5 0 0 1 1.5 1.5z"
fill="#2EB67D" />
<path
d="M18 13.5a1.5 1.5 0 1 1 0 3 1.5 1.5 0 0 1 0-3zm-2.5 0a1.5 1.5 0 0 1 1.5 1.5v3.5a1.5 1.5 0 1 1-3 0V15a1.5 1.5 0 0 1 1.5-1.5z"
fill="#ECB22E" />
<path
d="M13.5 6a1.5 1.5 0 1 1 3 0 1.5 1.5 0 0 1-3 0zm0 2.5a1.5 1.5 0 0 1 1.5-1.5h3.5a1.5 1.5 0 1 1 0 3H15a1.5 1.5 0 0 1-1.5-1.5z"
fill="#E01E5A" />
</svg>
</div>
<div>
<strong style="font-size:15px" data-i18n="notif_slack_title">Notification Slack</strong>
<div class="muted" style="font-size:12px" data-i18n="notif_slack_desc">Alertes sur un canal Slack
via Webhook entrant (Incoming Webhook)</div>
</div>
</div>
<label class="check" style="margin:0;font-weight:700">
<input id="notifSlackEnabled" type="checkbox" onchange="toggleNotifFields('slack')">
<span data-i18n="notif_slack_enable">Activer Slack</span>
</label>
</div>
<div id="notifSlackFields" style="display:none;padding-top:10px;border-top:1px solid var(--line)">
<label class="label" for="notifSlackWebhook" style="margin-top:4px"
data-i18n="notif_slack_url_label">URL du Webhook entrant Slack</label>
<input id="notifSlackWebhook" type="text"
placeholder="https://hooks.slack.com/services/T00000000/B00000000/XXXXXXXXXXXXXXXXXXXXXXXX">
<label class="label" for="notifSlackBotName" data-i18n="notif_slack_bot_label">Nom d’expéditeur du bot
(optionnel)</label>
<input id="notifSlackBotName" type="text" placeholder="AP Manageur" value="AP Manageur">
<div style="display:flex;justify-content:flex-end;margin-top:8px">
<button type="button" class="secondary" onclick="testSetupNotification('slack')"
style="font-size:13px;padding:6px 14px" data-i18n="notif_slack_test_btn">Tester Slack</button>
</div>
</div>
</div>
<!-- Canal 8 : Telegram -->
<div
style="background:var(--panel);border:1px solid var(--line);border-radius:12px;padding:16px;margin-bottom:16px">
<div
style="display:flex;justify-content:space-between;align-items:center;flex-wrap:wrap;gap:10px;margin-bottom:12px">
<div style="display:flex;align-items:center;gap:10px">
<div
style="width:32px;height:32px;flex-shrink:0;display:flex;align-items:center;justify-content:center">
<svg width="28" height="28" viewBox="0 0 24 24" fill="none">
<rect width="24" height="24" rx="6" fill="#24A1DE" />
<path
d="M5.2 11.8l11.6-4.7c.6-.2 1.1.1 1 .8l-2 9.5c-.2.7-.6.9-1.2.6l-3.3-2.4-1.6 1.5c-.2.2-.4.4-.8.4l.2-3.3 6-5.4c.3-.3-.1-.4-.4-.2l-7.4 4.7-3.2-1c-.7-.2-.7-.7.1-1z"
fill="#FFFFFF" />
</svg>
</div>
<div>
<strong style="font-size:15px" data-i18n="notif_telegram_title">Notification Telegram</strong>
<div class="muted" style="font-size:12px" data-i18n="notif_telegram_desc">Alertes instantanées par
bot Telegram (canal, groupe ou privé)</div>
</div>
</div>
<label class="check" style="margin:0;font-weight:700">
<input id="notifTelegramEnabled" type="checkbox" onchange="toggleNotifFields('telegram')">
<span data-i18n="notif_telegram_enable">Activer Telegram</span>
</label>
</div>
<div id="notifTelegramFields" style="display:none;padding-top:10px;border-top:1px solid var(--line)">
<label class="label" for="notifTelegramToken" style="margin-top:4px"
data-i18n="notif_telegram_token_label">Jeton du Bot (Bot Token @BotFather)</label>
<div style="display:flex;gap:8px;margin:7px 0 16px">
<input id="notifTelegramToken" type="password" placeholder="123456789:ABCdefGhIJKlmNoPQRsTUVwxyZ"
style="margin:0">
<button id="toggleNotifTelegramToken" class="secondary pwd-eye-btn" type="button" aria-label="Afficher"
title="Afficher" data-i18n-title="toggle_pwd_show" data-i18n-aria-label="toggle_pwd_show"
onclick="togglePasswordVisibility('notifTelegramToken', this)">👁️</button>
</div>
<div style="display:grid;grid-template-columns:2fr 1fr;gap:10px">
<div>
<label class="label" for="notifTelegramChatId" data-i18n="notif_telegram_chat_label">Identifiant
de discussion (Chat ID)</label>
<input id="notifTelegramChatId" type="text" placeholder="123456789 ou -100123456789">
</div>
<div>
<label class="label" for="notifTelegramThreadId" data-i18n="notif_telegram_thread_label">Fil /
Topic (optionnel)</label>
<input id="notifTelegramThreadId" type="text" placeholder="12">
</div>
</div>
<div style="display:flex;justify-content:flex-end;margin-top:8px">
<button type="button" class="secondary" onclick="testSetupNotification('telegram')"
style="font-size:13px;padding:6px 14px" data-i18n="notif_telegram_test_btn">Tester
Telegram</button>
</div>
</div>
</div>
<!-- Canal 9 : Webhook personnalisé -->
<div
style="background:var(--panel);border:1px solid var(--line);border-radius:12px;padding:16px;margin-bottom:8px">
<div
style="display:flex;justify-content:space-between;align-items:center;flex-wrap:wrap;gap:10px;margin-bottom:12px">
<div style="display:flex;align-items:center;gap:10px">
<div
style="width:32px;height:32px;flex-shrink:0;display:flex;align-items:center;justify-content:center">
<svg width="28" height="28" viewBox="0 0 24 24" fill="none">
<rect width="24" height="24" rx="6" fill="#6366F1" />
<path
d="M17 12a3 3 0 1 1-2.8-2h-4.4a3 3 0 1 1 0-2h4.4A3 3 0 0 1 17 12zm-8.8 4a3 3 0 1 1 2.8 2h3.6a1 1 0 1 1 0 2H11a3 3 0 0 1-2.8-4z"
fill="#FFFFFF" />
</svg>
</div>
<div>
<strong style="font-size:15px" data-i18n="notif_custom_title">Webhook personnalisé (HTTP)</strong>
<div class="muted" style="font-size:12px" data-i18n="notif_custom_desc">Requête HTTP vers
n’importe quelle API, domotique ou service cloud</div>
</div>
</div>
<label class="check" style="margin:0;font-weight:700">
<input id="notifWebhookEnabled" type="checkbox" onchange="toggleNotifFields('webhook')">
<span data-i18n="notif_custom_enable">Activer Webhook</span>
</label>
</div>
<div id="notifWebhookFields" style="display:none;padding-top:10px;border-top:1px solid var(--line)">
<div style="display:grid;grid-template-columns:3fr 1fr;gap:10px">
<div>
<label class="label" for="notifWebhookUrl" style="margin-top:4px"
data-i18n="notif_custom_url_label">URL de destination</label>
<input id="notifWebhookUrl" type="text" placeholder="https://api.mon-domaine.fr/webhook">
</div>
<div>
<label class="label" for="notifWebhookMethod" style="margin-top:4px"
data-i18n="notif_custom_method_label">Méthode</label>
<select id="notifWebhookMethod"
style="display:block;width:100%;margin:7px 0 16px;padding:12px;border-radius:9px;border:1px solid var(--line);background:var(--panel2);color:var(--text);font-size:14px">
<option value="POST" selected>POST</option>
<option value="PUT">PUT</option>
<option value="GET">GET</option>
</select>
</div>
</div>
<label class="label" for="notifWebhookHeaders" data-i18n="notif_custom_headers_label">En-têtes
personnalisés (optionnel, JSON ou Clé: Valeur)</label>
<textarea id="notifWebhookHeaders" rows="2"
placeholder='{"Authorization": "Bearer secret123", "X-Custom": "val"}'
style="width:100%;margin:4px 0 16px;padding:9px 12px;border-radius:9px;border:1px solid var(--line);background:var(--panel2);color:var(--text);font-family:inherit;font-size:14px;resize:vertical"></textarea>
<div style="display:flex;justify-content:flex-end;margin-top:8px">
<button type="button" class="secondary" onclick="testSetupNotification('webhook')"
style="font-size:13px;padding:6px 14px" data-i18n="notif_custom_test_btn">Tester le
Webhook</button>
</div>
</div>
</div>
</div>
<!-- Sous-onglet 2 : Événements déclencheurs et Cron -->
<div id="panelSetupNotifAlerts" style="display:none">
<div
style="background:var(--panel);border:1px solid var(--line);border-radius:12px;padding:16px;margin:8px 0">
<h3 style="margin:0 0 8px;font-size:15px;display:flex;align-items:center;gap:8px">
<span>⚡</span> <span data-i18n="notif_events_title">Événements déclencheurs d’alerte</span>
</h3>
<p class="muted" style="font-size:12px;margin:0 0 14px" data-i18n="notif_events_desc">Sélectionnez les
événements qui déclencheront l’envoi d’une notification :</p>
<div style="display:grid;grid-template-columns:repeat(auto-fit,minmax(260px,1fr));gap:10px">
<label class="check" style="margin:0"><input id="notifEvtNewDevice" type="checkbox" checked><span
data-i18n="notif_evt_new_device">📱 Nouvel appareil Wi‑Fi (première connexion)</span></label>
<label class="check" style="margin:0"><input id="notifEvtDeviceConnected" type="checkbox"><span
data-i18n="notif_evt_device_connected">📶 Reconnexion d’un appareil Wi‑Fi connu</span></label>
<label class="check" style="margin:0"><input id="notifEvtDeviceDisconnected" type="checkbox"><span
data-i18n="notif_evt_device_disconnected">📴 Déconnexion d’un appareil Wi‑Fi</span></label>
<label class="check" style="margin:0"><input id="notifEvtAdminLogin" type="checkbox" checked><span
data-i18n="notif_evt_admin_login">🔒 Connexion au compte administrateur</span></label>
<label class="check" style="margin:0"><input id="notifEvtAdminLoginFailed" type="checkbox"
checked><span data-i18n="notif_evt_admin_login_failed">⚠️ Échec de connexion
administrateur</span></label>
<label class="check" style="margin:0"><input id="notifEvtDeviceBlocked" type="checkbox" checked><span
data-i18n="notif_evt_device_blocked">🛑 Équipement bloqué ou débloqué</span></label>
<label class="check" style="margin:0"><input id="notifEvtSettingsChanged" type="checkbox"
checked><span data-i18n="notif_evt_settings_changed">⚙️ Modification réglages Wi‑Fi /
AP</span></label>
<label class="check" style="margin:0"><input id="notifEvtVpnClientConnected" type="checkbox"
checked><span data-i18n="notif_evt_vpn_client_connected">🛡️ Client routé via VPN</span></label>
<label class="check" style="margin:0"><input id="notifEvtVpnClientDisconnected" type="checkbox"
checked><span data-i18n="notif_evt_vpn_client_disconnected">🌐 Déconnexion / Retrait client du
VPN</span></label>
<label class="check" style="margin:0"><input id="notifEvtVpnProfileConnected" type="checkbox"
checked><span data-i18n="notif_evt_vpn_profile_connected">🛡️ Profil VPN connecté (tunnel
actif)</span></label>
<label class="check" style="margin:0"><input id="notifEvtVpnProfileDisconnected" type="checkbox"
checked><span data-i18n="notif_evt_vpn_profile_disconnected">⚠️ Déconnexion profil VPN (tunnel
coupé)</span></label>
<label class="check" style="margin:0"><input id="notifEvtQuotaExceeded" type="checkbox" checked><span
data-i18n="notif_evt_quota_exceeded">⚖️ Quota de données dépassé par un appareil</span></label>
<label class="check"
style="margin:0;grid-column:1/-1;background:var(--panel2);padding:10px 14px;border-radius:10px;border:1px solid var(--line);font-weight:600">
<input id="notifEvtStatsReport" type="checkbox" onchange="toggleStatsReportSchedule(this.checked)">
<span data-i18n="stats_cron_tab_title">📊 Rapport planifié des statistiques et métriques (Tâche
Cron)</span>
</label>
</div>
<!-- Configuration Tâche Cron pour le rapport statistiques & métriques -->
<div id="statsReportScheduleBox"
style="display:none;background:var(--panel2);border:1px solid var(--blue);border-radius:12px;padding:16px;margin-top:14px">
<div
style="display:flex;justify-content:space-between;align-items:center;flex-wrap:wrap;gap:10px;margin-bottom:12px">
<div style="display:flex;align-items:center;gap:10px">
<span style="font-size:22px">⏰</span>
<div>
<strong style="font-size:15px;color:var(--text)" data-i18n="stats_cron_title">Planification Cron
du rapport statistique</strong>
<div class="muted" style="font-size:12px" data-i18n="stats_cron_desc">Configurez la périodicité
d'envoi automatique (Jour, Heure, Minute)</div>
</div>
</div>
<span id="statsReportCronHuman" class="pill pill-blue pill-no-dot" style="font-size:12px"
data-i18n="stats_report_cron_default">📅 Tous les jours à 08:00</span>
</div>
<div
style="display:grid;grid-template-columns:repeat(auto-fit,minmax(180px,1fr));gap:12px;align-items:end">
<div>
<label class="label" for="statsReportDay" style="font-size:12px;margin-top:0"
data-i18n="stats_cron_day_label">📅 Jour d’exécution</label>
<select id="statsReportDay" onchange="updateStatsReportCronFromFields()"
style="width:100%;margin:4px 0 0;padding:10px 12px;border-radius:8px;border:1px solid var(--line);background:var(--panel);color:var(--text);font-size:13px">
<option value="*" data-i18n="stats_cron_day_all">Tous les jours (*)</option>
<option value="1-5" data-i18n="stats_cron_day_workdays">Jours ouvrés (Lundi à Vendredi)</option>
<option value="6,7" data-i18n="stats_cron_day_weekend">Week-end (Samedi &amp; Dimanche)</option>
<option value="1" data-i18n="stats_cron_day_mon">Chaque Lundi</option>
<option value="2" data-i18n="stats_cron_day_tue">Chaque Mardi</option>
<option value="3" data-i18n="stats_cron_day_wed">Chaque Mercredi</option>
<option value="4" data-i18n="stats_cron_day_thu">Chaque Jeudi</option>
<option value="5" data-i18n="stats_cron_day_fri">Chaque Vendredi</option>
<option value="6" data-i18n="stats_cron_day_sat">Chaque Samedi</option>
<option value="0" data-i18n="stats_cron_day_sun">Chaque Dimanche</option>
</select>
</div>
<div>
<label class="label" for="statsReportHour" style="font-size:12px;margin-top:0"
data-i18n="stats_report_hour_label">🕐 Heure (00 - 23)</label>
<select id="statsReportHour" onchange="updateStatsReportCronFromFields()"
style="width:100%;margin:4px 0 0;padding:10px 12px;border-radius:8px;border:1px solid var(--line);background:var(--panel);color:var(--text);font-size:13px">
</select>
</div>
<div>
<label class="label" for="statsReportMinute" style="font-size:12px;margin-top:0"
data-i18n="stats_report_minute_label">⏱️ Minute (00 - 59)</label>
<select id="statsReportMinute" onchange="updateStatsReportCronFromFields()"
style="width:100%;margin:4px 0 0;padding:10px 12px;border-radius:8px;border:1px solid var(--line);background:var(--panel);color:var(--text);font-size:13px">
</select>
</div>
<div>
<label class="label" for="statsReportTopRange" style="font-size:12px;margin-top:0"
data-i18n="stats_cron_top_range_label">📊 Période Top clients</label>
<select id="statsReportTopRange"
style="width:100%;margin:4px 0 0;padding:10px 12px;border-radius:8px;border:1px solid var(--line);background:var(--panel);color:var(--text);font-size:13px">
<option value="day" data-i18n="stats_cron_range_day">Aujourd’hui (Par jour)</option>
<option value="week" data-i18n="stats_cron_range_week">Cette semaine (Par semaine)</option>
<option value="month" data-i18n="stats_cron_range_month">Ce mois-ci (Par mois)</option>
</select>
</div>
</div>
<input id="statsReportCronExpr" type="hidden" value="0 8 * * *">
</div>
</div>
</div>
</div>
<div class="notice" data-i18n-html="step4_optional_note">
💡 <strong>Facultatif</strong> : Vous pouvez ignorer cette étape et configurer vos notifications
ultérieurement depuis le tableau de bord.
</div>
<div id="step4Error" class="muted"
style="color:var(--red);font-weight:600;font-size:13px;display:none;margin-top:8px"></div>
<div class="step-actions">
<button type="button" class="secondary" onclick="goToStep(3)" data-i18n="btn_prev">← Précédent</button>
<div class="step-actions-right">
<button type="button" class="secondary" onclick="skipStep4()" style="margin-right:6px"
data-i18n="btn_skip">Ignorer</button>
<button type="button" id="btnStep4Continue" onclick="validateStep4()" data-i18n="btn_continue">
<span>Continuer</span> <span>→</span>
</button>
</div>
</div>
</section>
<!-- ============================================== -->
<!-- ÉTAPE 5 : OPTION FACULTATIF -->
<!-- ============================================== -->
<section class="step-panel" id="panelStep5">
<div class="panel-header">
<h2 class="panel-title"><span>🎨</span> <span data-i18n="step5_title">Options facultatives</span></h2>
<p class="panel-desc" data-i18n="step5_desc">
Personnalisez l'apparence visuelle, les profils VPN et le comportement de votre point d'accès.
</p>
</div>
<label class="label" data-i18n="step5_theme_label">Thème visuel de l'interface (test en direct) :</label>
<div class="theme-grid">
<div class="theme-card active" id="themeCard_auto" onclick="setSetupTheme('auto', true)">
<div class="theme-icon">🖥️</div>
<div style="font-size:12px" data-i18n="theme_auto">Auto (Système)</div>
</div>
<div class="theme-card" id="themeCard_dark" onclick="setSetupTheme('dark', true)">
<div class="theme-icon">🌙</div>
<div style="font-size:12px" data-i18n="theme_dark">Sombre</div>
</div>
<div class="theme-card" id="themeCard_light" onclick="setSetupTheme('light', true)">
<div class="theme-icon">☀️</div>
<div style="font-size:12px" data-i18n="theme_light">Clair</div>
</div>
<div class="theme-card" id="themeCard_winxp" onclick="setSetupTheme('winxp', true)">
<div class="theme-icon">🪟</div>
<div style="font-size:12px" data-i18n="theme_winxp">Windows XP</div>
</div>
<div class="theme-card" id="themeCard_futuristic" onclick="setSetupTheme('futuristic', true)">
<div class="theme-icon">🚀</div>
<div style="font-size:12px" data-i18n="theme_futuristic">Futuriste</div>
</div>
<div class="theme-card" id="themeCard_macos" onclick="setSetupTheme('macos', true)">
<div class="theme-icon">🍏</div>
<div style="font-size:12px" data-i18n="theme_macos">macOS</div>
</div>
<div class="theme-card" id="themeCard_hacker" onclick="setSetupTheme('hacker', true)">
<div class="theme-icon">🟩</div>
<div style="font-size:12px" data-i18n="theme_hacker">Hacker</div>
</div>
</div>
<label class="label" for="setupAppName" data-i18n="step5_app_title_label">Titre personnalisé de
l'application</label>
<input id="setupAppName" type="text" maxlength="64" value="Administration de l’AP Wi‑Fi"
placeholder="Ex : Wi-Fi Maison" data-i18n-placeholder="step5_app_title_placeholder">
<label
style="display:flex;align-items:center;gap:10px;cursor:pointer;margin-top:6px;margin-bottom:14px;user-select:none">
<input type="checkbox" id="setupAutoconnect" checked style="width:auto;margin:0">
<span data-i18n="step5_autoconnect_label">Démarrer automatiquement le réseau Wi-Fi au démarrage de la
machine</span>
</label>
<!-- Section Profils VPN optionnels -->
<div style="margin-top:22px;padding-top:18px;border-top:1px solid var(--line)">
<div
style="display:flex;align-items:center;justify-content:space-between;margin-bottom:10px;flex-wrap:wrap;gap:8px">
<div>
<h3 style="margin:0;font-size:15px;display:flex;align-items:center;gap:8px">
<span data-i18n="step5_vpn_title">Profils VPN (WireGuard / OpenVPN)</span>
<span class="pill" style="font-size:11px" data-i18n="optional_badge">Optionnel</span>
</h3>
<p class="muted" style="font-size:12px;margin:3px 0 0" data-i18n="step5_vpn_desc">
Importez ou configurez dès maintenant des tunnels VPN pour router le trafic de vos appareils.
</p>
</div>
<button type="button" class="secondary" onclick="openSetupVpnModal()"
style="font-size:13px;padding:7px 12px;display:inline-flex;align-items:center;gap:6px">
<span>➕</span> <span data-i18n="step5_vpn_add_btn">Ajouter un profil VPN</span>
</button>
</div>
<div id="setupVpnList" style="display:flex;flex-direction:column;gap:8px;margin-top:10px">
<div id="setupVpnEmpty" class="muted"
style="font-size:13px;font-style:italic;padding:12px;background:var(--panel2);border:1px dashed var(--line);border-radius:8px;text-align:center"
data-i18n="step5_vpn_empty">
Aucun profil VPN ajouté pour le moment.
</div>
</div>
</div>
<div class="step-actions">
<button type="button" class="secondary" onclick="goToStep(4)" data-i18n="btn_prev">← Précédent</button>
<div class="step-actions-right">
<button type="button" onclick="goToStep(6)" data-i18n="btn_see_recap">
<span>Voir le récapitulatif</span> <span>→</span>
</button>
</div>
</div>
</section>
<!-- ============================================== -->
<!-- ÉTAPE 6 : FIN DE CONFIGURATION -->
<!-- ============================================== -->
<section class="step-panel" id="panelStep6">
<div class="panel-header">
<h2 class="panel-title"><span>✨</span> <span data-i18n="step6_title">Fin de configuration</span></h2>
<p class="panel-desc" data-i18n="step6_desc">
Tous vos paramètres sont prêts ! Vérifiez les informations ci-dessous puis lancez le point d'accès.
</p>
</div>
<div class="recap-grid">
<!-- Réseau Wi-Fi -->
<div class="recap-box">
<div class="recap-box-title"><span>📶</span> <span data-i18n="recap_wifi_title">Réseau Wi-Fi</span></div>
<div class="recap-box-val" id="recapSsid">—</div>
<div class="recap-box-sub" id="recapMode">Mode AP • WPA2</div>
</div>
<!-- Administrateur -->
<div class="recap-box">
<div class="recap-box-title"><span>🛡️</span> <span data-i18n="recap_admin_title">Administrateur</span>
</div>
<div class="recap-box-val" id="recapAdminUser">admin</div>
<div class="recap-box-sub" id="recapAdminSub" data-i18n="recap_admin_pwd_set">Mot de passe défini
(••••••••)</div>
</div>
<!-- Notifications -->
<div class="recap-box">
<div class="recap-box-title"><span>🔔</span> <span data-i18n="recap_notif_title">Notifications</span>
</div>
<div class="recap-box-val" id="recapNotif" data-i18n="recap_notif_off">Désactivées</div>
<div class="recap-box-sub" id="recapNotifSub" data-i18n="recap_notif_off_sub">Modifiable ultérieurement
</div>
</div>
<!-- Options & VPN -->
<div class="recap-box">
<div class="recap-box-title"><span>🌐</span> <span data-i18n="recap_vpn_title">Profils VPN</span></div>
<div class="recap-box-val" id="recapVpnVal" data-i18n="recap_vpn_none">Aucun profil configuré</div>
<div class="recap-box-sub" id="recapVpnSub">Internet direct par défaut</div>
</div>
<!-- Thème & Démarrage -->
<div class="recap-box" style="grid-column: 1 / -1">
<div class="recap-box-title"><span>🎨</span> <span data-i18n="recap_options_title">Options & Thème</span>
</div>
<div class="recap-box-val" id="recapTheme">Auto (Système)</div>
<div class="recap-box-sub" id="recapAutoconnect" data-i18n="recap_auto_start_yes">Démarrage auto : Oui
</div>
</div>
</div>
<div class="progress-bar-container" id="setupProgressContainer">
<div class="progress-bar-fill" id="setupProgressBar"></div>
</div>
<div id="setupMessage" style="font-weight:600;font-size:14px;margin-bottom:12px;min-height:20px"></div>
<div class="step-actions">
<button type="button" class="secondary" id="btnBackTo5" onclick="goToStep(5)"
data-i18n="btn_modify_settings">← Modifier les réglages</button>
<div class="step-actions-right">
<button id="btnSubmitSetup" type="button" onclick="submitSetup()"
style="padding:14px 28px;font-size:15px;background:var(--green);color:#ffffff"
data-i18n="btn_submit_setup">
<span>🚀</span> <span>Enregistrer et démarrer l'AP</span>
</button>
</div>
</div>
</section>
</main>
</div>
</div>
<!-- Modal Sélecteur de Sauvegardes (Serveur, Fichier local, Cloud) -->
<div id="modalSetupBackupPicker"
style="display:none;position:fixed;inset:0;background:rgba(0,0,0,0.72);backdrop-filter:blur(4px);z-index:9998;align-items:center;justify-content:center;padding:16px">
<div class="card"
style="max-width:760px;width:100%;max-height:92vh;display:flex;flex-direction:column;background:var(--panel);border:1px solid var(--line);box-shadow:0 12px 48px rgba(0,0,0,0.55);border-radius:14px;overflow:hidden;padding:0">
<!-- En-tête -->
<div style="padding:16px 20px;border-bottom:1px solid var(--line);display:flex;align-items:center;justify-content:space-between;background:var(--panel2)">
<div style="display:flex;align-items:center;gap:10px">
<span style="font-size:24px">📦</span>
<div>
<h3 style="margin:0;font-size:17px;font-weight:700" data-i18n="modal_picker_title">Importer une sauvegarde</h3>
<p class="muted" style="margin:2px 0 0;font-size:12px" data-i18n="modal_picker_sub">Restaurez vos réglages, profils VPN et équipements depuis le serveur, votre PC ou le Cloud</p>
</div>
</div>
<button type="button" class="secondary" onclick="closeSetupBackupPickerModal()"
style="padding:5px 9px;font-size:14px;line-height:1;border-radius:6px">✕</button>
</div>
<!-- Onglets (Tabs) -->
<div style="display:flex;border-bottom:1px solid var(--line);background:var(--panel2);padding:0 16px;gap:8px;overflow-x:auto">
<button type="button" class="setup-backup-tab active" id="tabBtnServer" onclick="switchSetupBackupTab('server')"
style="display:flex;align-items:center;gap:8px;padding:10px 14px;background:none;border:none;border-bottom:2px solid var(--accent);color:var(--text);font-size:13px;font-weight:600;cursor:pointer;border-radius:0">
<span>💾</span> <span data-i18n="tab_server_backups">Sauvegardes serveur</span>
<span class="pill" id="badgeServerBackupsCount" style="font-size:11px;padding:1px 6px;display:none">0</span>
</button>
<button type="button" class="setup-backup-tab" id="tabBtnCloud" onclick="switchSetupBackupTab('cloud')"
style="display:flex;align-items:center;gap:8px;padding:10px 14px;background:none;border:none;border-bottom:2px solid transparent;color:var(--muted);font-size:13px;font-weight:600;cursor:pointer;border-radius:0">
<span>☁️</span> <span data-i18n="tab_cloud_backups">Services Cloud</span>
</button>
<button type="button" class="setup-backup-tab" id="tabBtnLocal" onclick="switchSetupBackupTab('local')"
style="display:flex;align-items:center;gap:8px;padding:10px 14px;background:none;border:none;border-bottom:2px solid transparent;color:var(--muted);font-size:13px;font-weight:600;cursor:pointer;border-radius:0">
<span>💻</span> <span data-i18n="tab_local_file">Fichier local (PC)</span>
</button>
</div>
<!-- Corps défilable -->
<div style="padding:20px;overflow-y:auto;flex:1">
<!-- ================= Onglet 1 : Sauvegardes Serveur ================= -->
<div id="setupTabContent_server">
<div style="display:flex;align-items:center;justify-content:space-between;margin-bottom:14px;flex-wrap:wrap;gap:8px">
<div>
<strong style="font-size:14px" data-i18n="server_backups_list_title">Fichiers trouvés sur le serveur</strong>
<div class="muted" style="font-size:12px" data-i18n="server_backups_dir_hint">Emplacement de stockage : /app/backups/</div>
</div>
<button type="button" class="secondary" onclick="loadServerBackupsInSetup(true)" style="display:inline-flex;align-items:center;gap:6px;font-size:12px;padding:5px 10px">
<span>🔄</span> <span data-i18n="btn_refresh">Actualiser</span>
</button>
</div>
<div id="setupServerBackupsList" style="display:flex;flex-direction:column;gap:10px">
<div class="muted" style="text-align:center;padding:24px" data-i18n="server_backups_loading">Recherche des sauvegardes sur le serveur…</div>
</div>
</div>
<!-- ================= Onglet 2 : Services Cloud ================= -->
<div id="setupTabContent_cloud" style="display:none">
<p class="muted" style="font-size:13px;margin:0 0 14px" data-i18n="cloud_setup_desc">
Connectez-vous directement à votre stockage distant (Google Drive, Dropbox, SFTP, FTP, WebDAV ou S3) pour lister et importer vos sauvegardes sans passer par votre PC.
</p>
<!-- Sélecteur de fournisseur cloud avec logos -->
<div id="setupCloudProviderSelector" style="display:flex;flex-wrap:wrap;gap:8px;margin-bottom:16px">
<button type="button" class="setup-prov-btn active" data-prov="ftp" onclick="selectSetupCloudProvider('ftp')"
style="padding:6px 12px;font-size:12px;border-radius:8px;display:inline-flex;align-items:center;gap:6px;cursor:pointer;border:1px solid var(--accent);background:var(--accent);color:#fff">
📡 <span>FTP / FTPS</span>
</button>
<button type="button" class="setup-prov-btn" data-prov="sftp" onclick="selectSetupCloudProvider('sftp')"
style="padding:6px 12px;font-size:12px;border-radius:8px;display:inline-flex;align-items:center;gap:6px;cursor:pointer;border:1px solid var(--line);background:var(--panel2);color:var(--text)">
🔐 <span>SFTP (SSH)</span>
</button>
<button type="button" class="setup-prov-btn" data-prov="gdrive" onclick="selectSetupCloudProvider('gdrive')"
style="padding:6px 12px;font-size:12px;border-radius:8px;display:inline-flex;align-items:center;gap:6px;cursor:pointer;border:1px solid var(--line);background:var(--panel2);color:var(--text)">
<img src="/images/gdrive.svg" width="16" height="15" alt="Google Drive" style="object-fit:contain;vertical-align:middle">
<span>Google Drive</span>
</button>
<button type="button" class="setup-prov-btn" data-prov="dropbox" onclick="selectSetupCloudProvider('dropbox')"
style="padding:6px 12px;font-size:12px;border-radius:8px;display:inline-flex;align-items:center;gap:6px;cursor:pointer;border:1px solid var(--line);background:var(--panel2);color:var(--text)">
<img src="/images/dropbox.svg" width="16" height="16" alt="Dropbox" style="object-fit:contain;vertical-align:middle">
<span>Dropbox</span>
</button>
<button type="button" class="setup-prov-btn" data-prov="webdav" onclick="selectSetupCloudProvider('webdav')"
style="padding:6px 12px;font-size:12px;border-radius:8px;display:inline-flex;align-items:center;gap:6px;cursor:pointer;border:1px solid var(--line);background:var(--panel2);color:var(--text)">
🌐 <span>WebDAV</span>
</button>
<button type="button" class="setup-prov-btn" data-prov="s3" onclick="selectSetupCloudProvider('s3')"
style="padding:6px 12px;font-size:12px;border-radius:8px;display:inline-flex;align-items:center;gap:6px;cursor:pointer;border:1px solid var(--line);background:var(--panel2);color:var(--text)">
🪣 <span>S3 / MinIO</span>
</button>
</div>
<input type="hidden" id="setupCloudProvider" value="ftp">
<!-- Formulaire dynamique par fournisseur -->
<div id="setupCloudFieldsBox" style="background:var(--panel2);border:1px solid var(--line);border-radius:10px;padding:14px;margin-bottom:14px">
<!-- FTP -->
<div id="setupCloudFields_ftp">
<div style="display:grid;grid-template-columns:2fr 1fr 1fr;gap:10px">
<div><label class="label" data-i18n="backup_remote_host">Hôte / IP</label><input id="setupFtpHost" type="text" placeholder="ftp.exemple.fr ou 192.168.1.10"></div>
<div><label class="label" data-i18n="backup_remote_port">Port</label><input id="setupFtpPort" type="number" value="21" min="1" max="65535"></div>
<div>
<label class="label" data-i18n="backup_remote_security">Sécurité</label>
<select id="setupFtpTls">
<option value="none">FTP Standard</option>
<option value="explicit">FTPS (TLS explicite)</option>
</select>
</div>
</div>
<div style="display:grid;grid-template-columns:1fr 1fr 1fr;gap:10px;margin-top:10px">
<div><label class="label" data-i18n="backup_remote_user">Utilisateur</label><input id="setupFtpUser" type="text" placeholder="backup_user"></div>
<div>
<label class="label" data-i18n="backup_remote_pass">Mot de passe</label>
<input id="setupFtpPass" type="password" placeholder="••••••••" style="margin:0">
</div>
<div><label class="label" data-i18n="backup_remote_path">Dossier distant</label><input id="setupFtpPath" type="text" value="backups/" placeholder="backups/"></div>
</div>
</div>
<!-- SFTP -->
<div id="setupCloudFields_sftp" style="display:none">
<div style="display:grid;grid-template-columns:2fr 1fr 1.5fr;gap:10px">
<div><label class="label" data-i18n="backup_remote_host">Hôte / IP</label><input id="setupSftpHost" type="text" placeholder="nas.exemple.fr ou 192.168.1.10"></div>
<div><label class="label" data-i18n="backup_remote_port">Port</label><input id="setupSftpPort" type="number" value="22" min="1" max="65535"></div>
<div><label class="label" data-i18n="backup_remote_path">Dossier distant</label><input id="setupSftpPath" type="text" value="backups/" placeholder="backups/"></div>
</div>
<div style="display:grid;grid-template-columns:1fr 1fr;gap:10px;margin-top:10px">
<div><label class="label" data-i18n="backup_remote_user">Utilisateur</label><input id="setupSftpUser" type="text" placeholder="root ou backup"></div>
<div><label class="label" data-i18n="backup_remote_pass">Mot de passe</label><input id="setupSftpPass" type="password" placeholder="••••••••" style="margin:0"></div>
</div>
<div style="margin-top:10px">
<label class="label" data-i18n="backup_remote_ssh_key">Clé privée SSH (facultative)</label>
<textarea id="setupSftpKey" rows="2" placeholder="-----BEGIN OPENSSH PRIVATE KEY-----" style="width:100%;margin-top:4px;padding:8px 10px;background:var(--panel);border:1px solid var(--line);border-radius:8px;color:var(--text);font-family:monospace;font-size:11px;resize:vertical;box-sizing:border-box"></textarea>
</div>
</div>
<!-- Google Drive -->
<div id="setupCloudFields_gdrive" style="display:none">
<div style="display:grid;grid-template-columns:2fr 1fr;gap:10px">
<div><label class="label" data-i18n="backup_remote_token">Jeton d’accès OAuth2 (Access Token)</label><input id="setupGdriveToken" type="password" placeholder="ya29.a0..." style="margin:0"></div>
<div><label class="label" data-i18n="backup_remote_gdrive_folder">ID du dossier (facultatif)</label><input id="setupGdriveFolder" type="text" placeholder="1AbCdEfGh..."></div>
</div>
</div>
<!-- Dropbox -->
<div id="setupCloudFields_dropbox" style="display:none">
<div style="display:grid;grid-template-columns:2fr 1fr;gap:10px">
<div><label class="label" data-i18n="backup_remote_token">Jeton d’accès Dropbox</label><input id="setupDropboxToken" type="password" placeholder="sl.B..." style="margin:0"></div>
<div><label class="label" data-i18n="backup_remote_path">Dossier distant</label><input id="setupDropboxPath" type="text" value="/AP-Manageur-Backups/" placeholder="/AP-Manageur-Backups/"></div>
</div>
</div>
<!-- WebDAV -->
<div id="setupCloudFields_webdav" style="display:none">
<div><label class="label" data-i18n="backup_remote_webdav_url">URL WebDAV</label><input id="setupWebdavUrl" type="url" placeholder="https://cloud.exemple.fr/remote.php/dav/files/user/Backups/"></div>
<div style="display:grid;grid-template-columns:1fr 1fr;gap:10px;margin-top:10px">
<div><label class="label" data-i18n="backup_remote_user">Utilisateur</label><input id="setupWebdavUser" type="text" placeholder="utilisateur"></div>
<div><label class="label" data-i18n="backup_remote_pass">Mot de passe</label><input id="setupWebdavPass" type="password" placeholder="••••••••" style="margin:0"></div>
</div>
</div>
<!-- S3 / MinIO -->
<div id="setupCloudFields_s3" style="display:none">
<div style="display:grid;grid-template-columns:2fr 1fr 1fr;gap:10px">
<div><label class="label" data-i18n="backup_remote_s3_endpoint">Endpoint S3</label><input id="setupS3Endpoint" type="url" value="https://s3.amazonaws.com" placeholder="https://s3.amazonaws.com"></div>
<div><label class="label" data-i18n="backup_remote_s3_region">Région</label><input id="setupS3Region" type="text" value="us-east-1" placeholder="us-east-1"></div>
<div><label class="label" data-i18n="backup_remote_s3_bucket">Bucket</label><input id="setupS3Bucket" type="text" placeholder="ap-backups"></div>
</div>
<div style="display:grid;grid-template-columns:1fr 1fr;gap:10px;margin-top:10px">
<div><label class="label">Access Key</label><input id="setupS3AccessKey" type="text" placeholder="AKIA..."></div>
<div><label class="label">Secret Key</label><input id="setupS3SecretKey" type="password" placeholder="••••••••" style="margin:0"></div>
</div>
</div>
</div>
<!-- Actions de test et d'exploration cloud -->
<div style="display:flex;gap:10px;align-items:center;flex-wrap:wrap;margin-bottom:14px">
<button type="button" class="secondary" id="btnTestSetupCloud" onclick="testSetupCloudConnection()" style="display:inline-flex;align-items:center;gap:6px;font-size:13px">
<span>🧪</span> <span data-i18n="btn_test_cloud_connection">Tester la connexion</span>
</button>
<button type="button" id="btnExploreSetupCloud" onclick="exploreSetupCloudBackups()" style="display:inline-flex;align-items:center;gap:6px;font-size:13px">
<span>🔄</span> <span data-i18n="btn_explore_cloud_backups">Explorer les sauvegardes Cloud</span>
</button>
</div>
<div id="setupCloudMsg" style="display:none;font-size:12px;padding:8px 12px;border-radius:8px;margin-bottom:14px"></div>
<!-- Liste des fichiers Cloud trouvés -->
<div id="setupCloudFilesContainer" style="display:none">
<div style="font-weight:700;font-size:13px;margin-bottom:8px" data-i18n="cloud_files_found_title">Sauvegardes disponibles sur le Cloud :</div>
<div id="setupCloudFilesList" style="display:flex;flex-direction:column;gap:8px"></div>
</div>
</div>
<!-- ================= Onglet 3 : Fichier Local (PC) ================= -->
<div id="setupTabContent_local" style="display:none">
<p class="muted" style="font-size:13px;margin:0 0 16px" data-i18n="local_file_upload_desc">
Sélectionnez une archive de sauvegarde (.zip) ou un fichier de configuration (.json) exporté précédemment depuis AP Manageur.
</p>
<div id="setupDropZone" onclick="triggerBackupUpload()"
style="border:2px dashed var(--line);border-radius:12px;padding:36px 20px;text-align:center;cursor:pointer;background:var(--panel2);transition:all .2s ease">
<div style="font-size:38px;margin-bottom:10px">📁</div>
<div style="font-weight:700;font-size:15px;margin-bottom:4px" data-i18n="dropzone_title">Cliquez ou glissez-déposez votre fichier ici</div>
<div class="muted" style="font-size:12px" data-i18n="dropzone_hint">Formats acceptés : .zip, .json (max 100 Mo)</div>
<button type="button" class="secondary" style="margin-top:14px;pointer-events:none" data-i18n="btn_browse_pc">
Parcourir vos fichiers…
</button>
</div>
</div>
</div>
<!-- Pied de modal -->
<div style="padding:12px 20px;border-top:1px solid var(--line);background:var(--panel2);display:flex;justify-content:flex-end">
<button type="button" class="secondary" onclick="closeSetupBackupPickerModal()" data-i18n="btn_close">Fermer</button>
</div>
</div>
</div>
<!-- Modal Restauration de Sauvegarde -->
<div id="modalSetupBackup"
style="display:none;position:fixed;inset:0;background:rgba(0,0,0,0.72);backdrop-filter:blur(4px);z-index:9999;align-items:center;justify-content:center;padding:16px">
<div class="card"
style="max-width:560px;width:100%;max-height:90vh;overflow-y:auto;background:var(--panel);border:1px solid var(--line);box-shadow:0 10px 40px rgba(0,0,0,0.5)">
<div class="panel-header"
style="margin-bottom:16px;padding-bottom:12px;border-bottom:1px solid var(--line);display:flex;align-items:center;justify-content:space-between">
<div style="display:flex;align-items:center;gap:8px">
<span style="font-size:22px">📦</span>
<h3 style="margin:0;font-size:18px" data-i18n="modal_backup_title">Restauration d'une sauvegarde</h3>
</div>
<button type="button" class="secondary" onclick="closeSetupBackupModal()"
style="padding:4px 8px;font-size:14px;line-height:1">✕</button>
</div>
<div
style="background:var(--panel2);border:1px solid var(--line);border-radius:9px;padding:12px;margin-bottom:14px">
<div style="font-weight:700;font-size:14px;word-break:break-all" id="backupModalFileName">—</div>
<div class="muted" style="font-size:12px;margin-top:4px" id="backupModalMeta">—</div>
</div>
<div id="backupModalPills" style="display:flex;flex-wrap:wrap;gap:6px;margin-bottom:14px"></div>
<p class="muted" style="font-size:13px;margin:0 0 10px" data-i18n="modal_backup_desc">
Sélectionnez les éléments de la sauvegarde que vous souhaitez restaurer dans le système :
</p>
<div
style="display:flex;flex-direction:column;gap:10px;margin-bottom:18px;background:var(--panel2);border:1px solid var(--line);border-radius:9px;padding:14px">
<label style="display:flex;align-items:center;gap:10px;font-size:13px;cursor:pointer">
<input type="checkbox" id="chkSetupVpn" checked style="width:auto;margin:0">
<span data-i18n-html="restore_item_vpn">🌐 <strong>Profils VPN &amp; routages</strong> (WireGuard /
OpenVPN)</span>
</label>
<label style="display:flex;align-items:center;gap:10px;font-size:13px;cursor:pointer">
<input type="checkbox" id="chkSetupDevices" checked style="width:auto;margin:0">
<span data-i18n-html="restore_item_devices">📱 <strong>Noms des équipements</strong> &amp; types</span>
</label>
<label style="display:flex;align-items:center;gap:10px;font-size:13px;cursor:pointer">
<input type="checkbox" id="chkSetupCategories" checked style="width:auto;margin:0">
<span data-i18n-html="restore_item_categories">🎨 <strong>Catégories d'appareils</strong>
personnalisées</span>
</label>
<label style="display:flex;align-items:center;gap:10px;font-size:13px;cursor:pointer">
<input type="checkbox" id="chkSetupBlocked" checked style="width:auto;margin:0">
<span data-i18n-html="restore_item_blocked">🚫 <strong>Liste des appareils bloqués</strong></span>
</label>
<label style="display:flex;align-items:center;gap:10px;font-size:13px;cursor:pointer">
<input type="checkbox" id="chkSetupPrefs" checked style="width:auto;margin:0">
<span data-i18n-html="restore_item_prefs">⚙️ <strong>Préférences et personnalisation</strong> (thème,
nom)</span>
</label>
<label style="display:flex;align-items:center;gap:10px;font-size:13px;cursor:pointer">
<input type="checkbox" id="chkSetupAuth" checked style="width:auto;margin:0">
<span data-i18n-html="restore_item_auth">🔐 <strong>Comptes administrateurs &amp; passkeys</strong></span>
</label>
</div>
<div id="backupModalMsg"
style="display:none;font-size:13px;font-weight:600;margin-bottom:14px;padding:10px 12px;border-radius:8px">
</div>
<div style="display:flex;justify-content:flex-end;gap:10px">
<button type="button" class="secondary" onclick="closeSetupBackupModal()"
data-i18n="modal_backup_cancel">Annuler</button>
<button type="button" id="btnConfirmSetupBackup" onclick="submitSetupBackup()"
style="background:var(--green);color:#fff" data-i18n="modal_backup_btn_restore">
🚀 Restaurer cette sauvegarde
</button>
</div>
</div>
</div>
<!-- Modal Progression Restauration de Sauvegarde (Setup) -->
<div id="modalSetupRestoreProgress"
style="display:none;position:fixed;inset:0;background:rgba(0,0,0,0.85);backdrop-filter:blur(6px);z-index:999999;align-items:center;justify-content:center;padding:16px">
<div class="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;background:var(--panel)">
<!-- 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="setupRestoreIcon" style="font-size:34px;z-index:1;animation:iconFloat 2s ease-in-out infinite">📦</div>
</div>
<!-- Titre et badge -->
<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="setupRestoreBadgeIcon" style="display:inline-flex;align-items:center;justify-content:center;animation:spin 1.5s linear infinite">⚙️</span>
<span id="setupRestoreBadgeText" data-i18n="restore_progress_badge">Restauration en cours…</span>
</div>
</div>
<!-- Barre de progression -->
<div 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="setupRestoreStepLabel" style="font-weight:600;color:var(--text)" data-i18n="restore_step_label">Étape 1 / 5</span>
<span id="setupRestorePercent" style="font-weight:700;color:var(--blue);font-family:monospace">0%</span>
</div>
<div style="height:10px;border-radius:8px;background:var(--panel2);border:1px solid var(--line);overflow:hidden">
<div id="setupRestoreProgressBar" 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="setupRestoreStatusText" style="font-weight:700;font-size:14px;color:var(--text)" data-i18n="restore_starting">Démarrage de la restauration…</div>
<div id="setupRestoreDetails" 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 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="setupRestoreStepCheck" 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="setupRestoreStepCheckState" style="font-weight:700;color:var(--blue)">↻</span>
</div>
<div id="setupRestoreStepPrefs" 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="setupRestoreStepPrefsState">⏳</span>
</div>
<div id="setupRestoreStepDevices" 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="setupRestoreStepDevicesState">⏳</span>
</div>
<div id="setupRestoreStepVpn" 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="setupRestoreStepVpnState">⏳</span>
</div>
<div id="setupRestoreStepSync" 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="setupRestoreStepSyncState">⏳</span>
</div>
</div>
<div id="setupRestoreErrorBox" 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="setupRestoreErrorText"></span>
<div style="margin-top:8px">
<button type="button" class="secondary" style="padding:4px 10px;font-size:12px" onclick="closeSetupRestoreProgressModal()">Fermer</button>
</div>
</div>
</div>
</div>
<!-- Modal Ajout de Profil VPN en Étape 5 -->
<div id="modalSetupVpn"
style="display:none;position:fixed;inset:0;background:rgba(0,0,0,0.72);backdrop-filter:blur(4px);z-index:9999;align-items:center;justify-content:center;padding:16px">
<div class="card"
style="max-width:540px;width:100%;max-height:90vh;overflow-y:auto;background:var(--panel);border:1px solid var(--line);box-shadow:0 10px 40px rgba(0,0,0,0.5)">
<div class="panel-header"
style="margin-bottom:16px;padding-bottom:12px;border-bottom:1px solid var(--line);display:flex;align-items:center;justify-content:space-between">
<div style="display:flex;align-items:center;gap:8px">
<h3 style="margin:0;font-size:17px" data-i18n="modal_vpn_title">Ajouter un profil VPN</h3>
</div>
<button type="button" class="secondary" onclick="closeSetupVpnModal()"
style="padding:4px 8px;font-size:14px;line-height:1">✕</button>
</div>
<label class="label" for="vpnModalName" data-i18n="modal_vpn_name_label">Nom du profil VPN *</label>
<input type="text" id="vpnModalName" placeholder="Ex: ProtonVPN, Mullvad, Bureau..." maxlength="64"
style="margin-bottom:12px">
<label class="label" data-i18n="modal_vpn_type_label">Type de protocole</label>
<div style="display:grid;grid-template-columns:1fr 1fr;gap:10px;margin-bottom:14px">
<label class="mode-card selected" id="vpnTypeWgCard"
style="padding:10px 12px;cursor:pointer;display:flex;align-items:center;gap:12px">
<input type="radio" name="vpnModalType" id="vpnTypeWg" value="wireguard" checked style="width:auto;margin:0"
onchange="onVpnTypeChange()">
<svg class="vpn-type-logo vpn-logo-wg" viewBox="0 0 24 24" width="28" height="28"
style="vertical-align:middle;flex-shrink:0">
<path fill="#88171A"
d="M23.98 11.645S24.533 0 11.735 0C.418 0 .064 11.17.064 11.17S-1.6 24 11.997 24C25.04 24 23.98 11.645 23.98 11.645z" />
<path fill="#ffffff"
d="M8.155 7.576c2.4-1.47 5.469-.571 6.618 1.638.218.419.246 1.063.108 1.503-.477 1.516-1.601 2.366-3.145 2.728.455-.39.817-.832.933-1.442a2.112 2.112 0 0 0-.364-1.677 2.14 2.14 0 0 0-2.465-.75c-.95.36-1.47 1.228-1.377 2.294.087.99.839 1.632 2.245 1.876-.21.111-.372.193-.53.281a5.113 5.113 0 0 0-1.644 1.43c-.143.192-.24.208-.458.075-2.827-1.729-3.009-6.067.078-7.956zM6.04 18.258c-.455.116-.895.286-1.359.438.227-1.532 2.021-2.943 3.539-2.782a3.91 3.91 0 0 0-.74 2.072c-.504.093-.98.155-1.44.272zM15.703 3.3c.448.017.898.01 1.347.02a2.324 2.324 0 0 1 .334.047 3.249 3.249 0 0 1-.34.434c-.16.15-.341.296-.573.069-.055-.055-.187-.042-.283-.044-.447-.005-.894-.02-1.34-.003a8.323 8.323 0 0 0-1.154.118c-.072.013-.178.25-.146.338.078.207.191.435.359.567.619.49 1.277.928 1.9 1.413.604.472 1.167.99 1.51 1.7.446.928.46 1.9.267 2.877-.322 1.63-1.147 2.98-2.483 3.962-.538.395-1.205.62-1.821.903-.543.25-1.1.465-1.644.712-.98.446-1.53 1.51-1.369 2.615.149 1.015 1.04 1.862 2.059 2.037 1.223.21 2.486-.586 2.785-1.83.336-1.397-.423-2.646-1.845-3.024l-.256-.066c.38-.17.708-.291 1.012-.458q.793-.437 1.558-.925c.15-.096.231-.096.36.014.977.846 1.56 1.898 1.724 3.187.27 2.135-.74 4.096-2.646 5.101-2.948 1.555-6.557-.215-7.208-3.484-.558-2.8 1.418-5.34 3.797-5.83 1.023-.211 1.958-.637 2.685-1.425.47-.508.697-.944.775-1.141a3.165 3.165 0 0 0 .217-1.158 2.71 2.71 0 0 0-.237-.992c-.248-.566-1.2-1.466-1.435-1.656l-2.24-1.754c-.079-.065-.168-.06-.36-.047-.23.016-.815.048-1.067-.018.204-.155.76-.38 1-.56-.726-.49-1.554-.314-2.315-.46.176-.328 1.046-.831 1.541-.888a7.323 7.323 0 0 0-.135-.822c-.03-.111-.154-.22-.263-.283-.262-.154-.541-.281-.843-.434a1.755 1.755 0 0 1 .906-.28 3.385 3.385 0 0 1 .908.088c.54.123.97.042 1.399-.324-.338-.136-.676-.26-1.003-.407a9.843 9.843 0 0 1-.942-.493c.85.118 1.671.437 2.54.32l.022-.118-2.018-.47c1.203-.11 2.323-.128 3.384.388.299.146.61.266.897.432.14.08.233.24.348.365.09.098.164.23.276.29.424.225.89.234 1.366.223l.01-.16c.479.15 1.017.702 1.017 1.105-.776 0-1.55-.003-2.325.004-.083 0-.165.061-.247.094.078.046.155.128.235.131z M14.703 2.153a.118.118 0 0 0-.016.19.179.179 0 0 0 .246.065c.075-.038.148-.078.238-.125-.072-.062-.13-.114-.19-.163-.106-.087-.193-.032-.278.033z" />
</svg>
<div>
<strong style="font-size:13px;display:block">WireGuard</strong>
<div class="muted" style="font-size:11px" data-i18n="modal_vpn_wireguard_sub">Fichier .conf moderne &amp;
rapide</div>
</div>
</label>
<label class="mode-card" id="vpnTypeOvpnCard"
style="padding:10px 12px;cursor:pointer;display:flex;align-items:center;gap:12px">
<input type="radio" name="vpnModalType" id="vpnTypeOvpn" value="openvpn" style="width:auto;margin:0"
onchange="onVpnTypeChange()">
<svg class="vpn-type-logo vpn-logo-ovpn" viewBox="0 0 24 24" width="28" height="28"
style="vertical-align:middle;flex-shrink:0" fill="#EA580C">
<path
d="M12 .357C5.385.357 0 5.69 0 12.254c0 4.36 2.358 8.153 5.896 10.204l.77-5.076a7.046 7.046 0 01-1.846-4.719c0-3.897 3.18-7.076 7.13-7.076 3.948 0 7.126 3.18 7.126 7.076 0 1.847-.717 3.488-1.846 4.77L18 22.51c3.59-2.05 6-5.899 6-10.258C24 5.69 18.615.357 12 .357zm-.05 8.157a3.786 3.786 0 00-3.796 3.795 3.738 3.738 0 002.461 3.54L9.13 23.643h5.64l-1.435-7.795c1.385-.564 2.41-1.898 2.41-3.54a3.786 3.786 0 00-3.795-3.794z" />
</svg>
<div>
<strong style="font-size:13px;display:block">OpenVPN</strong>
<div class="muted" style="font-size:11px" data-i18n="modal_vpn_openvpn_sub">Fichier .ovpn standard</div>
</div>
</label>
</div>
<div style="margin-bottom:12px">
<div style="display:flex;justify-content:space-between;align-items:center;margin-bottom:6px">
<label class="label" style="margin:0" data-i18n="modal_vpn_config_label">Fichier de configuration *</label>
<button type="button" class="secondary" onclick="$('vpnConfigFile').click()"
style="padding:4px 10px;font-size:12px">
📄 <span data-i18n="modal_vpn_browse_btn">Choisir un fichier</span>
</button>
</div>
<input type="file" id="vpnConfigFile" accept=".conf,.ovpn,.txt" style="display:none"
onchange="onVpnConfigFileSelected(event)">
<textarea id="vpnModalConfig" rows="6"
placeholder="[Interface]&#10;PrivateKey = ...&#10;Address = ...&#10;&#10;[Peer]&#10;PublicKey = ...&#10;Endpoint = ..."
style="width:100%;padding:10px;background:var(--panel2);color:var(--text);border:1px solid var(--line);border-radius:8px;font-family:monospace;font-size:12px;outline:none;resize:vertical;line-height:1.4"></textarea>
</div>
<div id="vpnOvpnAuthBox"
style="display:none;margin-bottom:14px;background:var(--panel2);border:1px solid var(--line);border-radius:8px;padding:12px">
<div class="label" style="font-size:12px" data-i18n="modal_vpn_auth_opt">Identifiants OpenVPN (si requis par le
fournisseur) :</div>
<div style="display:grid;grid-template-columns:1fr 1fr;gap:10px;margin-top:6px">
<input type="text" id="vpnModalUser" placeholder="Utilisateur" style="margin:0;font-size:13px">
<input type="password" id="vpnModalPass" placeholder="Mot de passe" style="margin:0;font-size:13px">
</div>
</div>
<label
style="display:flex;align-items:center;gap:10px;font-size:13px;cursor:pointer;margin-bottom:16px;user-select:none">
<input type="checkbox" id="vpnModalAutoConnect" checked style="width:auto;margin:0">
<span data-i18n="modal_vpn_autoconnect">Connexion automatique au démarrage</span>
</label>
<div id="vpnModalError" class="muted"
style="color:var(--red);font-size:13px;font-weight:600;display:none;margin-bottom:12px"></div>
<div style="display:flex;justify-content:flex-end;gap:10px">
<button type="button" class="secondary" onclick="closeSetupVpnModal()" data-i18n="btn_cancel">Annuler</button>
<button type="button" onclick="saveSetupVpnProfile()" style="background:var(--blue);color:var(--blue-text)">
<span>✓</span> <span data-i18n="modal_vpn_save_btn">Ajouter ce profil</span>
</button>
</div>
</div>
</div>
<script>
const API_URL = location.protocol === 'file:' ? 'http://127.0.0.1:8080' : '';
// Détection de la langue du navigateur : si la langue n'existe pas dans le programme, repli sur l'anglais britannique (en-gb)
function detectBrowserLanguage() {
const raw = (navigator.language || (navigator.languages && navigator.languages[0]) || '').toLowerCase().trim();
if (raw.indexOf('fr') === 0) return 'fr';
if (raw === 'en-us' || raw.indexOf('en-us') === 0) return 'en-us';
return 'en-gb';
}
const explicitLang = sessionStorage.getItem('setupExplicitLang');
let currentLanguage = (explicitLang && ['fr', 'en-us', 'en-gb'].includes(explicitLang))
? explicitLang
: detectBrowserLanguage();
// Thème automatique par défaut
let currentTheme = sessionStorage.getItem('setupExplicitTheme') || 'auto';
let authConfigured = false;
let isConfiguring = false;
let currentStep = 1;
let maxStepReached = 1;
let pendingBackupData = null;
let setupVpnProfiles = [];
const SETUP_I18N = {
'fr': {
'page_title': 'Configuration initiale - AP Manageur',
'app_title': 'Administration de l’AP Wi‑Fi',
'app_badge_setup': 'Configuration initiale',
'sidebar_title': 'Étapes d\'installation',
'step_label_1': 'Étape 1',
'step_name_1': 'Bienvenue',
'step_label_2': 'Étape 2',
'step_name_2': 'Configuration du réseau Wifi',
'step_label_3': 'Étape 3',
'step_name_3': 'Création du compte administrateur',
'step_label_4': 'Étape 4',
'step_name_4': 'Notification',
'step_label_5': 'Étape 5',
'step_name_5': 'Option facultatif',
'step_label_6': 'Étape 6',
'step_name_6': 'Fin de configuration',
'step1_title': 'Bienvenue sur AP Manageur',
'step1_desc': 'Cet assistant vous accompagne pas à pas pour initialiser votre point d\'accès Wi-Fi et sécuriser l\'accès à votre tableau de bord.',
'step1_guide_title': '🚀 Mise en route en 6 étapes simples :',
'step1_guide_1': 'Définition du nom (SSID) et du mot de passe de votre réseau sans fil',
'step1_guide_2': 'Création du compte administrateur du tableau de bord',
'step1_guide_3': 'Paramétrage des alertes et notifications (optionnel)',
'step1_guide_4': 'Personnalisation du thème, des profils VPN et des préférences (optionnel)',
'step1_choose_lang': 'Choisissez la langue de l\'interface :',
'lang_fr_name': 'Français',
'lang_fr_sub': 'France',
'lang_en_us_name': 'English (US)',
'lang_en_us_sub': 'United States',
'lang_en_gb_name': 'English (UK)',
'lang_en_gb_sub': 'United Kingdom',
'step1_counter': 'Étape 1 sur 6',
'btn_import_backup': 'Importer une sauvegarde',
'btn_start_config': 'Commencer la configuration',
'step2_title': 'Configuration du réseau Wi-Fi',
'step2_desc': 'Configurez le nom de diffusion (SSID), la clé de sécurité et le mode de routage.',
'step2_ssid_label': 'Nom du réseau (SSID) *',
'step2_ssid_hint': '1 à 32 caractères visibles par vos téléphones, PC et équipements.',
'step2_pwd_label': 'Mot de passe Wi-Fi (Clé de sécurité WPA) *',
'step2_pwd_ph': '8 caractères minimum',
'step2_pwd_confirm_label': 'Confirmation du mot de passe Wi-Fi *',
'step2_pwd_confirm_ph': 'Confirmation identique',
'step2_sec_label': 'Type de sécurité Wi-Fi',
'step2_sec_wpa2': 'WPA2-Personal (Recommandé - compatible tous appareils)',
'step2_sec_wpa3': 'WPA3-Personal (Sécurité maximale - appareils récents)',
'step2_sec_wpa1': 'WPA/WPA2 Mixte (Équipements anciens)',
'step2_mode_label': 'Mode de fonctionnement réseau',
'step2_mode_ap_title': 'Mode AP (Routeur / NAT)',
'step2_mode_ap_desc': 'Serveur DHCP interne (10.42.0.x). Réseau Wi-Fi autonome et sécurisé.',
'step2_mode_bridge_title': 'Mode Bridge (Pont transparent)',
'step2_mode_bridge_desc': 'Les appareils Wi-Fi reçoivent leur IP directement de votre box Internet.',
'step2_bridge_eth_label': 'Interface Ethernet reliée à la box (Pont)',
'step2_bridge_eth_hint': 'L\'interface réseau physique qui transmet les paquets vers votre réseau local.',
'step2_max_clients_label': 'Limite d\'appareils simultanés (0 = illimité)',
'btn_prev': '← Précédent',
'btn_continue': 'Continuer →',
'step3_title': 'Création du compte administrateur',
'step3_desc': 'Définissez le compte d\'administration qui protégera l\'accès au tableau de bord.',
'step3_user_label': 'Nom d\'utilisateur administrateur *',
'step3_pwd_label': 'Mot de passe administrateur *',
'step3_pwd_ph': 'Mot de passe robuste',
'step3_pwd_confirm_label': 'Confirmation du mot de passe *',
'step3_pwd_confirm_ph': 'Ressaisissez le mot de passe',
'pwd_strength_label': 'Force du mot de passe :',
'pwd_strength_weak': 'Faible',
'pwd_strength_fair': 'Passable',
'pwd_strength_strong': 'Fort',
'pwd_strength_extreme': 'Extrême',
'pwd_match_yes': '✓ Identique',
'pwd_match_no': '⚠️ Différent',
'step3_security_note': '🔐 <strong>Sécurité renforcée</strong> : Une fois le compte créé, vous pourrez activer l\'authentification à double facteur (2FA TOTP) et enregistrer des clés Passkeys (WebAuthn / Empreinte) dans les Paramètres.',
'step4_title': 'Notifications & Alertes',
'step4_desc': 'Configurez des alertes en temps réel lors des connexions, déconnexions ou blocages d\'appareils.',
'step4_enable_label': 'Activer les notifications automatiques',
'step4_channels_hint': 'Renseignez au moins un canal ci-dessous (vous pourrez aussi le faire plus tard dans les Réglages) :',
'step4_optional_note': '💡 <strong>Facultatif</strong> : Vous pouvez ignorer cette étape et configurer vos notifications ultérieurement depuis le tableau de bord.',
'btn_skip': 'Ignorer',
'step5_title': 'Options facultatives',
'step5_desc': 'Personnalisez l\'apparence visuelle, les profils VPN et le comportement de votre point d\'accès.',
'step5_theme_label': 'Thème visuel de l\'interface (test en direct) :',
'theme_auto': 'Auto (Système)',
'theme_dark': 'Sombre',
'theme_light': 'Clair',
'theme_winxp': 'Windows XP',
'theme_futuristic': 'Futuriste',
'theme_macos': 'macOS',
'theme_hacker': 'Hacker',
'step5_app_title_label': 'Titre personnalisé de l\'application',
'step5_app_title_default': 'Administration de l’AP Wi‑Fi',
'step5_app_title_placeholder': 'Ex : Wi-Fi Maison',
'step5_autoconnect_label': 'Démarrer automatiquement le réseau Wi-Fi au démarrage de la machine',
'step5_vpn_title': 'Profils VPN (WireGuard / OpenVPN)',
'step5_vpn_desc': 'Importez ou configurez dès maintenant des tunnels VPN pour router le trafic de vos appareils.',
'step5_vpn_add_btn': 'Ajouter un profil VPN',
'step5_vpn_empty': 'Aucun profil VPN ajouté pour le moment. Vous pourrez également en ajouter ultérieurement dans les Réglages.',
'optional_badge': 'Optionnel',
'btn_see_recap': 'Voir le récapitulatif →',
'step6_title': 'Fin de configuration',
'step6_desc': 'Tous vos paramètres sont prêts ! Vérifiez les informations ci-dessous puis lancez le point d\'accès.',
'recap_wifi_title': 'Réseau Wi-Fi',
'recap_admin_title': 'Administrateur',
'recap_admin_pwd_set': 'Mot de passe défini (••••••••)',
'recap_notif_title': 'Notifications',
'recap_notif_off': 'Désactivées',
'recap_notif_off_sub': 'Modifiable ultérieurement',
'recap_vpn_title': 'Profils VPN',
'recap_vpn_none': 'Aucun profil configuré',
'recap_options_title': 'Options & Thème',
'recap_auto_start_yes': 'Démarrage auto : Oui',
'recap_auto_start_no': 'Démarrage auto : Non',
'btn_modify_settings': '← Modifier les réglages',
'btn_submit_setup': '🚀 Enregistrer et démarrer l\'AP',
'modal_backup_title': 'Restauration d\'une sauvegarde',
'modal_backup_desc': 'Sélectionnez les éléments de la sauvegarde que vous souhaitez restaurer dans le système :',
'modal_backup_btn_restore': '🚀 Restaurer cette sauvegarde',
'modal_backup_reading': 'Lecture du fichier de sauvegarde…',
'modal_backup_success': '✅ Sauvegarde restaurée avec succès ! Redirection vers le tableau de bord…',
'modal_backup_cancel': 'Annuler',
'restore_item_vpn': '🌐 <strong>Profils VPN &amp; routages</strong> (WireGuard / OpenVPN)',
'restore_item_devices': '📱 <strong>Noms des équipements</strong> &amp; types',
'restore_item_categories': '🎨 <strong>Catégories d\'appareils</strong> personnalisées',
'restore_item_blocked': '🚫 <strong>Liste des appareils bloqués</strong>',
'restore_item_prefs': '⚙️ <strong>Préférences et personnalisation</strong> (thème, nom)',
'restore_item_auth': '🔐 <strong>Comptes administrateurs &amp; passkeys</strong>',
'modal_vpn_title': 'Ajouter un profil VPN',
'modal_vpn_name_label': 'Nom du profil VPN *',
'modal_vpn_type_label': 'Type de protocole',
'modal_vpn_config_label': 'Fichier de configuration *',
'modal_vpn_browse_btn': 'Choisir un fichier',
'modal_vpn_auth_opt': 'Identifiants OpenVPN (si requis par le fournisseur) :',
'modal_vpn_autoconnect': 'Connexion automatique au démarrage',
'modal_vpn_save_btn': 'Ajouter ce profil',
'btn_cancel': 'Annuler',
'toggle_pwd_show': 'Afficher',
'toggle_pwd_hide': 'Masquer',
'setup_detected_backups_title': 'Sauvegardes existantes détectées',
'setup_detected_backups_desc': 'Des sauvegardes ont été trouvées sur le serveur. Vous pouvez restaurer votre configuration immédiatement.',
'btn_view_detected_backups': 'Voir les sauvegardes',
'modal_picker_title': 'Importer une sauvegarde',
'modal_picker_sub': 'Restaurez vos réglages, profils VPN et équipements depuis le serveur, votre PC ou le Cloud',
'tab_server_backups': 'Sauvegardes serveur',
'tab_cloud_backups': 'Services Cloud',
'tab_local_file': 'Fichier local (PC)',
'server_backups_list_title': 'Fichiers trouvés sur le serveur',
'server_backups_dir_hint': 'Emplacement de stockage : /app/backups/',
'server_backups_loading': 'Recherche des sauvegardes sur le serveur…',
'server_backups_none': 'Aucune sauvegarde trouvée sur le serveur.',
'cloud_setup_desc': 'Connectez-vous directement à votre stockage distant (Google Drive, Dropbox, SFTP, FTP, WebDAV ou S3) pour lister et importer vos sauvegardes sans passer par votre PC.',
'btn_test_cloud_connection': 'Tester la connexion',
'btn_explore_cloud_backups': 'Explorer les sauvegardes Cloud',
'cloud_files_found_title': 'Sauvegardes disponibles sur le Cloud :',
'local_file_upload_desc': 'Sélectionnez une archive de sauvegarde (.zip) ou un fichier de configuration (.json) exporté précédemment depuis AP Manageur.',
'dropzone_title': 'Cliquez ou glissez-déposez votre fichier ici',
'dropzone_hint': 'Formats acceptés : .zip, .json (max 100 Mo)',
'btn_browse_pc': 'Parcourir vos fichiers…',
'btn_close': 'Fermer',
'btn_refresh': 'Actualiser'
},
'en-us': {
'page_title': 'Initial Setup - AP Manageur',
'app_title': 'Wi‑Fi Access Point Administration',
'app_badge_setup': 'Initial Setup',
'sidebar_title': 'Setup Steps',
'step_label_1': 'Step 1',
'step_name_1': 'Welcome',
'step_label_2': 'Step 2',
'step_name_2': 'Wi-Fi Network Setup',
'step_label_3': 'Step 3',
'step_name_3': 'Admin Account Creation',
'step_label_4': 'Step 4',
'step_name_4': 'Notifications',
'step_label_5': 'Step 5',
'step_name_5': 'Optional Settings',
'step_label_6': 'Step 6',
'step_name_6': 'Setup Summary',
'step1_title': 'Welcome to AP Manageur',
'step1_desc': 'This wizard guides you step-by-step through setting up your Wi-Fi access point and securing dashboard access.',
'step1_guide_title': '🚀 Quick setup in 6 easy steps:',
'step1_guide_1': 'Choose network name (SSID) and wireless password',
'step1_guide_2': 'Create administrator account for dashboard access',
'step1_guide_3': 'Configure alert channels and notifications (optional)',
'step1_guide_4': 'Customize theme, VPN profiles, and preferences (optional)',
'step1_choose_lang': 'Choose interface language:',
'lang_fr_name': 'Français',
'lang_fr_sub': 'France',
'lang_en_us_name': 'English (US)',
'lang_en_us_sub': 'United States',
'lang_en_gb_name': 'English (UK)',
'lang_en_gb_sub': 'United Kingdom',
'step1_counter': 'Step 1 of 6',
'btn_import_backup': 'Import Backup',
'btn_start_config': 'Start Setup',
'step2_title': 'Wi-Fi Network Configuration',
'step2_desc': 'Configure the broadcast network name (SSID), security key, and network mode.',
'step2_ssid_label': 'Network Name (SSID) *',
'step2_ssid_hint': '1 to 32 characters visible to your phones, computers, and devices.',
'step2_pwd_label': 'Wi-Fi Password (WPA Security Key) *',
'step2_pwd_ph': 'Minimum 8 characters',
'step2_pwd_confirm_label': 'Confirm Wi-Fi Password *',
'step2_pwd_confirm_ph': 'Exact matching password',
'step2_sec_label': 'Wi-Fi Security Type',
'step2_sec_wpa2': 'WPA2-Personal (Recommended - compatible with all devices)',
'step2_sec_wpa3': 'WPA3-Personal (Maximum security - recent devices)',
'step2_sec_wpa1': 'WPA/WPA2 Mixed (Legacy devices)',
'step2_mode_label': 'Network Operating Mode',
'step2_mode_ap_title': 'AP Mode (Router / NAT)',
'step2_mode_ap_desc': 'Internal DHCP server (10.42.0.x). Standalone and secure Wi-Fi network.',
'step2_mode_bridge_title': 'Bridge Mode (Transparent bridge)',
'step2_mode_bridge_desc': 'Wi-Fi devices receive IP addresses directly from your home router/modem.',
'step2_bridge_eth_label': 'Ethernet Interface Connected to Router (Bridge)',
'step2_bridge_eth_hint': 'Physical network interface forwarding packets to your local network.',
'step2_max_clients_label': 'Max concurrent devices (0 = unlimited)',
'btn_prev': '← Back',
'btn_continue': 'Continue →',
'step3_title': 'Administrator Account Creation',
'step3_desc': 'Define the administrator credentials protecting access to the dashboard.',
'step3_user_label': 'Administrator Username *',
'step3_pwd_label': 'Administrator Password *',
'step3_pwd_ph': 'Strong password',
'step3_pwd_confirm_label': 'Confirm Password *',
'step3_pwd_confirm_ph': 'Re-enter your password',
'pwd_strength_label': 'Password strength:',
'pwd_strength_weak': 'Weak',
'pwd_strength_fair': 'Fair',
'pwd_strength_strong': 'Strong',
'pwd_strength_extreme': 'Extreme',
'pwd_match_yes': '✓ Matching',
'pwd_match_no': '⚠️ Different',
'step3_security_note': '🔐 <strong>Enhanced Security</strong>: Once created, you can enable Two-Factor Authentication (2FA TOTP) and register Passkeys (WebAuthn / Fingerprint) in Settings.',
'step4_title': 'Notifications & Alerts',
'step4_desc': 'Set up real-time alerts when devices connect, disconnect, or get blocked.',
'step4_enable_label': 'Enable automatic notifications',
'step4_channels_hint': 'Configure at least one channel below (you can also do this later in Settings):',
'step4_optional_note': '💡 <strong>Optional</strong>: You can skip this step and configure notifications anytime from the dashboard.',
'btn_skip': 'Skip',
'step5_title': 'Optional Settings',
'step5_desc': 'Customize appearance, VPN profiles, and behavior of your access point.',
'step5_theme_label': 'Interface Visual Theme (live preview):',
'theme_auto': 'Auto (System)',
'theme_dark': 'Dark',
'theme_light': 'Light',
'theme_winxp': 'Windows XP',
'theme_futuristic': 'Futuristic',
'theme_macos': 'macOS',
'theme_hacker': 'Hacker',
'step5_app_title_label': 'Custom Application Title',
'step5_app_title_default': 'Wi-Fi AP Administration',
'step5_app_title_placeholder': 'e.g. Home Wi-Fi',
'step5_autoconnect_label': 'Automatically start Wi-Fi access point on system boot',
'step5_vpn_title': 'VPN Profiles (WireGuard / OpenVPN)',
'step5_vpn_desc': 'Import or configure VPN tunnels right now to route device network traffic.',
'step5_vpn_add_btn': 'Add VPN Profile',
'step5_vpn_empty': 'No VPN profiles added yet. You can also configure them later in Settings.',
'optional_badge': 'Optional',
'btn_see_recap': 'View Summary →',
'step6_title': 'Setup Summary',
'step6_desc': 'All settings are ready! Review the summary below and launch the access point.',
'recap_wifi_title': 'Wi-Fi Network',
'recap_admin_title': 'Administrator',
'recap_admin_pwd_set': 'Password configured (••••••••)',
'recap_notif_title': 'Notifications',
'recap_notif_off': 'Disabled',
'recap_notif_off_sub': 'Can be configured later',
'recap_vpn_title': 'VPN Profiles',
'recap_vpn_none': 'No profiles configured',
'recap_options_title': 'Options & Theme',
'recap_auto_start_yes': 'Autostart: Yes',
'recap_auto_start_no': 'Autostart: No',
'btn_modify_settings': '← Modify Settings',
'btn_submit_setup': '🚀 Save and Start AP',
'modal_backup_title': 'Restore Backup',
'modal_backup_desc': 'Select the components from your backup file that you wish to restore:',
'modal_backup_btn_restore': '🚀 Restore This Backup',
'modal_backup_reading': 'Reading backup file…',
'modal_backup_success': '✅ Backup restored successfully! Redirecting to dashboard…',
'modal_backup_cancel': 'Cancel',
'restore_item_vpn': '🌐 <strong>VPN Profiles &amp; Routing</strong> (WireGuard / OpenVPN)',
'restore_item_devices': '📱 <strong>Device Names</strong> &amp; types',
'restore_item_categories': '🎨 <strong>Custom Device Categories</strong>',
'restore_item_blocked': '🚫 <strong>Blocked Devices List</strong>',
'restore_item_prefs': '⚙️ <strong>Preferences &amp; Customization</strong> (theme, title)',
'restore_item_auth': '🔐 <strong>Administrator Accounts &amp; Passkeys</strong>',
'modal_vpn_title': 'Add VPN Profile',
'modal_vpn_name_label': 'VPN Profile Name *',
'modal_vpn_type_label': 'Protocol Type',
'modal_vpn_config_label': 'Configuration File *',
'modal_vpn_browse_btn': 'Choose file',
'modal_vpn_auth_opt': 'OpenVPN Credentials (if required by provider):',
'modal_vpn_autoconnect': 'Automatic connection on startup',
'modal_vpn_save_btn': 'Add this profile',
'btn_cancel': 'Cancel',
'toggle_pwd_show': 'Show',
'toggle_pwd_hide': 'Hide',
'setup_detected_backups_title': 'Existing Backups Detected',
'setup_detected_backups_desc': 'Backups were found on the server. You can restore your configuration right away.',
'btn_view_detected_backups': 'View Backups',
'modal_picker_title': 'Import Backup',
'modal_picker_sub': 'Restore settings, VPN profiles and devices from the server, your PC or the Cloud',
'tab_server_backups': 'Server Backups',
'tab_cloud_backups': 'Cloud Services',
'tab_local_file': 'Local File (PC)',
'server_backups_list_title': 'Files found on server',
'server_backups_dir_hint': 'Storage location: /app/backups/',
'server_backups_loading': 'Searching for backups on the server…',
'server_backups_none': 'No backups found on server.',
'cloud_setup_desc': 'Connect directly to your remote storage (Google Drive, Dropbox, SFTP, FTP, WebDAV or S3) to browse and import your backups without your PC.',
'btn_test_cloud_connection': 'Test Connection',
'btn_explore_cloud_backups': 'Browse Cloud Backups',
'cloud_files_found_title': 'Backups available on the Cloud:',
'local_file_upload_desc': 'Select a backup archive (.zip) or configuration file (.json) previously exported from AP Manageur.',
'dropzone_title': 'Click or drag and drop your file here',
'dropzone_hint': 'Accepted formats: .zip, .json (max 100 MB)',
'btn_browse_pc': 'Browse your files…',
'btn_close': 'Close',
'btn_refresh': 'Refresh'
},
'en-gb': {
'page_title': 'Initial Setup - AP Manageur',
'app_title': 'Wi‑Fi Access Point Administration',
'app_badge_setup': 'Initial Setup',
'sidebar_title': 'Setup Steps',
'step_label_1': 'Step 1',
'step_name_1': 'Welcome',
'step_label_2': 'Step 2',
'step_name_2': 'Wi-Fi Network Setup',
'step_label_3': 'Step 3',
'step_name_3': 'Admin Account Creation',
'step_label_4': 'Step 4',
'step_name_4': 'Notifications',
'step_label_5': 'Step 5',
'step_name_5': 'Optional Settings',
'step_label_6': 'Step 6',
'step_name_6': 'Setup Summary',
'step1_title': 'Welcome to AP Manageur',
'step1_desc': 'This wizard guides you step-by-step through setting up your Wi-Fi access point and securing dashboard access.',
'step1_guide_title': '🚀 Quick setup in 6 easy steps:',
'step1_guide_1': 'Choose network name (SSID) and wireless password',
'step1_guide_2': 'Create administrator account for dashboard access',
'step1_guide_3': 'Configure alert channels and notifications (optional)',
'step1_guide_4': 'Customise theme, VPN profiles, and preferences (optional)',
'step1_choose_lang': 'Choose interface language:',
'lang_fr_name': 'Français',
'lang_fr_sub': 'France',
'lang_en_us_name': 'English (US)',
'lang_en_us_sub': 'United States',
'lang_en_gb_name': 'English (UK)',
'lang_en_gb_sub': 'United Kingdom',
'step1_counter': 'Step 1 of 6',
'btn_import_backup': 'Import Backup',
'btn_start_config': 'Start Setup',
'step2_title': 'Wi-Fi Network Configuration',
'step2_desc': 'Configure the broadcast network name (SSID), security key, and network mode.',
'step2_ssid_label': 'Network Name (SSID) *',
'step2_ssid_hint': '1 to 32 characters visible to your phones, computers, and devices.',
'step2_pwd_label': 'Wi-Fi Password (WPA Security Key) *',
'step2_pwd_ph': 'Minimum 8 characters',
'step2_pwd_confirm_label': 'Confirm Wi-Fi Password *',
'step2_pwd_confirm_ph': 'Exact matching password',
'step2_sec_label': 'Wi-Fi Security Type',
'step2_sec_wpa2': 'WPA2-Personal (Recommended - compatible with all devices)',
'step2_sec_wpa3': 'WPA3-Personal (Maximum security - recent devices)',
'step2_sec_wpa1': 'WPA/WPA2 Mixed (Legacy devices)',
'step2_mode_label': 'Network Operating Mode',
'step2_mode_ap_title': 'AP Mode (Router / NAT)',
'step2_mode_ap_desc': 'Internal DHCP server (10.42.0.x). Standalone and secure Wi-Fi network.',
'step2_mode_bridge_title': 'Bridge Mode (Transparent bridge)',
'step2_mode_bridge_desc': 'Wi-Fi devices receive IP addresses directly from your home router/modem.',
'step2_bridge_eth_label': 'Ethernet Interface Connected to Router (Bridge)',
'step2_bridge_eth_hint': 'Physical network interface forwarding packets to your local network.',
'step2_max_clients_label': 'Max concurrent devices (0 = unlimited)',
'btn_prev': '← Back',
'btn_continue': 'Continue →',
'step3_title': 'Administrator Account Creation',
'step3_desc': 'Define the administrator credentials protecting access to the dashboard.',
'step3_user_label': 'Administrator Username *',
'step3_pwd_label': 'Administrator Password *',
'step3_pwd_ph': 'Strong password',
'step3_pwd_confirm_label': 'Confirm Password *',
'step3_pwd_confirm_ph': 'Re-enter your password',
'pwd_strength_label': 'Password strength:',
'pwd_strength_weak': 'Weak',
'pwd_strength_fair': 'Fair',
'pwd_strength_strong': 'Strong',
'pwd_strength_extreme': 'Extreme',
'pwd_match_yes': '✓ Matching',
'pwd_match_no': '⚠️ Different',
'step3_security_note': '🔐 <strong>Enhanced Security</strong>: Once created, you can enable Two-Factor Authentication (2FA TOTP) and register Passkeys (WebAuthn / Fingerprint) in Settings.',
'step4_title': 'Notifications & Alerts',
'step4_desc': 'Set up real-time alerts when devices connect, disconnect, or get blocked.',
'step4_enable_label': 'Enable automatic notifications',
'step4_channels_hint': 'Configure at least one channel below (you can also do this later in Settings):',
'step4_optional_note': '💡 <strong>Optional</strong>: You can skip this step and configure notifications anytime from the dashboard.',
'btn_skip': 'Skip',
'step5_title': 'Optional Settings',
'step5_desc': 'Customise appearance, VPN profiles, and behaviour of your access point.',
'step5_theme_label': 'Interface Visual Theme (live preview):',
'theme_auto': 'Auto (System)',
'theme_dark': 'Dark',
'theme_light': 'Light',
'theme_winxp': 'Windows XP',
'theme_futuristic': 'Futuristic',
'theme_macos': 'macOS',
'theme_hacker': 'Hacker',
'step5_app_title_label': 'Custom Application Title',
'step5_app_title_default': 'Wi-Fi AP Administration',
'step5_app_title_placeholder': 'e.g. Home Wi-Fi',
'step5_autoconnect_label': 'Automatically start Wi-Fi access point on system boot',
'step5_vpn_title': 'VPN Profiles (WireGuard / OpenVPN)',
'step5_vpn_desc': 'Import or configure VPN tunnels right now to route device network traffic.',
'step5_vpn_add_btn': 'Add VPN Profile',
'step5_vpn_empty': 'No VPN profiles added yet. You can also configure them later in Settings.',
'optional_badge': 'Optional',
'btn_see_recap': 'View Summary →',
'step6_title': 'Setup Summary',
'step6_desc': 'All settings are ready! Review the summary below and launch the access point.',
'recap_wifi_title': 'Wi-Fi Network',
'recap_admin_title': 'Administrator',
'recap_admin_pwd_set': 'Password configured (••••••••)',
'recap_notif_title': 'Notifications',
'recap_notif_off': 'Disabled',
'recap_notif_off_sub': 'Can be configured later',
'recap_vpn_title': 'VPN Profiles',
'recap_vpn_none': 'No profiles configured',
'recap_options_title': 'Options & Theme',
'recap_auto_start_yes': 'Autostart: Yes',
'recap_auto_start_no': 'Autostart: No',
'btn_modify_settings': '← Modify Settings',
'btn_submit_setup': '🚀 Save and Start AP',
'modal_backup_title': 'Restore Backup',
'modal_backup_desc': 'Select the components from your backup file that you wish to restore:',
'modal_backup_btn_restore': '🚀 Restore This Backup',
'modal_backup_reading': 'Reading backup file…',
'modal_backup_success': '✅ Backup restored successfully! Redirecting to dashboard…',
'modal_backup_cancel': 'Cancel',
'restore_item_vpn': '🌐 <strong>VPN Profiles &amp; Routing</strong> (WireGuard / OpenVPN)',
'restore_item_devices': '📱 <strong>Device Names</strong> &amp; types',
'restore_item_categories': '🎨 <strong>Custom Device Categories</strong>',
'restore_item_blocked': '🚫 <strong>Blocked Devices List</strong>',
'restore_item_prefs': '⚙️ <strong>Preferences &amp; Customisation</strong> (theme, title)',
'restore_item_auth': '🔐 <strong>Administrator Accounts &amp; Passkeys</strong>',
'modal_vpn_title': 'Add VPN Profile',
'modal_vpn_name_label': 'VPN Profile Name *',
'modal_vpn_type_label': 'Protocol Type',
'modal_vpn_config_label': 'Configuration File *',
'modal_vpn_browse_btn': 'Choose file',
'modal_vpn_auth_opt': 'OpenVPN Credentials (if required by provider):',
'modal_vpn_autoconnect': 'Automatic connection on startup',
'modal_vpn_save_btn': 'Add this profile',
'btn_cancel': 'Cancel',
'toggle_pwd_show': 'Show',
'toggle_pwd_hide': 'Hide',
'setup_detected_backups_title': 'Existing Backups Detected',
'setup_detected_backups_desc': 'Backups were found on the server. You can restore your configuration right away.',
'btn_view_detected_backups': 'View Backups',
'modal_picker_title': 'Import Backup',
'modal_picker_sub': 'Restore settings, VPN profiles and devices from the server, your PC or the Cloud',
'tab_server_backups': 'Server Backups',
'tab_cloud_backups': 'Cloud Services',
'tab_local_file': 'Local File (PC)',
'server_backups_list_title': 'Files found on server',
'server_backups_dir_hint': 'Storage location: /app/backups/',
'server_backups_loading': 'Searching for backups on the server…',
'server_backups_none': 'No backups found on server.',
'cloud_setup_desc': 'Connect directly to your remote storage (Google Drive, Dropbox, SFTP, FTP, WebDAV or S3) to browse and import your backups without your PC.',
'btn_test_cloud_connection': 'Test Connection',
'btn_explore_cloud_backups': 'Browse Cloud Backups',
'cloud_files_found_title': 'Backups available on the Cloud:',
'local_file_upload_desc': 'Select a backup archive (.zip) or configuration file (.json) previously exported from AP Manageur.',
'dropzone_title': 'Click or drag and drop your file here',
'dropzone_hint': 'Accepted formats: .zip, .json (max 100 MB)',
'btn_browse_pc': 'Browse your files…',
'btn_close': 'Close',
'btn_refresh': 'Refresh'
}
};
function $(id) { return document.getElementById(id); }
function t(key, fallback) {
const sDict = SETUP_I18N[currentLanguage];
if (sDict && sDict[key]) return sDict[key];
const dict = window.I18N && window.I18N[currentLanguage];
if (dict && dict[key]) return dict[key];
const frDict = SETUP_I18N['fr'];
if (frDict && frDict[key]) return frDict[key];
const winFr = window.I18N && window.I18N['fr'];
if (winFr && winFr[key]) return winFr[key];
return fallback || key;
}
function applySetupTranslations(lang) {
const dict = SETUP_I18N[lang] || SETUP_I18N['fr'];
document.title = dict['page_title'] || 'Configuration initiale - AP Manageur';
const lookup = (k) => {
return (dict && dict[k]) ||
(window.I18N && window.I18N[lang] && window.I18N[lang][k]) ||
(window.I18N && window.I18N['fr'] && window.I18N['fr'][k]) ||
(SETUP_I18N['fr'] && SETUP_I18N['fr'][k]);
};
document.querySelectorAll('[data-i18n]').forEach(el => {
const k = el.getAttribute('data-i18n');
const v = lookup(k);
if (v) el.textContent = v;
});
document.querySelectorAll('[data-i18n-html]').forEach(el => {
const k = el.getAttribute('data-i18n-html');
const v = lookup(k);
if (v) el.innerHTML = v;
});
document.querySelectorAll('[data-i18n-placeholder]').forEach(el => {
const k = el.getAttribute('data-i18n-placeholder');
const v = lookup(k);
if (v) el.setAttribute('placeholder', v);
});
document.querySelectorAll('[data-i18n-title]').forEach(el => {
const k = el.getAttribute('data-i18n-title');
const v = lookup(k);
if (v) el.setAttribute('title', v);
});
document.querySelectorAll('[data-i18n-aria-label]').forEach(el => {
const k = el.getAttribute('data-i18n-aria-label');
const v = lookup(k);
if (v) el.setAttribute('aria-label', v);
});
if ($('setupAppName')) {
const defaultTitles = [
'',
'Administration de l’AP Wi‑Fi',
'Administration de l’AP Wi-Fi',
"Administration de l'AP Wi-Fi",
"Administration de l'AP Wi‑Fi",
'Wi-Fi AP Administration'
];
const curTitle = $('setupAppName').value.trim();
if (defaultTitles.includes(curTitle)) {
$('setupAppName').value = lookup('step5_app_title_default') || 'Administration de l’AP Wi‑Fi';
}
}
if ($('sidebarProgressText')) {
const isEn = lang.startsWith('en');
$('sidebarProgressText').textContent = isEn ? `${currentStep} of 6` : `${currentStep} / 6`;
}
if ($('step1CounterText')) {
const isEn = lang.startsWith('en');
$('step1CounterText').textContent = isEn ? 'Step 1 of 6' : 'Étape 1 sur 6';
}
renderSetupVpnList();
updateStatsReportCronFromFields();
if (typeof updateStep4ContinueState === 'function') updateStep4ContinueState();
if (currentStep === 6) {
updateRecap();
}
if (typeof updatePasswordStrengthIndicator === 'function') {
updatePasswordStrengthIndicator('setupWifi');
updatePasswordStrengthIndicator('setupWifiConfirm');
updatePasswordStrengthIndicator('setupAdmin');
updatePasswordStrengthIndicator('setupAdminConfirm');
}
}
function togglePasswordVisibility(id, btn) {
const el = $(id);
if (!el) return;
const show = el.type === 'password';
el.type = show ? 'text' : 'password';
if (btn) {
btn.textContent = show ? '🙈' : '👁️';
const key = show ? 'toggle_pwd_hide' : 'toggle_pwd_show';
const label = t(key, show ? 'Masquer' : 'Afficher');
btn.setAttribute('data-i18n-title', key);
btn.setAttribute('data-i18n-aria-label', key);
btn.setAttribute('title', label);
btn.setAttribute('aria-label', label);
btn.classList.toggle('is-visible', show);
btn.classList.remove('eye-pop');
void btn.offsetWidth;
btn.classList.add('eye-pop');
}
}
function evaluatePasswordStrength(pwd) {
if (!pwd) return null;
const len = pwd.length;
const hasLower = /[a-z]/.test(pwd);
const hasUpper = /[A-Z]/.test(pwd);
const hasDigit = /[0-9]/.test(pwd);
const hasSpecial = /[^a-zA-Z0-9]/.test(pwd);
let score = 0;
if (len >= 8) score++;
if (len >= 12) score++;
if (hasLower && hasUpper) score++;
if (hasDigit) score++;
if (hasSpecial) score++;
if (len < 8 || score <= 1) {
return {
tier: 'weak',
label: t('pwd_strength_weak', 'Faible'),
percent: 25,
color: 'var(--red, #ef4444)'
};
} else if (score === 2) {
return {
tier: 'fair',
label: t('pwd_strength_fair', 'Passable'),
percent: 50,
color: '#f59e0b'
};
} else if (score === 3 || score === 4) {
return {
tier: 'strong',
label: t('pwd_strength_strong', 'Fort'),
percent: 75,
color: 'var(--green, #10b981)'
};
} else {
return {
tier: 'extreme',
label: t('pwd_strength_extreme', 'Extrême'),
percent: 100,
color: '#8b5cf6'
};
}
}
function updatePasswordStrengthIndicator(type) {
let input, wrap, bar, text, matchText = null, mainInput = null;
let isConfirm = false;
if (type === 'setupWifi') {
input = $('setupPassword');
wrap = $('pwdStrengthWrap_setupWifi');
bar = $('pwdStrengthBar_setupWifi');
text = $('pwdStrengthText_setupWifi');
} else if (type === 'setupWifiConfirm') {
input = $('setupPasswordConfirm');
mainInput = $('setupPassword');
wrap = $('pwdStrengthWrap_setupWifiConfirm');
bar = $('pwdStrengthBar_setupWifiConfirm');
text = $('pwdStrengthText_setupWifiConfirm');
matchText = $('pwdMatchText_setupWifiConfirm');
isConfirm = true;
} else if (type === 'setupAdmin') {
input = $('setupAdminPassword');
wrap = $('pwdStrengthWrap_setupAdmin');
bar = $('pwdStrengthBar_setupAdmin');
text = $('pwdStrengthText_setupAdmin');
} else if (type === 'setupAdminConfirm') {
input = $('setupAdminPasswordConfirm');
mainInput = $('setupAdminPassword');
wrap = $('pwdStrengthWrap_setupAdminConfirm');
bar = $('pwdStrengthBar_setupAdminConfirm');
text = $('pwdStrengthText_setupAdminConfirm');
matchText = $('pwdMatchText_setupAdminConfirm');
isConfirm = true;
}
if (!input || !wrap || !bar || !text) return;
const val = input.value;
if (!val) {
wrap.style.display = 'none';
bar.style.width = '0%';
text.textContent = '';
if (matchText) matchText.textContent = '';
return;
}
wrap.style.display = 'block';
const res = evaluatePasswordStrength(val);
bar.style.width = res.percent + '%';
bar.style.backgroundColor = res.color;
text.textContent = res.label;
text.style.color = res.color;
if (isConfirm && matchText) {
const mainVal = mainInput ? mainInput.value : '';
if (mainVal) {
if (val === mainVal) {
matchText.textContent = t('pwd_match_yes', '✓ Identique');
matchText.style.color = 'var(--green, #10b981)';
} else {
matchText.textContent = t('pwd_match_no', '⚠️ Différent');
matchText.style.color = 'var(--red, #ef4444)';
}
} else {
matchText.textContent = '';
}
}
}
function initPasswordStrengthListeners() {
if ($('setupPassword')) {
$('setupPassword').addEventListener('input', () => {
updatePasswordStrengthIndicator('setupWifi');
if ($('setupPasswordConfirm') && $('setupPasswordConfirm').value) {
updatePasswordStrengthIndicator('setupWifiConfirm');
}
});
}
if ($('setupPasswordConfirm')) {
$('setupPasswordConfirm').addEventListener('input', () => {
updatePasswordStrengthIndicator('setupWifiConfirm');
});
}
if ($('setupAdminPassword')) {
$('setupAdminPassword').addEventListener('input', () => {
updatePasswordStrengthIndicator('setupAdmin');
if ($('setupAdminPasswordConfirm') && $('setupAdminPasswordConfirm').value) {
updatePasswordStrengthIndicator('setupAdminConfirm');
}
});
}
if ($('setupAdminPasswordConfirm')) {
$('setupAdminPasswordConfirm').addEventListener('input', () => {
updatePasswordStrengthIndicator('setupAdminConfirm');
});
}
}
function onModeChange() {
const isBridge = $('setupModeBridge') && $('setupModeBridge').checked;
const bBox = $('setupBridgeBlock');
if (bBox) {
bBox.style.display = isBridge ? 'block' : 'none';
if (isBridge) {
bBox.classList.remove('field-reveal');
void bBox.offsetWidth;
bBox.classList.add('field-reveal');
}
}
if ($('cardModeAp')) $('cardModeAp').classList.toggle('selected', !isBridge);
if ($('cardModeBridge')) $('cardModeBridge').classList.toggle('selected', isBridge);
}
function onNotifToggle() {
toggleNotifFields();
initStatsReportTimeSelects();
updateStep4ContinueState();
}
function selectSetupNotifSubTab(tab) {
const isServices = tab === 'services';
const ts = $('btnSubTabNotifServices');
const ta = $('btnSubTabNotifAlerts');
if (ts) {
ts.classList.toggle('active', isServices);
ts.setAttribute('aria-selected', isServices);
}
if (ta) {
ta.classList.toggle('active', !isServices);
ta.setAttribute('aria-selected', !isServices);
}
const ps = $('panelSetupNotifServices');
const pa = $('panelSetupNotifAlerts');
if (ps) ps.style.display = isServices ? 'block' : 'none';
if (pa) pa.style.display = !isServices ? 'block' : 'none';
}
function toggleNotifFields(type) {
const types = ['email', 'gotify', 'discord', 'ntfy', 'pushbullet', 'pushover', 'slack', 'telegram', 'webhook'];
const target = type ? [type] : types;
target.forEach(t => {
const cap = t.charAt(0).toUpperCase() + t.slice(1);
const en = $('notif' + cap + 'Enabled')?.checked;
const f = $('notif' + cap + 'Fields');
if (f) {
const wasHidden = f.style.display === 'none' || !f.style.display;
f.style.display = en ? 'block' : 'none';
if (en && wasHidden) {
f.classList.remove('field-reveal');
void f.offsetWidth;
f.classList.add('field-reveal');
}
}
});
updateStep4ContinueState();
}
function toggleStatsReportSchedule(isEn) {
const box = $('statsReportScheduleBox');
if (box) box.style.display = isEn ? 'block' : 'none';
}
function initStatsReportTimeSelects() {
const hSel = $('statsReportHour');
const mSel = $('statsReportMinute');
if (hSel && hSel.options.length <= 1) {
let hHtml = '<option value="*">' + t('stats_cron_day_all', 'Toutes les heures (*)') + '</option>';
for (let i = 0; i < 24; i++) {
const v = String(i).padStart(2, '0');
const sel = (i === 8) ? ' selected' : '';
hHtml += `<option value="${i}"${sel}>${v}h (${v}:00)</option>`;
}
hSel.innerHTML = hHtml;
}
if (mSel && mSel.options.length <= 1) {
let mHtml = '';
for (let i = 0; i < 60; i++) {
const v = String(i).padStart(2, '0');
const sel = (i === 0) ? ' selected' : '';
mHtml += `<option value="${i}"${sel}>${v} min (:${v})</option>`;
}
mSel.innerHTML = mHtml;
}
updateStatsReportCronFromFields();
}
function updateStatsReportCronFromFields() {
const d = $('statsReportDay')?.value || '*';
const h = $('statsReportHour')?.value || '8';
const m = $('statsReportMinute')?.value || '0';
const expr = `${m} ${h} * * ${d}`;
if ($('statsReportCronExpr')) $('statsReportCronExpr').value = expr;
updateStatsReportHumanSummary(expr);
}
function updateStatsReportHumanSummary(expr) {
const humanBadge = $('statsReportCronHuman');
if (!humanBadge) return;
const parts = expr.trim().split(/\s+/);
if (parts.length !== 5) {
humanBadge.textContent = '⚙️ Cron : ' + expr;
return;
}
const [minPart, hourPart, domPart, monthPart, dowPart] = parts;
const daysMap = {
'*': t('stats_cron_day_all_short', 'Tous les jours'),
'1-5': t('stats_cron_day_workdays_short', 'Jours ouvrés (Lun-Ven)'),
'6,7': t('stats_cron_day_weekend_short', 'Week-end (Sam-Dim)'),
'1': t('stats_cron_day_mon', 'Chaque Lundi'),
'2': t('stats_cron_day_tue', 'Chaque Mardi'),
'3': t('stats_cron_day_wed', 'Chaque Mercredi'),
'4': t('stats_cron_day_thu', 'Chaque Jeudi'),
'5': t('stats_cron_day_fri', 'Chaque Vendredi'),
'6': t('stats_cron_day_sat', 'Chaque Samedi'),
'0': t('stats_cron_day_sun', 'Chaque Dimanche'),
'7': t('stats_cron_day_sun', 'Chaque Dimanche')
};
const dStr = daysMap[dowPart] || (t('stats_cron_day_prefix', 'Jour ') + dowPart);
let timeStr = '';
if (hourPart === '*') {
timeStr = t('stats_cron_hourly_at', 'toutes les heures à :{min}').replace('{min}', String(minPart).padStart(2, '0'));
} else {
timeStr = t('stats_cron_at_time', 'à {time}').replace('{time}', `${String(hourPart).padStart(2, '0')}:${String(minPart).padStart(2, '0')}`);
}
humanBadge.textContent = `📅 ${dStr} ${timeStr}`;
}
function getNotificationFormPayload() {
return {
events: {
new_device: $('notifEvtNewDevice')?.checked || false,
device_connected: $('notifEvtDeviceConnected')?.checked || false,
device_disconnected: $('notifEvtDeviceDisconnected')?.checked || false,
admin_login: $('notifEvtAdminLogin')?.checked || false,
admin_login_failed: $('notifEvtAdminLoginFailed')?.checked || false,
device_blocked: $('notifEvtDeviceBlocked')?.checked || false,
settings_changed: $('notifEvtSettingsChanged')?.checked || false,
vpn_client_connected: $('notifEvtVpnClientConnected')?.checked || false,
vpn_client_disconnected: $('notifEvtVpnClientDisconnected')?.checked || false,
vpn_profile_connected: $('notifEvtVpnProfileConnected')?.checked || false,
vpn_profile_disconnected: $('notifEvtVpnProfileDisconnected')?.checked || false,
quota_exceeded: $('notifEvtQuotaExceeded')?.checked ?? true,
stats_report: $('notifEvtStatsReport')?.checked || false
},
stats_report_schedule: {
enabled: $('notifEvtStatsReport')?.checked || false,
day: $('statsReportDay')?.value || '*',
hour: parseInt($('statsReportHour')?.value || '8', 10),
minute: parseInt($('statsReportMinute')?.value || '0', 10),
cron_expr: $('statsReportCronExpr')?.value?.trim() || '0 8 * * *',
top_range: $('statsReportTopRange')?.value || 'day'
},
email: {
enabled: $('notifEmailEnabled')?.checked || false,
smtp_host: $('notifEmailHost')?.value?.trim() || '',
smtp_port: parseInt($('notifEmailPort')?.value || '587', 10) || 587,
smtp_secure: $('notifEmailSecure')?.value || 'starttls',
smtp_user: $('notifEmailUser')?.value?.trim() || '',
smtp_pass: $('notifEmailPass')?.value || '',
from_addr: $('notifEmailFrom')?.value?.trim() || '',
to_addr: $('notifEmailTo')?.value?.trim() || ''
},
gotify: {
enabled: $('notifGotifyEnabled')?.checked || false,
server_url: $('notifGotifyUrl')?.value?.trim() || '',
token: $('notifGotifyToken')?.value?.trim() || '',
priority: parseInt($('notifGotifyPriority')?.value || '5', 10) || 5
},
discord: {
enabled: $('notifDiscordEnabled')?.checked || false,
webhook_url: $('notifDiscordWebhook')?.value?.trim() || '',
bot_name: $('notifDiscordBotName')?.value?.trim() || 'AP Manageur'
},
ntfy: {
enabled: $('notifNtfyEnabled')?.checked || false,
server_url: $('notifNtfyUrl')?.value?.trim() || 'https://ntfy.sh',
topic: $('notifNtfyTopic')?.value?.trim() || '',
token: $('notifNtfyToken')?.value?.trim() || '',
priority: parseInt($('notifNtfyPriority')?.value || '3', 10) || 3
},
pushbullet: {
enabled: $('notifPushbulletEnabled')?.checked || false,
api_token: $('notifPushbulletToken')?.value?.trim() || '',
device_iden: $('notifPushbulletDevice')?.value?.trim() || ''
},
pushover: {
enabled: $('notifPushoverEnabled')?.checked || false,
user_key: $('notifPushoverUser')?.value?.trim() || '',
api_token: $('notifPushoverToken')?.value?.trim() || '',
priority: parseInt($('notifPushoverPriority')?.value || '0', 10) || 0
},
slack: {
enabled: $('notifSlackEnabled')?.checked || false,
webhook_url: $('notifSlackWebhook')?.value?.trim() || '',
bot_name: $('notifSlackBotName')?.value?.trim() || 'AP Manageur'
},
telegram: {
enabled: $('notifTelegramEnabled')?.checked || false,
bot_token: $('notifTelegramToken')?.value?.trim() || '',
chat_id: $('notifTelegramChatId')?.value?.trim() || '',
thread_id: $('notifTelegramThreadId')?.value?.trim() || ''
},
webhook: {
enabled: $('notifWebhookEnabled')?.checked || false,
url: $('notifWebhookUrl')?.value?.trim() || '',
method: $('notifWebhookMethod')?.value || 'POST',
headers: $('notifWebhookHeaders')?.value?.trim() || ''
}
};
}
function getSetupAuthToken(extraToken) {
if (extraToken) return extraToken;
try {
const m = document.cookie.match(/(?:^|;\s*)apAuthToken=([^;]+)/);
if (m && m[1]) return decodeURIComponent(m[1]);
} catch (_) { }
try {
return localStorage.getItem('apAuthToken') || sessionStorage.getItem('apAuthToken') || '';
} catch (_) {
return '';
}
}
function getSetupAuthHeaders(extraToken, jsonContent = true) {
const h = jsonContent ? { 'Content-Type': 'application/json' } : {};
const tok = getSetupAuthToken(extraToken);
if (tok) {
h['X-Session-Token'] = tok;
h['Authorization'] = 'Bearer ' + tok;
}
return h;
}
const setupNotifVerifiedSigs = {};
function getNotifChannelSignature(ch, cfg) {
const c = (cfg || getNotificationFormPayload())[ch];
if (!c) return '';
return JSON.stringify(c);
}
async function testSetupNotification(channel) {
const detailsBox = $('setupNotifTestDetails');
if (detailsBox) {
detailsBox.innerHTML = `<div style="font-size:13px;color:var(--blue);padding:10px 14px;background:var(--panel);border:1px solid var(--line);border-radius:8px;margin-bottom:12px;display:flex;align-items:center;gap:8px"><span>⏳</span> <span>${t('notif_testing_progress', 'Envoi de la notification de test en cours…')}</span></div>`;
}
const testedConfig = getNotificationFormPayload();
try {
const payload = {
channel: channel,
config: testedConfig
};
const res = await fetch(API_URL + '/api/notifications/test', {
method: 'POST',
headers: getSetupAuthHeaders(),
body: JSON.stringify(payload)
});
const data = await res.json();
if (!res.ok) throw new Error(data.error || 'Erreur lors du test');
const results = data.results || {};
let html = '<div style="display:flex;flex-direction:column;gap:8px;margin-bottom:12px">';
const labels = {
email: '✉️ Email SMTP',
gotify: '🔔 Gotify',
discord: '🎮 Discord Webhook',
ntfy: '📢 ntfy.sh',
pushbullet: '📱 Pushbullet',
pushover: '📣 Pushover',
slack: '💼 Slack Webhook',
telegram: '✈️ Telegram Bot',
webhook: '🌐 Webhook personnalisé',
general: 'ℹ️ Information'
};
for (const [ch, info] of Object.entries(results)) {
const chName = labels[ch] || ch;
if (info.ok) {
if (ch !== 'general') {
setupNotifVerifiedSigs[ch] = getNotifChannelSignature(ch, testedConfig);
}
html += `<div style="font-size:13px;color:var(--green);background:rgba(50,213,131,0.1);border:1px solid rgba(50,213,131,0.3);padding:9px 12px;border-radius:8px;display:flex;align-items:center;gap:8px"><span>✅</span> <strong>${chName} :</strong> <span>${info.message || 'Succès'}</span></div>`;
} else {
if (ch !== 'general') {
delete setupNotifVerifiedSigs[ch];
}
html += `<div style="font-size:13px;color:var(--red);background:rgba(255,107,107,0.1);border:1px solid rgba(255,107,107,0.3);padding:9px 12px;border-radius:8px;display:flex;align-items:center;gap:8px"><span>❌</span> <strong>${chName} :</strong> <span>${info.error || 'Échec'}</span></div>`;
}
}
html += '</div>';
if (detailsBox) detailsBox.innerHTML = html;
} catch (e) {
if (channel && channel !== 'all') {
delete setupNotifVerifiedSigs[channel];
} else {
Object.keys(setupNotifVerifiedSigs).forEach(k => delete setupNotifVerifiedSigs[k]);
}
if (detailsBox) {
detailsBox.innerHTML = `<div style="font-size:13px;color:var(--red);background:rgba(255,107,107,0.1);border:1px solid rgba(255,107,107,0.3);padding:9px 12px;border-radius:8px;margin-bottom:12px;display:flex;align-items:center;gap:8px"><span>❌</span> <strong>${t('notif_test_err', 'Erreur lors du test : ')}</strong> <span>${e.message}</span></div>`;
}
} finally {
updateStep4ContinueState();
}
}
async function loadNotificationSettingsInSetup() {
try {
const res = await fetch(API_URL + '/api/notifications/settings', {
headers: getSetupAuthHeaders('', false)
});
if (!res.ok) return;
const cfg = await res.json();
const evts = cfg.events || {};
if ($('notifEvtNewDevice') && evts.new_device !== undefined) $('notifEvtNewDevice').checked = !!evts.new_device;
if ($('notifEvtDeviceConnected') && evts.device_connected !== undefined) $('notifEvtDeviceConnected').checked = !!evts.device_connected;
if ($('notifEvtDeviceDisconnected') && evts.device_disconnected !== undefined) $('notifEvtDeviceDisconnected').checked = !!evts.device_disconnected;
if ($('notifEvtAdminLogin') && evts.admin_login !== undefined) $('notifEvtAdminLogin').checked = !!evts.admin_login;
if ($('notifEvtAdminLoginFailed') && evts.admin_login_failed !== undefined) $('notifEvtAdminLoginFailed').checked = !!evts.admin_login_failed;
if ($('notifEvtDeviceBlocked') && evts.device_blocked !== undefined) $('notifEvtDeviceBlocked').checked = !!evts.device_blocked;
if ($('notifEvtSettingsChanged') && evts.settings_changed !== undefined) $('notifEvtSettingsChanged').checked = !!evts.settings_changed;
if ($('notifEvtVpnClientConnected') && evts.vpn_client_connected !== undefined) $('notifEvtVpnClientConnected').checked = !!evts.vpn_client_connected;
if ($('notifEvtVpnClientDisconnected') && evts.vpn_client_disconnected !== undefined) $('notifEvtVpnClientDisconnected').checked = !!evts.vpn_client_disconnected;
if ($('notifEvtVpnProfileConnected') && evts.vpn_profile_connected !== undefined) $('notifEvtVpnProfileConnected').checked = !!evts.vpn_profile_connected;
if ($('notifEvtVpnProfileDisconnected') && evts.vpn_profile_disconnected !== undefined) $('notifEvtVpnProfileDisconnected').checked = !!evts.vpn_profile_disconnected;
if ($('notifEvtQuotaExceeded') && evts.quota_exceeded !== undefined) $('notifEvtQuotaExceeded').checked = !!evts.quota_exceeded;
const sched = cfg.stats_report_schedule || {};
const isStatsRep = !!(evts.stats_report || sched.enabled);
if ($('notifEvtStatsReport')) $('notifEvtStatsReport').checked = isStatsRep;
initStatsReportTimeSelects();
toggleStatsReportSchedule(isStatsRep);
if (sched.day && $('statsReportDay')) $('statsReportDay').value = sched.day;
if (sched.hour !== undefined && $('statsReportHour')) $('statsReportHour').value = String(sched.hour);
if (sched.minute !== undefined && $('statsReportMinute')) $('statsReportMinute').value = String(sched.minute);
if (sched.top_range && $('statsReportTopRange')) $('statsReportTopRange').value = sched.top_range;
updateStatsReportCronFromFields();
const em = cfg.email || {};
if ($('notifEmailEnabled')) $('notifEmailEnabled').checked = !!em.enabled;
if ($('notifEmailHost') && em.smtp_host) $('notifEmailHost').value = em.smtp_host;
if ($('notifEmailPort') && em.smtp_port) $('notifEmailPort').value = em.smtp_port;
if ($('notifEmailSecure') && em.smtp_secure) $('notifEmailSecure').value = em.smtp_secure;
if ($('notifEmailUser') && em.smtp_user) $('notifEmailUser').value = em.smtp_user;
if ($('notifEmailFrom') && em.from_addr) $('notifEmailFrom').value = em.from_addr;
if ($('notifEmailTo') && em.to_addr) $('notifEmailTo').value = em.to_addr;
const got = cfg.gotify || {};
if ($('notifGotifyEnabled')) $('notifGotifyEnabled').checked = !!got.enabled;
if ($('notifGotifyUrl') && got.server_url) $('notifGotifyUrl').value = got.server_url;
if ($('notifGotifyToken') && got.token) $('notifGotifyToken').value = got.token;
if ($('notifGotifyPriority') && got.priority) $('notifGotifyPriority').value = got.priority;
const dis = cfg.discord || {};
if ($('notifDiscordEnabled')) $('notifDiscordEnabled').checked = !!dis.enabled;
if ($('notifDiscordWebhook') && dis.webhook_url) $('notifDiscordWebhook').value = dis.webhook_url;
if ($('notifDiscordBotName') && dis.bot_name) $('notifDiscordBotName').value = dis.bot_name;
const ntf = cfg.ntfy || {};
if ($('notifNtfyEnabled')) $('notifNtfyEnabled').checked = !!ntf.enabled;
if ($('notifNtfyUrl') && ntf.server_url) $('notifNtfyUrl').value = ntf.server_url;
if ($('notifNtfyTopic') && ntf.topic) $('notifNtfyTopic').value = ntf.topic;
if ($('notifNtfyToken') && ntf.token) $('notifNtfyToken').value = ntf.token;
if ($('notifNtfyPriority') && ntf.priority) $('notifNtfyPriority').value = ntf.priority;
const pb = cfg.pushbullet || {};
if ($('notifPushbulletEnabled')) $('notifPushbulletEnabled').checked = !!pb.enabled;
if ($('notifPushbulletToken') && pb.api_token) $('notifPushbulletToken').value = pb.api_token;
if ($('notifPushbulletDevice') && pb.device_iden) $('notifPushbulletDevice').value = pb.device_iden;
const po = cfg.pushover || {};
if ($('notifPushoverEnabled')) $('notifPushoverEnabled').checked = !!po.enabled;
if ($('notifPushoverUser') && po.user_key) $('notifPushoverUser').value = po.user_key;
if ($('notifPushoverToken') && po.api_token) $('notifPushoverToken').value = po.api_token;
if ($('notifPushoverPriority') && po.priority !== undefined) $('notifPushoverPriority').value = po.priority;
const sl = cfg.slack || {};
if ($('notifSlackEnabled')) $('notifSlackEnabled').checked = !!sl.enabled;
if ($('notifSlackWebhook') && sl.webhook_url) $('notifSlackWebhook').value = sl.webhook_url;
if ($('notifSlackBotName') && sl.bot_name) $('notifSlackBotName').value = sl.bot_name;
const tg = cfg.telegram || {};
if ($('notifTelegramEnabled')) $('notifTelegramEnabled').checked = !!tg.enabled;
if ($('notifTelegramToken') && tg.bot_token) $('notifTelegramToken').value = tg.bot_token;
if ($('notifTelegramChatId') && tg.chat_id) $('notifTelegramChatId').value = tg.chat_id;
if ($('notifTelegramThreadId') && tg.thread_id) $('notifTelegramThreadId').value = tg.thread_id;
const wh = cfg.webhook || {};
if ($('notifWebhookEnabled')) $('notifWebhookEnabled').checked = !!wh.enabled;
if ($('notifWebhookUrl') && wh.url) $('notifWebhookUrl').value = wh.url;
if ($('notifWebhookMethod') && wh.method) $('notifWebhookMethod').value = wh.method;
if ($('notifWebhookHeaders') && wh.headers) $('notifWebhookHeaders').value = wh.headers;
toggleNotifFields();
} catch (_) { }
}
function setSetupTheme(theme, userExplicit = false) {
currentTheme = theme;
if (userExplicit) {
try { sessionStorage.setItem('setupExplicitTheme', theme); } catch (_) { }
}
try {
localStorage.setItem('apTheme', theme);
var m = window.matchMedia('(prefers-color-scheme: light)');
var resolved = theme === 'auto' ? (m.matches ? 'light' : 'dark') : theme;
document.documentElement.dataset.theme = resolved;
if (theme === 'macos') {
document.documentElement.dataset.macosMode = m.matches ? 'light' : 'dark';
} else {
delete document.documentElement.dataset.macosMode;
}
} catch (_) { }
['auto', 'dark', 'light', 'winxp', 'futuristic', 'macos', 'hacker'].forEach(t => {
const el = $('themeCard_' + t);
if (el) el.classList.toggle('active', t === theme);
});
if (currentStep === 6) updateRecap();
}
function setSetupLanguage(lang, userExplicit = false) {
currentLanguage = lang;
if (userExplicit) {
try { sessionStorage.setItem('setupExplicitLang', lang); } catch (_) { }
}
try { localStorage.setItem('apLanguage', lang); } catch (_) { }
document.documentElement.lang = lang === 'en-us' ? 'en-US' : (lang === 'en-gb' ? 'en-GB' : 'fr');
['fr', 'en-us', 'en-gb'].forEach(k => {
const el = $('langCard_' + k);
if (el) el.classList.toggle('active', k === lang);
});
applySetupTranslations(lang);
if (detectedServerBackups && detectedServerBackups.length > 0) {
const desc = $('setupDetectedBackupsDesc');
if (desc) {
const isEn = lang.startsWith('en');
desc.textContent = isEn
? `${detectedServerBackups.length} backup file(s) found on the server. You can restore your configuration right away.`
: `${detectedServerBackups.length} sauvegarde(s) trouvée(s) sur le serveur. Vous pouvez restaurer votre configuration en 1 clic !`;
}
}
}
/* ============================================================ */
/* GESTION DES PROFILS VPN EN ÉTAPE 5 */
/* ============================================================ */
function openSetupVpnModal() {
$('vpnModalName').value = '';
$('vpnModalConfig').value = '';
$('vpnModalUser').value = '';
$('vpnModalPass').value = '';
$('vpnTypeWg').checked = true;
$('vpnModalAutoConnect').checked = true;
onVpnTypeChange();
const err = $('vpnModalError');
if (err) err.style.display = 'none';
$('modalSetupVpn').style.display = 'flex';
}
function closeSetupVpnModal() {
$('modalSetupVpn').style.display = 'none';
}
function onVpnTypeChange() {
const isOvpn = $('vpnTypeOvpn') && $('vpnTypeOvpn').checked;
if ($('vpnTypeWgCard')) $('vpnTypeWgCard').classList.toggle('selected', !isOvpn);
if ($('vpnTypeOvpnCard')) $('vpnTypeOvpnCard').classList.toggle('selected', isOvpn);
if ($('vpnOvpnAuthBox')) $('vpnOvpnAuthBox').style.display = isOvpn ? 'block' : 'none';
}
function onVpnConfigFileSelected(e) {
const file = e.target.files && e.target.files[0];
if (!file) return;
if (!$('vpnModalName').value.trim()) {
const base = file.name.replace(/\.[^/.]+$/, "");
$('vpnModalName').value = base;
}
if (file.name.toLowerCase().endsWith('.ovpn')) {
$('vpnTypeOvpn').checked = true;
onVpnTypeChange();
} else if (file.name.toLowerCase().endsWith('.conf')) {
$('vpnTypeWg').checked = true;
onVpnTypeChange();
}
const reader = new FileReader();
reader.onload = (evt) => {
$('vpnModalConfig').value = evt.target.result;
};
reader.readAsText(file);
}
function saveSetupVpnProfile() {
const err = $('vpnModalError');
if (err) err.style.display = 'none';
const name = $('vpnModalName').value.trim();
const type = $('vpnTypeOvpn').checked ? 'openvpn' : 'wireguard';
const config = $('vpnModalConfig').value.trim();
const user = $('vpnModalUser') ? $('vpnModalUser').value.trim() : '';
const pass = $('vpnModalPass') ? $('vpnModalPass').value : '';
const autoConn = $('vpnModalAutoConnect').checked;
const isEn = currentLanguage.startsWith('en');
if (!name) {
showError(err, isEn ? '⚠️ Please enter a VPN profile name.' : '⚠️ Veuillez saisir un nom de profil VPN.');
return;
}
if (!config) {
showError(err, isEn ? '⚠️ Configuration file content cannot be empty.' : '⚠️ Le fichier de configuration ne peut pas être vide.');
return;
}
setupVpnProfiles.push({
id: Date.now(),
name: name,
type: type,
config_content: config,
auth_user: user,
auth_pass: pass,
auto_connect: autoConn
});
closeSetupVpnModal();
renderSetupVpnList();
if (currentStep === 6) updateRecap();
}
function removeSetupVpnProfile(id) {
setupVpnProfiles = setupVpnProfiles.filter(p => p.id !== id);
renderSetupVpnList();
if (currentStep === 6) updateRecap();
}
function renderSetupVpnList() {
const listEl = $('setupVpnList');
if (!listEl) return;
if (!setupVpnProfiles.length) {
const isEn = currentLanguage.startsWith('en');
listEl.innerHTML = `<div id="setupVpnEmpty" class="muted" style="font-size:13px;font-style:italic;padding:12px;background:var(--panel2);border:1px dashed var(--line);border-radius:8px;text-align:center">${isEn ? 'No VPN profiles added yet.' : 'Aucun profil VPN ajouté pour le moment.'}</div>`;
return;
}
const isEn = currentLanguage.startsWith('en');
let html = '';
setupVpnProfiles.forEach(p => {
const badgeColor = p.type === 'wireguard' ? 'var(--blue)' : 'var(--yellow)';
const badgeText = p.type === 'wireguard' ? 'WireGuard' : 'OpenVPN';
const autoText = p.auto_connect ? (isEn ? 'Autostart: On' : 'Démarrage auto : Oui') : (isEn ? 'Manual' : 'Manuel');
html += `
<div class="vpn-profile-item">
<div style="display:flex;align-items:center;gap:10px;min-width:0">
<span class="pill" style="font-size:11px;font-weight:700;color:${badgeColor};border-color:${badgeColor}">${badgeText}</span>
<div style="font-weight:700;font-size:13px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis">${p.name}</div>
<span class="muted" style="font-size:11px">(${autoText})</span>
</div>
<button type="button" class="secondary" onclick="removeSetupVpnProfile(${p.id})" style="padding:4px 8px;font-size:12px;color:var(--red);border-color:transparent" title="Supprimer">✕</button>
</div>
`;
});
listEl.innerHTML = html;
}
function updateRecap() {
const isEn = currentLanguage.startsWith('en');
// Wi-Fi
const ssid = $('setupSsid') ? ($('setupSsid').value.trim() || 'Mon-WiFi-AP') : 'Mon-WiFi-AP';
const isBridge = $('setupModeBridge') && $('setupModeBridge').checked;
const sec = $('setupSecurity') ? $('setupSecurity').value.toUpperCase() : 'WPA2';
if ($('recapSsid')) $('recapSsid').textContent = ssid;
if ($('recapMode')) {
const modeLabel = isBridge ? (isEn ? 'Bridge Mode' : 'Mode Pont (Bridge)') : (isEn ? 'AP Mode (Router)' : 'Mode AP (Routeur/NAT)');
$('recapMode').textContent = modeLabel + ' • ' + sec;
}
// Admin
const adminUser = $('setupAdminUser') ? ($('setupAdminUser').value.trim() || 'admin') : 'admin';
if ($('recapAdminUser')) $('recapAdminUser').textContent = adminUser;
if ($('recapAdminSub')) {
$('recapAdminSub').textContent = isEn ? 'Password configured (••••••••)' : 'Mot de passe défini (••••••••)';
}
// Notifications
const notifSt = getStep4NotificationStatus();
const channels = [
{ id: 'notifEmailEnabled', name: 'Email' },
{ id: 'notifGotifyEnabled', name: 'Gotify' },
{ id: 'notifDiscordEnabled', name: 'Discord' },
{ id: 'notifNtfyEnabled', name: 'ntfy' },
{ id: 'notifPushbulletEnabled', name: 'Pushbullet' },
{ id: 'notifPushoverEnabled', name: 'Pushover' },
{ id: 'notifSlackEnabled', name: 'Slack' },
{ id: 'notifTelegramEnabled', name: 'Telegram' },
{ id: 'notifWebhookEnabled', name: 'Webhook' }
];
let activeChannels = [];
if (notifSt.ready) {
channels.forEach(c => {
if ($(c.id) && $(c.id).checked) activeChannels.push(c.name);
});
}
if ($('recapNotif')) {
if (activeChannels.length) {
$('recapNotif').textContent = activeChannels.join(', ');
} else {
$('recapNotif').textContent = isEn ? 'Disabled' : 'Désactivées';
}
}
if ($('recapNotifSub')) {
if (notifOn && activeChannels.length) {
let evCount = 0;
const evIds = ['notifEvtNewDevice', 'notifEvtDeviceConnected', 'notifEvtDeviceDisconnected', 'notifEvtAdminLogin', 'notifEvtAdminLoginFailed', 'notifEvtDeviceBlocked', 'notifEvtSettingsChanged', 'notifEvtVpnClientConnected', 'notifEvtVpnClientDisconnected', 'notifEvtVpnProfileConnected', 'notifEvtVpnProfileDisconnected', 'notifEvtQuotaExceeded', 'notifEvtStatsReport'];
evIds.forEach(eid => { if ($(eid) && $(eid).checked) evCount++; });
$('recapNotifSub').textContent = isEn ? `${activeChannels.length} channel(s) • ${evCount} alert event(s)` : `${activeChannels.length} canal(aux) • ${evCount} événement(s) d’alerte`;
} else {
$('recapNotifSub').textContent = isEn ? 'Can be configured later' : 'Modifiable ultérieurement';
}
}
// Profils VPN
if ($('recapVpnVal')) {
if (setupVpnProfiles.length) {
$('recapVpnVal').textContent = `${setupVpnProfiles.length} ${isEn ? 'profile(s) configured' : 'profil(s) configuré(s)'}`;
if ($('recapVpnSub')) {
const names = setupVpnProfiles.map(p => p.name).join(', ');
$('recapVpnSub').textContent = names;
}
} else {
$('recapVpnVal').textContent = isEn ? 'No profiles configured' : 'Aucun profil configuré';
if ($('recapVpnSub')) $('recapVpnSub').textContent = isEn ? 'Direct Internet by default' : 'Internet direct par défaut';
}
}
// Thème
const themeNamesFr = { 'auto': 'Auto (Système)', 'dark': 'Sombre', 'light': 'Clair', 'winxp': 'Windows XP', 'futuristic': 'Futuriste', 'macos': 'macOS', 'hacker': 'Hacker' };
const themeNamesEn = { 'auto': 'Auto (System)', 'dark': 'Dark', 'light': 'Light', 'winxp': 'Windows XP', 'futuristic': 'Futuristic', 'macos': 'macOS', 'hacker': 'Hacker' };
const themeDict = isEn ? themeNamesEn : themeNamesFr;
if ($('recapTheme')) $('recapTheme').textContent = themeDict[currentTheme] || currentTheme;
const autoOn = $('setupAutoconnect') && $('setupAutoconnect').checked;
if ($('recapAutoconnect')) {
$('recapAutoconnect').textContent = isEn ? ('Autostart: ' + (autoOn ? 'Yes' : 'No')) : ('Démarrage auto : ' + (autoOn ? 'Oui' : 'Non'));
}
}
function goToStep(stepNum) {
if (stepNum < 1 || stepNum > 6) return;
if (currentStep === 4 && stepNum > 4) {
const st = getStep4NotificationStatus();
if (st.anyChecked && !st.ready) {
updateStep4ContinueState();
selectSetupNotifSubTab('services');
return;
}
}
const prevStep = currentStep;
currentStep = stepNum;
maxStepReached = Math.max(maxStepReached, stepNum);
// Panneaux (animation directionnelle gauche/droite)
for (let i = 1; i <= 6; i++) {
const panel = $('panelStep' + i);
if (panel) {
panel.classList.remove('slide-prev');
if (i === stepNum) {
if (stepNum < prevStep) panel.classList.add('slide-prev');
panel.classList.add('active');
} else {
panel.classList.remove('active');
}
}
}
// Stepper
for (let i = 1; i <= 6; i++) {
const nav = $('stepNav' + i);
const badge = $('stepBadge' + i);
if (nav && badge) {
nav.classList.toggle('active', i === stepNum);
nav.classList.toggle('completed', i < stepNum);
if (i < stepNum) {
badge.textContent = '✓';
} else {
badge.textContent = String(i);
}
}
}
if ($('sidebarProgressText')) {
const isEn = currentLanguage.startsWith('en');
$('sidebarProgressText').textContent = isEn ? `${stepNum} of 6` : `${stepNum} / 6`;
}
if (stepNum === 6) {
updateRecap();
}
window.scrollTo({ top: 0, behavior: 'smooth' });
}
function validateStep2() {
const errEl = $('step2Error');
if (errEl) errEl.style.display = 'none';
const ssid = $('setupSsid') ? $('setupSsid').value.trim() : '';
const password = $('setupPassword') ? $('setupPassword').value : '';
const confirmation = $('setupPasswordConfirm') ? $('setupPasswordConfirm').value : '';
const isEn = currentLanguage.startsWith('en');
if (!ssid) {
showError(errEl, isEn ? '⚠️ Please enter a Wi-Fi network name (SSID).' : '⚠️ Veuillez saisir un nom de réseau Wi-Fi (SSID).');
return;
}
if (password.length < 8) {
showError(errEl, isEn ? '⚠️ Wi-Fi password must be at least 8 characters long.' : '⚠️ La clé Wi-Fi doit comporter au moins 8 caractères.');
return;
}
if (password !== confirmation) {
showError(errEl, isEn ? '⚠️ Wi-Fi passwords do not match.' : '⚠️ Les mots de passe Wi-Fi ne correspondent pas.');
return;
}
goToStep(3);
}
function validateStep3() {
const errEl = $('step3Error');
if (errEl) errEl.style.display = 'none';
const adminUser = $('setupAdminUser') ? $('setupAdminUser').value.trim() : '';
const adminPass = $('setupAdminPassword') ? $('setupAdminPassword').value : '';
const adminPassConf = $('setupAdminPasswordConfirm') ? $('setupAdminPasswordConfirm').value : '';
const isEn = currentLanguage.startsWith('en');
if (!adminUser) {
showError(errEl, isEn ? '⚠️ Please enter an administrator username.' : '⚠️ Veuillez saisir un nom d\'utilisateur administrateur.');
return;
}
if (!adminPass) {
showError(errEl, isEn ? '⚠️ Please enter an administrator password.' : '⚠️ Veuillez saisir un mot de passe administrateur.');
return;
}
if (adminPass.length < 4) {
showError(errEl, isEn ? '⚠️ Password must be at least 4 characters long.' : '⚠️ Le mot de passe administrateur doit comporter au moins 4 caractères.');
return;
}
if (adminPass !== adminPassConf) {
showError(errEl, isEn ? '⚠️ Administrator passwords do not match.' : '⚠️ Les mots de passe administrateur ne correspondent pas.');
return;
}
goToStep(4);
}
function getStep4NotificationStatus() {
const p = getNotificationFormPayload();
const checks = [
{ key: 'email', en: p.email.enabled, ok: !!(p.email.smtp_host && p.email.to_addr) },
{ key: 'gotify', en: p.gotify.enabled, ok: !!(p.gotify.server_url && p.gotify.token) },
{ key: 'discord', en: p.discord.enabled, ok: !!p.discord.webhook_url },
{ key: 'ntfy', en: p.ntfy.enabled, ok: !!(p.ntfy.server_url && p.ntfy.topic) },
{ key: 'pushbullet', en: p.pushbullet.enabled, ok: !!p.pushbullet.api_token },
{ key: 'pushover', en: p.pushover.enabled, ok: !!(p.pushover.user_key && p.pushover.api_token) },
{ key: 'slack', en: p.slack.enabled, ok: !!p.slack.webhook_url },
{ key: 'telegram', en: p.telegram.enabled, ok: !!(p.telegram.bot_token && p.telegram.chat_id) },
{ key: 'webhook', en: p.webhook.enabled, ok: !!p.webhook.url }
];
const enabledList = checks.filter(c => c.en);
const anyChecked = enabledList.length > 0;
const allEnabledConfigured = anyChecked && enabledList.every(c => c.ok);
const allEnabledVerified = allEnabledConfigured && enabledList.every(c => setupNotifVerifiedSigs[c.key] === getNotifChannelSignature(c.key, p));
return {
anyChecked,
anyConfigured: allEnabledConfigured,
allEnabledConfigured,
allEnabledVerified,
ready: allEnabledVerified
};
}
function updateStep4ContinueState() {
const btn = $('btnStep4Continue');
const errEl = $('step4Error');
const st = getStep4NotificationStatus();
const isEn = currentLanguage.startsWith('en');
if (!st.ready) {
if (btn) {
btn.disabled = true;
btn.style.opacity = '0.5';
btn.style.cursor = 'not-allowed';
}
let msg;
if (!st.anyChecked) {
msg = isEn
? '⚠️ Please enable, configure, and test at least one notification service to continue, or click "Skip".'
: '⚠️ Veuillez activer, configurer et tester au moins un service de notification pour continuer, ou cliquez sur « Ignorer ».';
} else if (!st.allEnabledConfigured) {
msg = isEn
? '⚠️ Please fill in the required fields for each enabled notification service (URL, token, recipient...) to continue, or click "Skip".'
: '⚠️ Veuillez compléter les champs obligatoires de chaque service de notification activé (URL, jeton, destinataire...) pour continuer, ou cliquez sur « Ignorer ».';
} else {
msg = isEn
? '🧪 Please click "Test" and make sure the test succeeds before continuing (or click "Skip").'
: '🧪 Veuillez lancer un test réussi sur chaque service activé avant de pouvoir continuer (ou cliquez sur « Ignorer »).';
}
showError(errEl, msg);
} else {
if (btn) {
btn.disabled = false;
btn.style.opacity = '';
btn.style.cursor = '';
}
if (errEl) errEl.style.display = 'none';
}
}
function skipStep4() {
['Email', 'Gotify', 'Discord', 'Ntfy', 'Pushbullet', 'Pushover', 'Slack', 'Telegram', 'Webhook'].forEach(cap => {
const chk = $('notif' + cap + 'Enabled');
if (chk) chk.checked = false;
});
Object.keys(setupNotifVerifiedSigs).forEach(k => delete setupNotifVerifiedSigs[k]);
toggleNotifFields();
if ($('step4Error')) $('step4Error').style.display = 'none';
goToStep(5);
}
function validateStep4() {
updateStep4ContinueState();
const st = getStep4NotificationStatus();
if (!st.ready) {
selectSetupNotifSubTab('services');
return;
}
goToStep(5);
}
function showError(el, msg) {
if (!el) return;
const changed = el.style.display === 'none' || el.textContent !== msg;
el.textContent = msg;
el.style.display = 'block';
if (changed) {
el.classList.remove('err-shake');
void el.offsetWidth;
el.classList.add('err-shake');
}
}
/* ============================================================ */
/* GESTION IMPORT DE SAUVEGARDE (SERVEUR, CLOUD, LOCAL) */
/* ============================================================ */
let currentSetupBackupTab = 'server';
let detectedServerBackups = [];
function openSetupBackupPickerModal(preferredTab) {
const modal = $('modalSetupBackupPicker');
if (!modal) return;
modal.style.display = 'flex';
switchSetupBackupTab(preferredTab || (detectedServerBackups.length > 0 ? 'server' : 'server'));
loadServerBackupsInSetup();
}
function closeSetupBackupPickerModal() {
const modal = $('modalSetupBackupPicker');
if (modal) modal.style.display = 'none';
}
function switchSetupBackupTab(tab) {
currentSetupBackupTab = tab;
['server', 'cloud', 'local'].forEach(t => {
const btn = $('tabBtn' + t.charAt(0).toUpperCase() + t.slice(1));
const content = $('setupTabContent_' + t);
const isActive = (t === tab);
if (btn) {
btn.classList.toggle('active', isActive);
btn.style.borderBottomColor = isActive ? 'var(--accent)' : 'transparent';
btn.style.color = isActive ? 'var(--text)' : 'var(--muted)';
}
if (content) {
content.style.display = isActive ? 'block' : 'none';
}
});
}
async function checkDetectedServerBackups() {
try {
const res = await fetch(API_URL + '/api/backups/list', { cache: 'no-store' });
if (!res.ok) return;
const d = await res.json();
detectedServerBackups = Array.isArray(d.backups) ? d.backups : [];
const banner = $('setupDetectedBackupsBanner');
const countBadge = $('badgeServerBackupsCount');
if (countBadge) {
countBadge.textContent = detectedServerBackups.length;
countBadge.style.display = detectedServerBackups.length > 0 ? 'inline-block' : 'none';
}
if (banner) {
if (detectedServerBackups.length > 0) {
banner.style.display = 'flex';
const desc = $('setupDetectedBackupsDesc');
if (desc) {
const isEn = currentLanguage.startsWith('en');
desc.textContent = isEn
? `${detectedServerBackups.length} backup file(s) found on the server. You can restore your configuration right away.`
: `${detectedServerBackups.length} sauvegarde(s) trouvée(s) sur le serveur. Vous pouvez restaurer votre configuration en 1 clic !`;
}
} else {
banner.style.display = 'none';
}
}
if (d.remote && typeof d.remote === 'object') {
populateSetupRemoteConfig(d.remote);
}
} catch (err) {
console.warn('Vérification sauvegardes serveur:', err);
}
}
async function loadServerBackupsInSetup(forceSync = false) {
const listEl = $('setupServerBackupsList');
if (!listEl) return;
const isEn = currentLanguage.startsWith('en');
listEl.innerHTML = `<div class="muted" style="text-align:center;padding:24px">${isEn ? 'Searching for backups on the server…' : 'Recherche des sauvegardes sur le serveur…'}</div>`;
try {
const url = API_URL + '/api/backups/list' + (forceSync ? '?sync_remote=1' : '');
const res = await fetch(url, { cache: 'no-store' });
const d = await res.json();
if (!res.ok) throw new Error(d.error || 'Erreur');
detectedServerBackups = Array.isArray(d.backups) ? d.backups : [];
const countBadge = $('badgeServerBackupsCount');
if (countBadge) {
countBadge.textContent = detectedServerBackups.length;
countBadge.style.display = detectedServerBackups.length > 0 ? 'inline-block' : 'none';
}
if (detectedServerBackups.length === 0) {
listEl.innerHTML = `
<div style="text-align:center;padding:32px 16px;background:var(--panel2);border:1px dashed var(--line);border-radius:10px">
<div style="font-size:32px;margin-bottom:8px">📂</div>
<div style="font-weight:700;font-size:14px;margin-bottom:6px">${isEn ? 'No backups found on the server' : 'Aucune sauvegarde trouvée sur le serveur'}</div>
<p class="muted" style="font-size:12px;margin:0 0 14px;max-width:440px;margin-left:auto;margin-right:auto">
${isEn ? 'You can import a backup file (.zip, .json) from your computer, or pull backups directly from your Cloud storage.' : 'Vous pouvez importer un fichier de sauvegarde (.zip, .json) depuis votre ordinateur, ou rapatrier vos sauvegardes directement depuis le Cloud.'}
</p>
<div style="display:flex;gap:10px;justify-content:center;flex-wrap:wrap">
<button type="button" class="secondary" onclick="switchSetupBackupTab('local')" style="font-size:12px">💻 ${isEn ? 'Browse PC file' : 'Fichier local (PC)'}</button>
<button type="button" class="secondary" onclick="switchSetupBackupTab('cloud')" style="font-size:12px">☁️ ${isEn ? 'Cloud services' : 'Services Cloud'}</button>
</div>
</div>
`;
return;
}
let html = '';
detectedServerBackups.forEach(b => {
const szStr = b.size_str || `${Math.round((b.size || 0) / 1024)} Ko`;
const dtStr = b.created_at || (b.mtime ? new Date(b.mtime * 1000).toLocaleString() : '—');
const isAuto = b.trigger === 'auto';
const trigBadge = isAuto
? `<span class="pill" style="font-size:10px;color:var(--blue);border-color:var(--blue)">🤖 Auto</span>`
: `<span class="pill" style="font-size:10px">👤 Manuel</span>`;
html += `
<div style="display:flex;align-items:center;justify-content:space-between;gap:12px;background:var(--panel2);border:1px solid var(--line);border-radius:10px;padding:12px 14px;flex-wrap:wrap">
<div style="display:flex;align-items:center;gap:10px;min-width:240px;flex:1">
<span style="font-size:22px">📦</span>
<div>
<div style="font-weight:700;font-size:13px;word-break:break-all">${b.filename}</div>
<div class="muted" style="font-size:11px;margin-top:2px;display:flex;align-items:center;gap:8px;flex-wrap:wrap">
<span>📅 ${dtStr}</span>
<span>💾 ${szStr}</span>
${trigBadge}
</div>
</div>
</div>
<button type="button" onclick="inspectServerBackup('${encodeURIComponent(b.filename)}', ${b.size || 0})"
style="display:inline-flex;align-items:center;gap:6px;font-size:12px;padding:6px 12px;white-space:nowrap;background:var(--accent);color:#fff">
<span>🔍</span> <span>${isEn ? 'Inspect & Restore' : 'Inspecter & Restaurer'}</span>
</button>
</div>
`;
});
listEl.innerHTML = html;
if (d.remote && typeof d.remote === 'object') {
populateSetupRemoteConfig(d.remote);
}
} catch (err) {
listEl.innerHTML = `<div style="color:var(--red);padding:14px;background:rgba(255,107,107,0.1);border-radius:8px;font-size:13px">❌ ${err.message || 'Erreur'}</div>`;
}
}
async function inspectServerBackup(encodedName, fileSize) {
const fileName = decodeURIComponent(encodedName);
try {
const res = await fetch(API_URL + '/api/backup/inspect', {
method: 'POST',
headers: getSetupAuthHeaders(),
body: JSON.stringify({ filename: fileName })
});
const d = await res.json();
if (!res.ok) throw new Error(d.error || 'Erreur d\'analyse de la sauvegarde');
pendingBackupData = d.backup;
closeSetupBackupPickerModal();
showSetupBackupModal(fileName, d.size || fileSize, d.backup);
} catch (err) {
alert('Erreur lors de l\'inspection de la sauvegarde : ' + err.message);
}
}
function selectSetupCloudProvider(prov) {
if ($('setupCloudProvider')) $('setupCloudProvider').value = prov;
document.querySelectorAll('#setupCloudProviderSelector .setup-prov-btn').forEach(btn => {
const isMatch = btn.getAttribute('data-prov') === prov;
btn.classList.toggle('active', isMatch);
btn.style.borderColor = isMatch ? 'var(--accent)' : 'var(--line)';
btn.style.background = isMatch ? 'var(--accent)' : 'var(--panel2)';
btn.style.color = isMatch ? '#fff' : 'var(--text)';
});
['ftp', 'sftp', 'gdrive', 'dropbox', 'webdav', 's3'].forEach(p => {
const box = $('setupCloudFields_' + p);
if (box) box.style.display = (p === prov) ? 'block' : 'none';
});
const msg = $('setupCloudMsg');
if (msg) msg.style.display = 'none';
}
function populateSetupRemoteConfig(remote) {
if (!remote || typeof remote !== 'object') return;
if (remote.provider && $('setupCloudProvider')) {
selectSetupCloudProvider(remote.provider);
}
if (remote.ftp && typeof remote.ftp === 'object') {
if ($('setupFtpHost')) $('setupFtpHost').value = remote.ftp.host || '';
if ($('setupFtpPort')) $('setupFtpPort').value = remote.ftp.port || 21;
if ($('setupFtpTls')) $('setupFtpTls').value = remote.ftp.tls || 'none';
if ($('setupFtpUser')) $('setupFtpUser').value = remote.ftp.user || '';
if ($('setupFtpPath')) $('setupFtpPath').value = remote.ftp.path || 'backups/';
}
if (remote.sftp && typeof remote.sftp === 'object') {
if ($('setupSftpHost')) $('setupSftpHost').value = remote.sftp.host || '';
if ($('setupSftpPort')) $('setupSftpPort').value = remote.sftp.port || 22;
if ($('setupSftpUser')) $('setupSftpUser').value = remote.sftp.user || '';
if ($('setupSftpPath')) $('setupSftpPath').value = remote.sftp.path || 'backups/';
if ($('setupSftpKey')) $('setupSftpKey').value = remote.sftp.ssh_key || '';
}
if (remote.gdrive && typeof remote.gdrive === 'object') {
if ($('setupGdriveToken')) $('setupGdriveToken').value = remote.gdrive.token || '';
if ($('setupGdriveFolder')) $('setupGdriveFolder').value = remote.gdrive.folder_id || '';
}
if (remote.dropbox && typeof remote.dropbox === 'object') {
if ($('setupDropboxToken')) $('setupDropboxToken').value = remote.dropbox.token || '';
if ($('setupDropboxPath')) $('setupDropboxPath').value = remote.dropbox.path || '/AP-Manageur-Backups/';
}
if (remote.webdav && typeof remote.webdav === 'object') {
if ($('setupWebdavUrl')) $('setupWebdavUrl').value = remote.webdav.url || '';
if ($('setupWebdavUser')) $('setupWebdavUser').value = remote.webdav.user || '';
}
if (remote.s3 && typeof remote.s3 === 'object') {
if ($('setupS3Endpoint')) $('setupS3Endpoint').value = remote.s3.endpoint || 'https://s3.amazonaws.com';
if ($('setupS3Region')) $('setupS3Region').value = remote.s3.region || 'us-east-1';
if ($('setupS3Bucket')) $('setupS3Bucket').value = remote.s3.bucket || '';
if ($('setupS3AccessKey')) $('setupS3AccessKey').value = remote.s3.access_key || '';
}
}
function getSetupCloudConfig() {
const prov = $('setupCloudProvider')?.value || 'ftp';
const cfg = {
enabled: true,
provider: prov,
[prov]: {}
};
if (prov === 'ftp') {
cfg.ftp = {
host: $('setupFtpHost')?.value.trim() || '',
port: parseInt($('setupFtpPort')?.value, 10) || 21,
tls: $('setupFtpTls')?.value || 'none',
user: $('setupFtpUser')?.value.trim() || '',
password: $('setupFtpPass')?.value || '',
path: $('setupFtpPath')?.value.trim() || ''
};
} else if (prov === 'sftp') {
cfg.sftp = {
host: $('setupSftpHost')?.value.trim() || '',
port: parseInt($('setupSftpPort')?.value, 10) || 22,
user: $('setupSftpUser')?.value.trim() || '',
password: $('setupSftpPass')?.value || '',
path: $('setupSftpPath')?.value.trim() || '',
ssh_key: $('setupSftpKey')?.value.trim() || ''
};
} else if (prov === 'gdrive') {
cfg.gdrive = {
token: $('setupGdriveToken')?.value.trim() || '',
folder_id: $('setupGdriveFolder')?.value.trim() || ''
};
} else if (prov === 'dropbox') {
cfg.dropbox = {
token: $('setupDropboxToken')?.value.trim() || '',
path: $('setupDropboxPath')?.value.trim() || '/AP-Manageur-Backups/'
};
} else if (prov === 'webdav') {
cfg.webdav = {
url: $('setupWebdavUrl')?.value.trim() || '',
user: $('setupWebdavUser')?.value.trim() || '',
password: $('setupWebdavPass')?.value || ''
};
} else if (prov === 's3') {
cfg.s3 = {
endpoint: $('setupS3Endpoint')?.value.trim() || 'https://s3.amazonaws.com',
region: $('setupS3Region')?.value.trim() || 'us-east-1',
bucket: $('setupS3Bucket')?.value.trim() || '',
access_key: $('setupS3AccessKey')?.value.trim() || '',
secret_key: $('setupS3SecretKey')?.value || ''
};
}
return cfg;
}
async function testSetupCloudConnection() {
const btn = $('btnTestSetupCloud');
const msg = $('setupCloudMsg');
const isEn = currentLanguage.startsWith('en');
const cfg = getSetupCloudConfig();
if (btn) btn.disabled = true;
if (msg) {
msg.style.display = 'block';
msg.style.background = 'rgba(92,167,255,0.15)';
msg.style.color = 'var(--blue)';
msg.textContent = isEn ? 'Testing cloud connection…' : 'Test de la connexion au cloud en cours…';
}
try {
const res = await fetch(API_URL + '/api/backups/remote/test', {
method: 'POST',
headers: getSetupAuthHeaders(),
body: JSON.stringify({ config: cfg })
});
const d = await res.json();
if (!res.ok || !d.ok) throw new Error(d.error || d.message || 'Échec du test');
if (msg) {
msg.style.background = 'rgba(50,213,131,0.15)';
msg.style.color = 'var(--green)';
msg.textContent = '✅ ' + (d.message || (isEn ? 'Connection successful!' : 'Connexion réussie !'));
}
} catch (err) {
if (msg) {
msg.style.background = 'rgba(255,107,107,0.15)';
msg.style.color = 'var(--red)';
msg.textContent = '❌ ' + (err.message || 'Erreur');
}
} finally {
if (btn) btn.disabled = false;
}
}
async function exploreSetupCloudBackups() {
const btn = $('btnExploreSetupCloud');
const msg = $('setupCloudMsg');
const container = $('setupCloudFilesContainer');
const listEl = $('setupCloudFilesList');
const isEn = currentLanguage.startsWith('en');
const cfg = getSetupCloudConfig();
if (btn) btn.disabled = true;
if (msg) {
msg.style.display = 'block';
msg.style.background = 'rgba(92,167,255,0.15)';
msg.style.color = 'var(--blue)';
msg.textContent = isEn ? 'Retrieving backups from cloud…' : 'Récupération de la liste des sauvegardes sur le cloud…';
}
if (container) container.style.display = 'none';
try {
const res = await fetch(API_URL + '/api/backups/remote/files', {
method: 'POST',
headers: getSetupAuthHeaders(),
body: JSON.stringify({ config: cfg })
});
const d = await res.json();
if (!res.ok || !d.ok) throw new Error(d.error || 'Impossible de lister les fichiers distants');
const files = Array.isArray(d.files) ? d.files : [];
if (msg) {
msg.style.background = 'rgba(50,213,131,0.15)';
msg.style.color = 'var(--green)';
msg.textContent = `✅ ${files.length} ` + (isEn ? 'backup file(s) found on cloud storage' : 'fichier(s) de sauvegarde trouvé(s) sur le cloud');
}
if (container && listEl) {
container.style.display = 'block';
if (files.length === 0) {
listEl.innerHTML = `<div class="muted" style="padding:14px;background:var(--panel);border-radius:8px;font-size:12px;text-align:center">${isEn ? 'No backup files found on this cloud storage.' : 'Aucun fichier de sauvegarde trouvé sur cet espace cloud.'}</div>`;
} else {
let html = '';
files.forEach(f => {
const szStr = f.size_str || `${Math.round((f.size || 0) / 1024)} Ko`;
const dtStr = f.date || '—';
const localBadge = f.is_local
? `<span class="pill" style="font-size:10px;color:var(--green);border-color:var(--green)">💾 Déjà présent localement</span>`
: '';
html += `
<div style="display:flex;align-items:center;justify-content:space-between;gap:10px;background:var(--panel);border:1px solid var(--line);border-radius:8px;padding:10px 12px;flex-wrap:wrap">
<div style="display:flex;align-items:center;gap:8px;min-width:220px;flex:1">
<span style="font-size:20px">☁️</span>
<div>
<div style="font-weight:700;font-size:13px;word-break:break-all">${f.name}</div>
<div class="muted" style="font-size:11px;display:flex;align-items:center;gap:6px;flex-wrap:wrap">
${dtStr ? `<span>📅 ${dtStr}</span>` : ''}
<span>💾 ${szStr}</span>
${localBadge}
</div>
</div>
</div>
<button type="button" class="btn-pull-cloud" onclick="pullAndInspectCloudBackup('${encodeURIComponent(f.name)}', this)"
style="display:inline-flex;align-items:center;gap:6px;font-size:12px;padding:6px 12px;white-space:nowrap;background:var(--green);color:#fff">
<span>📥</span> <span>${isEn ? 'Download & Restore' : 'Rapatrier & Restaurer'}</span>
</button>
</div>
`;
});
listEl.innerHTML = html;
}
}
} catch (err) {
if (msg) {
msg.style.background = 'rgba(255,107,107,0.15)';
msg.style.color = 'var(--red)';
msg.textContent = '❌ ' + (err.message || 'Erreur');
}
} finally {
if (btn) btn.disabled = false;
}
}
async function pullAndInspectCloudBackup(encodedName, btnEl) {
const fileName = decodeURIComponent(encodedName);
const isEn = currentLanguage.startsWith('en');
const cfg = getSetupCloudConfig();
const origText = btnEl ? btnEl.innerHTML : '';
if (btnEl) {
btnEl.disabled = true;
btnEl.innerHTML = `<span>⏳</span> <span>${isEn ? 'Downloading…' : 'Téléchargement…'}</span>`;
}
try {
const res = await fetch(API_URL + '/api/backups/remote/file/pull', {
method: 'POST',
headers: getSetupAuthHeaders(),
body: JSON.stringify({ filename: fileName, config: cfg })
});
const d = await res.json();
if (!res.ok || !d.ok) throw new Error(d.error || 'Erreur lors du téléchargement');
pendingBackupData = d.backup;
closeSetupBackupPickerModal();
showSetupBackupModal(d.filename || fileName, d.size || 0, d.backup);
} catch (err) {
alert('Erreur lors du rapatriement de la sauvegarde : ' + err.message);
if (btnEl) {
btnEl.disabled = false;
btnEl.innerHTML = origText;
}
}
}
function initSetupDropZone() {
const dz = $('setupDropZone');
if (!dz) return;
['dragenter', 'dragover'].forEach(ev => {
dz.addEventListener(ev, (e) => {
e.preventDefault();
e.stopPropagation();
dz.style.borderColor = 'var(--accent)';
dz.style.background = 'var(--panel3)';
});
});
['dragleave', 'drop'].forEach(ev => {
dz.addEventListener(ev, (e) => {
e.preventDefault();
e.stopPropagation();
dz.style.borderColor = 'var(--line)';
dz.style.background = 'var(--panel2)';
});
});
dz.addEventListener('drop', (e) => {
const dt = e.dataTransfer;
const files = dt && dt.files;
if (files && files.length) {
closeSetupBackupPickerModal();
handleSetupBackupFile({ target: { files: files } });
}
});
}
function triggerBackupUpload() {
const input = $('setupBackupFileInput');
if (input) {
input.value = '';
input.click();
}
}
function closeSetupBackupModal() {
const modal = $('modalSetupBackup');
if (modal) modal.style.display = 'none';
pendingBackupData = null;
}
async function handleSetupBackupFile(evt) {
const file = evt.target.files && evt.target.files[0];
if (!file) return;
const isJson = file.name.toLowerCase().endsWith('.json');
if (isJson) {
const reader = new FileReader();
reader.onload = (e) => {
try {
const data = JSON.parse(e.target.result);
pendingBackupData = data.backup || data;
showSetupBackupModal(file.name, file.size, pendingBackupData);
} catch (err) {
alert('Erreur lors de la lecture du fichier JSON : ' + err.message);
}
};
reader.readAsText(file);
} else {
const reader = new FileReader();
reader.onload = async (e) => {
try {
const b64 = e.target.result.split(',')[1];
const res = await fetch(API_URL + '/api/backup/inspect', {
method: 'POST',
headers: getSetupAuthHeaders(),
body: JSON.stringify({ filename: file.name, data_base64: b64 })
});
const d = await res.json();
if (!res.ok) throw new Error(d.error || 'Fichier invalide');
pendingBackupData = d.backup;
showSetupBackupModal(file.name, file.size, d.backup);
} catch (err) {
alert('Erreur lors de l\'analyse de la sauvegarde : ' + err.message);
}
};
reader.readAsDataURL(file);
}
}
function showSetupBackupModal(fileName, fileSize, data) {
const modal = $('modalSetupBackup');
if (!modal) return;
$('backupModalFileName').textContent = `${fileName} (${Math.round(fileSize / 1024)} Ko)`;
const meta = data.ap_manageur_backup || {};
const dateFormatted = meta.exported_at ? new Date(meta.exported_at).toLocaleString() : 'Inconnue';
$('backupModalMeta').textContent = `Date : ${dateFormatted} • Version : ${meta.app_version || '1.0'}`;
const pillsEl = $('backupModalPills');
if (pillsEl) {
const vpnCount = Array.isArray(data.vpn_profiles) ? data.vpn_profiles.length : 0;
const devCount = Array.isArray(data.client_names) ? data.client_names.length : 0;
const catCount = Array.isArray(data.custom_device_types) ? data.custom_device_types.length : 0;
const blockCount = Array.isArray(data.blocked_clients) ? data.blocked_clients.length : 0;
const prefCount = (data.preferences && typeof data.preferences === 'object') ? Object.keys(data.preferences).length : 0;
const authCount = Array.isArray(data.auth_users) ? data.auth_users.length : 0;
pillsEl.innerHTML = `
<span class="pill" style="font-size:11px;color:var(--blue);border-color:var(--blue)">🌐 ${vpnCount} Profil(s) VPN</span>
<span class="pill" style="font-size:11px;color:var(--green);border-color:var(--green)">📱 ${devCount} Appareil(s)</span>
<span class="pill" style="font-size:11px">🎨 ${catCount} Catégorie(s)</span>
<span class="pill" style="font-size:11px;color:var(--red);border-color:var(--red)">🚫 ${blockCount} Bloqué(s)</span>
<span class="pill" style="font-size:11px">⚙️ ${prefCount} Paramètre(s)</span>
${authCount ? `<span class="pill" style="font-size:11px;color:var(--yellow);border-color:var(--yellow)">🔐 ${authCount} Compte(s) admin</span>` : ''}
`;
}
const msg = $('backupModalMsg');
if (msg) msg.style.display = 'none';
modal.style.display = 'flex';
}
function closeSetupRestoreProgressModal() {
const modal = $('modalSetupRestoreProgress');
if (modal) modal.style.display = 'none';
}
window.closeSetupRestoreProgressModal = closeSetupRestoreProgressModal;
async function submitSetupBackup() {
if (!pendingBackupData) return;
const isEn = currentLanguage.startsWith('en');
const options = {
restore_vpn: $('chkSetupVpn') ? $('chkSetupVpn').checked : true,
restore_devices: $('chkSetupDevices') ? $('chkSetupDevices').checked : true,
restore_blocked: $('chkSetupBlocked') ? $('chkSetupBlocked').checked : true,
restore_categories: $('chkSetupCategories') ? $('chkSetupCategories').checked : true,
restore_preferences: $('chkSetupPrefs') ? $('chkSetupPrefs').checked : true,
restore_auth: $('chkSetupAuth') ? $('chkSetupAuth').checked : true
};
if (!options.restore_vpn && !options.restore_devices && !options.restore_blocked && !options.restore_categories && !options.restore_preferences && !options.restore_auth) {
alert(isEn ? 'Please check at least one component to restore.' : 'Veuillez cocher au moins un élément à restaurer.');
return;
}
const backupPayload = pendingBackupData;
const backupModal = $('modalSetupBackup');
if (backupModal) backupModal.style.display = 'none';
closeSetupBackupPickerModal();
pendingBackupData = null;
const progressModal = $('modalSetupRestoreProgress');
if (progressModal) progressModal.style.display = 'flex';
$('setupRestoreProgressBar').style.width = '20%';
$('setupRestorePercent').textContent = '20%';
$('setupRestoreStepLabel').textContent = (t('restore_step_label', 'Étape {step} / {total}') || 'Étape {step} / {total}').replace('{step}', '1').replace('{total}', '5');
$('setupRestoreBadgeText').textContent = t('restore_progress_badge', 'Restauration en cours…');
$('setupRestoreBadgeIcon').textContent = '⚙️';
$('setupRestoreBadgeIcon').style.animation = 'spin 1.5s linear infinite';
$('setupRestoreIcon').textContent = '📦';
$('setupRestoreStatusText').textContent = t('restore_step1_check', 'Analyse & vérification de l\'archive…');
$('setupRestoreDetails').textContent = t('restore_preparing', 'Inspection du fichier et validation du format…');
if ($('setupRestoreErrorBox')) $('setupRestoreErrorBox').style.display = 'none';
const restoreStepPills = [
{ id: 'setupRestoreStepCheck', stateId: 'setupRestoreStepCheckState' },
{ id: 'setupRestoreStepPrefs', stateId: 'setupRestoreStepPrefsState' },
{ id: 'setupRestoreStepDevices', stateId: 'setupRestoreStepDevicesState' },
{ id: 'setupRestoreStepVpn', stateId: 'setupRestoreStepVpnState' },
{ id: 'setupRestoreStepSync', stateId: 'setupRestoreStepSyncState' }
];
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 doPollSetupRestore = 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));
$('setupRestoreProgressBar').style.width = pct + '%';
$('setupRestorePercent').textContent = pct + '%';
if (p.step) {
$('setupRestoreStepLabel').textContent = (t('restore_step_label', 'Étape {step} / {total}') || 'Étape {step} / {total}')
.replace('{step}', p.step).replace('{total}', p.total_steps || 5);
}
if (p.message) {
$('setupRestoreStatusText').textContent = p.message;
}
if (p.details) {
$('setupRestoreDetails').textContent = 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 ($('setupRestoreErrorBox')) {
$('setupRestoreErrorBox').style.display = 'block';
$('setupRestoreErrorText').textContent = p.error;
}
$('setupRestoreBadgeText').textContent = isEn ? 'Error' : 'Erreur';
$('setupRestoreBadgeIcon').textContent = '⚠️';
$('setupRestoreBadgeIcon').style.animation = 'none';
$('setupRestoreIcon').textContent = '⚠️';
return;
}
if (p.done && !isDone) {
isDone = true;
if (restorePollInterval) clearInterval(restorePollInterval);
$('setupRestoreProgressBar').style.width = '100%';
$('setupRestorePercent').textContent = '100%';
$('setupRestoreBadgeText').textContent = isEn ? 'Done!' : 'Terminé !';
$('setupRestoreBadgeIcon').textContent = '✅';
$('setupRestoreBadgeIcon').style.animation = 'none';
$('setupRestoreIcon').textContent = '✅';
$('setupRestoreStatusText').textContent = t('restore_complete_title', 'Sauvegarde restaurée avec succès !');
$('setupRestoreDetails').textContent = t('restore_redirecting_dash', 'Redirection vers le tableau de bord…');
setTimeout(() => {
window.location.replace('/');
}, 1200);
}
} catch (_) {}
};
restorePollInterval = setInterval(doPollSetupRestore, 200);
try {
const res = await fetch(API_URL + '/api/backup/import', {
method: 'POST',
headers: getSetupAuthHeaders(),
body: JSON.stringify({ backup: backupPayload, options: options })
});
const d = await res.json();
if (!res.ok) throw new Error(d.error || 'Erreur lors de la restauration');
if (!isDone) {
await doPollSetupRestore();
}
} catch (err) {
if (!isDone) {
if (restorePollInterval) clearInterval(restorePollInterval);
if ($('setupRestoreErrorBox')) {
$('setupRestoreErrorBox').style.display = 'block';
$('setupRestoreErrorText').textContent = err.message || 'Erreur de restauration';
}
$('setupRestoreBadgeText').textContent = isEn ? 'Error' : 'Erreur';
$('setupRestoreBadgeIcon').textContent = '⚠️';
$('setupRestoreBadgeIcon').style.animation = 'none';
$('setupRestoreIcon').textContent = '⚠️';
}
}
}
async function initSetupPage() {
initPasswordStrengthListeners();
setSetupLanguage(currentLanguage);
setSetupTheme(currentTheme);
initStatsReportTimeSelects();
loadNotificationSettingsInSetup();
initSetupDropZone();
checkDetectedServerBackups();
const notifBox = $('notifChannelsBox');
if (notifBox) {
notifBox.addEventListener('input', updateStep4ContinueState);
notifBox.addEventListener('change', updateStep4ContinueState);
}
updateStep4ContinueState();
// 1. Vérification du statut d'authentification et de configuration
try {
const rAuth = await fetch(API_URL + '/api/auth/status', { cache: 'no-store' });
if (rAuth.ok) {
const dAuth = await rAuth.json();
if (dAuth.version) {
document.querySelectorAll('.app-version').forEach(el => el.textContent = dAuth.version);
}
authConfigured = !!dAuth.configured;
const params = new URLSearchParams(window.location.search);
const isForced = params.has('force') || params.has('reconfigure');
const alreadyConfigured = !!(dAuth.configured || dAuth.setup_completed);
if (alreadyConfigured && !isForced) {
window.location.replace('/');
return;
}
if (authConfigured && $('adminAlreadySetMsg')) {
$('adminAlreadySetMsg').style.display = 'block';
}
const ethList = dAuth.ethernet_interfaces || [];
const sel = $('setupBridgeEth');
if (sel && ethList.length) {
sel.innerHTML = ethList.map(e => `<option value="${e}">${e}</option>`).join('');
}
}
} catch (e) {
console.warn("Vérification auth :", e);
}
}
async function submitSetup() {
if (isConfiguring) return;
const msg = $('setupMessage');
const btn = $('btnSubmitSetup');
const btnBack = $('btnBackTo5');
const progBox = $('setupProgressContainer');
const progBar = $('setupProgressBar');
const isEn = currentLanguage.startsWith('en');
msg.textContent = '';
msg.style.color = 'var(--muted)';
const ssid = $('setupSsid') ? $('setupSsid').value.trim() : '';
const password = $('setupPassword') ? $('setupPassword').value : '';
const confirmation = $('setupPasswordConfirm') ? $('setupPasswordConfirm').value : '';
const security = $('setupSecurity') ? $('setupSecurity').value : 'wpa2';
const mode = document.querySelector('input[name="setupMode"]:checked')?.value || 'ap';
const bridge_eth = $('setupBridgeEth') ? $('setupBridgeEth').value : '';
const max_clients = parseInt($('setupMaxClients') ? $('setupMaxClients').value : 0, 10) || 0;
const adminUser = $('setupAdminUser') ? $('setupAdminUser').value.trim() : '';
const adminPass = $('setupAdminPassword') ? $('setupAdminPassword').value : '';
const defaultAppName = t('step5_app_title_default', 'Administration de l’AP Wi‑Fi');
const appName = ($('setupAppName') && $('setupAppName').value.trim()) ? $('setupAppName').value.trim() : defaultAppName;
// Validations
if (!ssid) { goToStep(2); return validateStep2(); }
if (!password || password !== confirmation) { goToStep(2); return validateStep2(); }
if (!adminUser || !adminPass) { goToStep(3); return validateStep3(); }
const notifSt = getStep4NotificationStatus();
if (notifSt.anyChecked && !notifSt.ready) { goToStep(4); return validateStep4(); }
isConfiguring = true;
btn.disabled = true;
if (btnBack) btnBack.disabled = true;
btn.style.opacity = '0.7';
if (progBox) progBox.style.display = 'block';
if (progBar) progBar.style.width = '20%';
try {
// A. Création du compte administrateur
msg.textContent = isEn ? '1/5 Creating administrator account…' : '1/5 Création du compte administrateur…';
if (progBar) progBar.style.width = '25%';
const rAdmin = await fetch(API_URL + '/api/auth/setup', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({ username: adminUser, password: adminPass })
});
const dAdmin = await rAdmin.json();
if (!rAdmin.ok && !dAdmin.message?.includes('déjà')) {
throw new Error(dAdmin.error || 'Erreur lors de la création du compte');
}
// B. Connexion pour obtenir le jeton de session
let token = '';
try {
const rLog = await fetch(API_URL + '/api/login', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({ username: adminUser, password: adminPass })
});
if (rLog.ok) {
const dLog = await rLog.json();
token = dLog.token || '';
if (token) {
sessionStorage.setItem('apAuthToken', token);
localStorage.setItem('apAuthToken', token);
document.cookie = `apAuthToken=${encodeURIComponent(token)}; path=/; max-age=604800; SameSite=Lax`;
}
}
} catch (_) { }
const headers = getSetupAuthHeaders(token, true);
// C. Configuration du réseau Wi-Fi
msg.textContent = isEn ? '2/5 Configuring Wi-Fi Access Point…' : '2/5 Configuration du point d\'accès Wi-Fi…';
if (progBar) progBar.style.width = '45%';
const rSetup = await fetch(API_URL + '/api/setup', {
method: 'POST',
headers: headers,
body: JSON.stringify({
ssid: ssid,
password: password,
security: security,
mode: mode,
bridge_eth: bridge_eth,
max_clients: max_clients
})
});
const dSetup = await rSetup.json();
if (!rSetup.ok) throw new Error(dSetup.error || 'Erreur lors de la configuration du Wi-Fi');
// D. Enregistrement des profils VPN (si ajoutés en Étape 5)
if (setupVpnProfiles.length) {
msg.textContent = isEn ? '3/5 Saving VPN profiles…' : '3/5 Enregistrement des profils VPN…';
if (progBar) progBar.style.width = '65%';
for (const p of setupVpnProfiles) {
try {
await fetch(API_URL + '/api/vpn/profiles', {
method: 'POST',
headers: headers,
body: JSON.stringify({
name: p.name,
type: p.type,
config_content: p.config_content,
auth_user: p.auth_user || '',
auth_pass: p.auth_pass || '',
auto_connect: p.auto_connect ? 1 : 0
})
});
} catch (eVpn) {
console.warn('Erreur enregistrement profil VPN:', eVpn);
}
}
}
// E. Enregistrement des notifications (si au moins un service configuré et testé)
if (notifSt.ready) {
msg.textContent = isEn ? '4/5 Saving notification channels & alert events…' : '4/5 Enregistrement des alertes et notifications…';
if (progBar) progBar.style.width = '80%';
try {
const notifPayload = getNotificationFormPayload();
await fetch(API_URL + '/api/notifications/settings', {
method: 'POST',
headers: headers,
body: JSON.stringify(notifPayload)
});
} catch (_) { }
}
// F. Enregistrement des préférences (Thème, langue, nom)
msg.textContent = isEn ? '5/5 Finalizing preferences…' : '5/5 Finalisation des préférences…';
if (progBar) progBar.style.width = '95%';
try {
await fetch(API_URL + '/api/preferences', {
method: 'POST',
headers: headers,
body: JSON.stringify({
theme: currentTheme,
language: currentLanguage,
app_name: appName,
app_short_name: 'AP Manageur'
})
});
} catch (_) { }
if (progBar) progBar.style.width = '100%';
msg.style.color = 'var(--green)';
msg.textContent = isEn ? '✅ Configuration complete! Redirecting to dashboard…' : '✅ Configuration réussie ! Redirection vers le tableau de bord…';
setTimeout(() => {
location.href = '/';
}, 1200);
} catch (err) {
msg.style.color = 'var(--red)';
msg.textContent = '❌ ' + (err.message || 'Une erreur est survenue');
isConfiguring = false;
btn.disabled = false;
if (btnBack) btnBack.disabled = false;
btn.style.opacity = '';
if (progBox) progBox.style.display = 'none';
}
}
window.addEventListener('DOMContentLoaded', initSetupPage);
</script>
</body>
</html>