Run formatter
This commit is contained in:
parent
8a7c78219f
commit
b6dca2df78
@ -1,9 +1,9 @@
|
||||
<script>
|
||||
export let service;
|
||||
export let service;
|
||||
|
||||
import Reason from "$lib/raw-fetchers/reason.svelte";
|
||||
import Reason from '$lib/raw-fetchers/reason.svelte';
|
||||
|
||||
function parseTimes(service) {
|
||||
function parseTimes(service) {
|
||||
const sta = new Date(service.sta),
|
||||
eta = new Date(service.eta),
|
||||
ata = new Date(service.ata);
|
||||
@ -108,51 +108,51 @@
|
||||
</script>
|
||||
|
||||
{#await generateServiceData(service)}
|
||||
<tr>
|
||||
<td colspan="8"> Loading... </td>
|
||||
</tr>
|
||||
{:then serviceStats}
|
||||
<tr class="{serviceStats.isCancelled && 'can-dat'} {serviceStats.isNonPublic && 'ecs'}">
|
||||
<td class="id id-data data" on:click={showDetails(service.rid, service.uid, service.trainid)} on:keypress={showDetails(service.rid, service.uid, service.trainid)}
|
||||
>{service.trainid}</td
|
||||
>
|
||||
<td
|
||||
class="from from-data data {serviceStats.isCancelled && 'can-dat'} {serviceStats.isNonPublic && 'ecs'}"
|
||||
on:click={showDetails(service.rid, service.uid, service.trainid)}
|
||||
on:keypress={showDetails(service.rid, service.uid, service.trainid)}>{serviceStats.from}</td
|
||||
>
|
||||
<td
|
||||
class="to to-data data {serviceStats.isCancelled && 'can-dat'} {serviceStats.isNonPublic && 'ecs'}"
|
||||
on:click={showDetails(service.rid, service.uid, service.trainid)}
|
||||
on:keypress={showDetails(service.rid, service.uid, service.trainid)}>{serviceStats.to}</td
|
||||
>
|
||||
<td class="plat plat-data data {serviceStats.platformHidden && 'hidden'}">{serviceStats.platform.number || '-'}</td>
|
||||
<td class="time time-data data">{serviceStats.schArr}</td>
|
||||
<td
|
||||
class="time time-data data {serviceStats.canArr && 'can-time'} {serviceStats.isArrDelayed && 'late'} {serviceStats.isEarlyArr && 'early'} {serviceStats.isLateArr &&
|
||||
'late'}">{serviceStats.isArrDelayed ? 'LATE' : serviceStats.expArr}</td
|
||||
>
|
||||
<td class="time time-data data {serviceStats.isCancelled && 'can-dat'}">{serviceStats.schDep}</td>
|
||||
<td
|
||||
class="time time-data data {serviceStats.canDep && 'can-time'} {serviceStats.isDepDelayed && 'late'} {serviceStats.isEarlyDep && 'early'} {serviceStats.isLateDep &&
|
||||
'late'}">{serviceStats.isDepDelayed ? 'LATE' : serviceStats.expDep}</td
|
||||
>
|
||||
</tr>
|
||||
<tr class="text-row">
|
||||
<td colspan="8" class="text-data">
|
||||
{service.operator}
|
||||
{#if serviceStats.length} | {serviceStats.length} carriages{/if}
|
||||
<br />
|
||||
{#if service.cancelReason}
|
||||
<Reason type="cancel" code={service.cancelReason} />
|
||||
{/if}
|
||||
{#if service?.delayReason && !service.isCancelled}
|
||||
<Reason type="delay" code={service.delayReason} />
|
||||
{/if}
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td colspan="8"> Loading... </td>
|
||||
</tr>
|
||||
{:then serviceStats}
|
||||
<tr class="{serviceStats.isCancelled && 'can-dat'} {serviceStats.isNonPublic && 'ecs'}">
|
||||
<td class="id id-data data" on:click={showDetails(service.rid, service.uid, service.trainid)} on:keypress={showDetails(service.rid, service.uid, service.trainid)}
|
||||
>{service.trainid}</td
|
||||
>
|
||||
<td
|
||||
class="from from-data data {serviceStats.isCancelled && 'can-dat'} {serviceStats.isNonPublic && 'ecs'}"
|
||||
on:click={showDetails(service.rid, service.uid, service.trainid)}
|
||||
on:keypress={showDetails(service.rid, service.uid, service.trainid)}>{serviceStats.from}</td
|
||||
>
|
||||
<td
|
||||
class="to to-data data {serviceStats.isCancelled && 'can-dat'} {serviceStats.isNonPublic && 'ecs'}"
|
||||
on:click={showDetails(service.rid, service.uid, service.trainid)}
|
||||
on:keypress={showDetails(service.rid, service.uid, service.trainid)}>{serviceStats.to}</td
|
||||
>
|
||||
<td class="plat plat-data data {serviceStats.platformHidden && 'hidden'}">{serviceStats.platform.number || '-'}</td>
|
||||
<td class="time time-data data">{serviceStats.schArr}</td>
|
||||
<td
|
||||
class="time time-data data {serviceStats.canArr && 'can-time'} {serviceStats.isArrDelayed && 'late'} {serviceStats.isEarlyArr && 'early'} {serviceStats.isLateArr && 'late'}"
|
||||
>{serviceStats.isArrDelayed ? 'LATE' : serviceStats.expArr}</td
|
||||
>
|
||||
<td class="time time-data data {serviceStats.isCancelled && 'can-dat'}">{serviceStats.schDep}</td>
|
||||
<td
|
||||
class="time time-data data {serviceStats.canDep && 'can-time'} {serviceStats.isDepDelayed && 'late'} {serviceStats.isEarlyDep && 'early'} {serviceStats.isLateDep && 'late'}"
|
||||
>{serviceStats.isDepDelayed ? 'LATE' : serviceStats.expDep}</td
|
||||
>
|
||||
</tr>
|
||||
<tr class="text-row">
|
||||
<td colspan="8" class="text-data">
|
||||
{service.operator}
|
||||
{#if serviceStats.length} | {serviceStats.length} carriages{/if}
|
||||
<br />
|
||||
{#if service.cancelReason}
|
||||
<Reason type="cancel" code={service.cancelReason} />
|
||||
{/if}
|
||||
{#if service?.delayReason && !service.isCancelled}
|
||||
<Reason type="delay" code={service.delayReason} />
|
||||
{/if}
|
||||
</td>
|
||||
</tr>
|
||||
{:catch}
|
||||
<tr>
|
||||
<td colspan="8">Unable to load service</td>
|
||||
</tr>
|
||||
{/await}
|
||||
<tr>
|
||||
<td colspan="8">Unable to load service</td>
|
||||
</tr>
|
||||
{/await}
|
||||
|
@ -93,7 +93,6 @@
|
||||
}
|
||||
return times;
|
||||
}
|
||||
|
||||
</script>
|
||||
|
||||
<OverlayIsland>
|
||||
@ -111,14 +110,18 @@
|
||||
</p>
|
||||
<table id="detailTable">
|
||||
{#if train.GetServiceDetailsResult.delayReason}
|
||||
<tr><td colspan="7" class="late">
|
||||
<Reason type="delay" code={train.GetServiceDetailsResult.delayReason} />
|
||||
</td></tr>
|
||||
<tr
|
||||
><td colspan="7" class="late">
|
||||
<Reason type="delay" code={train.GetServiceDetailsResult.delayReason} />
|
||||
</td></tr
|
||||
>
|
||||
{/if}
|
||||
{#if train.GetServiceDetailsResult.cancelReason}
|
||||
<tr><td colspan="7" class="canc">
|
||||
<Reason type="cancel" code={train.GetServiceDetailsResult.cancelReason} />
|
||||
</td></tr>
|
||||
<tr
|
||||
><td colspan="7" class="canc">
|
||||
<Reason type="cancel" code={train.GetServiceDetailsResult.cancelReason} />
|
||||
</td></tr
|
||||
>
|
||||
{/if}
|
||||
<tr>
|
||||
<th colspan="2" />
|
||||
|
@ -1,18 +1,17 @@
|
||||
<script>
|
||||
|
||||
import { uuid } from "$lib/stores/uuid";
|
||||
import { uuid } from '$lib/stores/uuid';
|
||||
|
||||
export let code = '';
|
||||
export let type = '';
|
||||
|
||||
async function getDelay(code = '') {
|
||||
console.log(`Fetching delay reason ${code}`)
|
||||
console.log(`Fetching delay reason ${code}`);
|
||||
const data = await getReason(code);
|
||||
return data[0].lateReason || 'This train has been delayed';
|
||||
}
|
||||
|
||||
async function getCancel(code = '') {
|
||||
console.log(`Fetching cancel reason ${code}`)
|
||||
console.log(`Fetching cancel reason ${code}`);
|
||||
const data = await getReason(code);
|
||||
return data[0].cancReason || 'This train has been cancelled';
|
||||
}
|
||||
@ -28,23 +27,22 @@
|
||||
const res = await fetch(url, options);
|
||||
return await res.json();
|
||||
}
|
||||
|
||||
</script>
|
||||
|
||||
{#if type === "cancel"}
|
||||
{#if type === 'cancel'}
|
||||
{#await getCancel(code)}
|
||||
This train has been cancelled
|
||||
{:then reason}
|
||||
{:then reason}
|
||||
{reason}
|
||||
{:catch}
|
||||
This train has been cancelled
|
||||
{/await}
|
||||
{:else if type === "delay"}
|
||||
{:else if type === 'delay'}
|
||||
{#await getDelay(code)}
|
||||
This train has been delayed
|
||||
This train has been delayed
|
||||
{:then reason}
|
||||
{reason}
|
||||
{:catch}
|
||||
This train has been delayed
|
||||
{/await}
|
||||
{/if}
|
||||
{/if}
|
||||
|
Loading…
Reference in New Issue
Block a user