From 5021e01018842e98a7ed4692e254ab37d48e4b14 Mon Sep 17 00:00:00 2001 From: Raj Nandan Sharma Date: Fri, 19 Jun 2026 11:23:57 +0530 Subject: [PATCH 1/4] implement event display settings and notifications list component implements #665 --- src/lib/client/notifications-client.ts | 19 +++ src/lib/components/NotificationsList.svelte | 111 +++++++++++++++++ .../components/NotificationsPopover.svelte | 66 +--------- src/lib/components/ThemePlus.svelte | 8 +- .../server/controllers/dashboardController.ts | 7 +- .../server/controllers/layoutController.ts | 38 +++++- src/lib/server/db/seedSiteData.ts | 1 + src/lib/types/site.ts | 1 + .../content/v4/setup/site-configuration.md | 6 +- src/routes/(kener)/+page.svelte | 114 ++++++++++-------- src/routes/(kener)/[page_path]/+page.svelte | 7 +- .../monitors/[monitor_tag]/+page.server.ts | 11 +- .../monitors/[monitor_tag]/+page.svelte | 7 +- .../app/site-configurations/+page.svelte | 53 +++++++- 14 files changed, 316 insertions(+), 133 deletions(-) create mode 100644 src/lib/client/notifications-client.ts create mode 100644 src/lib/components/NotificationsList.svelte diff --git a/src/lib/client/notifications-client.ts b/src/lib/client/notifications-client.ts new file mode 100644 index 00000000..3911276f --- /dev/null +++ b/src/lib/client/notifications-client.ts @@ -0,0 +1,19 @@ +import { resolve } from "$app/paths"; +import clientResolver from "$lib/client/resolver.js"; +import type { NotificationEvent } from "$lib/server/controllers/dashboardController.js"; + +interface NotificationsResponse { + notifications?: NotificationEvent[]; +} + +export async function requestNotifications(monitorTags: string[] = []): Promise { + const query = monitorTags.length > 0 ? `?tags=${encodeURIComponent(monitorTags.join(","))}` : ""; + const response = await fetch(clientResolver(resolve, "/dashboard-apis/notifications") + query); + + if (!response.ok) { + throw new Error("Failed to fetch notifications"); + } + + const payload = (await response.json()) as NotificationsResponse; + return payload.notifications || []; +} \ No newline at end of file diff --git a/src/lib/components/NotificationsList.svelte b/src/lib/components/NotificationsList.svelte new file mode 100644 index 00000000..9c4e9cdf --- /dev/null +++ b/src/lib/components/NotificationsList.svelte @@ -0,0 +1,111 @@ + + +{#snippet notificationItem(item: NotificationEvent)} +
+ {$t(item.eventType)} + {$t(item.eventStatus)} +
+
+

{item.eventTitle}

+
+
+ {$formatDate(item.eventDate, page.data.dateAndTimeFormat.datePlusTime)} + + + {$formatDuration(item.eventStartDateTime, item.eventEndDateTime, $t("Ongoing"))} +
+{/snippet} + +
+

{$t("Events")}

+ +
+ +{#if notifications.length === 0} +
+ {$t("No events to show")} +
+{:else} +
+ {#each notifications as item, i (`${item.eventType}-${item.eventURL}-${item.eventDate}-${i}`)} + {@const eventId = getEventId(item.eventURL)} + {#if item.eventURL.startsWith("/incidents/")} + + {@render notificationItem(item)} + + {:else} + + {@render notificationItem(item)} + + {/if} + {/each} +
+{/if} diff --git a/src/lib/components/NotificationsPopover.svelte b/src/lib/components/NotificationsPopover.svelte index 4eaba21e..69eb43f1 100644 --- a/src/lib/components/NotificationsPopover.svelte +++ b/src/lib/components/NotificationsPopover.svelte @@ -1,22 +1,18 @@ @@ -87,40 +67,6 @@ class="bg-background/30 supports-backdrop-filter:bg-background/20 w-96 rounded-3xl border p-0 shadow-2xl backdrop-blur-2xl" sideOffset={8} > -
-

{$t("Events")}

- -
- - {#if notifications.length === 0} -
- {$t("No events to show")} -
- {:else} - - {/if} + diff --git a/src/lib/components/ThemePlus.svelte b/src/lib/components/ThemePlus.svelte index 27adae91..921671b3 100644 --- a/src/lib/components/ThemePlus.svelte +++ b/src/lib/components/ThemePlus.svelte @@ -27,14 +27,16 @@ interface Props { monitor_tags?: string[]; embedMonitorTag?: string; + hideNotificationsPopover?: boolean; } - let { monitor_tags = [], embedMonitorTag = "" }: Props = $props(); + let { monitor_tags = [], embedMonitorTag = "", hideNotificationsPopover = false }: Props = $props(); let protocol = $state(""); let domain = $state(""); let shareLink = $state(""); const eventsPath = $derived(`/events/${format(new Date(), "MMMM-yyyy")}`); + const showNotificationsPopover = $derived(!hideNotificationsPopover); const rssHref = $derived.by(() => { const params = page.params; @@ -183,7 +185,9 @@ {/if} - + {#if showNotificationsPopover} + + {/if} {#if loginDetails}