From ecc8e872f7d6d20f16c0c8241af6422ec3bb8d69 Mon Sep 17 00:00:00 2001 From: yoannmultigaming Date: Sat, 21 Nov 2026 20:00:54 +0100 Subject: [PATCH] APmanageur Wi-Fi V1.0 --- Dockerfile | 9 +++++++++ ap.py | 25 +++++++++++++++++++++++++ docker-compose.yml | 2 +- index.html | 45 ++++++++++++++++++++++++++++++++++++++++----- lang/en-gb.js | 4 +++- lang/en-us.js | 4 +++- lang/fr.js | 4 +++- version.json | 6 +++--- 8 files changed, 87 insertions(+), 12 deletions(-) diff --git a/Dockerfile b/Dockerfile index f5c52f7..1f31a04 100644 --- a/Dockerfile +++ b/Dockerfile @@ -36,6 +36,15 @@ COPY jeux/ /app/jeux/ COPY jeux/ /var/www/html/jeux/ COPY version.json /app/version.json COPY version.json /var/www/html/version.json +ARG AP_GIT_COMMIT="" +ARG BUILD_DATE="" +ENV AP_GIT_COMMIT=${AP_GIT_COMMIT} +RUN if [ -n "${AP_GIT_COMMIT}" ]; then \ + sed -i "s/\"commit\": *\"[^\"]*\"/\"commit\": \"${AP_GIT_COMMIT}\"/" /app/version.json /var/www/html/version.json 2>/dev/null || true; \ + fi && \ + if [ -n "${BUILD_DATE}" ]; then \ + sed -i "s/\"build_date\": *\"[^\"]*\"/\"build_date\": \"${BUILD_DATE}\"/" /app/version.json /var/www/html/version.json 2>/dev/null || true; \ + fi # L'API n'est plus joignable que via Apache : le HTML appelle /api sur le même port (1001) RUN sed -i 's#const API_URL=[^;]*;#const API_URL="";#' /app/index.html /var/www/html/index.html /app/setup.html /var/www/html/setup.html 2>/dev/null || true COPY apache-ap.conf /etc/apache2/sites-available/000-default.conf diff --git a/ap.py b/ap.py index 0dac78b..ce1307e 100644 --- a/ap.py +++ b/ap.py @@ -3508,6 +3508,7 @@ def get_current_commit(): # 2. Sinon, lecture de version.json (conteneur Docker où .git n'est pas présent) for path in ( + '/data/version.json', os.path.join(BASE_DIR, 'version.json'), '/app/version.json', '/var/www/html/version.json', @@ -10725,6 +10726,30 @@ class Handler(BaseHTTPRequestHandler): 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}) return + if self.path == '/api/system/update/sync': + if not valid_session(self) and auth_state()['configured']: self.send_json({'error':'Authentification requise'},401); return + target_commit = str(data.get('commit', '')).strip() + if not target_commit: + chk = check_gitea_update(force_refresh=True) + target_commit = chk.get('latest_commit_full') or chk.get('latest_commit') or '' + if not target_commit: + raise ValueError('Impossible de déterminer le dernier commit') + v_data = { + 'version': 'V5.5', + 'commit': target_commit, + 'build_date': datetime.datetime.now(datetime.timezone.utc).strftime('%Y-%m-%dT%H:%M:%SZ') + } + for v_path in ('/data/version.json', os.path.join(BASE_DIR, 'version.json'), 'version.json'): + try: + with open(v_path, 'w', encoding='utf-8') as f: + json.dump(v_data, f, indent=2) + except Exception: + pass + with _update_lock: + _update_cache['time'] = 0 + res = check_gitea_update(force_refresh=True) + self.send_json({'ok': True, 'update': res, 'message': 'Synchronisé avec succès !'}) + return if self.path == '/api/backup/inspect': if not valid_session(self) and auth_state()['configured']: self.send_json({'error':'Authentification requise'},401); return fname = str(data.get('filename', 'sauvegarde')).strip() diff --git a/docker-compose.yml b/docker-compose.yml index e79ed09..d4efdc5 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -1,7 +1,7 @@ services: AP-Manageur: build: . - image: gitea.yoann-nas.fr/yoannmultigaming/apmanageur.git:latest + image: gitea.yoann-nas.fr/yoannmultigaming/apmanageur:latest container_name: ap-manageur restart: unless-stopped network_mode: host # accès direct à la carte Wi-Fi de l'hôte (Apache sur le port 1001) diff --git a/index.html b/index.html index 9591ff4..95429b3 100644 --- a/index.html +++ b/index.html @@ -6155,11 +6155,17 @@ commande dans le dossier de votre projet sur votre serveur hôte. - @@ -9147,6 +9153,9 @@ ${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; @@ -9201,6 +9210,32 @@ ${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 { diff --git a/lang/en-gb.js b/lang/en-gb.js index 4b04861..ea20c8b 100644 --- a/lang/en-gb.js +++ b/lang/en-gb.js @@ -1281,5 +1281,7 @@ window.I18N['en-gb'] = { "update_no_msg": "No commit message", "update_up_to_date": "AP Manageur is up to date!", "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", + "update_sync_error": "Error synchronising version" }; diff --git a/lang/en-us.js b/lang/en-us.js index 669d6c8..18133b7 100644 --- a/lang/en-us.js +++ b/lang/en-us.js @@ -1281,5 +1281,7 @@ window.I18N['en-us'] = { "update_no_msg": "No commit message", "update_up_to_date": "AP Manageur is up to date!", "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", + "update_sync_error": "Error synchronizing version" }; diff --git a/lang/fr.js b/lang/fr.js index 14a47dd..2c51cdf 100644 --- a/lang/fr.js +++ b/lang/fr.js @@ -1281,5 +1281,7 @@ window.I18N['fr'] = { "update_no_msg": "Aucun message de commit", "update_up_to_date": "AP Manageur est à jour !", "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", + "update_sync_error": "Erreur lors de la synchronisation de la version" }; diff --git a/version.json b/version.json index e36e36f..6bf5164 100644 --- a/version.json +++ b/version.json @@ -1,5 +1,5 @@ { "version": "V5.5", - "commit": "ceeab6fa4a650ce9a251236971661bc4b39c321f", - "build_date": "2026-11-21T03:30:00Z" -} \ No newline at end of file + "commit": "5eed2d607e7e5f5502e783578497747982bde5de", + "build_date": "2026-11-21T04:49:09Z" +}