From 063a912c825906f66eb83d9f52222845b6e3b218 Mon Sep 17 00:00:00 2001 From: Pieter Vander Vennet Date: Wed, 4 Dec 2024 18:48:05 +0100 Subject: [PATCH] Feature(inspector): allow to load multiple contributors at once --- assets/layers/usertouched/usertouched.json | 7 ++-- langs/el.json | 3 +- src/UI/History/AggregateImages.svelte | 17 +++++---- src/UI/History/AggregateView.svelte | 12 ++++--- src/UI/History/History.svelte | 18 ++++++---- src/UI/History/HistoryUtils.ts | 4 +-- src/UI/History/PreviouslySpiedUsers.svelte | 7 +++- src/UI/InspectorGUI.svelte | 42 +++++++++++++--------- 8 files changed, 69 insertions(+), 41 deletions(-) diff --git a/assets/layers/usertouched/usertouched.json b/assets/layers/usertouched/usertouched.json index 6e75ebada..f22e5e104 100644 --- a/assets/layers/usertouched/usertouched.json +++ b/assets/layers/usertouched/usertouched.json @@ -52,8 +52,11 @@ "render": 0, "mappings": [ { - "if": {"or": - ["_geometry:type=Polygon","_geometry:type=MultiPolygon"] + "if": { + "or": [ + "_geometry:type=Polygon", + "_geometry:type=MultiPolygon" + ] }, "then": 20 } diff --git a/langs/el.json b/langs/el.json index 0967ef424..7a73a41bf 100644 --- a/langs/el.json +++ b/langs/el.json @@ -1 +1,2 @@ -{} +{ +} \ No newline at end of file diff --git a/src/UI/History/AggregateImages.svelte b/src/UI/History/AggregateImages.svelte index 9955360eb..78dda9385 100644 --- a/src/UI/History/AggregateImages.svelte +++ b/src/UI/History/AggregateImages.svelte @@ -5,11 +5,9 @@ import OsmObjectDownloader from "../../Logic/Osm/OsmObjectDownloader" import { OsmObject } from "../../Logic/Osm/OsmObject" import Loading from "../Base/Loading.svelte" - import AttributedImage from "../Image/AttributedImage.svelte" import AttributedPanoramaxImage from "./AttributedPanoramaxImage.svelte" - import History from "./History.svelte" - export let onlyShowUsername: string + export let onlyShowUsername: string[] export let features: Feature[] const downloader = new OsmObjectDownloader() @@ -23,11 +21,12 @@ } return result })) + let usernamesSet = new Set(onlyShowUsername) let allDiffs: Store<{ key: string; value?: string; oldValue?: string - }[]> = allHistories.mapD(histories => HistoryUtils.fullHistoryDiff(histories, onlyShowUsername)) + }[]> = allHistories.mapD(histories => HistoryUtils.fullHistoryDiff(histories, usernamesSet)) let addedImages = allDiffs.mapD(diffs => [].concat(...diffs.filter(({ key }) => imageKeys.has(key)))) @@ -37,7 +36,11 @@ {:else if $addedImages.length === 0} No images added by this contributor {:else} - {#each $addedImages as imgDiff} - - {/each} +
+ {#each $addedImages as imgDiff} +
+ +
+ {/each} +
{/if} diff --git a/src/UI/History/AggregateView.svelte b/src/UI/History/AggregateView.svelte index 79baeda81..22bd1d822 100644 --- a/src/UI/History/AggregateView.svelte +++ b/src/UI/History/AggregateView.svelte @@ -6,14 +6,16 @@ import Loading from "../Base/Loading.svelte" import { HistoryUtils } from "./HistoryUtils" import * as shared_questions from "../../assets/generated/layers/questions.json" - import TagRenderingQuestion from "../Popup/TagRendering/TagRenderingQuestion.svelte" import TagRenderingConfig from "../../Models/ThemeConfig/TagRenderingConfig" import Tr from "../Base/Tr.svelte" import AccordionSingle from "../Flowbite/AccordionSingle.svelte" + import Translations from "../i18n/Translations" - export let onlyShowUsername: string + export let onlyShowUsername: string[] export let features: Feature[] + let usernames = new Set(onlyShowUsername) + const downloader = new OsmObjectDownloader() let allHistories: UIEventSource = UIEventSource.FromPromise( Promise.all(features.map(f => downloader.downloadHistory(f.properties.id))) @@ -22,7 +24,7 @@ key: string; value?: string; oldValue?: string - }[]> = allHistories.mapD(histories => HistoryUtils.fullHistoryDiff(histories, onlyShowUsername)) + }[]> = allHistories.mapD(histories => HistoryUtils.fullHistoryDiff(histories, usernames)) const trs = shared_questions.tagRenderings.map(tr => new TagRenderingConfig(tr)) @@ -69,6 +71,7 @@ return perKey }) + const t = Translations.t.inspector @@ -85,8 +88,7 @@ - - Answered {diff.count} times +
    {#each diff.values as value} diff --git a/src/UI/History/History.svelte b/src/UI/History/History.svelte index e4354b048..5cfa6b908 100644 --- a/src/UI/History/History.svelte +++ b/src/UI/History/History.svelte @@ -9,10 +9,12 @@ import { HistoryUtils } from "./HistoryUtils" import ToSvelte from "../Base/ToSvelte.svelte" import Tr from "../Base/Tr.svelte" + import Translations from "../i18n/Translations" - export let onlyShowChangesBy: string + export let onlyShowChangesBy: string[] export let id: OsmId + let usernames = new Set(onlyShowChangesBy) let fullHistory = UIEventSource.FromPromise(new OsmObjectDownloader().downloadHistory(id)) let partOfLayer = fullHistory.mapD(history => history.map(step => ({ @@ -21,11 +23,11 @@ }))) let filteredHistory = partOfLayer.mapD(history => history.filter(({ step }) => { - if (!onlyShowChangesBy) { + if (usernames.size == 0) { return true } - console.log("Comparing ", step.tags["_last_edit:contributor"], onlyShowChangesBy, step.tags["_last_edit:contributor"] === onlyShowChangesBy) - return step.tags["_last_edit:contributor"] === onlyShowChangesBy + console.log("Checking if ", step.tags["_last_edit:contributor"],"is contained in", onlyShowChangesBy) + return usernames.has(step.tags["_last_edit:contributor"]) }).map(({ step, layer }) => { const diff = HistoryUtils.tagHistoryDiff(step, fullHistory.data) @@ -38,6 +40,8 @@ * These layers are only shown if there are tag changes as well */ const ignoreLayersIfNoChanges: ReadonlySet = new Set(["walls_and_buildings"]) + const t = Translations.t.inspector.previousContributors + {#if !$allGeometry || !ignoreLayersIfNoChanges.has($lastStep?.layer?.id)} @@ -55,7 +59,7 @@ {#if !$filteredHistory} Loading history... {:else if $filteredHistory.length === 0} - Only geometry changes found + {:else} {#each $filteredHistory as { step, layer }} @@ -64,7 +68,7 @@ @@ -72,7 +76,7 @@ {#if HistoryUtils.tagHistoryDiff(step, $fullHistory).length === 0} {:else} diff --git a/src/UI/History/HistoryUtils.ts b/src/UI/History/HistoryUtils.ts index 9ba4bf0fe..c85aaeff2 100644 --- a/src/UI/History/HistoryUtils.ts +++ b/src/UI/History/HistoryUtils.ts @@ -33,10 +33,10 @@ export class HistoryUtils { }).filter(ch => ch.oldValue !== ch.value) } - public static fullHistoryDiff(histories: OsmObject[][], onlyShowUsername?: string){ + public static fullHistoryDiff(histories: OsmObject[][], onlyShowUsername?: Set){ const allDiffs: {key: string, oldValue?: string, value?: string}[] = [].concat(...histories.map( history => { - const filtered = history.filter(step => !onlyShowUsername || step.tags["_last_edit:contributor"] === onlyShowUsername) + const filtered = history.filter(step => !onlyShowUsername || onlyShowUsername?.has(step.tags["_last_edit:contributor"] )) const diffs: { key: string; value?: string; diff --git a/src/UI/History/PreviouslySpiedUsers.svelte b/src/UI/History/PreviouslySpiedUsers.svelte index f8c45347e..4bb757b43 100644 --- a/src/UI/History/PreviouslySpiedUsers.svelte +++ b/src/UI/History/PreviouslySpiedUsers.svelte @@ -88,7 +88,12 @@ No labels {:else} {#each $labels as label} -
    {label}
    +
    {label} + +
    {/each} {/if}
    diff --git a/src/UI/InspectorGUI.svelte b/src/UI/InspectorGUI.svelte index 1a2781665..ea4457688 100644 --- a/src/UI/InspectorGUI.svelte +++ b/src/UI/InspectorGUI.svelte @@ -27,6 +27,8 @@ import PreviouslySpiedUsers from "./History/PreviouslySpiedUsers.svelte" import { OsmConnection } from "../Logic/Osm/OsmConnection" import MagnifyingGlassCircle from "@babeard/svelte-heroicons/outline/MagnifyingGlassCircle" + import Translations from "./i18n/Translations" + import Tr from "./Base/Tr.svelte" let username = QueryParameters.GetQueryParameter("user", undefined, "Inspect this user") let step = new UIEventSource<"waiting" | "loading" | "done">("waiting") @@ -52,10 +54,12 @@ lon.set(l.lon) }) - + let allLayers = HistoryUtils.personalTheme.layers + let layersNoFixme = allLayers.filter(l => l.id !== "fixme") +let fixme = allLayers.find(l => l.id === "fixme") let featuresStore = new UIEventSource([]) let features = new StaticFeatureSource(featuresStore) - ShowDataLayer.showMultipleLayers(map, features, HistoryUtils.personalTheme.layers, { + ShowDataLayer.showMultipleLayers(map, features, [...layersNoFixme, fixme] , { zoomToFeatures: true, onClick: (f: Feature) => { selectedElement.set(undefined) @@ -75,7 +79,7 @@ async function load() { const user = username.data - { + if(user.indexOf(";")<0){ const inspectedData = inspectedContributors.data const previousEntry = inspectedData.find(e => e.name === user) @@ -93,7 +97,7 @@ step.setData("loading") featuresStore.set([]) - const overpass = new Overpass(undefined, ["nw(user_touched:\"" + user + "\");"], Constants.defaultOverpassUrls[0]) + const overpass = new Overpass(undefined, user.split(";").map(user => "nw(user_touched:\"" + user + "\");"), Constants.defaultOverpassUrls[0]) if (!maplibremap.bounds.data) { return } @@ -118,38 +122,44 @@ let mode: "map" | "table" | "aggregate" | "images" = "map" let showPreviouslyVisited = new UIEventSource(true) - +const t = Translations.t.inspector
    -

    Inspect contributor

    +

    +

    + load()} /> {#if loadingData} {:else} - + + {/if} - Back to index + + +
    @@ -195,16 +205,16 @@ {:else if mode === "table"}
    {#each $featuresStore as f} - + {/each}
    {:else if mode === "aggregate"}
    - +
    {:else if mode === "images"}
    - +
    {/if}

    - Created by {step.tags["_last_edit:contributor"]} +

    - Only changes in geometry +