diff --git a/src/lib/ldb/alert-bar.svelte b/src/lib/ldb/alert-bar.svelte new file mode 100644 index 0000000..765111e --- /dev/null +++ b/src/lib/ldb/alert-bar.svelte @@ -0,0 +1,112 @@ + + +
+
+ + {#if uniqueAlerts.length == 1} +

There is one active alert

+ {:else if uniqueAlerts.length > 1} +

There are {numberAsWord(uniqueAlerts.length)} active alerts

+ {:else} +

There are no active alerts

+ {/if} + +
+{#if displayAlerts} +
+ {#each uniqueAlerts as msg} +

{@html msg}

+ {/each} +
+{/if} + + \ No newline at end of file diff --git a/src/lib/ldb/public-ldb.svelte b/src/lib/ldb/public-ldb.svelte index ac16b9b..2f84b39 100644 --- a/src/lib/ldb/public-ldb.svelte +++ b/src/lib/ldb/public-ldb.svelte @@ -4,6 +4,7 @@ import { onMount } from 'svelte' import Loading from '$lib/navigation/loading.svelte'; import OverlayIsland from '$lib/islands/overlay-island.svelte'; + import AlertBar from './alert-bar.svelte'; let requestedStation; $: requestedStation = station; @@ -15,6 +16,7 @@ let dataAge = null; let isLoading = true; let dataExists = false; + let alerts = []; let serviceDetail; $: { @@ -61,6 +63,7 @@ } finally { isLoading = false; // Clear loading state } + prepareNrcc() } function parseTime(string){ @@ -123,6 +126,18 @@ serviceDetail = null; } + async function prepareNrcc() { + if (jsonData?.GetStationBoardResult?.nrccMessages?.message) { + const nrcc = jsonData.GetStationBoardResult.nrccMessages.message; + if (Array.isArray(nrcc)) { + alerts = nrcc + return; + } + alerts.push(nrcc); + return; + } + } + onMount(() => { if (requestedStation && jsonData === null) { fetchData(); @@ -130,6 +145,10 @@ }); +{#if alerts.length} + +{/if} + {#if isLoading} {:else} diff --git a/src/lib/navigation/header.svelte b/src/lib/navigation/header.svelte index 96369fa..0abb7d2 100644 --- a/src/lib/navigation/header.svelte +++ b/src/lib/navigation/header.svelte @@ -23,6 +23,7 @@ margin: 0; padding: 0; height: 50px; + z-index: 20; } img { diff --git a/static/images/navigation/alert.svg b/static/images/navigation/alert.svg new file mode 100644 index 0000000..68b5777 --- /dev/null +++ b/static/images/navigation/alert.svg @@ -0,0 +1,10 @@ + + + + + + + + + +image/svg+xmlOpenclipartWarning Notification2007-02-08T17:08:47Beveled yellow caution signhttp://openclipart.org/detail/3130/warning-notification-by-eastshoreseastshoresalertcautionclip artcliparticonimagemediapublic domainsvgwarning