Library phase 3: change feed and folder export for Locus (GPX) and OsmAnd (favourites + tracks zip)
This commit is contained in:
1 parent
cca985d2b9
commit
59447c56f2
8 files changed
+305
-3
No files matched your search
+19
-1
@@ -130,6 +130,10 @@ export class GpxPanelControl {
|
||||
if (!isLoggedIn()) {
|
||||
this._panel.querySelector('[data-action="new-folder"]').hidden = true;
|
||||
this._panel.querySelector('[data-action="upload"]').hidden = true;
|
||||
} else {
|
||||
// The top level's own items have no folder row with a menu of its own.
|
||||
const close = this._panel.querySelector(".gpx-panel__close");
|
||||
close.before(this._menuButton(DOWNLOAD_ICON, "Export the top level", this._exportEntries("", "MapTool")));
|
||||
}
|
||||
this._panel
|
||||
.querySelector(".gpx-panel__close")
|
||||
@@ -280,7 +284,12 @@ export class GpxPanelControl {
|
||||
name.textContent = folder.name;
|
||||
row.appendChild(name);
|
||||
if (isLoggedIn()) {
|
||||
row.appendChild(this._menuButton("⋯", "Edit", [{ label: "Rename…", run: () => this._renameFolder(folder) }]));
|
||||
row.appendChild(
|
||||
this._menuButton("⋯", "Edit", [
|
||||
{ label: "Rename…", run: () => this._renameFolder(folder) },
|
||||
...this._exportEntries(folder.path, folder.name),
|
||||
]),
|
||||
);
|
||||
row.appendChild(this._deleteButton(() => this._deleteFolder(folder.path)));
|
||||
// Dragged onto another folder (or the tree's blank space) moves it.
|
||||
summary.draggable = true;
|
||||
@@ -1083,6 +1092,15 @@ export class GpxPanelControl {
|
||||
this._renderTree(tree);
|
||||
}
|
||||
|
||||
// A folder (or "" for the top level) as files for the phone apps.
|
||||
_exportEntries(path, name) {
|
||||
const url = (flavor) => `/api/library/export?${new URLSearchParams({ folder: path, flavor })}`;
|
||||
return [
|
||||
{ label: "Export for Locus (GPX)", run: () => this._download(url("locus"), `${name}.gpx`) },
|
||||
{ label: "Export for OsmAnd (zip)", run: () => this._download(url("osmand"), `${name}-osmand.zip`) },
|
||||
];
|
||||
}
|
||||
|
||||
async _renameFolder(folder) {
|
||||
const name = window.prompt("Rename folder:", folder.name);
|
||||
if (name && name.trim() && name.trim() !== folder.name) await this._patchFolder(folder.path, { name: name.trim() });
|
||||
|
||||
Reference in new issue
Block a user