diff --git a/webui/src/components/Inspect.svelte b/webui/src/components/Inspect.svelte index bf56457..547a2d8 100644 --- a/webui/src/components/Inspect.svelte +++ b/webui/src/components/Inspect.svelte @@ -198,9 +198,6 @@ (entry) => ![ATTR_IN].includes(entry.attribute) )) || []; - $: groups = ($entity?.attr[ATTR_IN] || []).map( - (e) => [e.value.c as string, e.address] as [string, string] - ); $: tagged = $entity?.attr[`~${ATTR_IN}`] || []; let attributesUsed: UpEntry[] = []; @@ -372,15 +369,12 @@ {#if !$error} - {#if groups.length} (highlightedType = ev.detail)} on:change={() => revalidate()} /> - {/if}
{#each Object.entries(typedAttributes) as [typeAddr, entries] (typeAddr)} - import UpObject from "./display/UpObject.svelte"; + import UpObjectDisplay from "./display/UpObject.svelte"; import Selector from "./utils/Selector.svelte"; import IconButton from "./utils/IconButton.svelte"; import type { IValue } from "upend/types"; @@ -7,12 +7,17 @@ import { ATTR_IN } from "upend/constants"; import { createEventDispatcher } from "svelte"; import { i18n } from "../i18n"; + import type { UpObject } from "upend"; + import type { Readable } from "svelte/store"; const dispatch = createEventDispatcher(); - export let address: string; - export let groups: [string, string][]; + export let entity: Readable; export let editable = false; + $: groups = ($entity?.attr[ATTR_IN] || []).map( + (e) => [e.value.c as string, e.address] as [string, string] + ); + let groupToAdd: IValue | undefined; async function addGroup() { if (!groupToAdd) { @@ -20,7 +25,7 @@ } await api.putEntry([ { - entity: address, + entity: $entity.address, attribute: ATTR_IN, value: { t: "Address", @@ -38,37 +43,39 @@ } -
-

{$i18n.t("Groups")}

-
- {#each groups as [groupAddress, groupEntryAddress]} -
dispatch("highlighted", groupAddress)} - on:mouseleave={() => dispatch("highlighted", undefined)} - > - - {#if editable} - removeGroup(groupEntryAddress)} +{#if groups.length || editable} +
+

{$i18n.t("Groups")}

+
+ {#each groups as [groupAddress, groupEntryAddress]} +
dispatch("highlighted", groupAddress)} + on:mouseleave={() => dispatch("highlighted", undefined)} + > + + {#if editable} + removeGroup(groupEntryAddress)} + /> + {/if} +
+ {/each} + {#if editable} +
+ - {/if} -
- {/each} - {#if editable} -
- -
- {/if} -
-
+
+ {/if} +
+
+{/if}