From be7d0106d5f489c992b5c954dc8fbdae0bec6641 Mon Sep 17 00:00:00 2001 From: Fred Boniface Date: Thu, 13 Jul 2023 19:40:32 +0100 Subject: [PATCH] Add 'getTrainByUID - and format --- .../ldb/staff/table/table-generator.svelte | 5 +- src/lib/navigation/loading-text.svelte | 15 +++ src/lib/train/train-detail.svelte | 105 +++++++++++------- 3 files changed, 84 insertions(+), 41 deletions(-) create mode 100644 src/lib/navigation/loading-text.svelte diff --git a/src/lib/ldb/staff/table/table-generator.svelte b/src/lib/ldb/staff/table/table-generator.svelte index 83170df..151b916 100644 --- a/src/lib/ldb/staff/table/table-generator.svelte +++ b/src/lib/ldb/staff/table/table-generator.svelte @@ -333,7 +333,10 @@ .tableTxt { font-size: 14px; } - td.to,td.from,th.to,th.from { + td.to, + td.from, + th.to, + th.from { text-align: center; } } diff --git a/src/lib/navigation/loading-text.svelte b/src/lib/navigation/loading-text.svelte new file mode 100644 index 0000000..e17bf76 --- /dev/null +++ b/src/lib/navigation/loading-text.svelte @@ -0,0 +1,15 @@ +

Loading...

+ \ No newline at end of file diff --git a/src/lib/train/train-detail.svelte b/src/lib/train/train-detail.svelte index 2347917..80d85f9 100644 --- a/src/lib/train/train-detail.svelte +++ b/src/lib/train/train-detail.svelte @@ -1,15 +1,34 @@ -
@@ -21,48 +40,54 @@
{#if isExpanded}
- {#if service.pis} -

PIS: {service.pis}

- {/if} -

- Planned Type: {parseInt(service.planSpeed) || 68}mph {service.powerType || 'Bus'} -

-

- Days Run: {service.daysRun.join(', ').toUpperCase()} -

-

- Valid From: {new Date(service.scheduleStartDate).toLocaleDateString('en-GB', { - timeZone: 'UTC' - })} - {new Date(service.scheduleEndDate).toLocaleDateString('en-GB', { - timeZone: 'UTC' - })} -

- - - - - - - {#if service.stops[0]['publicDeparture']} - {#each service.stops as stop} - {#if stop.publicArrival || stop.publicDeparture} + {#await getTrainByUID(service.trainUid)} + + {:then serviceDetail} + {#if serviceDetail.pis} +

PIS: {serviceDetail.pis}

+ {/if} +

+ Planned Type: {parseInt(serviceDetail.planSpeed) || 68}mph {serviceDetail.powerType || 'Bus'} +

+

+ Days Run: {serviceDetail.daysRun.join(', ').toUpperCase()} +

+

+ Valid From: {new Date(serviceDetail.scheduleStartDate).toLocaleDateString('en-GB', { + timeZone: 'UTC' + })} - {new Date(serviceDetail.scheduleEndDate).toLocaleDateString('en-GB', { + timeZone: 'UTC' + })} +

+
LocationSch Arr.Sch Dep.
+ + + + + + {#if serviceDetail.stops[0]['publicDeparture']} + {#each serviceDetail.stops as stop} + {#if stop.publicArrival || stop.publicDeparture} + + + + + + {/if} + {/each} + {:else} + {#each serviceDetail.stops as stop} - - + + - {/if} - {/each} - {:else} - {#each service.stops as stop} - - - - - - {/each} - {/if} -
LocationSch Arr.Sch Dep.
{stop.tiploc}{stop.publicArrival || '-'}{stop.publicDeparture || '-'}
{stop.tiploc}{stop.publicArrival || '-'}{stop.publicDeparture || '-'}{stop.wttArrival || '-'}{stop.wttDeparture || '-'}
{stop.tiploc}{stop.wttArrival || '-'}{stop.wttDeparture || '-'}
+ {/each} + {/if} + + {:catch} +

Unable to fetch train data

+ {/await}
{/if}