Planning (the Design canvas' Plan and GridToday, ideas from azedler/roadplanner): a stop's type as its NPS pictogram (marker and list), notes on the trip, its days and stops, + on a leg inserts the next point there; a parking spot per stop (P marker, the route goes there, the walk shown); a link pasted into the search becomes a place (/api/link: the URL's coordinates, else the page's geo meta / JSON-LD / a map link; public addresses only, logged in), added on the leg it lengthens least; avoids for the trip (+ ferries, unpaved) or a day (routed in pieces, joined); Check and Costs folds in the Route panel (no leave time, long days, arriving after sunset, long walks, missing vignettes; fuel from km × consumption × price, stop costs / paid, the budget); Today in drive mode's Menu (stops left, tonight, sunset, Open-Meteo weather, the day's notes, Skip next, Tomorrow). Plugins along the trip's route (Maptool::Corridor, a corridor width; Overpass around:) and plugin settings saved server-side; p4n via a host Firefox's cookies (docs/deployment.adoc). The recording's days (cut where the car stood ≥ 4 h, or by hand) and their export (days, a piece A–B, the whole trip; GPX with times). Track replay in the GNSS simulator. Step advance 5 m past a maneuver. The level gauge (drive mode, from Terrain): lift per wheel to the ramps' steps from roll, pitch, wheelbase and track
CI / check (push) Successful in 23s
CI / deploy (push) Successful in 18s

This commit is contained in:
randy committed 2026-12-03 23:34:25 +01:00
1 parent 5e31dfaba9
commit 87d7bd2463
36 files changed
+2047 -123

No files matched your search

+43 -3
View File
@@ -1,6 +1,9 @@
import { PLUGIN_ICON } from "/js/icons.js";
import { notifyGpxStoreChanged, notifySidePanelOpen, onlyOneSidePanelOpen } from "/js/panels.js";
const CORRIDORS_KM = [1, 2, 5, 10, 20];
const CORRIDOR_KEY = "maptool.pluginCorridorKm";
// A side panel (#plugins-panel) listing whatever import plugins are on disk (see
// lib/maptool/plugins.rb for the contract) — each one just a "Run for
// this area" button using the current map viewport as the bbox, so there's
@@ -56,28 +59,65 @@ export class PluginsControl {
plugins.forEach((plugin) => this._list.appendChild(this._renderItem(plugin)));
}
// Per plugin: "Run for this area"; with "route" in its plugin.json also
// "Along the trip's route" N km either side (the corridor remembered); with
// "settings" (a login cookie) their fields — a value set shows as "set",
// never sent back from the server.
_renderItem(plugin) {
const li = document.createElement("li");
li.className = "plugins-panel__item";
li.innerHTML = `
<span class="plugins-panel__label"></span>
<button type="button" class="plugins-panel__run">Run for this area</button>
${plugin.route ? `<span class="plugins-panel__route"><button type="button" class="plugins-panel__run plugins-panel__run--route">Along the trip's route</button>
<select class="plugins-panel__corridor" aria-label="How far either side of the route">${CORRIDORS_KM.map((km) => `<option value="${km}">± ${km} km</option>`).join("")}</select></span>` : ""}
<span class="plugins-panel__status"></span>
${plugin.settings?.length ? `<details class="plugins-panel__settings"><summary>Settings</summary>${plugin.settings.map(() => `<label class="plugins-panel__setting"><span></span><input type="password" autocomplete="off" spellcheck="false"><small></small></label>`).join("")}
<button type="button" class="plugins-panel__save">Save</button></details>` : ""}
`;
li.querySelector(".plugins-panel__label").textContent = plugin.label;
const button = li.querySelector(".plugins-panel__run");
const status = li.querySelector(".plugins-panel__status");
button.addEventListener("click", () => this._run(plugin, button, status));
const routeButton = li.querySelector(".plugins-panel__run--route");
if (routeButton) {
const corridor = li.querySelector(".plugins-panel__corridor");
corridor.value = localStorage.getItem(CORRIDOR_KEY) || "5";
corridor.addEventListener("change", () => localStorage.setItem(CORRIDOR_KEY, corridor.value));
routeButton.addEventListener("click", () => this._run(plugin, routeButton, status, { route: "1", corridor_km: corridor.value }));
}
const fields = [...li.querySelectorAll(".plugins-panel__setting")];
fields.forEach((label, i) => {
const field = plugin.settings[i];
label.querySelector("span").textContent = field.label || field.key;
label.querySelector("small").textContent = field.help || "";
label.querySelector("input").placeholder = plugin.set?.includes(field.key) ? "set — paste to replace" : "not set";
});
li.querySelector(".plugins-panel__save")?.addEventListener("click", async () => {
const values = Object.fromEntries(plugin.settings.map((f, i) => [f.key, fields[i].querySelector("input").value]).filter(([, v]) => v));
try {
const response = await fetch(`/api/plugins/${encodeURIComponent(plugin.name)}/settings`, { method: "PUT", headers: { "Content-Type": "application/json" }, body: JSON.stringify(values) });
const data = await response.json().catch(() => ({}));
if (!response.ok) throw new Error(data.error || `save failed: ${response.status}`);
plugin.set = data.set;
fields.forEach((label, i) => { const input = label.querySelector("input"); input.value = ""; input.placeholder = data.set.includes(plugin.settings[i].key) ? "set — paste to replace" : "not set"; });
status.textContent = "Settings saved";
status.classList.remove("plugins-panel__status--error");
} catch (err) {
status.textContent = err.message;
status.classList.add("plugins-panel__status--error");
}
});
return li;
}
async _run(plugin, button, status) {
async _run(plugin, button, status, along = null) {
button.disabled = true;
status.textContent = "Running…";
try {
const bounds = this._map.getBounds();
const body = new URLSearchParams({
const body = new URLSearchParams(along || {
south: bounds.getSouth(),
west: bounds.getWest(),
north: bounds.getNorth(),
@@ -91,7 +131,7 @@ export class PluginsControl {
const data = await response.json().catch(() => ({}));
if (!response.ok) throw new Error(data.error || `run failed: ${response.status}`);
notifyGpxStoreChanged(data.path);
status.textContent = "Done";
status.textContent = `Done · ${data.count} found`;
status.classList.remove("plugins-panel__status--error");
} catch (err) {
// Plugins::RunError's message (e.g. "plugin exited with status 1")