Compare commits
2 Commits
v3.0.0-dev
...
main
| Author | SHA1 | Date | |
|---|---|---|---|
| 7edccf294b | |||
| 13d22d7b73 |
7
package-lock.json
generated
7
package-lock.json
generated
@@ -8,6 +8,7 @@
|
|||||||
"name": "web-pwa",
|
"name": "web-pwa",
|
||||||
"version": "0.0.1",
|
"version": "0.0.1",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
|
"@owlboard/api-schema-types": "^3.0.3-alpha18",
|
||||||
"@owlboard/owlboard-ts": "^3.0.0-dev.20260509t2101",
|
"@owlboard/owlboard-ts": "^3.0.0-dev.20260509t2101",
|
||||||
"@tabler/icons-svelte": "^3.40.0"
|
"@tabler/icons-svelte": "^3.40.0"
|
||||||
},
|
},
|
||||||
@@ -801,9 +802,9 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/@owlboard/api-schema-types": {
|
"node_modules/@owlboard/api-schema-types": {
|
||||||
"version": "3.0.3-alpha17",
|
"version": "3.0.3-alpha18",
|
||||||
"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",
|
"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-9jtsajZIq/1W9w1XPSIQSH/rcH2mfnS+3XoQpe81Yor2pOVl5+iyHZ9wAlJLrLEVKVVs3k4lkjcM5l6KgWgd9w==",
|
"integrity": "sha512-k9X83i8ljatuiKQWNxgixid8tneM0i0G5NP1Wo1N2O0SF0PBMs3gxkEMWwKMuc+htiGCeRLqvIZqrm//Bgeo/w==",
|
||||||
"license": "MIT"
|
"license": "MIT"
|
||||||
},
|
},
|
||||||
"node_modules/@owlboard/owlboard-ts": {
|
"node_modules/@owlboard/owlboard-ts": {
|
||||||
|
|||||||
@@ -41,6 +41,7 @@
|
|||||||
"vitest-browser-svelte": "^2.0.2"
|
"vitest-browser-svelte": "^2.0.2"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
|
"@owlboard/api-schema-types": "^3.0.3-alpha18",
|
||||||
"@owlboard/owlboard-ts": "^3.0.0-dev.20260509t2101",
|
"@owlboard/owlboard-ts": "^3.0.0-dev.20260509t2101",
|
||||||
"@tabler/icons-svelte": "^3.40.0"
|
"@tabler/icons-svelte": "^3.40.0"
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,6 +7,7 @@
|
|||||||
import TocStyle from '$lib/components/ui/TocStyle.svelte';
|
import TocStyle from '$lib/components/ui/TocStyle.svelte';
|
||||||
import TiplocConverter from '$lib/components/ui/TiplocConverter.svelte';
|
import TiplocConverter from '$lib/components/ui/TiplocConverter.svelte';
|
||||||
import { IconChevronDownFilled } from '@tabler/icons-svelte';
|
import { IconChevronDownFilled } from '@tabler/icons-svelte';
|
||||||
|
import { estClass } from '$lib/utils/time';
|
||||||
let { service }: { service: ApiTrainsTrainByHeadcode.TrainByHeadcodeResponse } = $props();
|
let { service }: { service: ApiTrainsTrainByHeadcode.TrainByHeadcodeResponse } = $props();
|
||||||
let isExpanded = $state(false);
|
let isExpanded = $state(false);
|
||||||
let loadingDetails = $state(false);
|
let loadingDetails = $state(false);
|
||||||
@@ -45,8 +46,6 @@
|
|||||||
loadingDetails = false;
|
loadingDetails = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
const estClass = (act, est) => (!act && est ? 'est' : 'act');
|
|
||||||
|
|
||||||
const activityMap: Record<string, string> = {
|
const activityMap: Record<string, string> = {
|
||||||
'-D': 'Vehicles detatched',
|
'-D': 'Vehicles detatched',
|
||||||
'-T': 'Vehicles attached & detached',
|
'-T': 'Vehicles attached & detached',
|
||||||
|
|||||||
148
src/lib/components/ui/station-board/StaffServicesTable.svelte
Normal file
148
src/lib/components/ui/station-board/StaffServicesTable.svelte
Normal file
@@ -0,0 +1,148 @@
|
|||||||
|
<script lang="ts">
|
||||||
|
import type { ApiStationsBoard } from '@owlboard/owlboard-ts';
|
||||||
|
import { formatUkTime, estClass, delayClassFromTimePair } from '$lib/utils/time';
|
||||||
|
|
||||||
|
let { services }: { services: ApiStationsBoard.BoardService[] } = $props();
|
||||||
|
|
||||||
|
const getRowKey = (s: ApiStationsBoard.BoardService) =>
|
||||||
|
`${s.r}${s.sta ?? ''}${s.std ?? ''}${s.wtp ?? ''}`;
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<table class="departure-board">
|
||||||
|
<thead>
|
||||||
|
<tr>
|
||||||
|
<th colspan="4" aria-hidden="true"></th>
|
||||||
|
<th scope="colgroup" colspan="2" class="upper-head"><abbr title="Arrival">Arr</abbr></th>
|
||||||
|
<th scope="colgroup" colspan="2" class="upper-head"><abbr title="Departure">Dep</abbr></th>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<th scope="col"><abbr title="Headcode">ID</abbr></th>
|
||||||
|
<th scope="col"><abbr title="Origin">Orig</abbr></th>
|
||||||
|
<th scope="col"><abbr title="Destination">Dest</abbr></th>
|
||||||
|
<th scope="col"><abbr title="Platform">Plt</abbr></th>
|
||||||
|
<th scope="col"><abbr title="Scheduled">Sch</abbr></th>
|
||||||
|
<th scope="col"><abbr title="Actual/Expected">Act</abbr></th>
|
||||||
|
<th scope="col"><abbr title="Scheduled">Sch</abbr></th>
|
||||||
|
<th scope="col"><abbr title="Actual/Expected">Act</abbr></th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
|
||||||
|
{#each services as service (getRowKey(service))}
|
||||||
|
<tbody>
|
||||||
|
<tr class="service-row" class:serviceCancelled={service.c} class:servicePass={service.wtp}>
|
||||||
|
<td class="id-cell">{service.h}</td>
|
||||||
|
<td class="orig-cell">{service.og.t}</td>
|
||||||
|
<td class="dest-cell">{service.dt.t}</td>
|
||||||
|
<td class="plt-cell" class:platSup={service.ps} class:platChange={service.pc}>{service.p}</td>
|
||||||
|
|
||||||
|
<!-- Handle different display for a passing train -->
|
||||||
|
{#if service.wtp}
|
||||||
|
<td class="pass-cell" colspan="2">Pass</td>
|
||||||
|
<td class="time-cell">{formatUkTime(service.wtp)}</td>
|
||||||
|
<td class="time-cell {estClass(service.atp, service.etp)} {delayClassFromTimePair(service.wtp, service.atp || service.etp)}">{formatUkTime(service.atp || service.etp)}</td>
|
||||||
|
{:else}
|
||||||
|
<td class="time-cell">{formatUkTime(service.sta)}</td>
|
||||||
|
<td class="time-cell {estClass(service.ata, service.eta)} {delayClassFromTimePair(service.sta, service.ata || service.eta)}">{formatUkTime(service.ata || service.eta)}</td>
|
||||||
|
<td class="time-cell">{formatUkTime(service.std)}</td>
|
||||||
|
<td class="time-cell {estClass(service.atd, service.etd)} {delayClassFromTimePair(service.std, service.atd || service.etd)}">{formatUkTime(service.atd || service.etd)}</td>
|
||||||
|
{/if}
|
||||||
|
</tr>
|
||||||
|
|
||||||
|
{#if service.c && service.cr?.r}
|
||||||
|
<tr>
|
||||||
|
<td aria-hidden="true"></td>
|
||||||
|
<td colspan="8">
|
||||||
|
{service.cr.r}
|
||||||
|
{#if service.cr.l}
|
||||||
|
{service.cr.n ? "near" : "at"}
|
||||||
|
{service.cr.l}
|
||||||
|
{/if}
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
{/if}
|
||||||
|
{#if service.dr?.r}
|
||||||
|
<tr>
|
||||||
|
<td aria-hidden="true"></td>
|
||||||
|
<td colspan="8">
|
||||||
|
{service.dr.r}
|
||||||
|
{#if service.dr.l}
|
||||||
|
{service.dr.n ? "near" : "at"}
|
||||||
|
{service.dr.l}
|
||||||
|
{/if}
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
{/if}
|
||||||
|
</tbody>
|
||||||
|
{/each}
|
||||||
|
|
||||||
|
</table>
|
||||||
|
|
||||||
|
<style>
|
||||||
|
.departure-board {
|
||||||
|
width: 100%;
|
||||||
|
margin: 0 auto;
|
||||||
|
font-family: 'URW Gothic', sans-serif;
|
||||||
|
font-variant-numeric: tabular-nums;
|
||||||
|
border-collapse: collapse;
|
||||||
|
}
|
||||||
|
thead {
|
||||||
|
position: sticky;
|
||||||
|
top: 0;
|
||||||
|
z-index: 2;
|
||||||
|
background: var(--color-bg-dark);
|
||||||
|
}
|
||||||
|
.serviceCancelled {
|
||||||
|
text-decoration: line-through;
|
||||||
|
}
|
||||||
|
.servicePass {
|
||||||
|
font-style: italic;
|
||||||
|
opacity: 0.5;
|
||||||
|
}
|
||||||
|
.id-cell{
|
||||||
|
font-family:'Courier New', Courier, monospace;
|
||||||
|
text-align: center;
|
||||||
|
}
|
||||||
|
.orig-cell, .dest-cell {
|
||||||
|
color: var(--location-yellow);
|
||||||
|
}
|
||||||
|
.orig-cell {
|
||||||
|
text-align: left;
|
||||||
|
}
|
||||||
|
.dest-cell {
|
||||||
|
text-align: right;
|
||||||
|
}
|
||||||
|
.plt-cell {
|
||||||
|
text-align: center;
|
||||||
|
}
|
||||||
|
.platChange {
|
||||||
|
animation: 2s fast-pulse ease-in-out infinite;
|
||||||
|
}
|
||||||
|
.platSup {
|
||||||
|
filter: opacity(0.5);
|
||||||
|
}
|
||||||
|
.pass-cell {
|
||||||
|
text-align: center;
|
||||||
|
}
|
||||||
|
.time-cell {
|
||||||
|
text-align: center;
|
||||||
|
}
|
||||||
|
.est {
|
||||||
|
font-style: oblique;
|
||||||
|
opacity: 0.75;
|
||||||
|
}
|
||||||
|
.act {
|
||||||
|
font-weight: 600;
|
||||||
|
color: green;
|
||||||
|
}
|
||||||
|
.delay-cell {
|
||||||
|
text-align: center;
|
||||||
|
}
|
||||||
|
.delay-late {
|
||||||
|
color: var(--delay-orange);
|
||||||
|
animation: 2s fast-pulse ease-in-out infinite;
|
||||||
|
}
|
||||||
|
.delay-early {
|
||||||
|
color: var(--early-blue);
|
||||||
|
animation: 2s fast-pulse ease-in-out infinite;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
@@ -41,7 +41,7 @@
|
|||||||
|
|
||||||
<style>
|
<style>
|
||||||
.alert-card {
|
.alert-card {
|
||||||
margin: 1rem 0;
|
margin: 0;
|
||||||
border-radius: 8px;
|
border-radius: 8px;
|
||||||
background: transparent;
|
background: transparent;
|
||||||
position: relative;
|
position: relative;
|
||||||
@@ -130,6 +130,10 @@
|
|||||||
font-display: swap;
|
font-display: swap;
|
||||||
}
|
}
|
||||||
:root {
|
:root {
|
||||||
|
/* Fixed Heights */
|
||||||
|
--header-height: 80px;
|
||||||
|
--nav-height: 60px;
|
||||||
|
|
||||||
/* Brand Colours */
|
/* Brand Colours */
|
||||||
--color-brand: #4fd1d1;
|
--color-brand: #4fd1d1;
|
||||||
--color-accent: #3c6f79;
|
--color-accent: #3c6f79;
|
||||||
@@ -171,7 +175,7 @@
|
|||||||
}
|
}
|
||||||
25%,
|
25%,
|
||||||
75% {
|
75% {
|
||||||
opacity: 0;
|
opacity: 0.25;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,7 @@
|
|||||||
import type { ApiTrainsTrainDetails } from '@owlboard/owlboard-ts';
|
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
|
* Converts ISO/JSON time to UK-formatted HH:MM string, with optional (default off) seconds
|
||||||
* Ensures Europe/London timezone irrespective of browser timezone.
|
* Ensures Europe/London timezone irrespective of browser timezone.
|
||||||
@@ -49,21 +52,40 @@ export function formatUkDateTime(
|
|||||||
.replace(',', '');
|
.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:
|
* Calculates a 'delay' value, in the formats:
|
||||||
* RT, 1E, 7L, etc.
|
* RT, 1E, 7L, etc.
|
||||||
* @param 'Schedule Location' object
|
* @param 'Schedule Location' or 'Board Service' object
|
||||||
* @returns Delay string for departure boards
|
* @returns Delay string for departure boards
|
||||||
*/
|
*/
|
||||||
export function calculateDelay(loc: ApiTrainsTrainDetails.ServiceLocation): {
|
export function calculateDelay(loc: DelayInput): {
|
||||||
val: string;
|
val: string;
|
||||||
type: string;
|
type: string;
|
||||||
} {
|
} {
|
||||||
const pairs = [
|
const pairs = [
|
||||||
{ actual: loc.atd, sched: loc.ptd ?? loc.wtd },
|
// Departure check (Board: atd/etd vs std | Journey: atd vs ptd/wtd)
|
||||||
{ actual: loc.ata, sched: loc.pta ?? loc.wta },
|
{ actual: loc.atd || loc.etd, sched: loc.std || loc.ptd || loc.wtd },
|
||||||
{ actual: loc.atp, sched: loc.wtp }
|
// 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);
|
const match = pairs.find((p) => p.actual && p.sched);
|
||||||
|
|
||||||
@@ -80,3 +102,27 @@ export function calculateDelay(loc: ApiTrainsTrainDetails.ServiceLocation): {
|
|||||||
return { val: `${absDiff}E`, type: 'early' };
|
return { val: `${absDiff}E`, type: 'early' };
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Accepts a pair of times (string or Date) and outputs a delay class 'delay-early', 'delay-late' or 'delay-rt'
|
||||||
|
* @param sched Scheduled Time (string, Date)
|
||||||
|
* @param act Actual Time (string, Date)
|
||||||
|
*/
|
||||||
|
export function delayClassFromTimePair(sched: any, act: any): string {
|
||||||
|
if (!sched || !act) return '';
|
||||||
|
|
||||||
|
const s = new Date(sched).getTime();
|
||||||
|
const a = new Date(act).getTime();
|
||||||
|
|
||||||
|
if (isNaN(s) || isNaN(a)) return '';
|
||||||
|
|
||||||
|
const diff = a - s;
|
||||||
|
const oneMinute = 60000;
|
||||||
|
|
||||||
|
// on-time if within one minute
|
||||||
|
if (Math.abs(diff) < oneMinute) {
|
||||||
|
return 'delay-rt';
|
||||||
|
}
|
||||||
|
|
||||||
|
return diff > 0 ? 'delay-late' : 'delay-early';
|
||||||
|
}
|
||||||
|
|||||||
@@ -154,7 +154,7 @@
|
|||||||
<style>
|
<style>
|
||||||
header {
|
header {
|
||||||
top: 0;
|
top: 0;
|
||||||
height: 80px;
|
height: var(--header-height);
|
||||||
box-shadow: var(--shadow-std);
|
box-shadow: var(--shadow-std);
|
||||||
}
|
}
|
||||||
.logo-link {
|
.logo-link {
|
||||||
@@ -201,13 +201,12 @@
|
|||||||
min-height: 100dvh;
|
min-height: 100dvh;
|
||||||
box-sizing: border-box;
|
box-sizing: border-box;
|
||||||
background-color: var(--color-bg-dark);
|
background-color: var(--color-bg-dark);
|
||||||
background-image: radial-gradient(var(--color-bg-dark), var(--color-bg-light));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
nav {
|
nav {
|
||||||
display: flex;
|
display: flex;
|
||||||
bottom: 0;
|
bottom: 0;
|
||||||
height: 60px;
|
height: var(--nav-height);
|
||||||
box-shadow: var(--shadow-up);
|
box-shadow: var(--shadow-up);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,9 +1,10 @@
|
|||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import { onMount, untrack } from 'svelte';
|
import { onMount, untrack } from 'svelte';
|
||||||
import { quickLinks } from '$lib/quick-links.svelte';
|
import { quickLinks } from '$lib/quick-links.svelte';
|
||||||
import StationAlertCard from '$lib/components/ui/cards/StationAlertCard.svelte';
|
import StationAlertCard from '$lib/components/ui/station-board/StationAlertCard.svelte';
|
||||||
|
|
||||||
import { formatUkDateTime, formatUkTime } from '$lib/utils/time';
|
import { formatUkDateTime, formatUkTime } from '$lib/utils/time';
|
||||||
|
import StaffServicesTable from '$lib/components/ui/station-board/StaffServicesTable.svelte';
|
||||||
let { data } = $props();
|
let { data } = $props();
|
||||||
let now = $state(new Date());
|
let now = $state(new Date());
|
||||||
|
|
||||||
@@ -35,23 +36,29 @@
|
|||||||
</script>
|
</script>
|
||||||
|
|
||||||
<section class="board-wrapper">
|
<section class="board-wrapper">
|
||||||
{#if data.boardData.data.m?.length}
|
|
||||||
<StationAlertCard messages={data.boardData.data.m} />
|
|
||||||
{/if}
|
|
||||||
<div class="time-data">
|
<div class="time-data">
|
||||||
<span class="time-loaded">Updated: {formatUkDateTime(data.boardData.producedAt, true)}</span>
|
<span class="time-loaded">Updated: {formatUkDateTime(data.boardData.producedAt, true)}</span>
|
||||||
<span class="time-now">{formatUkTime(now, true)}</span>
|
<span class="time-now">{formatUkTime(now, true)}</span>
|
||||||
</div>
|
</div>
|
||||||
<pre class="json-dump">{JSON.stringify(data.boardData.data.s, null, 2)}</pre>
|
{#if data.boardData.data.m?.length}
|
||||||
|
<StationAlertCard messages={data.boardData.data.m} />
|
||||||
|
{/if}
|
||||||
|
{#if data.boardData.data.s?.length}
|
||||||
|
<div class="service-list-wrapper">
|
||||||
|
<StaffServicesTable services={data.boardData.data.s} />
|
||||||
|
</div>
|
||||||
|
{/if}
|
||||||
</section>
|
</section>
|
||||||
|
|
||||||
<style>
|
<style>
|
||||||
.board-wrapper {
|
.board-wrapper {
|
||||||
display: flex;
|
display: flex;
|
||||||
|
height: calc(100dvh - var(--nav-height) - var(--header-height));
|
||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
width: 100%;
|
width: 100%;
|
||||||
margin: 0 auto;
|
margin: 0 auto;
|
||||||
|
overflow: hidden;
|
||||||
gap: 0;
|
gap: 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -78,21 +85,12 @@
|
|||||||
font-weight: 600;
|
font-weight: 600;
|
||||||
font-size: 1rem;
|
font-size: 1rem;
|
||||||
}
|
}
|
||||||
pre {
|
|
||||||
max-width: 100%;
|
.service-list-wrapper {
|
||||||
white-space: pre-wrap;
|
flex: 1;
|
||||||
word-wrap: break-word;
|
overflow-y: auto;
|
||||||
box-sizing: border-box;
|
height: calc(100dvh - 60px);
|
||||||
overflow-x: auto;
|
width: 100%;
|
||||||
}
|
margin-bottom: 5px;
|
||||||
.json-dump {
|
|
||||||
background: #222;
|
|
||||||
color: #0f0;
|
|
||||||
padding: 1rem;
|
|
||||||
border-radius: 4px;
|
|
||||||
font-size: 0.9rem;
|
|
||||||
max-height: 500px;
|
|
||||||
width: 95%;
|
|
||||||
margin: 1rem auto;
|
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|||||||
Reference in New Issue
Block a user