Show a GeoJSON icon next to files with a ready cache
GpxStore#tree now reports a "cached" flag per file (reusing the same mtime freshness check geojson() already does); the file tree shows a small curly-braces icon next to any file whose conversion is already on disk, so it's visible which files will toggle on instantly versus which still need to parse.
This commit is contained in:
1 parent
dd0ad6d845
commit
44d235bbcf
4 files changed
+56
-4
No files matched your search
@@ -6,6 +6,7 @@ import {
|
||||
WAYPOINT_ICON,
|
||||
TRACK_ICON,
|
||||
ROUTE_ICON,
|
||||
GEOJSON_ICON,
|
||||
MAP_MARKER_ICON,
|
||||
POI_ICONS,
|
||||
PARK4NIGHT_TAGS,
|
||||
@@ -276,6 +277,7 @@ export class GpxPanelControl {
|
||||
name.title = file.name;
|
||||
label.appendChild(checkbox);
|
||||
(file.kinds || []).forEach((kind) => label.appendChild(this._kindIcon(kind)));
|
||||
if (file.cached) label.appendChild(this._cachedIcon());
|
||||
label.appendChild(name);
|
||||
row.appendChild(label);
|
||||
row.appendChild(this._deleteButton(() => this._deleteFile(file.path)));
|
||||
@@ -299,6 +301,14 @@ export class GpxPanelControl {
|
||||
return icon;
|
||||
}
|
||||
|
||||
_cachedIcon() {
|
||||
const icon = document.createElement("span");
|
||||
icon.className = "gpx-tree__kind-icon";
|
||||
icon.innerHTML = GEOJSON_ICON;
|
||||
icon.title = "Ready to view instantly (GeoJSON cached)";
|
||||
return icon;
|
||||
}
|
||||
|
||||
_deleteButton(onClick) {
|
||||
const button = document.createElement("button");
|
||||
button.type = "button";
|
||||
|
||||
@@ -54,6 +54,16 @@ export const WAYPOINT_ICON = `
|
||||
|
||||
export const TRACK_ICON = GPX_ICON;
|
||||
|
||||
// Shown next to a file whose GeoJSON conversion is already cached on disk
|
||||
// (GpxStore#geojson) — ready to view instantly instead of paying REXML's
|
||||
// parse cost on click. Curly braces read as "structured data ready", the
|
||||
// same shorthand most editors/tools use for JSON.
|
||||
export const GEOJSON_ICON = `
|
||||
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.6" stroke-linecap="round" stroke-linejoin="round">
|
||||
<path d="M9 4c-1.5 0-2 .8-2 2v3c0 1-.5 1.5-1.5 1.5 1 0 1.5.5 1.5 1.5v3c0 1.2.5 2 2 2"/>
|
||||
<path d="M15 4c1.5 0 2 .8 2 2v3c0 1 .5 1.5 1.5 1.5-1 0-1.5.5-1.5 1.5v3c0 1.2-.5 2-2 2"/>
|
||||
</svg>`;
|
||||
|
||||
// Same shape as TRACK_ICON, dashed — a route is planned rather than
|
||||
// recorded, the same visual convention most map apps use for the
|
||||
// distinction.
|
||||
|
||||
Reference in new issue
Block a user