Status / debug: "Check for an update now" — past the update check's 10 min cache
CI / check (push) Successful in 22s
CI / deploy (push) Successful in 18s

This commit is contained in:
randy committed 2026-11-30 20:27:58 +01:00
1 parent d58f7efc41
commit a11a71dc89
5 files changed
+17 -6

No files matched your search

+1
View File
@@ -511,6 +511,7 @@ module Maptool
require_login! require_login!
halt json(enabled: false) unless SELF_UPDATE halt json(enabled: false) unless SELF_UPDATE
Updater.reset! if params[:fresh] # "Check now": past the 10 min cache
latest = Updater.latest(GITEA_URL, UPDATE_REPO) latest = Updater.latest(GITEA_URL, UPDATE_REPO)
available = !!latest && latest[:ci] == "success" && latest[:sha] && !latest[:sha].start_with?(REVISION) available = !!latest && latest[:ci] == "success" && latest[:sha] && !latest[:sha].start_with?(REVISION)
json enabled: true, current: REVISION, latest: latest&.dig(:sha)&.slice(0, 7), ci: latest&.dig(:ci), json enabled: true, current: REVISION, latest: latest&.dig(:sha)&.slice(0, 7), ci: latest&.dig(:ci),
+2
View File
@@ -721,6 +721,8 @@ body.side-pinned:has(.basemap-panel:not([hidden]), .gpx-panel:not([hidden])) .pr
font-size: 14px; font-size: 14px;
color: var(--accent); color: var(--accent);
} }
button.basemap-panel__link { width: 100%; border: none; background: none; text-align: left; font-family: inherit; cursor: pointer; }
button.basemap-panel__link[hidden] { display: none; }
.basemap-panel__sources[hidden] { .basemap-panel__sources[hidden] {
display: none; display: none;
+1 -1
View File
@@ -557,7 +557,7 @@ gnssControl.mount(sidebar);
new LiveTrackPanelControl(map).mount(sidebar); new LiveTrackPanelControl(map).mount(sidebar);
if (isLoggedIn()) new DebugControl().mount(sidebar); if (isLoggedIn()) new DebugControl().mount(sidebar);
if (isLoggedIn()) setupUpdate(document.querySelector(".topbar__update")); if (isLoggedIn()) setupUpdate(document.querySelector(".topbar__update"), document.querySelector(".debug-panel__update-check"));
setupSidePanelModes(); setupSidePanelModes();
// The sidebar already has a "Base map" icon (opens the same panel) — // The sidebar already has a "Base map" icon (opens the same panel) —
+12 -5
View File
@@ -5,23 +5,30 @@
const CHECK_MS = 10 * 60 * 1000; const CHECK_MS = 10 * 60 * 1000;
const RESTART_POLL_MS = 5000; const RESTART_POLL_MS = 5000;
export function setupUpdate(button) { export function setupUpdate(button, checkNow) {
let latest = null; let latest = null;
let timer = null;
async function check() { async function check(fresh = false) {
clearTimeout(timer);
try { try {
const state = await (await fetch("/api/update", { cache: "no-store" })).json(); const state = await (await fetch(`/api/update${fresh ? "?fresh=1" : ""}`, { cache: "no-store" })).json();
if (!state.enabled) return; if (!state.enabled) return;
if (checkNow) {
checkNow.hidden = false;
if (fresh) checkNow.textContent = state.available ? `Update ${state.latest} available ↑` : `Up to date (${state.current}) — check again`;
}
latest = state.latest; latest = state.latest;
button.hidden = !state.available; button.hidden = !state.available;
button.textContent = `⟳ ${state.latest}`; button.textContent = `⟳ ${state.latest}`;
button.title = `A new version (${state.latest}, now ${state.current}) — click to update; the app restarts for about a minute`; button.title = `A new version (${state.latest}, now ${state.current}) — click to update; the app restarts for about a minute`;
if (state.status?.state === "failed") button.title += `\nThe last update failed: ${state.status.message}`; if (state.status?.state === "failed") button.title += `\nThe last update failed: ${state.status.message}`;
setTimeout(check, CHECK_MS); timer = setTimeout(check, CHECK_MS);
} catch { } catch {
setTimeout(check, CHECK_MS); timer = setTimeout(check, CHECK_MS);
} }
} }
checkNow?.addEventListener("click", () => check(true));
async function waitForRestart(revision) { async function waitForRestart(revision) {
try { try {
+1
View File
@@ -107,6 +107,7 @@
</div> </div>
<div class="basemap-panel__list"> <div class="basemap-panel__list">
<a class="basemap-panel__link" href="/can.html" target="_blank">CANopen diagnostics ↗</a> <a class="basemap-panel__link" href="/can.html" target="_blank">CANopen diagnostics ↗</a>
<button type="button" class="basemap-panel__link debug-panel__update-check" hidden>Check for an update now</button>
</div> </div>
<!-- Filled by DebugControl (public/js/debug.js), logged-in only. --> <!-- Filled by DebugControl (public/js/debug.js), logged-in only. -->
<div class="debug-panel__body"></div> <div class="debug-panel__body"></div>