diff --git a/src/lib/api/ApiSchema.ts b/src/lib/api/ApiSchema.ts index 4596fd1..9a24037 100644 --- a/src/lib/api/ApiSchema.ts +++ b/src/lib/api/ApiSchema.ts @@ -94,6 +94,10 @@ type Topics = method: 'GET'; path: `/streams/${number}/topics/${number}`; } + | { + method: 'GET'; + path: `/streams/${number}/topics/${number}/messages`; + } | { method: 'POST'; path: `/streams/${number}/topics`; diff --git a/src/lib/components/Modals/AppModals.svelte b/src/lib/components/Modals/AppModals.svelte index 780ad6f..5d3830d 100644 --- a/src/lib/components/Modals/AppModals.svelte +++ b/src/lib/components/Modals/AppModals.svelte @@ -1,30 +1,32 @@ + + +
+
+

+ {message.id} +

+

+

+ {message.state} +

+
+
+

+ {message.checksum} +

+

+

+ {message.header} +

+
+
+

+ {message.timestamp} +

+

+

+ {message.header} +

+
+ + +
+
diff --git a/src/lib/components/Modals/ModalBase.svelte b/src/lib/components/Modals/ModalBase.svelte index a6c43f9..172cf20 100644 --- a/src/lib/components/Modals/ModalBase.svelte +++ b/src/lib/components/Modals/ModalBase.svelte @@ -43,13 +43,13 @@ )} >
- {#if title} -
-

{title}

+
+

{title}

{/if} diff --git a/src/lib/components/RouteComponents/Settings/UsersTab.svelte b/src/lib/components/RouteComponents/Settings/UsersTab.svelte index 7904882..41de049 100644 --- a/src/lib/components/RouteComponents/Settings/UsersTab.svelte +++ b/src/lib/components/RouteComponents/Settings/UsersTab.svelte @@ -116,7 +116,7 @@ /> {/if}
-
+
{row.id}
@@ -126,7 +126,7 @@
-
+
{row.createdAt}
@@ -154,7 +154,7 @@ close(); }} class={twMerge( - ' grid grid-cols-[20px,1fr] gap-x-1 rounded-md items-center w-full px-2 py-2 text-sm text-color cursor-default hoverable-strong' + 'grid grid-cols-[20px,1fr] gap-x-1 rounded-md items-center w-full px-2 py-2 text-sm text-color cursor-default hoverable-strong' )} > diff --git a/src/lib/components/SortableList.svelte b/src/lib/components/SortableList.svelte index cb2977d..c1c6ce6 100644 --- a/src/lib/components/SortableList.svelte +++ b/src/lib/components/SortableList.svelte @@ -51,6 +51,7 @@ }); export let hrefBuilder: ((item: T) => string) | undefined = undefined; + export let onclickAction: ((index: number) => any) | undefined = undefined; let ordering: Ordering = { key: undefined, @@ -78,7 +79,7 @@ } -
+
{columnDisplayedName} @@ -126,15 +127,19 @@
{#if data.length === 0 && !isAnimating} -
+
{emptyDataMessage}
{/if} - {#each orderedData as item (item.id)} + {#each orderedData as item, index} { if (!animationEnabled) return; e.target.style.backgroundColor = 'rgb(74, 222, 128)'; diff --git a/src/lib/domain/Message.ts b/src/lib/domain/Message.ts new file mode 100644 index 0000000..666cc77 --- /dev/null +++ b/src/lib/domain/Message.ts @@ -0,0 +1,36 @@ +export type Message = { + checksum: number; + header: Record; + id: number; + offset: number; + payload: string; + truncatedPayload: string + state: "available"; + timestamp: number; +}; + +export function messageMapper(item: any): Message { + let payload = ""; + + try { + payload = atob(item.payload) + } catch { + payload = "[NOT DECODABLE]" + } + + let truncatedPayload = payload; + if (payload.length > 100) { + truncatedPayload = `${payload.slice(0, 100)} [...]` + } + + return { + id: item.id, + header: item.header, + offset: item.offset, + payload, + state: item.state, + timestamp: item.timestamp, + checksum: item.checksum, + truncatedPayload, + }; +} diff --git a/src/lib/domain/MessageDetails.ts b/src/lib/domain/MessageDetails.ts new file mode 100644 index 0000000..9190178 --- /dev/null +++ b/src/lib/domain/MessageDetails.ts @@ -0,0 +1,11 @@ +import { Message, messageMapper } from './Message'; + +type Payload = { + partition_id: number, + current_offset: number, + messages: Array, +} + +export function messageDetailsMapper(payload: Payload): Array { + return payload.messages.map(messageMapper); +} diff --git a/src/lib/types/appRoutes.ts b/src/lib/types/appRoutes.ts index 7961ce2..0a00ec0 100644 --- a/src/lib/types/appRoutes.ts +++ b/src/lib/types/appRoutes.ts @@ -5,6 +5,7 @@ type DashboardRoutes = `/dashboard/${ | 'streams' | `streams/${number}` | `streams/${number}/topics/${number}` + | `streams/${number}/topics/${number}/messages` | 'clients' | 'logs' | SettingsSegment}`; diff --git a/src/routes/dashboard/streams/[streamId=i32]/+page.svelte b/src/routes/dashboard/streams/[streamId=i32]/+page.svelte index 2966f3e..99bd2e6 100644 --- a/src/routes/dashboard/streams/[streamId=i32]/+page.svelte +++ b/src/routes/dashboard/streams/[streamId=i32]/+page.svelte @@ -1,5 +1,4 @@ + +
+ + +

Messages for {topic.name}

+ +
+
+ Messages: {topic.messagesCount} +
+
+
+ + + openModal('InspectMessage', { message: data.messages[index] }) + } + colNames={{ + offset: "Offset", + truncatedPayload: "Payload", + timestamp: "timestamp", + checksum: "Checksum", + header: "Headers", + }} +/>