diff --git a/package-lock.json b/package-lock.json index fd500b8..fe2e2ce 100644 --- a/package-lock.json +++ b/package-lock.json @@ -8,6 +8,7 @@ "name": "web-pwa", "version": "0.0.1", "dependencies": { + "@owlboard/api-schema-types": "^3.0.3-alpha18", "@owlboard/owlboard-ts": "^3.0.0-dev.20260509t2101", "@tabler/icons-svelte": "^3.40.0" }, @@ -801,9 +802,9 @@ } }, "node_modules/@owlboard/api-schema-types": { - "version": "3.0.3-alpha17", - "resolved": "https://git.fjla.uk/api/packages/OwlBoard/npm/%40owlboard%2Fapi-schema-types/-/3.0.3-alpha17/api-schema-types-3.0.3-alpha17.tgz", - "integrity": "sha512-9jtsajZIq/1W9w1XPSIQSH/rcH2mfnS+3XoQpe81Yor2pOVl5+iyHZ9wAlJLrLEVKVVs3k4lkjcM5l6KgWgd9w==", + "version": "3.0.3-alpha18", + "resolved": "https://git.fjla.uk/api/packages/OwlBoard/npm/%40owlboard%2Fapi-schema-types/-/3.0.3-alpha18/api-schema-types-3.0.3-alpha18.tgz", + "integrity": "sha512-k9X83i8ljatuiKQWNxgixid8tneM0i0G5NP1Wo1N2O0SF0PBMs3gxkEMWwKMuc+htiGCeRLqvIZqrm//Bgeo/w==", "license": "MIT" }, "node_modules/@owlboard/owlboard-ts": { diff --git a/package.json b/package.json index d912866..ebeadea 100644 --- a/package.json +++ b/package.json @@ -41,6 +41,7 @@ "vitest-browser-svelte": "^2.0.2" }, "dependencies": { + "@owlboard/api-schema-types": "^3.0.3-alpha18", "@owlboard/owlboard-ts": "^3.0.0-dev.20260509t2101", "@tabler/icons-svelte": "^3.40.0" } diff --git a/src/lib/components/ui/TrainService.svelte b/src/lib/components/ui/TrainService.svelte index 3bdb509..104d3c5 100644 --- a/src/lib/components/ui/TrainService.svelte +++ b/src/lib/components/ui/TrainService.svelte @@ -7,6 +7,7 @@ import TocStyle from '$lib/components/ui/TocStyle.svelte'; import TiplocConverter from '$lib/components/ui/TiplocConverter.svelte'; import { IconChevronDownFilled } from '@tabler/icons-svelte'; + import { estClass } from '$lib/utils/time'; let { service }: { service: ApiTrainsTrainByHeadcode.TrainByHeadcodeResponse } = $props(); let isExpanded = $state(false); let loadingDetails = $state(false); @@ -45,8 +46,6 @@ loadingDetails = false; } - const estClass = (act, est) => (!act && est ? 'est' : 'act'); - const activityMap: Record = { '-D': 'Vehicles detatched', '-T': 'Vehicles attached & detached', diff --git a/src/lib/components/ui/station-board/StaffServicesTable.svelte b/src/lib/components/ui/station-board/StaffServicesTable.svelte new file mode 100644 index 0000000..26f7ec1 --- /dev/null +++ b/src/lib/components/ui/station-board/StaffServicesTable.svelte @@ -0,0 +1,117 @@ + + +
+ + + + + + + + + + + + + + + + + + + + + + {#each services as service (getRowKey(service))} + + + + + + + + + {#if service.wtp} + + + + {:else} + + + + + {/if} + + {#if service} + {@const delay = calculateDelay(service)} + + {/if} + + + {#if service.c && service.cr?.r} + + + + {/if} + + {/each} + +
ArrDep
IDOrigDestPltSchActSchAct+/-
{service.h}{service.og.t}{service.dt.t}{service.p}Pass{formatUkTime(service.wtp)}{formatUkTime(service.atp || service.etp)}{formatUkTime(service.sta)}{formatUkTime(service.ata || service.eta)}{formatUkTime(service.std)}{formatUkTime(service.atd || service.etd)}{delay.val}
{service.cr.r}
+
+ + \ No newline at end of file diff --git a/src/lib/components/ui/cards/StationAlertCard.svelte b/src/lib/components/ui/station-board/StationAlertCard.svelte similarity index 100% rename from src/lib/components/ui/cards/StationAlertCard.svelte rename to src/lib/components/ui/station-board/StationAlertCard.svelte diff --git a/src/lib/global.css b/src/lib/global.css index d8f8181..b0e3db6 100644 --- a/src/lib/global.css +++ b/src/lib/global.css @@ -171,7 +171,7 @@ } 25%, 75% { - opacity: 0; + opacity: 0.25; } } diff --git a/src/lib/utils/time.ts b/src/lib/utils/time.ts index 890191b..0b2aa20 100644 --- a/src/lib/utils/time.ts +++ b/src/lib/utils/time.ts @@ -1,4 +1,7 @@ import type { ApiTrainsTrainDetails } from '@owlboard/owlboard-ts'; + +export const estClass = (act: any, est: any) => (!act && est ? 'est' : 'act'); + /** * Converts ISO/JSON time to UK-formatted HH:MM string, with optional (default off) seconds * Ensures Europe/London timezone irrespective of browser timezone. @@ -49,21 +52,40 @@ export function formatUkDateTime( .replace(',', ''); } +/** + * Specific type that can handle the TrainDetails.ServiceLocation and the ApiStationsBoard.BoardService types for delay calculation + */ +interface DelayInput { + // Board types + sta?: string | null; std?: string | null; + eta?: string | null; etd?: string | null; + ata?: string | null; atd?: string | null; + + // Journey types + pta?: string | null; ptd?: string | null; + wta?: string | null; wtd?: string | null; + atp?: string | null; wtp?: string | null; + etp?: string | null; +} + /** * Calculates a 'delay' value, in the formats: * RT, 1E, 7L, etc. - * @param 'Schedule Location' object + * @param 'Schedule Location' or 'Board Service' object * @returns Delay string for departure boards */ -export function calculateDelay(loc: ApiTrainsTrainDetails.ServiceLocation): { +export function calculateDelay(loc: DelayInput): { val: string; type: string; } { const pairs = [ - { actual: loc.atd, sched: loc.ptd ?? loc.wtd }, - { actual: loc.ata, sched: loc.pta ?? loc.wta }, - { actual: loc.atp, sched: loc.wtp } - ]; + // Departure check (Board: atd/etd vs std | Journey: atd vs ptd/wtd) + { actual: loc.atd || loc.etd, sched: loc.std || loc.ptd || loc.wtd }, + // Arrival check (Board: ata/eta vs sta | Journey: ata vs pta/wta) + { actual: loc.ata || loc.eta, sched: loc.sta || loc.pta || loc.wta }, + // Passing check + { actual: loc.atp || loc.etp, sched: loc.wtp } + ]; const match = pairs.find((p) => p.actual && p.sched); diff --git a/src/routes/board/+page.svelte b/src/routes/board/+page.svelte index 62db472..d32af5c 100644 --- a/src/routes/board/+page.svelte +++ b/src/routes/board/+page.svelte @@ -1,9 +1,10 @@