diff --git a/ui/src/lib/entity.ts b/ui/src/lib/entity.ts index 226fce0..02e6ebb 100644 --- a/ui/src/lib/entity.ts +++ b/ui/src/lib/entity.ts @@ -42,6 +42,33 @@ export function useEntity(address: string | (() => string), condition?: () => Bo } } + +export function query(query: string | (() => string), condition?: () => Boolean) { + const { data, error, mutate } = useSWRV( + () => (condition === undefined || condition()) ? `/api/obj?query=${typeof query === "string" ? query : query()}` : null, + fetcher + ); + + const result = computed(() => { + if (data?.value) { + const entries = Object.entries(data.value) as [string, IEntry][]; + return entries + .sort(([_, a], [__, b]) => String(a.value.c).localeCompare(b.value.c)) + .sort(([_, a], [__, b]) => String(a.value.t).localeCompare(b.value.t)) + .sort(([_, a], [__, b]) => a.attribute.localeCompare(b.attribute)); + } else { + return []; + } + }); + + return { + result, + data, + error, + mutate + } +} + interface EntityIdentification { type: string; value: string; @@ -86,4 +113,4 @@ export function identify(attributes: ComputedRef<[string, IEntry][]>): ComputedR }) }).flat(); }); -} \ No newline at end of file +} diff --git a/ui/src/types/base.ts b/ui/src/types/base.ts index e5bfc56..3e45a9d 100644 --- a/ui/src/types/base.ts +++ b/ui/src/types/base.ts @@ -28,4 +28,8 @@ export interface IFile { export interface VaultInfo { name: string | null; location: string; +} + +export interface IType { + name?: string; } \ No newline at end of file diff --git a/ui/src/views/Inspect.vue b/ui/src/views/Inspect.vue index 6b779ef..c302f5a 100644 --- a/ui/src/views/Inspect.vue +++ b/ui/src/views/Inspect.vue @@ -9,6 +9,14 @@