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