diff --git a/app/src/lib/components/ui/table/table-cell.svelte b/app/src/lib/components/ui/table/table-cell.svelte
index 5329134596..6af9fe242c 100644
--- a/app/src/lib/components/ui/table/table-cell.svelte
+++ b/app/src/lib/components/ui/table/table-cell.svelte
@@ -9,7 +9,7 @@ export { className as class }
{value}
-
-
diff --git a/app/src/routes/explorer/(components)/cell-status.svelte b/app/src/routes/explorer/(components)/cell-status.svelte
new file mode 100644
index 0000000000..1a56e4be22
--- /dev/null
+++ b/app/src/routes/explorer/(components)/cell-status.svelte
@@ -0,0 +1,7 @@
+
+
+{value}
diff --git a/app/src/routes/explorer/(components)/table.svelte b/app/src/routes/explorer/(components)/table.svelte
new file mode 100644
index 0000000000..d888e23b7a
--- /dev/null
+++ b/app/src/routes/explorer/(components)/table.svelte
@@ -0,0 +1,96 @@
+
+
+
+
+
+
+ {#each $table.getHeaderGroups() as headerGroup (headerGroup.id)}
+
+ {#each headerGroup.headers as header (header.id)}
+
+ {/each}
+
+ {/each}
+
+
+ {#each $virtualizer.getVirtualItems() as row, index (row.index)}
+
+ {#each $rows[row.index].getVisibleCells() as cell, index (cell.id)}
+
+
+
+ {/each}
+
+ {/each}
+
+
+
+
diff --git a/app/src/routes/explorer/+layout.svelte b/app/src/routes/explorer/+layout.svelte
index 600fed0718..4adade749f 100644
--- a/app/src/routes/explorer/+layout.svelte
+++ b/app/src/routes/explorer/+layout.svelte
@@ -63,6 +63,11 @@ onNavigate(navigation => {
})
+
+ Union - Explorer
+
+
+
-import {
- flexRender,
- type ColumnDef,
- getCoreRowModel,
- type TableOptions,
- createSvelteTable,
- getFilteredRowModel,
- getPaginationRowModel
-} from "@tanstack/svelte-table"
+import { flexRender, type ColumnDef } from "@tanstack/svelte-table"
import request from "graphql-request"
import { URLS } from "$lib/constants"
import { writable } from "svelte/store"
import { DurationUnits } from "svelte-ux"
-import { cn } from "$lib/utilities/shadcn.ts"
import { CHAIN_MAP } from "$lib/constants/chains"
-import * as Table from "$lib/components/ui/table"
import { createQuery } from "@tanstack/svelte-query"
import { removeArrayDuplicates } from "$lib/utilities"
import type { Override } from "$lib/utilities/types.ts"
-import { createVirtualizer } from "@tanstack/svelte-virtual"
import Button from "$lib/components/ui/button/button.svelte"
import CellText from "../(components)/cell-plain-text.svelte"
import CellDurationText from "../(components)/cell-duration-text.svelte"
import { cosmosBlocksQuery } from "$lib/graphql/documents/cosmos-blocks.ts"
+import Table from "../(components)/table.svelte"
+
$: cosmosBlocks = createQuery({
queryKey: ["cosmos-blocks"],
refetchInterval: 6_000,
@@ -44,15 +35,14 @@ $: if (blockData) {
removeArrayDuplicates([...(blockData as Array), ...currentBlocks], "height")
)
}
-
-const defaultColumns: Array> = [
+const columns = [
{
accessorKey: "time",
size: 100,
meta: {
class: "ml-1.5 justify-start"
},
- header: info => "Time",
+ header: () => "Time",
cell: info =>
flexRender(CellDurationText, {
totalUnits: 3,
@@ -64,7 +54,7 @@ const defaultColumns: Array> = [
},
{
accessorKey: "height",
- header: info => "Height",
+ header: () => "Height",
size: 100,
meta: {
class: "w-full justify-start"
@@ -82,28 +72,26 @@ const defaultColumns: Array> = [
},
{
accessorKey: "chain_id",
- header: info => "Chain ID",
+ header: () => "Chain ID",
meta: {
class: "w-full justify-start"
},
- size: 100,
- maxSize: 100,
+ size: 200,
cell: info =>
flexRender(CellText, {
- value: CHAIN_MAP[info.getValue() as unknown as number].chainId,
- class: "min-w-[105px] text-clip"
+ value: CHAIN_MAP[info.getValue() as unknown as number].chainId
})
},
{
accessorKey: "hash",
meta: {
- class: "w-full justify-start ml-1.5"
+ class: "w-full justify-start"
},
- header: info => flexRender(CellText, { value: "Hash", class: "text-left" }),
+ header: () => flexRender(CellText, { value: "Hash" }),
size: 1000,
cell: info =>
flexRender(Button, {
- class: "py-0 px-2.5 max-w-[600px]",
+ class: "p-0 font-mono",
variant: "link",
target: "_blank",
value: info.getValue(),
@@ -111,109 +99,9 @@ const defaultColumns: Array> = [
href: `https://rpc.testnet.bonlulu.uno/block_by_hash?hash=${info.getValue()}`
})
}
-]
-
-const options = writable>({
- data: $blocksStore,
- enableHiding: true,
- enableFilters: true,
- columns: defaultColumns,
- autoResetPageIndex: true, // Automatically update pagination when data or page size changes
- enableColumnFilters: true,
- enableColumnResizing: true,
- enableMultiRowSelection: true,
- getCoreRowModel: getCoreRowModel(),
- getFilteredRowModel: getFilteredRowModel(),
- getPaginationRowModel: getPaginationRowModel()
-})
-
-let virtualListElement: HTMLDivElement
-
-const rerender = () =>
- options.update(options => ({ ...options, data: $blocksStore as unknown as Array }))
-
-const table = createSvelteTable(options)
-
-$: blocksStore.subscribe(() => {
- if (!$blocksStore) return
- $table.setPageSize($blocksStore.length)
- rerender()
-})
-
-$: rows = $table.getRowModel().rows
-
-$: virtualizer = createVirtualizer({
- overscan: 20,
- count: rows.length,
- estimateSize: () => 34,
- getScrollElement: () => virtualListElement
-})
+] as Array>
-
- Union - Explorer
-
+
+{JSON.stringify($blocksStore, null, 2)}
-
-
-
- {#each $table.getHeaderGroups() as headerGroup (headerGroup.id)}
-
- {#each headerGroup.headers as header (header.id)}
-
- {#if !header.isPlaceholder}
-
- {/if}
-
- {/each}
-
- {/each}
-
-
- {#each $virtualizer.getVirtualItems() as row, index (row.index)}
-
- {#each rows[row.index].getVisibleCells() as cell, index (cell.id)}
-
-
-
- {/each}
-
- {/each}
-
-
-
-
-
diff --git a/app/src/routes/explorer/index-status/+page.svelte b/app/src/routes/explorer/index-status/+page.svelte
index 348a1554ef..2228292ca4 100644
--- a/app/src/routes/explorer/index-status/+page.svelte
+++ b/app/src/routes/explorer/index-status/+page.svelte
@@ -1,24 +1,71 @@
-Index Status
+$: indexStatusData = $indexStatus?.data?.v0_index_status ?? []
+
+type IndexStatus = (typeof indexStatusData)[number]
+
+$: indexStatusStore = writable>(indexStatusData as Array)
+$: if (indexStatus) {
+ indexStatusStore.update(currentStatuses =>
+ removeArrayDuplicates(
+ [...(indexStatusData as Array), ...currentStatuses],
+ "chain_id"
+ )
+ )
+}
+
+const columns: Array> = [
+ {
+ accessorKey: "display_name",
+ header: () => "Chain",
+ size: 200,
+ cell: info => info.getValue()
+ },
+ {
+ accessorKey: "chain_id",
+ header: () => "Chain ID",
+ size: 200,
+ cell: info => info.getValue()
+ },
+ {
+ accessorKey: "timestamp",
+ header: () => "Latest block",
+ size: 200,
+ cell: info =>
+ flexRender(CellDurationText, {
+ totalUnits: 3,
+ variant: "short",
+ minUnits: DurationUnits.Second,
+ start: new Date(info.getValue() as string)
+ })
+ },
+ {
+ accessorKey: "status",
+ header: () => "Status",
+ size: 200,
+ cell: info =>
+ flexRender(CellStatus, {
+ value: info.getValue()
+ })
+ }
+]
+
-{#if $indexStatus?.data }
-
- {JSON.stringify($indexStatus?.data, null, 2)}
-
-{/if}
+
|