Initial commit - Trekker V2 source
This commit is contained in:
commit
d71faf19e3
65 files changed
+3615
No files matched your search
@@ -0,0 +1,442 @@
|
||||
/* Trekker UI: full-screen MapLibre map; sidebar, slide-out panel, modals. */
|
||||
"use strict";
|
||||
|
||||
const $ = (id) => document.getElementById(id);
|
||||
const api = async (path, opts = {}) => {
|
||||
const resp = await fetch(path, opts);
|
||||
if (!resp.ok) {
|
||||
let detail = resp.statusText;
|
||||
try { detail = (await resp.json()).detail || detail; } catch {}
|
||||
throw new Error(detail);
|
||||
}
|
||||
return resp.json();
|
||||
};
|
||||
|
||||
const state = {
|
||||
config: null,
|
||||
routes: [],
|
||||
guides: [],
|
||||
current: null, // full TrekkerRoute of selected route
|
||||
weather: null, // cached weather for selected route
|
||||
online: navigator.onLine,
|
||||
};
|
||||
|
||||
/* ---------- map ---------- */
|
||||
let map;
|
||||
function initMap(cfg) {
|
||||
// Base tiles via the backend-configured source; offline packs are served
|
||||
// from /api/offline-maps/tiles and tried first when offline.
|
||||
const sources = {
|
||||
base: {
|
||||
type: "raster",
|
||||
tiles: state.online
|
||||
? [cfg.tiles_base_url]
|
||||
: ["/api/offline-maps/tiles/base/{z}/{x}/{y}.png"],
|
||||
tileSize: 256,
|
||||
attribution: "© OpenStreetMap contributors",
|
||||
},
|
||||
};
|
||||
map = new maplibregl.Map({
|
||||
container: "map",
|
||||
style: { version: 8, sources, layers: [{ id: "base", type: "raster", source: "base" }] },
|
||||
center: [-84.36, 36.2], // Windrock-ish default
|
||||
zoom: 11,
|
||||
});
|
||||
map.addControl(new maplibregl.NavigationControl());
|
||||
map.on("load", () => {
|
||||
map.addSource("route", { type: "geojson", data: emptyFC() });
|
||||
map.addLayer({
|
||||
id: "route-line", type: "line", source: "route",
|
||||
paint: { "line-color": ["coalesce", ["get", "color"], "#2d6cdf"], "line-width": 4 },
|
||||
});
|
||||
map.addSource("waypoints", { type: "geojson", data: emptyFC() });
|
||||
map.addLayer({
|
||||
id: "wpt-circles", type: "circle", source: "waypoints",
|
||||
paint: { "circle-radius": 6, "circle-color": "#e67e22", "circle-stroke-color": "#fff", "circle-stroke-width": 1.5 },
|
||||
});
|
||||
map.addLayer({
|
||||
id: "wpt-labels", type: "symbol", source: "waypoints",
|
||||
layout: { "text-field": ["get", "name"], "text-size": 11, "text-offset": [0, 1.2] },
|
||||
paint: { "text-color": "#fff", "text-halo-color": "#000", "text-halo-width": 1 },
|
||||
});
|
||||
map.on("click", "wpt-circles", (e) => {
|
||||
const f = e.features[0];
|
||||
new maplibregl.Popup().setLngLat(f.geometry.coordinates)
|
||||
.setHTML(`<b>${f.properties.name || "Waypoint"}</b><br>${f.properties.desc || ""}`)
|
||||
.addTo(map);
|
||||
});
|
||||
});
|
||||
}
|
||||
const emptyFC = () => ({ type: "FeatureCollection", features: [] });
|
||||
|
||||
function gradeColor(g) {
|
||||
const a = Math.abs(g);
|
||||
return a < 5 ? "#2ecc71" : a < 10 ? "#f1c40f" : a < 18 ? "#e67e22" : "#e74c3c";
|
||||
}
|
||||
function precipColor(p) {
|
||||
p = p || 0;
|
||||
return p < 20 ? "#d6eaf8" : p < 50 ? "#5dade2" : p < 80 ? "#2e86c1" : "#1b4f72";
|
||||
}
|
||||
|
||||
function renderRouteOnMap() {
|
||||
const r = state.current;
|
||||
if (!r || !map.getSource("route")) return;
|
||||
const useGrade = $("layer-grade").checked;
|
||||
const useWeather = $("layer-weather").checked && state.weather;
|
||||
const tier = $("weather-tier").value;
|
||||
const features = r.segments.map((seg) => {
|
||||
let color = "#2d6cdf";
|
||||
if (useWeather) {
|
||||
const tiers = (state.weather.segments || {})[String(seg.index)] || {};
|
||||
const buckets = tiers[tier] || tiers.daily || [];
|
||||
const now = buckets[0] || {};
|
||||
color = precipColor(now.precip_prob_max);
|
||||
} else if (useGrade) {
|
||||
color = gradeColor(seg.grade_pct_max);
|
||||
}
|
||||
return {
|
||||
type: "Feature",
|
||||
properties: { color, name: seg.name },
|
||||
geometry: {
|
||||
type: "LineString",
|
||||
coordinates: r.points.slice(seg.start_idx, seg.end_idx + 1).map((p) => [p.lon, p.lat]),
|
||||
},
|
||||
};
|
||||
});
|
||||
if (!features.length && r.points.length > 1) {
|
||||
features.push({
|
||||
type: "Feature", properties: { color: "#2d6cdf" },
|
||||
geometry: { type: "LineString", coordinates: r.points.map((p) => [p.lon, p.lat]) },
|
||||
});
|
||||
}
|
||||
map.getSource("route").setData({ type: "FeatureCollection", features });
|
||||
map.getSource("waypoints").setData({
|
||||
type: "FeatureCollection",
|
||||
features: r.waypoints.map((w) => ({
|
||||
type: "Feature",
|
||||
properties: { name: w.name, desc: w.desc },
|
||||
geometry: { type: "Point", coordinates: [w.lon, w.lat] },
|
||||
})),
|
||||
});
|
||||
}
|
||||
|
||||
/* ---------- sidebar: routes ---------- */
|
||||
async function loadRoutes() {
|
||||
state.routes = await api("/api/routes");
|
||||
const filter = $("route-search").value.toLowerCase();
|
||||
const ul = $("route-list");
|
||||
ul.innerHTML = "";
|
||||
for (const r of state.routes) {
|
||||
if (filter && !r.name.toLowerCase().includes(filter)) continue;
|
||||
const li = document.createElement("li");
|
||||
if (state.current && state.current.id === r.id) li.classList.add("active");
|
||||
const mi = (r.stats.distance_m / 1609.344).toFixed(1);
|
||||
li.innerHTML = `<b>${r.name}</b><span class="route-sub">${r.source} · ${mi} mi · ${r.created_at.slice(0, 10)}</span>`;
|
||||
li.onclick = () => selectRoute(r.id);
|
||||
ul.appendChild(li);
|
||||
}
|
||||
}
|
||||
|
||||
async function selectRoute(id) {
|
||||
state.current = await api(`/api/routes/${id}`);
|
||||
try { state.weather = await api(`/api/routes/${id}/weather`); }
|
||||
catch { state.weather = null; }
|
||||
const b = boundsOf(state.current);
|
||||
if (b) map.fitBounds(b, { padding: 60 });
|
||||
renderRouteOnMap();
|
||||
openRoutePanel();
|
||||
loadRoutes();
|
||||
}
|
||||
function boundsOf(r) {
|
||||
if (!r.points.length) return null;
|
||||
const lons = r.points.map((p) => p.lon), lats = r.points.map((p) => p.lat);
|
||||
return [[Math.min(...lons), Math.min(...lats)], [Math.max(...lons), Math.max(...lats)]];
|
||||
}
|
||||
|
||||
/* ---------- route panel ---------- */
|
||||
function openRoutePanel() {
|
||||
const r = state.current;
|
||||
$("route-panel").hidden = false;
|
||||
$("rp-name").textContent = r.name;
|
||||
const mi = (r.stats.distance_m / 1609.344).toFixed(1);
|
||||
const gain = Math.round(r.stats.elevation_gain_m * 3.28084);
|
||||
const loss = Math.round(r.stats.elevation_loss_m * 3.28084);
|
||||
$("rp-meta").textContent = `${r.source} · ${mi} mi · +${gain} ft / −${loss} ft`;
|
||||
$("rp-export-gpx").href = `/api/routes/${r.id}/export?format=gpx`;
|
||||
$("rp-export-kml").href = `/api/routes/${r.id}/export?format=kml`;
|
||||
const ul = $("rp-segments");
|
||||
ul.innerHTML = "";
|
||||
for (const s of r.segments) {
|
||||
const li = document.createElement("li");
|
||||
li.style.borderLeftColor = gradeColor(s.grade_pct_max);
|
||||
li.innerHTML = `<b>${s.name}</b><br>${(s.distance_m / 1609.344).toFixed(2)} mi · max grade ${s.grade_pct_max}%`;
|
||||
ul.appendChild(li);
|
||||
}
|
||||
const sel = $("rp-guide");
|
||||
sel.innerHTML = `<option value="">— no trail guide —</option>` +
|
||||
state.guides.map((g) => `<option value="${g.id}" ${g.id === r.trail_guide_id ? "selected" : ""}>${g.name}</option>`).join("");
|
||||
$("rp-card-output").innerHTML = "";
|
||||
renderWeatherBadge();
|
||||
}
|
||||
|
||||
function renderWeatherBadge() {
|
||||
const el = $("rp-weather");
|
||||
if (!state.weather) { el.hidden = true; return; }
|
||||
const seg0 = (state.weather.segments || {})["0"] || {};
|
||||
const today = (seg0.daily || [])[0];
|
||||
if (!today) { el.hidden = true; return; }
|
||||
el.hidden = false;
|
||||
el.innerHTML = `🌡 ${Math.round(today.temp_min_f)}–${Math.round(today.temp_max_f)}°F · ` +
|
||||
`🌧 ${today.precip_prob_max ?? "?"}% · 💨 ${Math.round(today.wind_max_kmh || 0)} km/h` +
|
||||
(today.lightning_risk ? " · ⚡" : "");
|
||||
}
|
||||
|
||||
/* ---------- modals ---------- */
|
||||
function openModal(id) {
|
||||
$("modal-backdrop").hidden = false;
|
||||
for (const m of document.querySelectorAll(".modal")) m.hidden = m.id !== id;
|
||||
}
|
||||
function closeModal() { $("modal-backdrop").hidden = true; }
|
||||
|
||||
/* ---------- trail guide review form ---------- */
|
||||
let guideDraft = null;
|
||||
function showGuideReview(draft) {
|
||||
guideDraft = draft;
|
||||
const f = $("guide-review");
|
||||
f.hidden = false;
|
||||
f.name.value = draft.name || "";
|
||||
f.difficulty.value = draft.difficulty || "";
|
||||
f.obstacle_types.value = (draft.obstacle_types || []).join(", ");
|
||||
f.water_crossings.value = (draft.water_crossings || [])
|
||||
.map((w) => [w.name || "", w.depth_ft ?? "", w.notes || ""].join(" | ")).join("\n");
|
||||
f.gate_codes.value = (draft.gate_codes || []).join(", ");
|
||||
f.vehicle_recommendations.value = (draft.vehicle_recommendations || []).join(", ");
|
||||
f.warnings.value = (draft.warnings || []).join("\n");
|
||||
f.notes.value = draft.notes || "";
|
||||
}
|
||||
|
||||
const csv = (v) => v.split(",").map((s) => s.trim()).filter(Boolean);
|
||||
const lines = (v) => v.split("\n").map((s) => s.trim()).filter(Boolean);
|
||||
|
||||
/* ---------- offline packs ---------- */
|
||||
async function loadPacks() {
|
||||
const packs = await api("/api/offline-maps");
|
||||
const ul = $("pack-list");
|
||||
ul.innerHTML = "";
|
||||
let anyActive = false;
|
||||
for (const p of packs) {
|
||||
const li = document.createElement("li");
|
||||
const pct = p.tile_count ? Math.round((p.tiles_done / p.tile_count) * 100) : 0;
|
||||
const status = p.status === "downloading" ? `downloading ${pct}%` :
|
||||
p.status === "ready" ? `ready · ${(p.size_bytes / 1e6).toFixed(1)} MB` : p.status;
|
||||
li.innerHTML = `<b>${p.name}</b><span class="pack-sub">z${p.min_zoom}–${p.max_zoom} · ${status}</span>`;
|
||||
li.title = "Click to delete";
|
||||
li.onclick = async () => {
|
||||
if (confirm(`Delete offline pack "${p.name}"?`)) {
|
||||
await api(`/api/offline-maps/${p.id}`, { method: "DELETE" });
|
||||
loadPacks();
|
||||
}
|
||||
};
|
||||
ul.appendChild(li);
|
||||
if (p.status === "downloading" || p.status === "queued") anyActive = true;
|
||||
}
|
||||
if (anyActive) setTimeout(loadPacks, 2000);
|
||||
}
|
||||
|
||||
/* ---------- online/offline state ---------- */
|
||||
function updateNetState() {
|
||||
state.online = navigator.onLine;
|
||||
const badge = $("net-badge");
|
||||
badge.textContent = state.online ? "online" : "offline";
|
||||
badge.className = `badge ${state.online ? "online" : "offline"}`;
|
||||
$("btn-sync").hidden = !(state.online && state.config && state.config.sync_peer_configured);
|
||||
$("rp-weather-refresh").disabled = !state.online;
|
||||
}
|
||||
|
||||
/* ---------- wire-up ---------- */
|
||||
async function main() {
|
||||
try { state.config = await api("/api/config"); } catch { state.config = {}; }
|
||||
initMap(state.config);
|
||||
updateNetState();
|
||||
window.addEventListener("online", updateNetState);
|
||||
window.addEventListener("offline", updateNetState);
|
||||
|
||||
$("sidebar-toggle").onclick = () => $("sidebar").classList.toggle("collapsed");
|
||||
$("route-search").oninput = loadRoutes;
|
||||
$("layer-grade").onchange = renderRouteOnMap;
|
||||
$("layer-weather").onchange = renderRouteOnMap;
|
||||
$("weather-tier").onchange = renderRouteOnMap;
|
||||
|
||||
document.body.addEventListener("click", (e) => {
|
||||
const t = e.target.closest("[data-close]");
|
||||
if (!t) return;
|
||||
if (t.dataset.close === "modal") closeModal();
|
||||
else $(t.dataset.close).hidden = true;
|
||||
});
|
||||
|
||||
$("btn-upload").onclick = () => { $("upload-status").textContent = ""; openModal("modal-upload"); };
|
||||
$("gpx-submit").onclick = async () => {
|
||||
const file = $("gpx-file").files[0];
|
||||
if (!file) return;
|
||||
const fd = new FormData();
|
||||
fd.append("file", file);
|
||||
$("upload-status").textContent = "Uploading…";
|
||||
try {
|
||||
const route = await api("/api/routes/upload", { method: "POST", body: fd });
|
||||
closeModal();
|
||||
await loadRoutes();
|
||||
selectRoute(route.id);
|
||||
} catch (err) { $("upload-status").textContent = err.message; }
|
||||
};
|
||||
|
||||
$("btn-scrape").onclick = () => {
|
||||
$("guide-status").textContent = "";
|
||||
$("guide-review").hidden = true;
|
||||
openModal("modal-guide");
|
||||
};
|
||||
$("guide-scrape").onclick = async () => {
|
||||
const url = $("guide-url").value.trim();
|
||||
if (!url) return;
|
||||
$("guide-status").textContent = "Scraping + extracting…";
|
||||
try {
|
||||
showGuideReview(await api("/api/trails/scrape", {
|
||||
method: "POST", headers: { "Content-Type": "application/json" },
|
||||
body: JSON.stringify({ url }),
|
||||
}));
|
||||
$("guide-status").textContent = "Review the extraction, then save.";
|
||||
} catch (err) { $("guide-status").textContent = err.message; }
|
||||
};
|
||||
$("guide-pdf-submit").onclick = async () => {
|
||||
const file = $("guide-pdf").files[0];
|
||||
if (!file) return;
|
||||
const fd = new FormData();
|
||||
fd.append("file", file);
|
||||
$("guide-status").textContent = "Extracting from PDF…";
|
||||
try {
|
||||
showGuideReview(await api("/api/trails/upload-pdf", { method: "POST", body: fd }));
|
||||
$("guide-status").textContent = "Review the extraction, then save.";
|
||||
} catch (err) { $("guide-status").textContent = err.message; }
|
||||
};
|
||||
$("guide-review").onsubmit = async (e) => {
|
||||
e.preventDefault();
|
||||
const f = e.target;
|
||||
const guide = Object.assign({}, guideDraft, {
|
||||
name: f.name.value,
|
||||
difficulty: f.difficulty.value || null,
|
||||
obstacle_types: csv(f.obstacle_types.value),
|
||||
water_crossings: lines(f.water_crossings.value).map((ln) => {
|
||||
const [name, depth, notes] = ln.split("|").map((s) => s.trim());
|
||||
return { name: name || null, depth_ft: depth ? parseFloat(depth) : null, notes: notes || null };
|
||||
}),
|
||||
gate_codes: csv(f.gate_codes.value),
|
||||
vehicle_recommendations: csv(f.vehicle_recommendations.value),
|
||||
warnings: lines(f.warnings.value),
|
||||
notes: f.notes.value || null,
|
||||
});
|
||||
await api("/api/trails", {
|
||||
method: "POST", headers: { "Content-Type": "application/json" },
|
||||
body: JSON.stringify(guide),
|
||||
});
|
||||
state.guides = await api("/api/trails");
|
||||
closeModal();
|
||||
if (state.current) openRoutePanel();
|
||||
};
|
||||
|
||||
$("rp-guide").onchange = async (e) => {
|
||||
const r = state.current;
|
||||
state.current = await api(`/api/routes/${r.id}/trail-guide`, {
|
||||
method: "PUT", headers: { "Content-Type": "application/json" },
|
||||
body: JSON.stringify({ trail_guide_id: e.target.value || null }),
|
||||
});
|
||||
};
|
||||
$("rp-delete").onclick = async () => {
|
||||
if (!confirm(`Delete route "${state.current.name}"?`)) return;
|
||||
await api(`/api/routes/${state.current.id}`, { method: "DELETE" });
|
||||
state.current = null;
|
||||
$("route-panel").hidden = true;
|
||||
map.getSource("route").setData(emptyFC());
|
||||
map.getSource("waypoints").setData(emptyFC());
|
||||
loadRoutes();
|
||||
};
|
||||
$("rp-weather-refresh").onclick = async () => {
|
||||
const btn = $("rp-weather-refresh");
|
||||
btn.disabled = true;
|
||||
try {
|
||||
state.weather = await api(`/api/routes/${state.current.id}/refresh-weather`, { method: "POST" });
|
||||
renderWeatherBadge();
|
||||
renderRouteOnMap();
|
||||
} catch (err) { alert(`Weather refresh failed: ${err.message}`); }
|
||||
btn.disabled = false;
|
||||
};
|
||||
$("rp-card").onclick = async () => {
|
||||
try {
|
||||
const asset = await api(`/api/routes/${state.current.id}/generate/trail_card`, { method: "POST" });
|
||||
renderTrailCard(asset.data);
|
||||
} catch (err) { alert(err.message); }
|
||||
};
|
||||
|
||||
$("btn-offline").onclick = () => { $("pack-estimate").textContent = ""; openModal("modal-offline"); };
|
||||
const packBody = () => {
|
||||
const b = map.getBounds();
|
||||
return {
|
||||
name: $("pack-name").value,
|
||||
bbox: [b.getWest(), b.getSouth(), b.getEast(), b.getNorth()],
|
||||
min_zoom: parseInt($("pack-minz").value, 10),
|
||||
max_zoom: parseInt($("pack-maxz").value, 10),
|
||||
layers: $("pack-terrain").checked ? ["base", "terrain"] : ["base"],
|
||||
};
|
||||
};
|
||||
$("pack-estimate-btn").onclick = async () => {
|
||||
try {
|
||||
const est = await api("/api/offline-maps/estimate", {
|
||||
method: "POST", headers: { "Content-Type": "application/json" },
|
||||
body: JSON.stringify(packBody()),
|
||||
});
|
||||
$("pack-estimate").textContent =
|
||||
`${est.tile_count} tiles ≈ ${(est.estimated_bytes / 1e6).toFixed(1)} MB`;
|
||||
} catch (err) { $("pack-estimate").textContent = err.message; }
|
||||
};
|
||||
$("pack-create").onclick = async () => {
|
||||
try {
|
||||
await api("/api/offline-maps", {
|
||||
method: "POST", headers: { "Content-Type": "application/json" },
|
||||
body: JSON.stringify(packBody()),
|
||||
});
|
||||
closeModal();
|
||||
loadPacks();
|
||||
} catch (err) { $("pack-estimate").textContent = err.message; }
|
||||
};
|
||||
|
||||
$("btn-sync").onclick = async () => {
|
||||
try {
|
||||
const res = await api("/api/sync", {
|
||||
method: "POST", headers: { "Content-Type": "application/json" }, body: "{}",
|
||||
});
|
||||
alert(`Synced. Pulled ${res.pulled.routes} routes, ${res.pulled.trail_guides} guides.`);
|
||||
loadRoutes();
|
||||
} catch (err) { alert(err.message); }
|
||||
};
|
||||
|
||||
state.guides = await api("/api/trails").catch(() => []);
|
||||
await loadRoutes();
|
||||
loadPacks();
|
||||
}
|
||||
|
||||
function renderTrailCard(card) {
|
||||
const out = $("rp-card-output");
|
||||
const guide = card.guide;
|
||||
out.innerHTML = `<div class="card"><h4>Trail card — ${card.route_name}</h4>
|
||||
<div>${card.total_distance_mi} mi · +${card.total_gain_ft} ft</div>
|
||||
${guide ? `<div>Difficulty: ${guide.difficulty || "n/a"}</div>
|
||||
${guide.gate_codes.length ? `<div>Gate codes: ${guide.gate_codes.join(", ")}</div>` : ""}
|
||||
${guide.warnings.map((w) => `<div>⚠ ${w}</div>`).join("")}` : "<div><i>No trail guide linked.</i></div>"}
|
||||
${card.segments.map((s) => `<div class="card">
|
||||
<h4>${s.name}</h4>
|
||||
<div>${s.distance_mi} mi · max grade ${s.grade_pct_max}% · ${s.difficulty}</div>
|
||||
${s.obstacles.length ? `<div>Obstacles: ${s.obstacles.join(", ")}</div>` : ""}
|
||||
${s.weather_today ? `<div>Today: ${Math.round(s.weather_today.temp_min_f)}–${Math.round(s.weather_today.temp_max_f)}°F, rain ${s.weather_today.precip_prob_max ?? "?"}%</div>` : ""}
|
||||
</div>`).join("")}
|
||||
</div>`;
|
||||
}
|
||||
|
||||
main();
|
||||
+124
@@ -0,0 +1,124 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
||||
<title>Trekker</title>
|
||||
<link rel="stylesheet" href="https://unpkg.com/maplibre-gl@4.7.1/dist/maplibre-gl.css" />
|
||||
<link rel="stylesheet" href="/app/static/styles.css" />
|
||||
</head>
|
||||
<body>
|
||||
<div id="map"></div>
|
||||
|
||||
<!-- collapsible left sidebar: the map is the app -->
|
||||
<aside id="sidebar">
|
||||
<header>
|
||||
<h1>Trekker</h1>
|
||||
<span id="net-badge" class="badge online">online</span>
|
||||
</header>
|
||||
<div class="sidebar-actions">
|
||||
<button id="btn-upload">Upload GPX</button>
|
||||
<button id="btn-scrape">Trail guide</button>
|
||||
<button id="btn-offline">Save area</button>
|
||||
<button id="btn-sync" hidden>Sync</button>
|
||||
</div>
|
||||
<input id="route-search" type="search" placeholder="Filter routes…" />
|
||||
<section>
|
||||
<h2>Routes</h2>
|
||||
<ul id="route-list"></ul>
|
||||
</section>
|
||||
<section>
|
||||
<h2>Layers</h2>
|
||||
<label><input type="checkbox" id="layer-grade" /> Grade coloring</label>
|
||||
<label><input type="checkbox" id="layer-weather" /> Weather overlay</label>
|
||||
<label>Weather tier
|
||||
<select id="weather-tier">
|
||||
<option value="daily">Daily</option>
|
||||
<option value="12h">12-hour</option>
|
||||
<option value="6h">6-hour</option>
|
||||
<option value="hourly">Hourly</option>
|
||||
</select>
|
||||
</label>
|
||||
</section>
|
||||
<section>
|
||||
<h2>Offline packs</h2>
|
||||
<ul id="pack-list"></ul>
|
||||
</section>
|
||||
</aside>
|
||||
<button id="sidebar-toggle" title="Toggle sidebar">☰</button>
|
||||
|
||||
<!-- slide-out route panel -->
|
||||
<aside id="route-panel" hidden>
|
||||
<button class="close" data-close="route-panel">×</button>
|
||||
<h2 id="rp-name"></h2>
|
||||
<p id="rp-meta"></p>
|
||||
<div id="rp-weather" class="weather-badge" hidden></div>
|
||||
<div class="rp-actions">
|
||||
<button id="rp-card">Trail card</button>
|
||||
<button id="rp-weather-refresh">Weather ⟳</button>
|
||||
<a id="rp-export-gpx" class="button">GPX ↓</a>
|
||||
<a id="rp-export-kml" class="button">KML ↓</a>
|
||||
<button id="rp-delete" class="danger">Delete</button>
|
||||
</div>
|
||||
<label>Trail guide
|
||||
<select id="rp-guide"></select>
|
||||
</label>
|
||||
<h3>Segments</h3>
|
||||
<ul id="rp-segments"></ul>
|
||||
<div id="rp-card-output"></div>
|
||||
</aside>
|
||||
|
||||
<!-- modals -->
|
||||
<div id="modal-backdrop" hidden>
|
||||
<div id="modal-upload" class="modal" hidden>
|
||||
<button class="close" data-close="modal">×</button>
|
||||
<h2>Upload GPX</h2>
|
||||
<input type="file" id="gpx-file" accept=".gpx" />
|
||||
<button id="gpx-submit">Upload</button>
|
||||
<p class="status" id="upload-status"></p>
|
||||
</div>
|
||||
|
||||
<div id="modal-guide" class="modal" hidden>
|
||||
<button class="close" data-close="modal">×</button>
|
||||
<h2>Trail guide</h2>
|
||||
<div id="guide-source">
|
||||
<label>Trail URL <input type="url" id="guide-url" placeholder="https://…" /></label>
|
||||
<button id="guide-scrape">Scrape</button>
|
||||
<p>— or —</p>
|
||||
<input type="file" id="guide-pdf" accept=".pdf" />
|
||||
<button id="guide-pdf-submit">Extract from PDF</button>
|
||||
<p class="status" id="guide-status"></p>
|
||||
</div>
|
||||
<form id="guide-review" hidden>
|
||||
<h3>Review before saving</h3>
|
||||
<label>Name <input name="name" required /></label>
|
||||
<label>Difficulty <input name="difficulty" /></label>
|
||||
<label>Obstacles (comma-sep) <input name="obstacle_types" /></label>
|
||||
<label>Water crossings (one/line: name | depth_ft | notes)
|
||||
<textarea name="water_crossings" rows="3"></textarea></label>
|
||||
<label>Gate codes (comma-sep) <input name="gate_codes" /></label>
|
||||
<label>Vehicle recs (comma-sep) <input name="vehicle_recommendations" /></label>
|
||||
<label>Warnings (one/line) <textarea name="warnings" rows="2"></textarea></label>
|
||||
<label>Notes <textarea name="notes" rows="3"></textarea></label>
|
||||
<button type="submit">Save guide</button>
|
||||
</form>
|
||||
</div>
|
||||
|
||||
<div id="modal-offline" class="modal" hidden>
|
||||
<button class="close" data-close="modal">×</button>
|
||||
<h2>Save area for offline</h2>
|
||||
<p>Saves the current viewport as an offline map pack.</p>
|
||||
<label>Name <input id="pack-name" value="Offline area" /></label>
|
||||
<label>Min zoom <input id="pack-minz" type="number" value="10" min="0" max="16" /></label>
|
||||
<label>Max zoom <input id="pack-maxz" type="number" value="14" min="0" max="16" /></label>
|
||||
<label><input type="checkbox" id="pack-terrain" checked /> Include terrain tiles</label>
|
||||
<p class="status" id="pack-estimate"></p>
|
||||
<button id="pack-estimate-btn">Estimate</button>
|
||||
<button id="pack-create">Download pack</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script src="https://unpkg.com/maplibre-gl@4.7.1/dist/maplibre-gl.js"></script>
|
||||
<script src="/app/static/app.js"></script>
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1,84 @@
|
||||
* { box-sizing: border-box; }
|
||||
html, body { margin: 0; height: 100%; font-family: system-ui, sans-serif; }
|
||||
#map { position: absolute; inset: 0; }
|
||||
|
||||
#sidebar {
|
||||
position: absolute; top: 0; left: 0; bottom: 0; width: 300px;
|
||||
background: rgba(20, 24, 28, 0.94); color: #eee; z-index: 10;
|
||||
padding: 12px; overflow-y: auto; transition: transform 0.2s;
|
||||
}
|
||||
#sidebar.collapsed { transform: translateX(-100%); }
|
||||
#sidebar header { display: flex; align-items: center; justify-content: space-between; }
|
||||
#sidebar h1 { font-size: 20px; margin: 4px 0; }
|
||||
#sidebar h2 { font-size: 13px; text-transform: uppercase; color: #9ab; margin: 14px 0 6px; }
|
||||
#sidebar section label { display: block; margin: 4px 0; font-size: 14px; }
|
||||
#sidebar-toggle {
|
||||
position: absolute; top: 10px; left: 310px; z-index: 11;
|
||||
transition: left 0.2s; background: #14181c; color: #eee;
|
||||
border: none; border-radius: 4px; padding: 6px 10px; cursor: pointer;
|
||||
}
|
||||
#sidebar.collapsed ~ #sidebar-toggle { left: 10px; }
|
||||
|
||||
.sidebar-actions { display: flex; flex-wrap: wrap; gap: 6px; margin: 8px 0; }
|
||||
button, .button {
|
||||
background: #2d6cdf; color: #fff; border: none; border-radius: 4px;
|
||||
padding: 6px 10px; font-size: 13px; cursor: pointer; text-decoration: none;
|
||||
display: inline-block;
|
||||
}
|
||||
button.danger { background: #c0392b; }
|
||||
button.close {
|
||||
position: absolute; top: 6px; right: 6px; background: transparent;
|
||||
font-size: 20px; color: inherit;
|
||||
}
|
||||
#route-search { width: 100%; padding: 6px; border-radius: 4px; border: none; margin: 4px 0; }
|
||||
|
||||
#route-list, #pack-list { list-style: none; margin: 0; padding: 0; }
|
||||
#route-list li, #pack-list li {
|
||||
padding: 8px; border-radius: 4px; cursor: pointer; font-size: 14px;
|
||||
}
|
||||
#route-list li:hover { background: rgba(255,255,255,0.08); }
|
||||
#route-list li.active { background: rgba(45,108,223,0.35); }
|
||||
.route-sub, .pack-sub { font-size: 12px; color: #9ab; display: block; }
|
||||
|
||||
.badge { font-size: 11px; padding: 2px 8px; border-radius: 10px; }
|
||||
.badge.online { background: #27ae60; }
|
||||
.badge.offline { background: #c0392b; }
|
||||
|
||||
#route-panel {
|
||||
position: absolute; top: 0; right: 0; bottom: 0; width: 360px;
|
||||
background: rgba(20, 24, 28, 0.96); color: #eee; z-index: 10;
|
||||
padding: 16px; overflow-y: auto;
|
||||
}
|
||||
#route-panel h2 { margin: 4px 0; }
|
||||
#route-panel h3 { font-size: 13px; text-transform: uppercase; color: #9ab; }
|
||||
#route-panel label { display: block; margin: 10px 0; font-size: 14px; }
|
||||
#route-panel select { width: 100%; padding: 4px; }
|
||||
.rp-actions { display: flex; flex-wrap: wrap; gap: 6px; margin: 10px 0; }
|
||||
#rp-segments { list-style: none; padding: 0; font-size: 13px; }
|
||||
#rp-segments li { padding: 6px; border-left: 3px solid #2d6cdf; margin: 4px 0; background: rgba(255,255,255,0.05); }
|
||||
|
||||
.weather-badge {
|
||||
display: inline-block; background: rgba(45,108,223,0.25);
|
||||
border-radius: 6px; padding: 6px 10px; font-size: 13px; margin: 6px 0;
|
||||
}
|
||||
|
||||
#rp-card-output .card {
|
||||
background: rgba(255,255,255,0.06); border-radius: 6px; padding: 10px;
|
||||
margin: 10px 0; font-size: 13px;
|
||||
}
|
||||
#rp-card-output .card h4 { margin: 4px 0; }
|
||||
|
||||
#modal-backdrop {
|
||||
position: fixed; inset: 0; background: rgba(0,0,0,0.6); z-index: 20;
|
||||
display: flex; align-items: center; justify-content: center;
|
||||
}
|
||||
.modal {
|
||||
position: relative; background: #1c2228; color: #eee; border-radius: 8px;
|
||||
padding: 20px; width: min(440px, 92vw); max-height: 86vh; overflow-y: auto;
|
||||
}
|
||||
.modal label { display: block; margin: 8px 0; font-size: 14px; }
|
||||
.modal input:not([type="checkbox"]), .modal textarea, .modal select {
|
||||
width: 100%; padding: 6px; border-radius: 4px; border: 1px solid #445;
|
||||
background: #11161b; color: #eee;
|
||||
}
|
||||
.status { font-size: 13px; color: #f1c40f; min-height: 1em; }
|
||||
Reference in new issue
Block a user