From d077726894266bd073b40c6f59ab88f3041e3a9c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tom=C3=A1=C5=A1=20Ml=C3=A1dek?= Date: Wed, 28 Jun 2023 18:50:33 +0200 Subject: [PATCH] wip: add labels to address types --- webui/src/components/Inspect.svelte | 40 +++++++++++++++++++++-------- 1 file changed, 29 insertions(+), 11 deletions(-) diff --git a/webui/src/components/Inspect.svelte b/webui/src/components/Inspect.svelte index 6970bb6..1e0d1e0 100644 --- a/webui/src/components/Inspect.svelte +++ b/webui/src/components/Inspect.svelte @@ -9,7 +9,7 @@ import NotesEditor from "./utils/NotesEditor.svelte"; import type { AttributeChange } from "../types/base"; import Selector from "./utils/Selector.svelte"; - import type { EntityInfo, IValue } from "upend/types"; + import type { ADDRESS_TYPE, EntityInfo, IValue } from "upend/types"; import IconButton from "./utils/IconButton.svelte"; import type { BrowseContext } from "../util/browse"; import { Link, useParams } from "svelte-navigator"; @@ -76,16 +76,34 @@ const labelsQuery = await api.query( `(matches (in ${typeAddressesIn}) "${ATTR_LABEL}" ?)` ); - typeAddresses.forEach((address) => { - let labels = labelsQuery.getObject(address).identify(); - if (!labels.length) { - labels.push(address); - } - allTypes[address] = { - labels, - attributes: [], - }; - }); + await Promise.all( + typeAddresses.map(async (address) => { + let labels = labelsQuery.getObject(address).identify(); + + let typeLabel: string | undefined; + await Promise.all( + (["Hash", "Uuid", "Attribute", "Url"] as ADDRESS_TYPE[]).map( + async (t) => { + if ((await api.getAddress(t)) == address) { + labels.push(`[${t}]`); + } + } + ) + ); + if (typeLabel) { + labels.unshift(typeLabel); + } + + if (!labels.length) { + labels.push(address); + } + + allTypes[address] = { + labels, + attributes: [], + }; + }) + ); const attributes = await api.query( `(matches ? "${ATTR_OF}" (in ${typeAddressesIn}))`