From 53b72abff1bd9ec4187770d4dce52235a2ae1d1a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tom=C3=A1=C5=A1=20Ml=C3=A1dek?= Date: Fri, 14 Jan 2022 22:05:17 +0100 Subject: [PATCH] [webui] search finds object --- webui/src/lib/entity.ts | 9 ++- webui/src/views/Search.svelte | 101 ++++++++++++++++++++++++++++------ 2 files changed, 91 insertions(+), 19 deletions(-) diff --git a/webui/src/lib/entity.ts b/webui/src/lib/entity.ts index e667e4f..cdaa49e 100644 --- a/webui/src/lib/entity.ts +++ b/webui/src/lib/entity.ts @@ -1,7 +1,7 @@ // import { useSWR } from "sswr"; import LRU from "lru-cache"; import { derived, Readable } from "svelte/store"; -import { UpListing, UpObject } from "upend"; +import { UpEntry, UpListing, UpObject } from "upend"; import type { ListingResult } from "upend/types"; import { useSWR } from "../util/fetch"; @@ -27,6 +27,13 @@ export function useEntity(address: string) { }; } +export async function fetchEntry(address: string) { + const response = await fetch(`/api/raw/${address}`); + const data = await response.json(); + const listing = new UpListing({ address: data }); + return listing.entries[0]; +} + export function query(query: () => string) { let queryString = typeof query === "string" ? query : query(); console.debug(`Querying: ${queryString}`); diff --git a/webui/src/views/Search.svelte b/webui/src/views/Search.svelte index 1cbed24..f8157cf 100644 --- a/webui/src/views/Search.svelte +++ b/webui/src/views/Search.svelte @@ -1,9 +1,13 @@
- {#if $result} -
-

Objects

-
-
-

Raw results

-
    - {#each $result.entries as entry} -
  • + {#if !$error} + {#if $result} +
    +

    Exact

    + {#if exact.length} + exakt {:else} -
  • No results.
  • - {/each} -
-
+ Create? + {/if} + + {#await objects} +
+

Objects

+ +
+ {:then objects} +
+

Objects

+
    + {#each objects as address} +
  • + {/each} +
+
+ {/await} + {#if entries.length} +
+

Raw results

+
    + {#each entries as entry} +
  • + {/each} +
+
+ {:else} +
No results found.
+ {/if} + {:else} +
+ +
+ {/if} + {:else} +
+ {$error} +
{/if}
@@ -47,10 +103,19 @@ ul { list-style: none; margin: 0; + padding: 0; } - + li { margin: 1em auto; - width: 66em; + max-width: 66em; + } + + .global { + font-size: 48px; + position: absolute; + top: 50%; + left: 50%; + transform: translate(-50%, -50%); }