diff --git a/ui/src/components/Address.svelte b/ui/src/components/Address.svelte index 598865e..0846b53 100644 --- a/ui/src/components/Address.svelte +++ b/ui/src/components/Address.svelte @@ -1,19 +1,20 @@
diff --git a/ui/src/components/widgets/Table.svelte b/ui/src/components/widgets/Table.svelte index ff50a93..b97eb5a 100644 --- a/ui/src/components/widgets/Table.svelte +++ b/ui/src/components/widgets/Table.svelte @@ -13,12 +13,14 @@ export let attributes: OrderedListing; export let editable = false; - let newEntryAttribute = "'"; - let newEntryValue = ""; - + // Pagination let currentDisplay = 999; const MAX_DISPLAY = 50; + // Editing + let newEntryAttribute = "'"; + let newEntryValue = ""; + async function addEntry() { // this.$emit("edit", { // type: "create", @@ -50,8 +52,28 @@ // } as AttributeChange); } - let resolve = []; + // Sorting + let resolvedValues: { [key: string]: string } = {}; + $: sortedAttributes = attributes + .concat() + .sort(([aHash, _], [bHash, __]) => { + if ( + resolvedValues[aHash] === undefined || + resolvedValues[bHash] === undefined + ) { + return 0; + } else { + return resolvedValues[aHash].localeCompare(resolvedValues[bHash]); + } + }) + .sort(([_, aEntry], [__, bEntry]) => { + return aEntry.attribute.localeCompare(bEntry.attribute); + }) + .sort(([_, aEntry], [__, bEntry]) => { + return aEntry.entity.localeCompare(bEntry.entity); + }); + // Formatting & Display const ATTRIBUTE_LABELS: { [key: string]: string } = { FILE_MIME: "MIME type", FILE_MTIME: "Last modified", @@ -73,6 +95,9 @@ return handler(value); } } + + // Optimizations + let resolve = []; @@ -106,7 +131,7 @@ {/if} - {#each attributes as [id, entry] (id)} + {#each sortedAttributes as [id, entry] (id)} {#if editable}
@@ -140,7 +165,9 @@ link address={entry.value.c} resolve={Boolean(resolve[id]) || true} - data-id={id} + on:resolved={(event) => { + resolvedValues[id] = event.detail[0]; + }} /> {:else}