APmanageur Wi-Fi V1.0
This commit is contained in:
1 parent
b4aa9ab0f6
commit
5bfc833675
6 files changed
+412
-49
No files matched your search
+212
-35
@@ -3052,6 +3052,9 @@
|
||||
<button id="tabAdvPcap" class="settings-nav-btn" type="button" role="tab" onclick="selectAdvSubTab('pcap')">
|
||||
<span>📡</span> <span data-i18n="adv_subtab_pcap">Capture de paquets (PCAP)</span>
|
||||
</button>
|
||||
<button id="tabAdvUpdates" class="settings-nav-btn" type="button" role="tab" onclick="selectAdvSubTab('updates')">
|
||||
<span>🚀</span> <span data-i18n="adv_subtab_updates">Mises à jour système</span>
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<!-- Sous-panneau 1 : Routage VPN par client -->
|
||||
@@ -3275,6 +3278,83 @@
|
||||
pour inspecter l’en-tête décodé et le dump hexadécimal / ASCII style Wireshark.</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Sous-panneau 3 : Mises à jour du système -->
|
||||
<div id="panelAdvUpdates" style="display:none">
|
||||
<div class="grid" style="margin-bottom:16px">
|
||||
<div class="card">
|
||||
<div class="label" data-i18n="adv_update_current_ver">Version actuelle</div>
|
||||
<div class="metric" id="advUpdateCurrentCommit" style="font-family:monospace;font-size:20px;color:var(--text)">—</div>
|
||||
<div class="muted" style="font-size:12px;margin-top:4px" id="advUpdateVersionTag">AP Manageur V5.5</div>
|
||||
</div>
|
||||
<div class="card">
|
||||
<div class="label" data-i18n="adv_update_latest_ver">Dernière version (Gitea)</div>
|
||||
<div class="metric" id="advUpdateLatestCommit" style="font-family:monospace;font-size:20px;color:#10b981">—</div>
|
||||
<div class="muted" style="font-size:12px;margin-top:4px" id="advUpdateLatestDate">—</div>
|
||||
</div>
|
||||
<div class="card">
|
||||
<div class="label" data-i18n="adv_update_status_label">Statut des mises à jour</div>
|
||||
<div class="metric" id="advUpdateStatusBadge" style="font-size:16px;margin-top:6px">⚪ Inconnu</div>
|
||||
<div class="muted" style="font-size:12px;margin-top:4px" id="advUpdateLastChecked">—</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="card">
|
||||
<div style="display:flex;align-items:center;justify-content:space-between;flex-wrap:wrap;gap:12px;margin-bottom:16px">
|
||||
<div>
|
||||
<h2 style="margin:0 0 4px" data-i18n="adv_update_settings_title">Recherche automatique des mises à jour</h2>
|
||||
<p class="muted" style="margin:0;font-size:13px" data-i18n="adv_update_settings_desc">
|
||||
Contrôlez si AP Manageur doit vérifier automatiquement la présence de nouvelles versions sur le dépôt Gitea et à quelle fréquence.
|
||||
</p>
|
||||
</div>
|
||||
<button type="button" class="secondary" id="btnAdvCheckUpdateNow" onclick="advCheckUpdateNow()" style="display:inline-flex;align-items:center;gap:6px">
|
||||
🔄 <span data-i18n="btn_recheck">Vérifier à nouveau</span>
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<div style="display:flex;flex-direction:column;gap:16px;max-width:650px">
|
||||
<label class="check" style="margin:0;font-size:14px;font-weight:600">
|
||||
<input type="checkbox" id="chkUpdateCheckerEnabled" onchange="onToggleUpdateChecker(this.checked)">
|
||||
<span data-i18n="adv_update_enable_chk">Activer la recherche automatique de mises à jour</span>
|
||||
</label>
|
||||
<p class="muted" style="font-size:12px;margin:-8px 0 0 28px" data-i18n="adv_update_enable_hint">
|
||||
Lorsque cette option est désactivée, aucune requête n’est envoyée vers Gitea et le bouton de mise à jour reste masqué.
|
||||
</p>
|
||||
|
||||
<div id="advUpdateIntervalGroup" style="margin-top:6px">
|
||||
<label class="label" for="selectUpdateInterval" data-i18n="adv_update_interval_label" style="font-weight:600;font-size:13px">
|
||||
Fréquence de vérification automatique
|
||||
</label>
|
||||
<select id="selectUpdateInterval" style="width:100%;max-width:360px;margin-top:6px;padding:9px 12px;border-radius:8px;font-size:13px">
|
||||
<option value="300" data-i18n="interval_5m">Toutes les 5 minutes</option>
|
||||
<option value="900" data-i18n="interval_15m">Toutes les 15 minutes</option>
|
||||
<option value="1800" data-i18n="interval_30m">Toutes les 30 minutes</option>
|
||||
<option value="3600" data-i18n="interval_1h">Toutes les 1 heure</option>
|
||||
<option value="7200" selected data-i18n="interval_2h">Toutes les 2 heures (recommandé)</option>
|
||||
<option value="14400" data-i18n="interval_4h">Toutes les 4 heures</option>
|
||||
<option value="21600" data-i18n="interval_6h">Toutes les 6 heures</option>
|
||||
<option value="43200" data-i18n="interval_12h">Toutes les 12 heures</option>
|
||||
<option value="86400" data-i18n="interval_1d">Tous les 1 jour (24 heures)</option>
|
||||
<option value="172800" data-i18n="interval_2d">Tous les 2 jours</option>
|
||||
<option value="259200" data-i18n="interval_3d">Tous les 3 jours</option>
|
||||
<option value="604800" data-i18n="interval_7d">Tous les 7 jours (1 semaine)</option>
|
||||
<option value="1209600" data-i18n="interval_14d">Tous les 14 jours (2 semaines)</option>
|
||||
<option value="2592000" data-i18n="interval_30d">Tous les 30 jours (1 mois)</option>
|
||||
</select>
|
||||
<p class="muted" style="font-size:12px;margin-top:6px" data-i18n="adv_update_interval_hint">
|
||||
Définit l’intervalle entre chaque analyse en arrière-plan par le serveur.
|
||||
</p>
|
||||
</div>
|
||||
|
||||
<div style="display:flex;align-items:center;gap:12px;margin-top:10px">
|
||||
<button type="button" id="btnSaveUpdateSettings" onclick="saveUpdateSettings()" style="padding:9px 18px;font-size:13px;font-weight:600">
|
||||
💾 <span data-i18n="btn_save_preferences">Enregistrer les préférences</span>
|
||||
</button>
|
||||
<span id="advUpdateSettingsMsg" style="font-size:13px;display:none"></span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<section id="settingsView" class="view">
|
||||
@@ -6219,9 +6299,9 @@
|
||||
style="font-size:12px">
|
||||
🔄 <span data-i18n="btn_recheck">Vérifier à nouveau</span>
|
||||
</button>
|
||||
<button type="button" class="secondary" id="btnSyncUpdateManual" onclick="syncUpdateVersion()"
|
||||
style="font-size:12px;color:var(--green);display:none" title="Marquer cette version comme installée si vous avez déjà la dernière version">
|
||||
✓ <span data-i18n="btn_mark_up_to_date">Je suis déjà à jour</span>
|
||||
<button type="button" class="secondary" style="font-size:12px;color:var(--blue)"
|
||||
onclick="closeUpdateModal();selectTab('advanced');selectAdvSubTab('updates')">
|
||||
⚙️ <span data-i18n="btn_configure_updates">Configurer la fréquence</span>
|
||||
</button>
|
||||
</div>
|
||||
<button type="button" class="secondary" onclick="closeUpdateModal()" data-i18n="btn_close">Fermer</button>
|
||||
@@ -9211,9 +9291,7 @@ ${vpnBadgeTopo}
|
||||
if ($('updateDockerCmdSection')) {
|
||||
$('updateDockerCmdSection').style.display = isAvail ? 'block' : 'none';
|
||||
}
|
||||
if ($('btnSyncUpdateManual')) {
|
||||
$('btnSyncUpdateManual').style.display = isAvail ? 'inline-flex' : 'none';
|
||||
}
|
||||
|
||||
modal.classList.add('active');
|
||||
}
|
||||
window.openUpdateModal = openUpdateModal;
|
||||
@@ -9268,32 +9346,6 @@ ${vpnBadgeTopo}
|
||||
}
|
||||
window.triggerManualUpdateCheck = triggerManualUpdateCheck;
|
||||
|
||||
async function syncUpdateVersion() {
|
||||
const btn = $('btnSyncUpdateManual');
|
||||
if (btn) btn.disabled = true;
|
||||
try {
|
||||
const res = await apiFetch('/api/system/update/sync', {
|
||||
method: 'POST',
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
body: JSON.stringify({ commit: (lastUpdateData && lastUpdateData.latest_commit_full) || '' })
|
||||
});
|
||||
const d = await res.json();
|
||||
if (res.ok && d.update) {
|
||||
lastUpdateData = d.update;
|
||||
if (status) status.update = d.update;
|
||||
updateApButtons();
|
||||
openUpdateModal();
|
||||
} else {
|
||||
alert(d.error || t('update_sync_error', 'Erreur lors de la synchronisation'));
|
||||
}
|
||||
} catch (e) {
|
||||
alert(e.message || 'Erreur');
|
||||
} finally {
|
||||
if (btn) btn.disabled = false;
|
||||
}
|
||||
}
|
||||
window.syncUpdateVersion = syncUpdateVersion;
|
||||
|
||||
async function toggleBlock(mac, blocked) {
|
||||
return runAction(async () => {
|
||||
try {
|
||||
@@ -14596,19 +14648,144 @@ ${vpnBadgeTopo}
|
||||
|
||||
function selectAdvSubTab(subTab) {
|
||||
currentAdvSubTab = subTab;
|
||||
const btnVpn = $('tabAdvVpnRouting'), btnPcap = $('tabAdvPcap');
|
||||
const panelVpn = $('panelAdvVpnRouting'), panelPcap = $('panelAdvPcap');
|
||||
const btnVpn = $('tabAdvVpnRouting'), btnPcap = $('tabAdvPcap'), btnUpdates = $('tabAdvUpdates');
|
||||
const panelVpn = $('panelAdvVpnRouting'), panelPcap = $('panelAdvPcap'), panelUpdates = $('panelAdvUpdates');
|
||||
if (btnVpn) btnVpn.className = 'settings-nav-btn' + (subTab === 'vpn' ? ' active' : '');
|
||||
if (btnPcap) btnPcap.className = 'settings-nav-btn' + (subTab === 'pcap' ? ' active' : '');
|
||||
if (btnUpdates) btnUpdates.className = 'settings-nav-btn' + (subTab === 'updates' ? ' active' : '');
|
||||
if (panelVpn) panelVpn.style.display = (subTab === 'vpn' ? 'block' : 'none');
|
||||
if (panelPcap) panelPcap.style.display = (subTab === 'pcap' ? 'block' : 'none');
|
||||
if (panelUpdates) panelUpdates.style.display = (subTab === 'updates' ? 'block' : 'none');
|
||||
if (subTab === 'vpn') {
|
||||
loadVpnClients();
|
||||
stopCaptureTimer();
|
||||
} else {
|
||||
} else if (subTab === 'pcap') {
|
||||
loadCaptureStatus();
|
||||
loadCapturePackets(true);
|
||||
ensureCapturePolling();
|
||||
} else if (subTab === 'updates') {
|
||||
stopCaptureTimer();
|
||||
loadUpdateSettings();
|
||||
}
|
||||
}
|
||||
|
||||
/* ============================================================
|
||||
Gestion des Mises à jour du système (Onglet Avancé)
|
||||
============================================================ */
|
||||
async function loadUpdateSettings() {
|
||||
try {
|
||||
const res = await apiFetch('/api/system/update/settings');
|
||||
if (!res.ok) throw new Error('HTTP ' + res.status);
|
||||
const data = await res.json();
|
||||
|
||||
const isEnabled = data.enabled !== undefined ? !!data.enabled : true;
|
||||
if ($('chkUpdateCheckerEnabled')) $('chkUpdateCheckerEnabled').checked = isEnabled;
|
||||
if ($('selectUpdateInterval')) $('selectUpdateInterval').value = String(data.interval || 7200);
|
||||
onToggleUpdateChecker(isEnabled);
|
||||
|
||||
const u = data.update || lastUpdateData || (status && status.update) || {};
|
||||
renderUpdateStatusCards(u, isEnabled);
|
||||
} catch (err) {
|
||||
console.error('Erreur chargement paramètres mise à jour:', err);
|
||||
}
|
||||
}
|
||||
|
||||
function renderUpdateStatusCards(u, isEnabled) {
|
||||
if (u.current_commit || u.current_commit_full) {
|
||||
if ($('advUpdateCurrentCommit')) $('advUpdateCurrentCommit').textContent = u.current_commit || u.current_commit_full.substring(0, 7);
|
||||
}
|
||||
if ($('advUpdateLatestCommit')) {
|
||||
$('advUpdateLatestCommit').textContent = u.latest_commit || (u.latest_commit_full ? u.latest_commit_full.substring(0, 7) : (isEnabled ? '—' : t('disabled_m', 'Désactivé')));
|
||||
}
|
||||
if ($('advUpdateLatestDate')) {
|
||||
let dStr = '';
|
||||
if (u.date) {
|
||||
try { dStr = 'Publié le ' + new Date(u.date).toLocaleDateString(); } catch (_) { dStr = u.date; }
|
||||
}
|
||||
$('advUpdateLatestDate').textContent = dStr || (u.commit_msg ? u.commit_msg.substring(0, 35) : '');
|
||||
}
|
||||
if ($('advUpdateStatusBadge')) {
|
||||
if (!isEnabled) {
|
||||
$('advUpdateStatusBadge').innerHTML = '<span class="pill" style="background:rgba(100,116,139,0.2);color:var(--muted);font-size:12px;font-weight:600">⏸️ ' + t('update_status_disabled', 'Vérification désactivée') + '</span>';
|
||||
} else if (u.available) {
|
||||
$('advUpdateStatusBadge').innerHTML = '<span class="pill pill-green" style="font-size:12px;font-weight:600">🚀 ' + t('header_update_available', 'Mise à jour disponible') + '</span>';
|
||||
} else {
|
||||
$('advUpdateStatusBadge').innerHTML = '<span class="pill pill-green" style="font-size:12px;font-weight:600">✓ ' + t('update_up_to_date', 'AP Manageur est à jour') + '</span>';
|
||||
}
|
||||
}
|
||||
if ($('advUpdateLastChecked')) {
|
||||
$('advUpdateLastChecked').textContent = u.last_checked ? (t('last_checked', 'Dernière vérif. : ') + u.last_checked) : '';
|
||||
}
|
||||
}
|
||||
|
||||
function onToggleUpdateChecker(enabled) {
|
||||
const group = $('advUpdateIntervalGroup');
|
||||
const select = $('selectUpdateInterval');
|
||||
if (select) select.disabled = !enabled;
|
||||
if (group) group.style.opacity = enabled ? '1' : '0.45';
|
||||
}
|
||||
|
||||
async function saveUpdateSettings() {
|
||||
const btn = $('btnSaveUpdateSettings');
|
||||
const msg = $('advUpdateSettingsMsg');
|
||||
const enabled = $('chkUpdateCheckerEnabled') ? $('chkUpdateCheckerEnabled').checked : true;
|
||||
const interval = $('selectUpdateInterval') ? parseInt($('selectUpdateInterval').value, 10) : 7200;
|
||||
|
||||
if (btn) btn.disabled = true;
|
||||
if (msg) {
|
||||
msg.style.display = 'inline-block';
|
||||
msg.style.color = 'var(--text2)';
|
||||
msg.textContent = t('saving', 'Enregistrement…');
|
||||
}
|
||||
|
||||
try {
|
||||
const res = await apiFetch('/api/system/update/settings', {
|
||||
method: 'POST',
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
body: JSON.stringify({ enabled, interval })
|
||||
});
|
||||
const d = await res.json();
|
||||
if (!res.ok) throw new Error(d.error || 'Erreur lors de l’enregistrement');
|
||||
|
||||
if (d.update) {
|
||||
lastUpdateData = d.update;
|
||||
renderUpdateStatusCards(d.update, enabled);
|
||||
if ($('btnUpdateAvailable')) {
|
||||
$('btnUpdateAvailable').style.display = (status && status.configured && d.update.available && enabled) ? 'inline-flex' : 'none';
|
||||
}
|
||||
}
|
||||
if (msg) {
|
||||
msg.style.color = 'var(--green)';
|
||||
msg.textContent = '✓ ' + t('saved_successfully', 'Paramètres enregistrés avec succès !');
|
||||
setTimeout(() => { if (msg) msg.style.display = 'none'; }, 3500);
|
||||
}
|
||||
} catch (e) {
|
||||
if (msg) {
|
||||
msg.style.color = 'var(--red)';
|
||||
msg.textContent = '✕ ' + tErr(e.message);
|
||||
}
|
||||
} finally {
|
||||
if (btn) btn.disabled = false;
|
||||
}
|
||||
}
|
||||
|
||||
async function advCheckUpdateNow() {
|
||||
const btn = $('btnAdvCheckUpdateNow');
|
||||
if (btn) btn.disabled = true;
|
||||
try {
|
||||
const res = await apiFetch('/api/system/update?force=1');
|
||||
const data = await res.json();
|
||||
lastUpdateData = data;
|
||||
const isEnabled = $('chkUpdateCheckerEnabled') ? $('chkUpdateCheckerEnabled').checked : true;
|
||||
renderUpdateStatusCards(data, isEnabled);
|
||||
if ($('btnUpdateAvailable')) {
|
||||
$('btnUpdateAvailable').style.display = (status && status.configured && data.available && isEnabled) ? 'inline-flex' : 'none';
|
||||
}
|
||||
alert(data.available ? t('update_new_version_found', 'Une nouvelle version de AP Manageur est prête !') : t('update_up_to_date', 'AP Manageur est à jour !'));
|
||||
} catch (e) {
|
||||
alert(tErr(e.message));
|
||||
} finally {
|
||||
if (btn) btn.disabled = false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user