diff --git a/ap.py b/ap.py index d2a94ff..0dac78b 100644 --- a/ap.py +++ b/ap.py @@ -3476,10 +3476,37 @@ _update_cache = { } def get_current_commit(): - """Récupère le SHA du commit actuel (variable AP_GIT_COMMIT, version.json ou git).""" + """Récupère le SHA du commit actuel (variable AP_GIT_COMMIT, git rev-parse ou version.json).""" env_c = os.environ.get('AP_GIT_COMMIT', '').strip() if env_c: return env_c + + # 1. Priorité au dépôt Git réel si disponible + try: + c = command('git', 'rev-parse', 'HEAD') + if c and len(c.strip()) >= 7: + git_sha = c.strip() + # Mettre à jour version.json s'il existe et est désynchronisé + for v_path in ( + os.path.join(BASE_DIR, 'version.json'), + os.path.join(os.getcwd(), 'version.json'), + 'version.json' + ): + if os.path.isfile(v_path): + try: + with open(v_path, 'r', encoding='utf-8') as f: + vdata = json.load(f) + if vdata.get('commit') != git_sha: + vdata['commit'] = git_sha + with open(v_path, 'w', encoding='utf-8') as f: + json.dump(vdata, f, indent=2) + except Exception: + pass + return git_sha + except Exception: + pass + + # 2. Sinon, lecture de version.json (conteneur Docker où .git n'est pas présent) for path in ( os.path.join(BASE_DIR, 'version.json'), '/app/version.json', @@ -3496,12 +3523,6 @@ def get_current_commit(): return c except Exception: pass - try: - c = command('git', 'rev-parse', 'HEAD') - if c and len(c.strip()) >= 7: - return c.strip() - except Exception: - pass return '' def check_gitea_update(force_refresh=False): @@ -3545,10 +3566,14 @@ def check_gitea_update(force_refresh=False): date_str = (c_info.get('author') or {}).get('date', '') html_url = first.get('html_url') or GITEA_REPO_URL if current_sha and latest_sha: - c_low = current_sha.lower() - l_low = latest_sha.lower() + c_low = current_sha.lower().strip() + l_low = latest_sha.lower().strip() if not l_low.startswith(c_low) and not c_low.startswith(l_low): available = True + else: + available = False + else: + available = False except Exception as e: err_msg = str(e) diff --git a/index.html b/index.html index fa30dbd..e897063 100644 --- a/index.html +++ b/index.html @@ -83,9 +83,9 @@ } .wrap { - max-width: 1100px; + max-width: 1200px; margin: 0 auto; - padding: 24px; + padding: 20px 24px; width: 100% } @@ -94,49 +94,52 @@ justify-content: space-between; align-items: center; margin-bottom: 20px; - gap: 12px; - flex-wrap: wrap + gap: 16px; } h1 { margin: 0; - font-size: 26px + font-size: 24px; + white-space: nowrap; } .sub { color: var(--muted); - font-size: 14px; - margin-top: 4px + font-size: 13px; + margin-top: 3px } .header-actions { display: flex; - gap: 8px; - flex-wrap: wrap; - align-items: center + gap: 6px; + align-items: center; + flex-wrap: nowrap; } .header-actions button { display: inline-flex; align-items: center; justify-content: center; - gap: 8px; - height: 38px; - padding: 9px 16px; - font-size: 14px; + gap: 6px; + height: 36px; + padding: 7px 12px; + font-size: 13px; font-weight: 600; border-radius: 8px; box-sizing: border-box; line-height: 1; + white-space: nowrap; } .btn-update-available { - background: rgba(16, 185, 129, 0.16) !important; + background: rgba(16, 185, 129, 0.15) !important; + border: 1px solid #10b981 !important; color: #10b981 !important; - border: 1px solid rgba(16, 185, 129, 0.5) !important; box-shadow: 0 0 10px rgba(16, 185, 129, 0.2); transition: all 0.2s ease-in-out; cursor: pointer; + padding: 7px 12px !important; + font-size: 13px !important; } .btn-update-available:hover { @@ -2007,6 +2010,21 @@ } } + /* Écrans moyens / Tablettes (<= 960px) */ + @media (max-width: 960px) { + header { + flex-direction: column; + align-items: flex-start; + gap: 14px; + } + + .header-actions { + width: 100%; + flex-wrap: wrap; + gap: 6px; + } + } + /* Téléphone et écrans compacts (<= 600px) */ @media (max-width:600px) { .wrap { @@ -5682,11 +5700,11 @@ -
+
@@ -8625,8 +8643,19 @@ ${vpnBadgeTopo} if ($('settingsTab')) $('settingsTab').style.display = configured ? '' : 'none'; if ($('logsTab')) $('logsTab').style.display = configured ? '' : 'none'; if ($('blockedTab')) $('blockedTab').style.display = configured ? '' : 'none'; - if ($('apControl')) $('apControl').style.display = configured ? '' : 'none'; - if ($('apRestart')) $('apRestart').style.display = configured && active ? '' : 'none'; + if ($('apControl')) { + $('apControl').style.display = configured ? '' : 'none'; + $('apControl').textContent = active ? t('btn_stop', 'Arrêter') : t('btn_start', 'Démarrer'); + $('apControl').style.background = active ? 'var(--red)' : 'var(--blue)'; + $('apControl').style.color = active ? 'white' : 'var(--blue-text, #071326)'; + } + if ($('apRestart')) { + $('apRestart').style.display = configured ? '' : 'none'; + $('apRestart').disabled = !active; + $('apRestart').style.opacity = active ? '1' : '0.4'; + $('apRestart').style.cursor = active ? 'pointer' : 'not-allowed'; + $('apRestart').title = active ? t('btn_restart', 'Redémarrer') : t('ap_stopped_no_restart', "L'AP est arrêtée (démarrage requis)"); + } if ($('refresh')) $('refresh').style.display = configured ? '' : 'none'; const updateInfo = (status && status.update) ? status.update : null; if (updateInfo) lastUpdateData = updateInfo; @@ -8634,11 +8663,6 @@ ${vpnBadgeTopo} if ($('btnUpdateAvailable')) { $('btnUpdateAvailable').style.display = (configured && updateAvailable) ? 'inline-flex' : 'none'; } - if (configured && $('apControl')) { - $('apControl').textContent = active ? t('btn_stop', 'Arrêter') : t('btn_start', 'Démarrer'); - $('apControl').style.background = active ? 'var(--red)' : 'var(--blue)'; - $('apControl').style.color = active ? 'white' : 'var(--blue-text, #071326)'; - } } let lastUpdateData = null; @@ -8647,6 +8671,7 @@ ${vpnBadgeTopo} const modal = $('modalUpdateApp'); if (!modal) return; const u = lastUpdateData || (status && status.update) || {}; + const isAvail = !!u.available; if ($('updateCurrentCommit')) $('updateCurrentCommit').textContent = u.current_commit || (u.current_commit_full ? u.current_commit_full.substring(0, 7) : '—'); if ($('updateLatestCommit')) $('updateLatestCommit').textContent = u.latest_commit || (u.latest_commit_full ? u.latest_commit_full.substring(0, 7) : '—'); if ($('updateCommitMsg')) $('updateCommitMsg').textContent = u.commit_msg || t('update_no_msg', 'Aucun message de commit'); @@ -8658,6 +8683,23 @@ ${vpnBadgeTopo} } $('updateCommitDate').textContent = dStr; } + if ($('updateStatusAlert')) { + $('updateStatusAlert').style.background = isAvail ? 'rgba(16,185,129,0.1)' : 'rgba(56,189,248,0.1)'; + $('updateStatusAlert').style.borderColor = isAvail ? 'rgba(16,185,129,0.3)' : 'rgba(56,189,248,0.3)'; + } + if ($('updateStatusIcon')) { + $('updateStatusIcon').textContent = isAvail ? '🚀' : '✅'; + } + if ($('updateStatusTitle')) { + $('updateStatusTitle').textContent = isAvail ? t('update_new_version_found', 'Une nouvelle version de AP Manageur est prête !') : t('update_up_to_date', 'AP Manageur est à jour !'); + $('updateStatusTitle').style.color = isAvail ? '#10b981' : 'var(--blue)'; + } + if ($('updateStatusDesc')) { + $('updateStatusDesc').textContent = isAvail ? t('update_new_version_desc', "Une mise à jour plus récente de l'application est disponible sur le dépôt.") : t('update_up_to_date_desc', "Vous disposez déjà de la version la plus récente de l'application."); + } + if ($('updateDockerCmdSection')) { + $('updateDockerCmdSection').style.display = isAvail ? 'block' : 'none'; + } modal.classList.add('active'); } window.openUpdateModal = openUpdateModal; @@ -12360,7 +12402,7 @@ ${vpnBadgeTopo} } $('apControl').onclick = () => controlAp(status.active ? 'stop' : 'start'); - $('apRestart').onclick = () => controlAp('restart'); + $('apRestart').onclick = () => { if (status && status.active) controlAp('restart'); }; $('clearAllData').onclick = () => runAction(async () => { if (!confirm(t('confirm_delete_all_data', '⚠️ ATTENTION : Voulez-vous vraiment supprimer toutes les données de l’application ?'))) return; diff --git a/lang/en-gb.js b/lang/en-gb.js index 2f90d4c..4b04861 100644 --- a/lang/en-gb.js +++ b/lang/en-gb.js @@ -1278,5 +1278,8 @@ window.I18N['en-gb'] = { "update_cmd_hint": "Run this command in your project directory on your host server.", "update_cmd_copied": "✓ Copied!", "btn_recheck": "Check again", - "update_no_msg": "No commit message" + "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)" }; diff --git a/lang/en-us.js b/lang/en-us.js index 01ba3e1..669d6c8 100644 --- a/lang/en-us.js +++ b/lang/en-us.js @@ -1278,5 +1278,8 @@ window.I18N['en-us'] = { "update_cmd_hint": "Run this command in your project directory on your host server.", "update_cmd_copied": "✓ Copied!", "btn_recheck": "Check again", - "update_no_msg": "No commit message" + "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)" }; diff --git a/lang/fr.js b/lang/fr.js index a791f3e..14a47dd 100644 --- a/lang/fr.js +++ b/lang/fr.js @@ -1278,5 +1278,8 @@ window.I18N['fr'] = { "update_cmd_hint": "Exécutez cette commande dans le dossier de votre projet sur votre serveur hôte.", "update_cmd_copied": "✓ Copié !", "btn_recheck": "Vérifier à nouveau", - "update_no_msg": "Aucun message de commit" + "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)" }; diff --git a/version.json b/version.json index 94c603b..dbe375e 100644 --- a/version.json +++ b/version.json @@ -1,5 +1,5 @@ { "version": "V5.5", - "commit": "fe6594b964870ee466a06d90ad7acd821b50bfc7", - "build_date": "2026-11-21T02:00:00Z" + "commit": "ceeab6fa4a650ce9a251236971661bc4b39c321f", + "build_date": "2026-11-21T03:30:00Z" }