APmanageur Wi-Fi V1.0
This commit is contained in:
1 parent
b4aa9ab0f6
commit
5bfc833675
6 files changed
+411
-48
No files matched your search
@@ -3466,6 +3466,8 @@ _update_cache = {
|
|||||||
'checking': False,
|
'checking': False,
|
||||||
'data': {
|
'data': {
|
||||||
'available': False,
|
'available': False,
|
||||||
|
'enabled': True,
|
||||||
|
'interval': 7200,
|
||||||
'current_commit': '',
|
'current_commit': '',
|
||||||
'current_commit_full': '',
|
'current_commit_full': '',
|
||||||
'latest_commit': '',
|
'latest_commit': '',
|
||||||
@@ -3532,13 +3534,46 @@ def get_current_commit():
|
|||||||
return ''
|
return ''
|
||||||
|
|
||||||
def check_gitea_update(force_refresh=False):
|
def check_gitea_update(force_refresh=False):
|
||||||
"""Vérifie si une nouvelle version est disponible sur le dépôt Gitea (cache 30 min, non bloquant)."""
|
"""Vérifie si une nouvelle version est disponible sur le dépôt Gitea (cache selon intervalle, non bloquant)."""
|
||||||
|
enabled = get_pref('update_checker_enabled', '1') == '1'
|
||||||
|
try:
|
||||||
|
interval = int(get_pref('update_checker_interval', '7200'))
|
||||||
|
if interval < 60:
|
||||||
|
interval = 7200
|
||||||
|
except Exception:
|
||||||
|
interval = 7200
|
||||||
|
|
||||||
now = time.time()
|
now = time.time()
|
||||||
with _update_lock:
|
with _update_lock:
|
||||||
if not force_refresh and _update_cache['time'] > 0 and (now - _update_cache['time'] < 1800):
|
if not enabled and not force_refresh:
|
||||||
return dict(_update_cache['data'])
|
cur = get_current_commit()
|
||||||
|
return {
|
||||||
|
'available': False,
|
||||||
|
'enabled': False,
|
||||||
|
'interval': interval,
|
||||||
|
'current_commit': cur[:7] if cur else '',
|
||||||
|
'current_commit_full': cur,
|
||||||
|
'latest_commit': '',
|
||||||
|
'latest_commit_full': '',
|
||||||
|
'commit_msg': '',
|
||||||
|
'author': '',
|
||||||
|
'date': '',
|
||||||
|
'html_url': GITEA_REPO_URL,
|
||||||
|
'docker_command': 'docker compose pull && docker compose up -d',
|
||||||
|
'last_checked': _update_cache.get('data', {}).get('last_checked', ''),
|
||||||
|
'error': None
|
||||||
|
}
|
||||||
|
cache_ttl = min(interval, 1800)
|
||||||
|
if not force_refresh and _update_cache['time'] > 0 and (now - _update_cache['time'] < cache_ttl):
|
||||||
|
res = dict(_update_cache['data'])
|
||||||
|
res['enabled'] = enabled
|
||||||
|
res['interval'] = interval
|
||||||
|
return res
|
||||||
if _update_cache['checking'] and not force_refresh:
|
if _update_cache['checking'] and not force_refresh:
|
||||||
return dict(_update_cache['data'])
|
res = dict(_update_cache['data'])
|
||||||
|
res['enabled'] = enabled
|
||||||
|
res['interval'] = interval
|
||||||
|
return res
|
||||||
_update_cache['checking'] = True
|
_update_cache['checking'] = True
|
||||||
|
|
||||||
def _worker():
|
def _worker():
|
||||||
@@ -3588,6 +3623,8 @@ def check_gitea_update(force_refresh=False):
|
|||||||
_update_cache['checking'] = False
|
_update_cache['checking'] = False
|
||||||
_update_cache['data'] = {
|
_update_cache['data'] = {
|
||||||
'available': available,
|
'available': available,
|
||||||
|
'enabled': enabled,
|
||||||
|
'interval': interval,
|
||||||
'current_commit': current_sha[:7] if current_sha else '',
|
'current_commit': current_sha[:7] if current_sha else '',
|
||||||
'current_commit_full': current_sha,
|
'current_commit_full': current_sha,
|
||||||
'latest_commit': latest_sha[:7] if latest_sha else '',
|
'latest_commit': latest_sha[:7] if latest_sha else '',
|
||||||
@@ -3642,11 +3679,17 @@ def check_gitea_update(force_refresh=False):
|
|||||||
if force_refresh:
|
if force_refresh:
|
||||||
_worker()
|
_worker()
|
||||||
with _update_lock:
|
with _update_lock:
|
||||||
return dict(_update_cache['data'])
|
res = dict(_update_cache['data'])
|
||||||
|
res['enabled'] = enabled
|
||||||
|
res['interval'] = interval
|
||||||
|
return res
|
||||||
else:
|
else:
|
||||||
threading.Thread(target=_worker, daemon=True).start()
|
threading.Thread(target=_worker, daemon=True).start()
|
||||||
with _update_lock:
|
with _update_lock:
|
||||||
return dict(_update_cache['data'])
|
res = dict(_update_cache['data'])
|
||||||
|
res['enabled'] = enabled
|
||||||
|
res['interval'] = interval
|
||||||
|
return res
|
||||||
|
|
||||||
_status_cache = {'time': 0, 'data': None}
|
_status_cache = {'time': 0, 'data': None}
|
||||||
_status_cache_lock = threading.Lock()
|
_status_cache_lock = threading.Lock()
|
||||||
@@ -10389,6 +10432,20 @@ class Handler(BaseHTTPRequestHandler):
|
|||||||
q = urllib.parse.parse_qs(parsed.query)
|
q = urllib.parse.parse_qs(parsed.query)
|
||||||
force = 'force' in q or 'refresh' in q
|
force = 'force' in q or 'refresh' in q
|
||||||
self.send_json(check_gitea_update(force_refresh=force))
|
self.send_json(check_gitea_update(force_refresh=force))
|
||||||
|
elif path_only == '/api/system/update/settings':
|
||||||
|
enabled = get_pref('update_checker_enabled', '1') == '1'
|
||||||
|
try:
|
||||||
|
interval = int(get_pref('update_checker_interval', '7200'))
|
||||||
|
if interval < 60: interval = 7200
|
||||||
|
except Exception:
|
||||||
|
interval = 7200
|
||||||
|
up_data = check_gitea_update(force_refresh=False)
|
||||||
|
self.send_json({
|
||||||
|
'ok': True,
|
||||||
|
'enabled': enabled,
|
||||||
|
'interval': interval,
|
||||||
|
'update': up_data
|
||||||
|
})
|
||||||
elif path_only == '/api/clients': self.send_json(clients())
|
elif path_only == '/api/clients': self.send_json(clients())
|
||||||
elif path_only == '/api/clients/blocked': self.send_json(blocked_list())
|
elif path_only == '/api/clients/blocked': self.send_json(blocked_list())
|
||||||
elif path_only == '/api/devices': self.send_json(all_devices(self.get_req_lang()))
|
elif path_only == '/api/devices': self.send_json(all_devices(self.get_req_lang()))
|
||||||
@@ -10769,6 +10826,36 @@ class Handler(BaseHTTPRequestHandler):
|
|||||||
log('modification_identifiants', f"Renommage machine -> {new_name}", request_ip(self), 'AUTH')
|
log('modification_identifiants', f"Renommage machine -> {new_name}", request_ip(self), 'AUTH')
|
||||||
self.send_json({'ok': True, 'message': 'Machine renommée avec succès', 'name': new_name})
|
self.send_json({'ok': True, 'message': 'Machine renommée avec succès', 'name': new_name})
|
||||||
return
|
return
|
||||||
|
if self.path == '/api/system/update/settings':
|
||||||
|
if not valid_session(self) and auth_state()['configured']: self.send_json({'error':'Authentification requise'},401); return
|
||||||
|
enabled = bool(data.get('enabled', True))
|
||||||
|
try:
|
||||||
|
interval = int(data.get('interval', 7200))
|
||||||
|
if interval < 60: interval = 7200
|
||||||
|
except (TypeError, ValueError):
|
||||||
|
interval = 7200
|
||||||
|
set_pref('update_checker_enabled', '1' if enabled else '0')
|
||||||
|
set_pref('update_checker_interval', str(interval))
|
||||||
|
with _update_lock:
|
||||||
|
if not enabled:
|
||||||
|
_update_cache['time'] = time.time()
|
||||||
|
_update_cache['data']['available'] = False
|
||||||
|
_update_cache['data']['enabled'] = False
|
||||||
|
_update_cache['data']['interval'] = interval
|
||||||
|
else:
|
||||||
|
_update_cache['time'] = 0
|
||||||
|
invalidate_status_cache()
|
||||||
|
_update_loop_event.set()
|
||||||
|
log('modification_preferences', f"Recherche de MAJ: {'activée' if enabled else 'désactivée'}, intervalle={interval}s", request_ip(self), 'SETTINGS')
|
||||||
|
res = check_gitea_update(force_refresh=enabled)
|
||||||
|
self.send_json({
|
||||||
|
'ok': True,
|
||||||
|
'message': 'Paramètres de mise à jour enregistrés avec succès',
|
||||||
|
'enabled': enabled,
|
||||||
|
'interval': interval,
|
||||||
|
'update': res
|
||||||
|
})
|
||||||
|
return
|
||||||
if self.path == '/api/system/update/sync':
|
if self.path == '/api/system/update/sync':
|
||||||
if not valid_session(self) and auth_state()['configured']: self.send_json({'error':'Authentification requise'},401); return
|
if not valid_session(self) and auth_state()['configured']: self.send_json({'error':'Authentification requise'},401); return
|
||||||
target_commit = str(data.get('commit', '')).strip()
|
target_commit = str(data.get('commit', '')).strip()
|
||||||
@@ -11479,15 +11566,27 @@ class UnixServer(ThreadingHTTPServer):
|
|||||||
socketserver.TCPServer.server_bind(self)
|
socketserver.TCPServer.server_bind(self)
|
||||||
self.server_name, self.server_port = 'localhost', 0
|
self.server_name, self.server_port = 'localhost', 0
|
||||||
|
|
||||||
|
_update_loop_event = threading.Event()
|
||||||
|
|
||||||
def update_checker_loop():
|
def update_checker_loop():
|
||||||
"""Vérifie périodiquement si une mise à jour est disponible et déclenche une notification si configurée."""
|
"""Vérifie périodiquement si une mise à jour est disponible et déclenche une notification si configurée."""
|
||||||
time.sleep(45)
|
if _update_loop_event.wait(timeout=30):
|
||||||
|
_update_loop_event.clear()
|
||||||
while True:
|
while True:
|
||||||
try:
|
try:
|
||||||
|
enabled = get_pref('update_checker_enabled', '1') == '1'
|
||||||
|
if enabled:
|
||||||
check_gitea_update(force_refresh=True)
|
check_gitea_update(force_refresh=True)
|
||||||
except Exception:
|
except Exception:
|
||||||
pass
|
pass
|
||||||
time.sleep(7200)
|
try:
|
||||||
|
interval = int(get_pref('update_checker_interval', '7200'))
|
||||||
|
if interval < 60:
|
||||||
|
interval = 7200
|
||||||
|
except Exception:
|
||||||
|
interval = 7200
|
||||||
|
if _update_loop_event.wait(timeout=interval):
|
||||||
|
_update_loop_event.clear()
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
print(f"[ap-api] Initialisation de la base de données et surveillance sur {INTERFACE}...", flush=True)
|
print(f"[ap-api] Initialisation de la base de données et surveillance sur {INTERFACE}...", flush=True)
|
||||||
|
|||||||
+212
-35
@@ -3052,6 +3052,9 @@
|
|||||||
<button id="tabAdvPcap" class="settings-nav-btn" type="button" role="tab" onclick="selectAdvSubTab('pcap')">
|
<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>
|
<span>📡</span> <span data-i18n="adv_subtab_pcap">Capture de paquets (PCAP)</span>
|
||||||
</button>
|
</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>
|
</div>
|
||||||
|
|
||||||
<!-- Sous-panneau 1 : Routage VPN par client -->
|
<!-- 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>
|
pour inspecter l’en-tête décodé et le dump hexadécimal / ASCII style Wireshark.</p>
|
||||||
</div>
|
</div>
|
||||||
</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>
|
||||||
|
|
||||||
<section id="settingsView" class="view">
|
<section id="settingsView" class="view">
|
||||||
@@ -6219,9 +6299,9 @@
|
|||||||
style="font-size:12px">
|
style="font-size:12px">
|
||||||
🔄 <span data-i18n="btn_recheck">Vérifier à nouveau</span>
|
🔄 <span data-i18n="btn_recheck">Vérifier à nouveau</span>
|
||||||
</button>
|
</button>
|
||||||
<button type="button" class="secondary" id="btnSyncUpdateManual" onclick="syncUpdateVersion()"
|
<button type="button" class="secondary" style="font-size:12px;color:var(--blue)"
|
||||||
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">
|
onclick="closeUpdateModal();selectTab('advanced');selectAdvSubTab('updates')">
|
||||||
✓ <span data-i18n="btn_mark_up_to_date">Je suis déjà à jour</span>
|
⚙️ <span data-i18n="btn_configure_updates">Configurer la fréquence</span>
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
<button type="button" class="secondary" onclick="closeUpdateModal()" data-i18n="btn_close">Fermer</button>
|
<button type="button" class="secondary" onclick="closeUpdateModal()" data-i18n="btn_close">Fermer</button>
|
||||||
@@ -9211,9 +9291,7 @@ ${vpnBadgeTopo}
|
|||||||
if ($('updateDockerCmdSection')) {
|
if ($('updateDockerCmdSection')) {
|
||||||
$('updateDockerCmdSection').style.display = isAvail ? 'block' : 'none';
|
$('updateDockerCmdSection').style.display = isAvail ? 'block' : 'none';
|
||||||
}
|
}
|
||||||
if ($('btnSyncUpdateManual')) {
|
|
||||||
$('btnSyncUpdateManual').style.display = isAvail ? 'inline-flex' : 'none';
|
|
||||||
}
|
|
||||||
modal.classList.add('active');
|
modal.classList.add('active');
|
||||||
}
|
}
|
||||||
window.openUpdateModal = openUpdateModal;
|
window.openUpdateModal = openUpdateModal;
|
||||||
@@ -9268,32 +9346,6 @@ ${vpnBadgeTopo}
|
|||||||
}
|
}
|
||||||
window.triggerManualUpdateCheck = triggerManualUpdateCheck;
|
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) {
|
async function toggleBlock(mac, blocked) {
|
||||||
return runAction(async () => {
|
return runAction(async () => {
|
||||||
try {
|
try {
|
||||||
@@ -14596,19 +14648,144 @@ ${vpnBadgeTopo}
|
|||||||
|
|
||||||
function selectAdvSubTab(subTab) {
|
function selectAdvSubTab(subTab) {
|
||||||
currentAdvSubTab = subTab;
|
currentAdvSubTab = subTab;
|
||||||
const btnVpn = $('tabAdvVpnRouting'), btnPcap = $('tabAdvPcap');
|
const btnVpn = $('tabAdvVpnRouting'), btnPcap = $('tabAdvPcap'), btnUpdates = $('tabAdvUpdates');
|
||||||
const panelVpn = $('panelAdvVpnRouting'), panelPcap = $('panelAdvPcap');
|
const panelVpn = $('panelAdvVpnRouting'), panelPcap = $('panelAdvPcap'), panelUpdates = $('panelAdvUpdates');
|
||||||
if (btnVpn) btnVpn.className = 'settings-nav-btn' + (subTab === 'vpn' ? ' active' : '');
|
if (btnVpn) btnVpn.className = 'settings-nav-btn' + (subTab === 'vpn' ? ' active' : '');
|
||||||
if (btnPcap) btnPcap.className = 'settings-nav-btn' + (subTab === 'pcap' ? ' 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 (panelVpn) panelVpn.style.display = (subTab === 'vpn' ? 'block' : 'none');
|
||||||
if (panelPcap) panelPcap.style.display = (subTab === 'pcap' ? 'block' : 'none');
|
if (panelPcap) panelPcap.style.display = (subTab === 'pcap' ? 'block' : 'none');
|
||||||
|
if (panelUpdates) panelUpdates.style.display = (subTab === 'updates' ? 'block' : 'none');
|
||||||
if (subTab === 'vpn') {
|
if (subTab === 'vpn') {
|
||||||
loadVpnClients();
|
loadVpnClients();
|
||||||
stopCaptureTimer();
|
stopCaptureTimer();
|
||||||
} else {
|
} else if (subTab === 'pcap') {
|
||||||
loadCaptureStatus();
|
loadCaptureStatus();
|
||||||
loadCapturePackets(true);
|
loadCapturePackets(true);
|
||||||
ensureCapturePolling();
|
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;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+30
-1
@@ -1285,5 +1285,34 @@ window.I18N['en-gb'] = {
|
|||||||
"update_up_to_date_desc": "You already have the latest version of the application.",
|
"update_up_to_date_desc": "You already have the latest version of the application.",
|
||||||
"ap_stopped_no_restart": "AP is stopped (start required)",
|
"ap_stopped_no_restart": "AP is stopped (start required)",
|
||||||
"btn_mark_up_to_date": "I am already up to date",
|
"btn_mark_up_to_date": "I am already up to date",
|
||||||
"update_sync_error": "Error synchronising version"
|
"update_sync_error": "Error synchronising version",
|
||||||
|
"adv_subtab_updates": "System Updates",
|
||||||
|
"adv_update_current_ver": "Current Version",
|
||||||
|
"adv_update_latest_ver": "Latest Version (Gitea)",
|
||||||
|
"adv_update_status_label": "Update Status",
|
||||||
|
"adv_update_settings_title": "Automatic Update Checks",
|
||||||
|
"adv_update_settings_desc": "Control whether AP Manageur should automatically check for new versions on the Gitea repository and how often.",
|
||||||
|
"adv_update_enable_chk": "Enable automatic update checks",
|
||||||
|
"adv_update_enable_hint": "When disabled, no requests are sent to Gitea and the update button remains hidden.",
|
||||||
|
"adv_update_interval_label": "Automatic check frequency",
|
||||||
|
"adv_update_interval_hint": "Sets the interval between each background check by the server.",
|
||||||
|
"btn_configure_updates": "Configure Frequency",
|
||||||
|
"btn_save_preferences": "Save Preferences",
|
||||||
|
"update_status_disabled": "Update check disabled",
|
||||||
|
"last_checked": "Last check: ",
|
||||||
|
"disabled_m": "Disabled",
|
||||||
|
"interval_5m": "Every 5 minutes",
|
||||||
|
"interval_15m": "Every 15 minutes",
|
||||||
|
"interval_30m": "Every 30 minutes",
|
||||||
|
"interval_1h": "Every 1 hour",
|
||||||
|
"interval_2h": "Every 2 hours (recommended)",
|
||||||
|
"interval_4h": "Every 4 hours",
|
||||||
|
"interval_6h": "Every 6 hours",
|
||||||
|
"interval_12h": "Every 12 hours",
|
||||||
|
"interval_1d": "Every 1 day (24 hours)",
|
||||||
|
"interval_2d": "Every 2 days",
|
||||||
|
"interval_3d": "Every 3 days",
|
||||||
|
"interval_7d": "Every 7 days (1 week)",
|
||||||
|
"interval_14d": "Every 14 days (2 weeks)",
|
||||||
|
"interval_30d": "Every 30 days (1 month)"
|
||||||
};
|
};
|
||||||
+30
-1
@@ -1285,5 +1285,34 @@ window.I18N['en-us'] = {
|
|||||||
"update_up_to_date_desc": "You already have the latest version of the application.",
|
"update_up_to_date_desc": "You already have the latest version of the application.",
|
||||||
"ap_stopped_no_restart": "AP is stopped (start required)",
|
"ap_stopped_no_restart": "AP is stopped (start required)",
|
||||||
"btn_mark_up_to_date": "I am already up to date",
|
"btn_mark_up_to_date": "I am already up to date",
|
||||||
"update_sync_error": "Error synchronizing version"
|
"update_sync_error": "Error synchronizing version",
|
||||||
|
"adv_subtab_updates": "System Updates",
|
||||||
|
"adv_update_current_ver": "Current Version",
|
||||||
|
"adv_update_latest_ver": "Latest Version (Gitea)",
|
||||||
|
"adv_update_status_label": "Update Status",
|
||||||
|
"adv_update_settings_title": "Automatic Update Checks",
|
||||||
|
"adv_update_settings_desc": "Control whether AP Manageur should automatically check for new versions on the Gitea repository and how often.",
|
||||||
|
"adv_update_enable_chk": "Enable automatic update checks",
|
||||||
|
"adv_update_enable_hint": "When disabled, no requests are sent to Gitea and the update button remains hidden.",
|
||||||
|
"adv_update_interval_label": "Automatic check frequency",
|
||||||
|
"adv_update_interval_hint": "Sets the interval between each background check by the server.",
|
||||||
|
"btn_configure_updates": "Configure Frequency",
|
||||||
|
"btn_save_preferences": "Save Preferences",
|
||||||
|
"update_status_disabled": "Update check disabled",
|
||||||
|
"last_checked": "Last check: ",
|
||||||
|
"disabled_m": "Disabled",
|
||||||
|
"interval_5m": "Every 5 minutes",
|
||||||
|
"interval_15m": "Every 15 minutes",
|
||||||
|
"interval_30m": "Every 30 minutes",
|
||||||
|
"interval_1h": "Every 1 hour",
|
||||||
|
"interval_2h": "Every 2 hours (recommended)",
|
||||||
|
"interval_4h": "Every 4 hours",
|
||||||
|
"interval_6h": "Every 6 hours",
|
||||||
|
"interval_12h": "Every 12 hours",
|
||||||
|
"interval_1d": "Every 1 day (24 hours)",
|
||||||
|
"interval_2d": "Every 2 days",
|
||||||
|
"interval_3d": "Every 3 days",
|
||||||
|
"interval_7d": "Every 7 days (1 week)",
|
||||||
|
"interval_14d": "Every 14 days (2 weeks)",
|
||||||
|
"interval_30d": "Every 30 days (1 month)"
|
||||||
};
|
};
|
||||||
+30
-1
@@ -1285,5 +1285,34 @@ window.I18N['fr'] = {
|
|||||||
"update_up_to_date_desc": "Vous disposez déjà de la version la plus récente de l'application.",
|
"update_up_to_date_desc": "Vous disposez déjà de la version la plus récente de l'application.",
|
||||||
"ap_stopped_no_restart": "L'AP est arrêtée (démarrage requis)",
|
"ap_stopped_no_restart": "L'AP est arrêtée (démarrage requis)",
|
||||||
"btn_mark_up_to_date": "Je suis déjà à jour",
|
"btn_mark_up_to_date": "Je suis déjà à jour",
|
||||||
"update_sync_error": "Erreur lors de la synchronisation de la version"
|
"update_sync_error": "Erreur lors de la synchronisation de la version",
|
||||||
|
"adv_subtab_updates": "Mises à jour système",
|
||||||
|
"adv_update_current_ver": "Version actuelle",
|
||||||
|
"adv_update_latest_ver": "Dernière version (Gitea)",
|
||||||
|
"adv_update_status_label": "Statut des mises à jour",
|
||||||
|
"adv_update_settings_title": "Recherche automatique des mises à jour",
|
||||||
|
"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.",
|
||||||
|
"adv_update_enable_chk": "Activer la recherche automatique de mises à jour",
|
||||||
|
"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é.",
|
||||||
|
"adv_update_interval_label": "Fréquence de vérification automatique",
|
||||||
|
"adv_update_interval_hint": "Définit l’intervalle entre chaque analyse en arrière-plan par le serveur.",
|
||||||
|
"btn_configure_updates": "Configurer la fréquence",
|
||||||
|
"btn_save_preferences": "Enregistrer les préférences",
|
||||||
|
"update_status_disabled": "Vérification désactivée",
|
||||||
|
"last_checked": "Dernière vérif. : ",
|
||||||
|
"disabled_m": "Désactivé",
|
||||||
|
"interval_5m": "Toutes les 5 minutes",
|
||||||
|
"interval_15m": "Toutes les 15 minutes",
|
||||||
|
"interval_30m": "Toutes les 30 minutes",
|
||||||
|
"interval_1h": "Toutes les 1 heure",
|
||||||
|
"interval_2h": "Toutes les 2 heures (recommandé)",
|
||||||
|
"interval_4h": "Toutes les 4 heures",
|
||||||
|
"interval_6h": "Toutes les 6 heures",
|
||||||
|
"interval_12h": "Toutes les 12 heures",
|
||||||
|
"interval_1d": "Tous les 1 jour (24 heures)",
|
||||||
|
"interval_2d": "Tous les 2 jours",
|
||||||
|
"interval_3d": "Tous les 3 jours",
|
||||||
|
"interval_7d": "Tous les 7 jours (1 semaine)",
|
||||||
|
"interval_14d": "Tous les 14 jours (2 semaines)",
|
||||||
|
"interval_30d": "Tous les 30 jours (1 mois)"
|
||||||
};
|
};
|
||||||
+2
-2
@@ -1,5 +1,5 @@
|
|||||||
{
|
{
|
||||||
"version": "V5.5",
|
"version": "V5.5",
|
||||||
"commit": "ecc8e872f7d6d20f16c0c8241af6422ec3bb8d69",
|
"commit": "b4aa9ab0f6f1a5605138d5aeafad88f5f6817040",
|
||||||
"build_date": "2026-11-21T19:00:56Z"
|
"build_date": "2026-11-21T20:15:35Z"
|
||||||
}
|
}
|
||||||
Reference in new issue
Block a user