Library as on the artboard (after Locus Map), renamed from Tracks & Points: find on top (text, kind chips with counts, shown on the map only, Folders | List), one folder level at a time with ← up and the path (the up button takes a dragged item a level up), folders first, an eye per row (● shown, ◐ some of a folder, ○ none; a folder's eye shows or hides everything in it), a track's points open from its ›; while searching or in List every match flat with its folder; totals and Hide all at the foot; uploads, new folders and drops on blank space go to the folder open. The elevation profile docked under the map: the map gives up its height; a route shows its own profile once the terrain is sampled (not while driving) and hides it when cleared
CI / check (push) Successful in 22s
CI / deploy (push) Successful in 18s

This commit is contained in:
randy committed 2026-12-03 09:39:19 +01:00
1 parent fc8564fe3b
commit 91fa9cec41
6 files changed
+545 -155

No files matched your search

+239
View File
@@ -4370,3 +4370,242 @@ html.follow-3d .maplibregl-ctrl-overview-map { display: none; }
padding: 0; padding: 0;
min-height: 0; min-height: 0;
} }
/* ---- Library, as on the artboard (gpx.js): find on top, one level of
folders or a flat list, an eye per row, totals and Hide all at the foot. */
.lib-find {
display: flex;
flex-direction: column;
gap: 10px;
padding: 12px 16px 10px;
border-bottom: 1px solid var(--ui-line);
}
.lib-find__input {
height: 40px;
padding: 0 12px;
border: 2px solid var(--accent);
border-radius: 8px;
background: var(--ui-bg);
color: var(--ui-fg);
font-family: inherit;
font-size: 15px;
}
.lib-find__kinds,
.lib-find__bar {
display: flex;
flex-wrap: wrap;
align-items: center;
gap: 6px;
}
.gpx-panel .lib-chip {
min-height: 30px;
height: 30px;
padding: 0 10px;
border: 1px solid var(--ui-line);
border-radius: 15px;
background: var(--ui-bg);
color: var(--ui-fg);
font-family: inherit;
font-size: 13px;
font-weight: 600;
cursor: pointer;
}
.gpx-panel .lib-chip[aria-pressed="true"] {
border-color: var(--accent);
background: var(--accent-bg);
color: var(--accent);
}
.lib-chip small {
opacity: 0.7;
}
.lib-seg {
display: flex;
margin-left: auto;
border: 1px solid var(--ui-line);
border-radius: 6px;
overflow: hidden;
}
.gpx-panel .lib-seg button {
min-height: 30px;
height: 30px;
padding: 0 12px;
border: none;
background: none;
color: var(--ui-fg);
font-family: inherit;
font-size: 13px;
font-weight: 600;
cursor: pointer;
}
.gpx-panel .lib-seg button[aria-pressed="true"] {
background: var(--accent);
color: #fff;
}
.lib-crumb {
display: flex;
align-items: center;
gap: 8px;
padding: 8px 16px;
border-bottom: 1px solid var(--ui-line);
font-size: 14px;
}
.lib-crumb[hidden] {
display: none;
}
.gpx-panel .lib-crumb__up {
min-height: 32px;
width: 32px;
border: 1px solid var(--ui-line);
border-radius: 6px;
background: none;
color: var(--ui-fg);
font-size: 16px;
cursor: pointer;
}
.lib-crumb__path {
color: var(--ui-muted);
}
.lib-crumb b {
min-width: 0;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
}
.lib-crumb small {
margin-left: auto;
color: var(--ui-muted);
font-size: 12px;
white-space: nowrap;
}
.gpx-panel .gpx-tree {
padding: 0;
}
.lib-list {
list-style: none;
margin: 0;
padding: 0;
}
.lib-row {
display: flex;
align-items: center;
gap: 10px;
min-height: 52px;
padding: 0 8px 0 16px;
border-bottom: 1px solid var(--ui-line);
}
.lib-row:hover {
background: var(--ui-bg-2);
}
.lib-row.gpx-drop-hover {
background: var(--accent-bg);
}
.lib-row__icon {
width: 26px;
flex: none;
text-align: center;
font-size: 18px;
color: var(--ui-muted);
}
.lib-row__text {
flex: 1;
min-width: 0;
display: flex;
flex-direction: column;
cursor: pointer;
}
.lib-row__name {
font-size: 15px;
font-weight: 600;
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
}
.lib-row__name--folder {
font-weight: 700;
}
.lib-row__meta {
font-size: 12px;
color: var(--ui-muted);
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
}
.lib-row__aside {
color: var(--ui-muted);
font-size: 16px;
cursor: pointer;
}
.gpx-panel .lib-eye {
width: 36px;
min-height: 36px;
flex: none;
border: none;
background: none;
color: var(--accent);
font-size: 18px;
cursor: pointer;
}
.gpx-panel .lib-eye--none {
color: var(--ui-muted);
}
.lib-foot {
display: flex;
align-items: center;
justify-content: space-between;
gap: 8px;
margin-top: auto;
padding: 8px 16px;
border-top: 1px solid var(--ui-line);
font-size: 13px;
color: var(--ui-muted);
}
.gpx-panel .lib-foot button {
min-height: 32px;
padding: 0 12px;
border: 1px solid var(--ui-line);
border-radius: 6px;
background: none;
color: var(--ui-fg);
font-family: inherit;
font-size: 13px;
font-weight: 600;
cursor: pointer;
}
/* the profile docked under the map: the map ends above it (track_profile.js) */
#map {
margin-bottom: var(--profile-h, 0px);
}
html.driving #map {
margin-bottom: 0;
}
+267 -152
View File
@@ -4,9 +4,6 @@ import {
GPX_ICON, GPX_ICON,
NEW_FOLDER_ICON, NEW_FOLDER_ICON,
UPLOAD_ICON, UPLOAD_ICON,
WAYPOINT_ICON,
TRACK_ICON,
ROUTE_ICON,
DOWNLOAD_ICON, DOWNLOAD_ICON,
SYNC_ICON, SYNC_ICON,
MAP_MARKER_ICON, MAP_MARKER_ICON,
@@ -38,7 +35,15 @@ const BADGE_IMAGE_PREFIX = "badge-"; // one registered image per distinct badge
// one — both land on the same drop targets, told apart by this. // one — both land on the same drop targets, told apart by this.
const MOVE_MIME = "application/x-gpx-path"; const MOVE_MIME = "application/x-gpx-path";
const GPX_VISIBLE_KEY = "gpxVisible"; const GPX_VISIBLE_KEY = "gpxVisible";
const FOLDER_DRAG_PREFIX = "folder:"; // a dragged folder's MOVE_MIME payload, vs. a node key // The kinds the Library filters by: chip label, a row's word for one, glyph and colour.
const KINDS = {
waypoint: { label: "Points", one: "points", glyph: "●", color: "#12bedf" },
track: { label: "Tracks", one: "track", glyph: "〰", color: "#c2410c" },
route: { label: "Routes", one: "route", glyph: "↝", color: "#1d6fdc" },
layer: { label: "Layers", one: "layer", glyph: "▤", color: "#6b6b66" },
};
const FOLDER_DRAG_PREFIX = "folder:";
const plural = (n, word) => `${n} ${word}${n === 1 ? "" : "s"}`; // a dragged folder's MOVE_MIME payload, vs. a node key
// A sidebar icon that opens a side panel for uploading GPX files (via // A sidebar icon that opens a side panel for uploading GPX files (via
// drag & drop, stored server-side in a folder hierarchy the user can add to // drag & drop, stored server-side in a folder hierarchy the user can add to
@@ -119,7 +124,7 @@ export class GpxPanelControl {
mount(sidebar) { mount(sidebar) {
this._container = document.createElement("div"); this._container = document.createElement("div");
this._container.className = "sidebar-item"; this._container.className = "sidebar-item";
this._container.innerHTML = `<button type="button" class="sidebar-icon" title="Tracks &amp; Points" aria-label="Tracks &amp; Points">${GPX_ICON}</button>`; this._container.innerHTML = `<button type="button" class="sidebar-icon" title="Library" aria-label="Library">${GPX_ICON}</button>`;
this._icon = this._container.querySelector(".sidebar-icon"); this._icon = this._container.querySelector(".sidebar-icon");
this._icon.addEventListener("click", () => this._togglePanel()); this._icon.addEventListener("click", () => this._togglePanel());
@@ -162,6 +167,7 @@ export class GpxPanelControl {
// panels. // panels.
document.addEventListener("click", () => this._closeDownloadMenu()); document.addEventListener("click", () => this._closeDownloadMenu());
this._setupFind();
this._setupToolbarActions(); this._setupToolbarActions();
this._setupRootDropTarget(); this._setupRootDropTarget();
this._setupMapDropTarget(); this._setupMapDropTarget();
@@ -184,13 +190,13 @@ export class GpxPanelControl {
_setupToolbarActions() { _setupToolbarActions() {
const fileInput = this._panel.querySelector(".gpx-file-input"); const fileInput = this._panel.querySelector(".gpx-file-input");
fileInput.addEventListener("change", () => { fileInput.addEventListener("change", () => {
this._uploadFiles(fileInput.files, ""); this._uploadFiles(fileInput.files, this._cwd);
fileInput.value = ""; fileInput.value = "";
}); });
this._panel.querySelector('[data-action="upload"]').addEventListener("click", () => fileInput.click()); this._panel.querySelector('[data-action="upload"]').addEventListener("click", () => fileInput.click());
this._panel.querySelector('[data-action="new-folder"]').addEventListener("click", async () => { this._panel.querySelector('[data-action="new-folder"]').addEventListener("click", async () => {
const path = window.prompt("New folder name (e.g. Hiking/2026):"); const path = window.prompt("New folder name (e.g. Hiking/2026):", this._cwd ? `${this._cwd}/` : "");
if (!path || !path.trim()) return; if (!path || !path.trim()) return;
const response = await fetch(FOLDER_URL, { const response = await fetch(FOLDER_URL, {
@@ -223,11 +229,11 @@ export class GpxPanelControl {
event.preventDefault(); event.preventDefault();
this._treeContainer.classList.remove("gpx-drop-hover"); this._treeContainer.classList.remove("gpx-drop-hover");
if (event.dataTransfer.files?.length > 0) { if (event.dataTransfer.files?.length > 0) {
this._uploadFiles(event.dataTransfer.files, ""); this._uploadFiles(event.dataTransfer.files, this._cwd);
return; return;
} }
const from = event.dataTransfer.getData(MOVE_MIME); const from = event.dataTransfer.getData(MOVE_MIME);
if (from) this._moveFile(from, ""); if (from) this._moveFile(from, this._cwd);
}); });
} }
@@ -258,67 +264,266 @@ export class GpxPanelControl {
this._renderTree(tree); this._renderTree(tree);
} }
// The Design canvas' Library (after Locus Map): find on top — the text,
// what kinds, only the shown ones — then one folder level at a time (← up,
// the path), or, while searching or in List view, every match flat with
// the folder it lives in. An eye per row: ● shown, ◐ some (a folder), ○ not.
_renderTree(node) { _renderTree(node) {
this._root = node;
this._files = new Map(); this._files = new Map();
const index = (n) => (n.children || []).forEach((c) => (c.type === "folder" ? index(c) : this._files.set(c.path, c))); this._folders = new Map([["", node]]);
index(node); const index = (n) => (n.children || []).forEach((c) => {
this._treeContainer.innerHTML = ""; if (c.type === "folder") {
this._treeContainer.appendChild(this._renderChildren(node.children)); this._folders.set(c.path, c);
} index(c);
_renderChildren(children) {
const ul = document.createElement("ul");
if (children.length === 0) {
const li = document.createElement("li");
li.className = "gpx-tree__empty";
li.textContent = "No files yet";
ul.appendChild(li);
return ul;
}
children.forEach((child) => {
const li = document.createElement("li");
if (child.type === "folder") {
li.appendChild(this._renderFolder(child));
} else if (child.points) {
li.appendChild(this._renderTrackWithPoints(child));
} else { } else {
li.appendChild(this._renderFile(child)); c.folder = n.path;
this._files.set(c.path, c);
} }
ul.appendChild(li);
}); });
index(node);
return ul; if (!this._folders.has(this._cwd ?? "")) this._cwd = "";
if (this._openTrack && !this._files.has(this._openTrack)) this._openTrack = null;
this._renderView();
} }
// A track/route holding points: collapsed by default (there can be many), _setupFind() {
// each point zooms to itself and can be taken out again. this._cwd = "";
_renderTrackWithPoints(file) { this._query = "";
this._openTracks ||= new Set(); this._mode = "folders";
const details = document.createElement("details"); this._kindsOn = new Set(Object.keys(KINDS));
details.className = "gpx-tree__track"; this._shownOnly = false;
details.open = this._openTracks.has(file.path); const find = this._panel.querySelector(".lib-find");
details.addEventListener("toggle", () => (details.open ? this._openTracks.add(file.path) : this._openTracks.delete(file.path))); const input = find.querySelector(".lib-find__input");
const summary = document.createElement("summary"); input.addEventListener("input", () => {
summary.appendChild(this._renderFile(file)); this._query = input.value.trim().toLowerCase();
details.appendChild(summary); this._renderView();
});
find.querySelector(".lib-find__kinds").addEventListener("click", (event) => {
const chip = event.target.closest("[data-kind]");
if (!chip) return;
const kind = chip.dataset.kind;
if (this._kindsOn.has(kind) && this._kindsOn.size > 1) this._kindsOn.delete(kind);
else this._kindsOn.add(kind);
this._renderView();
});
find.querySelector('[data-find="shown"]').addEventListener("click", () => {
this._shownOnly = !this._shownOnly;
this._renderView();
});
find.querySelectorAll("[data-mode]").forEach((button) => button.addEventListener("click", () => {
this._mode = button.dataset.mode;
this._renderView();
}));
this._crumb = this._panel.querySelector(".lib-crumb");
this._footer = this._panel.querySelector(".lib-foot__text");
this._panel.querySelector('[data-action="hide-all"]').addEventListener("click", () => {
[...this._visible].forEach((path) => this._toggleFileOnly(path, false));
this._saveVisible();
this._renderView();
});
}
_kindOf(file) {
if (file.layer) return "layer";
if (file.kinds?.includes("route")) return "route";
if (file.kinds?.includes("track")) return "track";
return "waypoint";
}
_matches(file) {
if (!this._kindsOn.has(this._kindOf(file))) return false;
if (this._shownOnly && !this._visible.has(file.path)) return false;
return !this._query || `${file.folder} ${file.name}`.toLowerCase().includes(this._query);
}
// Every file under a folder (all levels).
_filesUnder(path) {
return [...this._files.values()].filter((f) => f.folder === path || f.folder.startsWith(`${path}/`) || path === "");
}
_renderView() {
if (!this._root) return;
const find = this._panel.querySelector(".lib-find");
const counts = {};
this._files.forEach((f) => (counts[this._kindOf(f)] = (counts[this._kindOf(f)] || 0) + 1));
find.querySelector(".lib-find__kinds").innerHTML = Object.entries(KINDS)
.map(([kind, { label, color }]) => `<button type="button" class="lib-chip" data-kind="${kind}" aria-pressed="${this._kindsOn.has(kind)}"><span style="color: ${color}">●</span> ${label} <small>${counts[kind] || 0}</small></button>`)
.join("");
find.querySelector('[data-find="shown"]').setAttribute("aria-pressed", this._shownOnly);
const flat = this._mode === "list" || this._query;
find.querySelectorAll("[data-mode]").forEach((button) => button.setAttribute("aria-pressed", (button.dataset.mode === "list") === Boolean(flat)));
const ul = document.createElement("ul"); const ul = document.createElement("ul");
ul.className = "gpx-tree__points"; ul.className = "lib-list";
file.points.forEach((point) => { if (flat) {
const li = document.createElement("li"); this._crumb.hidden = true;
li.className = "gpx-tree__point"; if (this._query) {
const name = document.createElement("button"); [...this._folders.values()]
name.type = "button"; .filter((f) => f.path && f.name.toLowerCase().includes(this._query))
name.className = "gpx-tree__point-name"; .forEach((f) => ul.appendChild(this._folderRow(f, true)));
name.textContent = point.name; }
name.addEventListener("click", () => this._goToPoint(file.path, point)); [...this._files.values()].filter((f) => this._matches(f)).forEach((f) => ul.appendChild(this._fileRow(f, true)));
li.appendChild(name); } else if (this._openTrack) {
if (isLoggedIn()) li.appendChild(this._deleteButton(() => this._removePoint(file, point))); const track = this._files.get(this._openTrack);
ul.appendChild(li); this._renderCrumb(track.folder, track.name, plural(track.points.length, "point"), () => (this._openTrack = null));
track.points.forEach((point) => ul.appendChild(this._pointRow(track, point)));
} else {
const folder = this._folders.get(this._cwd);
const subfolders = folder.children.filter((c) => c.type === "folder");
const files = folder.children.filter((c) => c.type !== "folder" && this._matches(c));
if (this._cwd) {
const parent = this._cwd.includes("/") ? this._cwd.slice(0, this._cwd.lastIndexOf("/")) : "";
this._renderCrumb(parent, folder.name, `${plural(subfolders.length, "folder")} · ${plural(files.length, "item")}`, () => (this._cwd = parent), parent);
} else {
this._crumb.hidden = true;
}
subfolders.forEach((f) => ul.appendChild(this._folderRow(f)));
files.forEach((f) => ul.appendChild(this._fileRow(f)));
}
if (!ul.children.length) {
ul.innerHTML = `<li class="gpx-tree__empty">${this._query ? "Nothing found" : "Nothing here yet"}</li>`;
}
this._treeContainer.innerHTML = "";
this._treeContainer.appendChild(ul);
this._footer.textContent = `${plural(this._folders.size - 1, "folder")} · ${plural(this._files.size, "item")} · ${this._visible.size} shown`;
}
// ← up, the path to here and its name; `dropTo` (the parent) also takes a
// dragged item, to move it a level up.
_renderCrumb(path, name, meta, up, dropTo) {
this._crumb.hidden = false;
this._crumb.innerHTML = "";
const back = Object.assign(document.createElement("button"), { type: "button", className: "lib-crumb__up", textContent: "←", title: "Up" });
back.addEventListener("click", () => {
up();
this._renderView();
}); });
details.appendChild(ul); if (dropTo !== undefined && isLoggedIn()) this._wireFolderDropTarget(back, dropTo);
return details; const where = Object.assign(document.createElement("span"), { className: "lib-crumb__path", textContent: path ? `${path.replaceAll("/", " › ")} › ` : "" });
this._crumb.append(back, where, Object.assign(document.createElement("b"), { textContent: name }), Object.assign(document.createElement("small"), { textContent: meta }));
}
_row({ icon, color, name, meta, aside, eye, onOpen, onEye, bold }) {
const li = document.createElement("li");
li.className = "lib-row";
li.innerHTML = `<span class="lib-row__icon" aria-hidden="true"></span><span class="lib-row__text"><span class="lib-row__name"></span><small class="lib-row__meta"></small></span><span class="lib-row__aside"></span>`;
const iconEl = li.querySelector(".lib-row__icon");
iconEl.textContent = icon;
iconEl.style.color = color || "";
li.querySelector(".lib-row__name").textContent = name;
li.querySelector(".lib-row__name").classList.toggle("lib-row__name--folder", Boolean(bold));
li.querySelector(".lib-row__meta").textContent = meta || "";
li.querySelector(".lib-row__aside").textContent = aside || "";
li.querySelector(".lib-row__text").addEventListener("click", onOpen);
if (eye) {
const button = Object.assign(document.createElement("button"), { type: "button", className: `lib-eye lib-eye--${eye}`, textContent: { all: "●", some: "◐", none: "○" }[eye] });
button.title = eye === "none" ? "Show on the map" : "Hide from the map";
button.setAttribute("aria-label", button.title);
button.setAttribute("aria-pressed", eye !== "none");
button.addEventListener("click", onEye);
li.appendChild(button);
}
return li;
}
_folderRow(folder, withPath = false) {
const files = this._filesUnder(folder.path);
const shown = files.filter((f) => this._visible.has(f.path)).length;
const subfolders = folder.children.filter((c) => c.type === "folder").length;
const items = folder.children.length - subfolders;
const parent = folder.path.includes("/") ? folder.path.slice(0, folder.path.lastIndexOf("/")).replaceAll("/", " › ") : "";
const li = this._row({
icon: "▣",
name: folder.name,
bold: true,
meta: [withPath && parent, subfolders && plural(subfolders, "folder"), plural(items, "item")].filter(Boolean).join(" · "),
aside: "›",
eye: files.length ? (shown === 0 ? "none" : shown === files.length ? "all" : "some") : null,
onOpen: () => {
this._cwd = folder.path;
this._openTrack = null;
this._query = "";
this._mode = "folders";
this._panel.querySelector(".lib-find__input").value = "";
this._renderView();
},
onEye: async () => {
const show = shown === 0;
await Promise.all(files.map((f) => this._toggleFileOnly(f.path, show)));
this._saveVisible();
this._renderView();
},
});
if (isLoggedIn()) {
li.appendChild(this._menuButton("⋯", "Actions", [
{ label: "Rename…", run: () => this._renameFolder(folder) },
...this._exportEntries(folder.path, folder.name),
{ label: "Delete…", run: () => this._deleteFolder(folder.path) },
]));
li.draggable = true;
li.addEventListener("dragstart", (event) => {
event.dataTransfer.setData(MOVE_MIME, `${FOLDER_DRAG_PREFIX}${folder.path}`);
event.dataTransfer.effectAllowed = "move";
});
this._wireFolderDropTarget(li, folder.path);
}
return li;
}
_fileRow(file, withPath = false) {
const kind = this._kindOf(file);
const visible = this._visible.has(file.path);
const li = this._row({
icon: KINDS[kind].glyph,
color: file.color || KINDS[kind].color,
name: file.name,
meta: [withPath && (file.folder ? file.folder.replaceAll("/", " › ") : "Top level"), KINDS[kind].one, file.points && plural(file.points.length, "point")].filter(Boolean).join(" · "),
aside: file.points ? "›" : "",
eye: visible ? "all" : "none",
// the name zooms to it, shown first if needed; a track's points open
// from its ›
onOpen: async (event) => {
if (file.points && event.target.closest(".lib-row__aside, .lib-row__meta")) {
this._openTrack = file.path;
return this._renderView();
}
if (!this._visible.has(file.path)) await this._toggleFile(file.path, true);
if (this._visible.has(file.path)) this._zoomTo(file.path);
this._renderView();
},
onEye: async () => {
await this._toggleFile(file.path, !visible);
this._renderView();
},
});
if (file.points) {
li.querySelector(".lib-row__aside").addEventListener("click", () => {
this._openTrack = file.path;
this._renderView();
});
}
li.draggable = true;
li.addEventListener("dragstart", (event) => {
event.dataTransfer.setData(MOVE_MIME, file.path);
event.dataTransfer.effectAllowed = "move";
});
// Every action behind one ⋯ menu (as OsmAnd does), shown only once
// logged in: they all require login (app.rb).
if (isLoggedIn()) li.appendChild(this._fileMenu(file));
return li;
}
_pointRow(track, point) {
const li = this._row({
icon: "●",
color: KINDS.waypoint.color,
name: point.name,
meta: "point",
onOpen: () => this._goToPoint(track.path, point),
});
if (isLoggedIn()) li.appendChild(this._deleteButton(() => this._removePoint(track, point)));
return li;
} }
async _goToPoint(path, point) { async _goToPoint(path, point) {
@@ -347,95 +552,6 @@ export class GpxPanelControl {
await this._reloadFile(target); await this._reloadFile(target);
} }
_renderFolder(folder) {
const details = document.createElement("details");
details.open = true;
const summary = document.createElement("summary");
const row = document.createElement("span");
row.className = "gpx-tree__folder-row";
const name = document.createElement("span");
name.textContent = folder.name;
row.appendChild(name);
if (isLoggedIn()) {
row.appendChild(
this._menuButton("⋯", "Actions", [
{ label: "Rename…", run: () => this._renameFolder(folder) },
...this._exportEntries(folder.path, folder.name),
{ label: "Delete…", run: () => this._deleteFolder(folder.path) },
]),
);
// Dragged onto another folder (or the tree's blank space) moves it.
summary.draggable = true;
summary.addEventListener("dragstart", (event) => {
event.dataTransfer.setData(MOVE_MIME, `${FOLDER_DRAG_PREFIX}${folder.path}`);
event.dataTransfer.effectAllowed = "move";
});
}
summary.appendChild(row);
this._wireFolderDropTarget(summary, folder.path);
details.appendChild(summary);
details.appendChild(this._renderChildren(folder.children));
return details;
}
_renderFile(file) {
const row = document.createElement("div");
row.className = "gpx-tree__file";
row.draggable = true;
row.addEventListener("dragstart", (event) => {
event.dataTransfer.setData(MOVE_MIME, file.path);
event.dataTransfer.effectAllowed = "move";
});
const label = document.createElement("label");
const checkbox = document.createElement("input");
checkbox.type = "checkbox";
checkbox.checked = this._visible.has(file.path);
checkbox.dataset.path = file.path;
checkbox.addEventListener("change", () => this._toggleFile(file.path, checkbox.checked, checkbox));
const loggedIn = isLoggedIn();
const name = document.createElement("span");
name.className = "gpx-tree__file-name";
name.textContent = file.name;
label.appendChild(checkbox);
(file.kinds || []).forEach((kind) => label.appendChild(this._kindIcon(kind)));
label.appendChild(name);
// The name zooms to it (showing it first if needed); the checkbox
// alone shows/hides.
name.addEventListener("click", async (event) => {
event.preventDefault();
if (!checkbox.checked) {
checkbox.checked = true;
await this._toggleFile(file.path, true, checkbox);
}
if (checkbox.checked) this._zoomTo(file.path);
});
row.appendChild(label);
// Every action behind one ⋯ menu (as OsmAnd does), shown only once
// logged in: they all require login (app.rb).
if (loggedIn) row.appendChild(this._fileMenu(file));
return row;
}
_kindIcon(kind) {
const icon = document.createElement("span");
icon.className = "gpx-tree__kind-icon";
if (kind === "waypoint") {
icon.innerHTML = WAYPOINT_ICON;
icon.title = "Has waypoints";
} else if (kind === "route") {
icon.innerHTML = ROUTE_ICON;
icon.title = "Has a route";
} else {
icon.innerHTML = TRACK_ICON;
icon.title = "Has a track";
}
return icon;
}
_fileMenu(file) { _fileMenu(file) {
const geojsonUrl = `${gpxFileUrl(file.path)}?${new URLSearchParams({ download: "geojson", name: file.name })}`; const geojsonUrl = `${gpxFileUrl(file.path)}?${new URLSearchParams({ download: "geojson", name: file.name })}`;
// A folder's "Points (N)" node has no name or color of its own. // A folder's "Points (N)" node has no name or color of its own.
@@ -585,9 +701,8 @@ export class GpxPanelControl {
// that isn't shown yet — same as ticking its box in the tree by hand. // that isn't shown yet — same as ticking its box in the tree by hand.
async show(path) { async show(path) {
if (this._visible.has(path)) return; if (this._visible.has(path)) return;
const checkbox = [...this._treeContainer.querySelectorAll("input[data-path]")].find((input) => input.dataset.path === path); await this._toggleFile(path, true);
if (checkbox) checkbox.checked = true; this._renderView();
await this._toggleFile(path, true, checkbox);
} }
// Search result picked: show its file, then open the matching point's // Search result picked: show its file, then open the matching point's
+1 -1
View File
@@ -515,7 +515,7 @@ new LiveTrackPanelControl(map).mount(sidebar);
if (isLoggedIn()) new DebugControl().mount(sidebar); if (isLoggedIn()) new DebugControl().mount(sidebar);
if (isLoggedIn()) setupUpdate(document.querySelector(".topbar__update"), document.querySelector(".debug-panel__update-check")); if (isLoggedIn()) setupUpdate(document.querySelector(".topbar__update"), document.querySelector(".debug-panel__update-check"));
// A short name under each icon (CSS ::after), the title stays the tooltip. // A short name under each icon (CSS ::after), the title stays the tooltip.
const RAIL_LABELS = { "Tracks & Points": "Library", "Import plugins": "Import", "Offline data": "Offline", LiveTrack: "Live", "Status / debug": "Status" }; const RAIL_LABELS = { "Import plugins": "Import", "Offline data": "Offline", LiveTrack: "Live", "Status / debug": "Status" };
sidebar.querySelectorAll(".sidebar-icon").forEach((icon) => (icon.dataset.label = RAIL_LABELS[icon.title] ?? icon.title)); sidebar.querySelectorAll(".sidebar-icon").forEach((icon) => (icon.dataset.label = RAIL_LABELS[icon.title] ?? icon.title));
setupSidePanelModes(); setupSidePanelModes();
+11 -1
View File
@@ -111,7 +111,10 @@ export class RoutePanelControl {
this._editingNote = this._panel.querySelector(".route-panel__editing"); this._editingNote = this._panel.querySelector(".route-panel__editing");
this._saveButton.addEventListener("click", () => this._save()); this._saveButton.addEventListener("click", () => this._save());
this._profileButton = this._panel.querySelector(".route-panel__profile"); this._profileButton = this._panel.querySelector(".route-panel__profile");
this._profileButton.addEventListener("click", () => this._profilePanel.show(this._profileProperties())); this._profileButton.addEventListener("click", () => {
this._profileShown = this._profileProperties();
this._profilePanel.show(this._profileShown);
});
this._reachStatus = this._panel.querySelector(".route-panel__reach-status"); this._reachStatus = this._panel.querySelector(".route-panel__reach-status");
this._reachClear = this._panel.querySelector('[data-action="reach-clear"]'); this._reachClear = this._panel.querySelector('[data-action="reach-clear"]');
this._panel.querySelector('[data-action="reach"]').addEventListener("click", () => this._showReach()); this._panel.querySelector('[data-action="reach"]').addEventListener("click", () => this._showReach());
@@ -507,6 +510,8 @@ export class RoutePanelControl {
this._showCountries(route?.properties.countries); this._showCountries(route?.properties.countries);
this._renderTotals(route); this._renderTotals(route);
this._summary.textContent = message; this._summary.textContent = message;
if (this._profileShown && this._profilePanel.shown === this._profileShown) this._profilePanel.hide();
this._profileShown = null;
if (!route) return; if (!route) return;
const { maneuvers } = route.properties; const { maneuvers } = route.properties;
@@ -530,6 +535,11 @@ export class RoutePanelControl {
route.elevation = profile; route.elevation = profile;
this._renderTotals(route); this._renderTotals(route);
this._profileButton.hidden = false; this._profileButton.hidden = false;
// the route's profile docked under the map while planning (not driving)
if (!document.documentElement.classList.contains("driving")) {
this._profileShown = this._profileProperties();
this._profilePanel.show(this._profileShown);
}
} }
// What TrackProfilePanel (and a library track) reads. // What TrackProfilePanel (and a library track) reads.
+9
View File
@@ -45,11 +45,18 @@ export class TrackProfilePanel {
this._stats = this._panel.querySelector(".profile-panel__stats"); this._stats = this._panel.querySelector(".profile-panel__stats");
this._chartsContainer = this._panel.querySelector(".profile-panel__charts"); this._chartsContainer = this._panel.querySelector(".profile-panel__charts");
this._panel.querySelector(".profile-panel__close").addEventListener("click", () => this.hide()); this._panel.querySelector(".profile-panel__close").addEventListener("click", () => this.hide());
// Docked under the map (the Design canvas' Desktop): the map gives up
// the profile's height instead of being covered by it.
new ResizeObserver(() => {
const height = this._panel.hidden ? 0 : this._panel.offsetHeight;
document.documentElement.style.setProperty("--profile-h", `${height}px`);
}).observe(this._panel);
} }
show(properties) { show(properties) {
const profile = properties.profile; const profile = properties.profile;
if (!profile || profile.length === 0) return; if (!profile || profile.length === 0) return;
this.shown = properties; // whose profile this is (route.js hides its own)
this._profile = profile.map((point) => ({ ...point, speed_kmh: typeof point.speed_mps === "number" ? point.speed_mps * 3.6 : null })); this._profile = profile.map((point) => ({ ...point, speed_kmh: typeof point.speed_mps === "number" ? point.speed_mps * 3.6 : null }));
addMovingTime(this._profile); addMovingTime(this._profile);
@@ -204,7 +211,9 @@ export class TrackProfilePanel {
} }
hide() { hide() {
this.shown = null;
this._panel.hidden = true; this._panel.hidden = true;
document.documentElement.style.setProperty("--profile-h", "0px");
this._plots?.removeEventListener("pointermove", this._onPointerMove); this._plots?.removeEventListener("pointermove", this._onPointerMove);
this._plots?.removeEventListener("pointerleave", this._onPointerLeave); this._plots?.removeEventListener("pointerleave", this._onPointerLeave);
this._marker.remove(); this._marker.remove();
+18 -1
View File
@@ -49,7 +49,7 @@
<div id="gpx-panel" class="gpx-panel" hidden<%= " data-sync-client" if sync_client %>> <div id="gpx-panel" class="gpx-panel" hidden<%= " data-sync-client" if sync_client %>>
<div class="gpx-panel__header"> <div class="gpx-panel__header">
<strong>Tracks &amp; Points</strong> <strong>Library</strong>
<div class="gpx-panel__actions"> <div class="gpx-panel__actions">
<button type="button" class="gpx-panel__action" data-action="new-folder" title="New folder" aria-label="New folder"></button> <button type="button" class="gpx-panel__action" data-action="new-folder" title="New folder" aria-label="New folder"></button>
<button type="button" class="gpx-panel__action" data-action="upload" title="Upload GPX/FIT/TCX/GeoJSON file" aria-label="Upload GPX/FIT/TCX/GeoJSON file"></button> <button type="button" class="gpx-panel__action" data-action="upload" title="Upload GPX/FIT/TCX/GeoJSON file" aria-label="Upload GPX/FIT/TCX/GeoJSON file"></button>
@@ -60,8 +60,25 @@
<input type="file" class="gpx-file-input" accept=".gpx,.fit,.tcx,.geojson,.zip" multiple hidden> <input type="file" class="gpx-file-input" accept=".gpx,.fit,.tcx,.geojson,.zip" multiple hidden>
<p class="gpx-upload__status" hidden></p> <p class="gpx-upload__status" hidden></p>
<!-- Find first (the Design canvas' Library): filled by GpxPanelControl. -->
<div class="lib-find">
<input type="search" class="lib-find__input" placeholder="Find a point, track, folder…" aria-label="Find in the library">
<div class="lib-find__kinds" role="group" aria-label="What"></div>
<div class="lib-find__bar">
<button type="button" class="lib-chip" data-find="shown" aria-pressed="false">Shown on the map</button>
<span class="lib-seg" role="group" aria-label="View">
<button type="button" data-mode="folders" aria-pressed="true">Folders</button>
<button type="button" data-mode="list" aria-pressed="false">List</button>
</span>
</div>
</div>
<div class="lib-crumb" hidden></div>
<div class="gpx-tree"></div> <div class="gpx-tree"></div>
<div class="gpx-legend" hidden></div> <div class="gpx-legend" hidden></div>
<div class="lib-foot">
<span class="lib-foot__text"></span>
<button type="button" data-action="hide-all">Hide all</button>
</div>
</div> </div>
<div id="overlays-panel" class="basemap-panel" hidden> <div id="overlays-panel" class="basemap-panel" hidden>