Show build progress instead of a static "Building…"
CI / check (push) Successful in 18s
CI / deploy (push) Successful in 13s

terrain.pmtiles can take minutes (tiles fetched one at a time) with no
way to tell a slow build from a stuck one. Now reports tiles_done/
tiles_total into the same status Hash the frontend already polls, and
the panel shows elapsed time (both files) plus tile counts (terrain
only) so the numbers visibly move every ~3s poll instead of sitting on
one static string.
This commit is contained in:
randy committed 2026-09-11 11:57:43 +02:00
1 parent d72f8a3c94
commit bbe9f38bda
3 files changed
+68 -8

No files matched your search

+19
View File
@@ -9,6 +9,24 @@ function formatBytes(bytes) {
return mb >= 1024 ? `${(mb / 1024).toFixed(1)} GB` : `${mb.toFixed(1)} MB`;
}
function formatElapsed(ms) {
const totalSeconds = Math.max(0, Math.floor(ms / 1000));
const minutes = Math.floor(totalSeconds / 60);
const seconds = totalSeconds % 60;
return minutes > 0 ? `${minutes}m ${seconds}s` : `${seconds}s`;
}
// "Building…" alone gave no way to tell a slow build (terrain.pmtiles can
// take minutes — lib/maptool/pmtiles_builder.rb fetches tiles one at a
// time) from a stuck one. Elapsed time alone answers "is it alive" for
// both files; tile counts (only terrain.pmtiles reports these) give an
// actual sense of how much is left.
function formatRunning(status) {
const elapsed = status.started_at ? ` (${formatElapsed(Date.now() - new Date(status.started_at).getTime())})` : "";
const tiles = status.tiles_total ? ` · ${status.tiles_done}/${status.tiles_total} tiles` : "";
return `Building…${elapsed}${tiles}`;
}
// One row of the Offline data panel — status text plus a "Regenerate for
// current view" button, for either offline.pmtiles or terrain.pmtiles.
// Both files behave identically from here (same status/build/build-status
@@ -103,6 +121,7 @@ class DataFileRow {
}
if (status.state === "running") {
this._statusEl.textContent = formatRunning(status);
this._poll();
return;
}