diff --git a/src/lib/islands/island.svelte b/src/lib/islands/island.svelte index 098bb96..d036ab2 100644 --- a/src/lib/islands/island.svelte +++ b/src/lib/islands/island.svelte @@ -1,8 +1,10 @@ -
+
{variables.title}
diff --git a/src/lib/ldb/public-ldb.svelte b/src/lib/ldb/public-ldb.svelte index bc26675..bd8f263 100644 --- a/src/lib/ldb/public-ldb.svelte +++ b/src/lib/ldb/public-ldb.svelte @@ -5,6 +5,7 @@ import Loading from '$lib/navigation/loading.svelte'; import OverlayIsland from '$lib/islands/overlay-island.svelte'; import AlertBar from '$lib/ldb/nrcc/alert-bar.svelte'; + import Island from '$lib/islands/island.svelte'; let requestedStation; $: requestedStation = station; @@ -54,7 +55,7 @@ isLoading = true; // Set loading state try { console.log(`Requested Station: ${requestedStation}`); - const data = await fetch(`https://owlboard.info/api/v1/ldb/${requestedStation}`); + const data = await fetch(`https://owlboard.info/api/v2/live/station/${requestedStation}/public`); jsonData = await data.json(); } catch (error) { console.error('Error fetching data:', error); @@ -286,7 +287,9 @@ {/if} {:else} -

Unable to find this station

+ +

Unable to load data

+
{/if} {#if serviceDetail} diff --git a/src/lib/ldb/staff/staff-ldb.svelte b/src/lib/ldb/staff/staff-ldb.svelte index ec65191..b920b0f 100644 --- a/src/lib/ldb/staff/staff-ldb.svelte +++ b/src/lib/ldb/staff/staff-ldb.svelte @@ -3,20 +3,26 @@ export let title = 'Loading...'; import { onMount } from 'svelte'; import AlertBar from '$lib/ldb/nrcc/alert-bar.svelte'; - import ServiceRow from './service-row.svelte'; + //import ServiceRow from './service-row.svelte'; import StaffTrainDetail from '$lib/ldb/staff/train-detail.svelte'; import Reason from '$lib/raw-fetchers/reason.svelte'; import Loading from '$lib/navigation/loading.svelte'; import Nav from '$lib/navigation/nav.svelte'; import { uuid } from '$lib/stores/uuid'; + import Error from '../../../routes/+error.svelte'; + import Island from '$lib/islands/island.svelte'; let requestedStation; $: requestedStation = station; let jsonData = {}; - let services = []; + let services = [], + busServices = [], + ferryServices = []; let dataAge = null; let isLoading = true; + let isErr = false; + let errMsg; let alerts = []; let detail = { show: false, rid: '', uid: '', headcode: '' }; @@ -31,6 +37,18 @@ services = []; } + if (jsonData?.GetBoardResult?.busServices?.service) { + busServices = jsonData.GetBoardResult.busServices.service; + } else { + busServices = []; + } + + if (jsonData?.GetBoardResult?.ferryServices?.service) { + ferryServices = jsonData.GetBoardResult.ferryServices.service; + } else { + ferryServices = []; + } + if (jsonData?.GetBoardResult?.locationName) { title = jsonData.GetBoardResult.locationName; } else { @@ -54,9 +72,18 @@ } }; const data = await fetch(url, opt); - jsonData = await data.json(); + const json = await data.json(); + if (json.ERROR === 'NOT_FOUND') { + isErr = true; + errMsg = 'Unable to find this station'; + } else { + jsonData = json; + } } catch (error) { console.error('Error fetching data:', error); + isLoading = false; + isErr = true; + errMsg = 'Connection error, try again later'; } finally { isLoading = false; // Clear loading state } @@ -251,74 +278,232 @@ {#if isLoading} +{:else if isErr} + +

{errMsg}

+
{:else} {#if alerts.length} {/if} + + + + - - - - + + + + - {#each services as service} - {#await generateServiceData(service)} - - - - {:then serviceStats} - - - - - - - - - - - - - - {:catch} - - - - {/await} - {/each} + {#if !services.length} + + {:else} + {#each services as service} + {#await generateServiceData(service)} + + + + {:then serviceStats} + + + + + + + + + + + + + + {:catch} + + + + {/await} + {/each} + {/if}
Updated: {dataAge.toLocaleTimeString()} - Staff Boards under development
+ ArrivalDeparture
ID From To PlatSch ArrExp ArrSch DepExp DepSchExpSchExp
Loading...
{service.trainid}{serviceStats.from}{serviceStats.to}{serviceStats.platform.number || '-'}{serviceStats.schArr}{serviceStats.isArrDelayed ? 'LATE' : serviceStats.expArr}{serviceStats.schDep}{serviceStats.isDepDelayed ? 'LATE' : serviceStats.expDep}
- {service.operator} - {#if serviceStats.length} | {serviceStats.length} carriages{/if} -
- {#if service.cancelReason} - - {/if} - {#if service?.delayReason && !service.isCancelled} - - {/if} -
Unable to load service
No Scheduled Train Services
Loading...
{service.trainid}{serviceStats.from}{serviceStats.to}{serviceStats.platform.number || '-'}{serviceStats.schArr}{serviceStats.isArrDelayed ? 'LATE' : serviceStats.expArr}{serviceStats.schDep}{serviceStats.isDepDelayed ? 'LATE' : serviceStats.expDep}
+ {service.operator} + {#if serviceStats.length} | {serviceStats.length} carriages{/if} +
+ {#if service.cancelReason} + +
+ {/if} + {#if service?.delayReason && !service.isCancelled} + + {/if} +
Unable to load service
+ {#if busServices.length} +
+ Bus services
+ + + + + + + + + + + + + + + + {#each busServices as service} + {#await generateServiceData(service)} + + + + {:then serviceStats} + + + + + + + + + + + + + + {:catch} + + + + {/await} + {/each} +
+ ArrivalDeparture
IDFromToPlatSchExpSchExp
Loading...
{service.trainid}{serviceStats.from}{serviceStats.to}{serviceStats.platform.number || '-'}{serviceStats.schArr}{serviceStats.isArrDelayed ? 'LATE' : serviceStats.expArr}{serviceStats.schDep}{serviceStats.isDepDelayed ? 'LATE' : serviceStats.expDep}
+ {service.operator} + {#if serviceStats.length} | {serviceStats.length} carriages{/if} +
+ {#if service.cancelReason} + + {/if} + {#if service?.delayReason && !service.isCancelled} + + {/if} +
Unable to load service
+ {/if} + {#if ferryServices.length} +
+ Ferry services
+ + + + + + + + + + + + + + + + {#each ferryServices as service} + {#await generateServiceData(service)} + + + + {:then serviceStats} + + + + + + + + + + + + + + {:catch} + + + + {/await} + {/each} +
+ ArrivalDeparture
IDFromToPlatSchExpSchExp
Loading...
{service.trainid}{serviceStats.from}{serviceStats.to}{serviceStats.platform.number || '-'}{serviceStats.schArr}{serviceStats.isArrDelayed ? 'LATE' : serviceStats.expArr}{serviceStats.schDep}{serviceStats.isDepDelayed ? 'LATE' : serviceStats.expDep}
+ {service.operator} + {#if serviceStats.length} | {serviceStats.length} carriages{/if} +
+ {#if service.cancelReason} + + {/if} + {#if service?.delayReason && !service.isCancelled} + + {/if} +
Unable to load service
+ {/if} {/if}