UI(Inspector): update tabgroups, fix import

This commit is contained in:
Pieter Vander Vennet 2025-08-27 02:51:33 +02:00
parent 0a48765f0f
commit 8ae09e25de
2 changed files with 89 additions and 79 deletions

View file

@ -12,9 +12,9 @@
import Translations from "../i18n/Translations" import Translations from "../i18n/Translations"
import type { TagRenderingConfigJson } from "../../Models/ThemeConfig/Json/TagRenderingConfigJson" import type { TagRenderingConfigJson } from "../../Models/ThemeConfig/Json/TagRenderingConfigJson"
import { Or } from "../../Logic/Tags/Or" import { Or } from "../../Logic/Tags/Or"
import { Utils } from "../../Utils"
import ChartJs from "../Base/ChartJs.svelte" import ChartJs from "../Base/ChartJs.svelte"
import { ChartJsUtils } from "../Base/ChartJsUtils" import { ChartJsUtils } from "../Base/ChartJsUtils"
import { Lists } from "../../Utils/Lists"
export let onlyShowUsername: string[] export let onlyShowUsername: string[]
export let features: Feature[] export let features: Feature[]

View file

@ -33,6 +33,9 @@
import GeocodeResults from "./Search/GeocodeResults.svelte" import GeocodeResults from "./Search/GeocodeResults.svelte"
import MagnifyingGlassCircle from "@babeard/svelte-heroicons/mini/MagnifyingGlassCircle" import MagnifyingGlassCircle from "@babeard/svelte-heroicons/mini/MagnifyingGlassCircle"
import type { GeocodeResult } from "../Logic/Search/GeocodingProvider" import type { GeocodeResult } from "../Logic/Search/GeocodingProvider"
import { Tab, TabGroup, TabList, TabPanel, TabPanels } from "@rgossiaux/svelte-headlessui"
import WikipediaTitle from "./Wikipedia/WikipediaTitle.svelte"
import WikipediaArticle from "./Wikipedia/WikipediaArticle.svelte"
console.log("Loading inspector GUI") console.log("Loading inspector GUI")
let username = QueryParameters.GetQueryParameter("user", undefined, "Inspect this user") let username = QueryParameters.GetQueryParameter("user", undefined, "Inspect this user")
@ -49,7 +52,7 @@
new CoordinateSearch(), new CoordinateSearch(),
new OpenLocationCodeSearch(), new OpenLocationCodeSearch(),
new PhotonSearch(true, 2), new PhotonSearch(true, 2),
new PhotonSearch() new PhotonSearch(),
) )
let showSearchDrawer = new UIEventSource(true) let showSearchDrawer = new UIEventSource(true)
let searchIsFocussed = new UIEventSource(false) let searchIsFocussed = new UIEventSource(false)
@ -138,7 +141,7 @@
const overpass = new Overpass( const overpass = new Overpass(
Constants.defaultOverpassUrls[0], Constants.defaultOverpassUrls[0],
undefined, undefined,
user.split(";").map((user) => 'nw(user_touched:"' + user + '");') user.split(";").map((user) => "nw(user_touched:\"" + user + "\");"),
) )
if (!maplibremap.bounds.data) { if (!maplibremap.bounds.data) {
return return
@ -161,8 +164,6 @@
return true return true
}) })
let mode: "map" | "table" | "aggregate" | "images" = "map"
let showPreviouslyVisited = new UIEventSource(true) let showPreviouslyVisited = new UIEventSource(true)
const t = Translations.t.inspector const t = Translations.t.inspector
@ -207,89 +208,98 @@
</a> </a>
</div> </div>
<div class="flex"> <TabGroup class="flex-grow flex flex-col">
<button class:primary={mode === "map"} on:click={() => (mode = "map")}> <TabList class="tablist">
<Tr t={t.mapView} /> <Tab class={({ selected }) => ("tab "+ (selected ? "tab-selected" : "tab-unselected"))}>
</button>
<button class:primary={mode === "table"} on:click={() => (mode = "table")}>
<Tr t={t.tableView} />
</button>
<button class:primary={mode === "aggregate"} on:click={() => (mode = "aggregate")}>
<Tr t={t.aggregateView} />
</button>
<button class:primary={mode === "images"} on:click={() => (mode = "images")}>
<Tr t={t.images} />
</button>
</div>
{#if mode === "map"} <Tr t={t.mapView} />
{#if $selectedElement !== undefined} </Tab>
<!-- right modal with the selected element view --> <Tab class={({ selected }) => ("tab "+ (selected ? "tab-selected" : "tab-unselected"))}>
<Drawer
placement="right" <Tr t={t.tableView} />
transitionType="fly" </Tab>
activateClickOutside={false} <Tab class={({ selected }) => ("tab "+ (selected ? "tab-selected" : "tab-unselected"))}>
backdrop={false}
id="drawer-right" <Tr t={t.aggregateView} />
width="w-full md:w-6/12 lg:w-5/12 xl:w-4/12" </Tab>
rightOffset="inset-y-0 right-0" <Tab class={({ selected }) => ("tab "+ (selected ? "tab-selected" : "tab-unselected"))}>
transitionParams={{
<Tr t={t.images} />
</Tab>
</TabList>
<TabPanels class="flex-grow flex flex-col">
<TabPanel class="flex-grow">
{#if $selectedElement !== undefined}
<!-- right modal with the selected element view -->
<Drawer
placement="right"
transitionType="fly"
activateClickOutside={false}
backdrop={false}
id="drawer-right"
width="w-full md:w-6/12 lg:w-5/12 xl:w-4/12"
rightOffset="inset-y-0 right-0"
transitionParams={{
x: 640, x: 640,
duration: 0, duration: 0,
easing: linear, easing: linear,
}} }}
divClass="overflow-y-auto z-50 bg-white" divClass="overflow-y-auto z-50 bg-white"
hidden={$selectedElement === undefined} hidden={$selectedElement === undefined}
on:close={() => { on:close={() => {
selectedElement.setData(undefined) selectedElement.setData(undefined)
}} }}
> >
<TitledPanel> <TitledPanel>
<div slot="title" class="flex justify-between"> <div slot="title" class="flex justify-between">
<a <a
target="_blank" target="_blank"
rel="noopener" rel="noopener"
href={"https://osm.org/" + $selectedElement.properties.id} href={"https://osm.org/" + $selectedElement.properties.id}
> >
{$selectedElement.properties.id} {$selectedElement.properties.id}
</a> </a>
<XCircleIcon class="h-6 w-6" on:click={() => selectedElement.set(undefined)} /> <XCircleIcon class="h-6 w-6" on:click={() => selectedElement.set(undefined)} />
</div> </div>
<History onlyShowChangesBy={$username.split(";")} id={$selectedElement.properties.id} /> <History onlyShowChangesBy={$username.split(";")} id={$selectedElement.properties.id} />
</TitledPanel> </TitledPanel>
</Drawer> </Drawer>
{/if}
<div class="relative m-1 flex-grow overflow-hidden rounded-xl">
<MaplibreMap {map} mapProperties={maplibremap} autorecovery={true} />
<div class="absolute right-0 top-0 w-1/4 p-4">
<Searchbar
on:search={() => search()}
isFocused={searchIsFocussed}
value={searchvalue}
on:focus={() => state.searchState.showSearchDrawer.set(true)}
/>
{#if $searchSuggestions?.length > 0 || $searchIsFocussed}
<GeocodeResults {state} on:select={(event) => search(event.detail)} />
{/if} {/if}
</div>
</div> <div class="relative m-1 h-full flex-grow overflow-hidden rounded-xl">
{:else if mode === "table"} <MaplibreMap {map} mapProperties={maplibremap} autorecovery={true} />
<div class="m-2 h-full overflow-y-auto"> <div class="absolute right-0 top-0 w-1/4 p-4">
{#each $featuresStore as f} <Searchbar
<History onlyShowChangesBy={$username?.split(";")} id={f.properties.id} /> on:search={() => search()}
{/each} isFocused={searchIsFocussed}
</div> value={searchvalue}
{:else if mode === "aggregate"} on:focus={() => state.searchState.showSearchDrawer.set(true)}
<div class="m-2 h-full overflow-y-auto"> />
<AggregateView features={$featuresStore} onlyShowUsername={$username?.split(";")} /> {#if $searchSuggestions?.length > 0 || $searchIsFocussed}
</div> <GeocodeResults {state} on:select={(event) => search(event.detail)} />
{:else if mode === "images"} {/if}
<div class="m-2 h-full overflow-y-auto"> </div>
<AggregateImages features={$featuresStore} onlyShowUsername={$username?.split(";")} /> </div>
</div>
{/if} </TabPanel>
<TabPanel class="overflow-auto grow-0">
{#each $featuresStore as f}
<History onlyShowChangesBy={$username?.split(";")} id={f.properties.id} />
{/each}
</TabPanel>
<TabPanel >
<AggregateView features={$featuresStore} onlyShowUsername={$username?.split(";")} />
</TabPanel>
<TabPanel>
<AggregateImages features={$featuresStore} onlyShowUsername={$username?.split(";")} />
</TabPanel>
</TabPanels>
</TabGroup>
</div> </div>
<Page shown={showPreviouslyVisited}> <Page shown={showPreviouslyVisited}>