From 4d0d92d250aaae890de91c94bf531089e96d39b4 Mon Sep 17 00:00:00 2001 From: Pieter Vander Vennet Date: Tue, 3 Dec 2024 19:12:42 +0100 Subject: [PATCH] Feature(inspector): keep track of previously visited contributors --- src/UI/History/PreviouslySpiedUsers.svelte | 102 +++++++++++++++++++++ src/UI/InspectorGUI.svelte | 64 +++++++++---- 2 files changed, 148 insertions(+), 18 deletions(-) create mode 100644 src/UI/History/PreviouslySpiedUsers.svelte diff --git a/src/UI/History/PreviouslySpiedUsers.svelte b/src/UI/History/PreviouslySpiedUsers.svelte new file mode 100644 index 000000000..f8c45347e --- /dev/null +++ b/src/UI/History/PreviouslySpiedUsers.svelte @@ -0,0 +1,102 @@ + + + + + + + + + + + {#each $inspectedContributors as c} + + + + + + + {/each} +
+ + + + + + + Remove
+ + + {c.visitedTime} + + + + remove(c.name)} /> +
+ + + +
Labels
+ {#if $labels.length === 0} + No labels + {:else} + {#each $labels as label} +
{label}
+ {/each} + {/if} +
+
Create a new label
+ + +
+
+
diff --git a/src/UI/InspectorGUI.svelte b/src/UI/InspectorGUI.svelte index c7d187013..1afa7ba5b 100644 --- a/src/UI/InspectorGUI.svelte +++ b/src/UI/InspectorGUI.svelte @@ -23,6 +23,9 @@ import AggregateView from "./History/AggregateView.svelte" import { HistoryUtils } from "./History/HistoryUtils" import AggregateImages from "./History/AggregateImages.svelte" + import Page from "./Base/Page.svelte" + import PreviouslySpiedUsers from "./History/PreviouslySpiedUsers.svelte" + import { OsmConnection } from "../Logic/Osm/OsmConnection" let username = QueryParameters.GetQueryParameter("user", undefined, "Inspect this user") let step = new UIEventSource<"waiting" | "loading" | "done">("waiting") @@ -32,8 +35,8 @@ let lon = UIEventSource.asFloat(QueryParameters.GetQueryParameter("lon", "0")) let theme = new ThemeConfig(inspector_theme, true) let layer = theme.layers.find(l => l.id === "usertouched") + // Is this a dirty hack? Yes it is! theme.getMatchingLayer = () => { - // Is this a dirty hack? Yes it is! return layer } let loadingData = false @@ -61,23 +64,35 @@ } }) - /* new ShowDataLayer(map, - { - layer, - zoomToFeatures: true, - features, - onClick: (f: Feature) => { - selectedElement.set(undefined) - Utils.waitFor(200).then(() => { - selectedElement.set(f) - }) - } - })*/ + let osmConnection = new OsmConnection() + let inspectedContributors: UIEventSource<{ + name: string, + visitedTime: string, + label: string + }[]> = UIEventSource.asObject( + osmConnection.getPreference("spied-upon-users"), []) async function load() { + const user = username.data + { + + const inspectedData = inspectedContributors.data + const previousEntry = inspectedData.find(e => e.name === user) + if (previousEntry) { + previousEntry.visitedTime = new Date().toISOString() + } else { + inspectedData.push({ + label: undefined, + visitedTime: new Date().toISOString(), + name: user + }) + } + inspectedContributors.ping() + } step.setData("loading") - const overpass = new Overpass(undefined, ["nw(user_touched:\"" + username.data + "\");"], Constants.defaultOverpassUrls[0]) + featuresStore.set([]) + const overpass = new Overpass(undefined, ["nw(user_touched:\"" + user + "\");"], Constants.defaultOverpassUrls[0]) if (!maplibremap.bounds.data) { return } @@ -100,6 +115,9 @@ }) let mode: "map" | "table" | "aggregate" | "images" = "map" + + let showPreviouslyVisited = new UIEventSource(true) +
@@ -112,6 +130,9 @@ {:else} {/if} + Back to index
@@ -171,13 +192,13 @@ {:else if mode === "table"}
- {#each $featuresStore as f} - - {/each} + {#each $featuresStore as f} + + {/each}
{:else if mode === "aggregate"}
- +
{:else if mode === "images"}
@@ -185,3 +206,10 @@
{/if} + + +
Earlier inspected constributors
+ { + username.set(e.detail); load();showPreviouslyVisited.set(false) + }} /> +