Add train details on public LDB
This commit is contained in:
parent
7ae10634e5
commit
6803438c63
32
src/lib/islands/overlay-island.svelte
Normal file
32
src/lib/islands/overlay-island.svelte
Normal file
@ -0,0 +1,32 @@
|
|||||||
|
<script>
|
||||||
|
export let variables = {title:""}
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<div>
|
||||||
|
<span>{variables.title}</span>
|
||||||
|
<slot />
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<style>
|
||||||
|
span {
|
||||||
|
font-family: urwgothic, 'Lucida Sans', 'Lucida Sans Regular', 'Lucida Grande', 'Lucida Sans Unicode', Geneva, Verdana, sans-serif;
|
||||||
|
font-weight: 600;
|
||||||
|
font-size: 20px;
|
||||||
|
}
|
||||||
|
div {
|
||||||
|
position: fixed;
|
||||||
|
top: 60px;
|
||||||
|
left: 50%;
|
||||||
|
transform: translateX(-50%);
|
||||||
|
width: 75%;
|
||||||
|
height: auto;
|
||||||
|
max-height: 75vh;
|
||||||
|
overflow-y: scroll;
|
||||||
|
max-width: 400px;
|
||||||
|
margin: auto;
|
||||||
|
margin-top: 25px;
|
||||||
|
padding: 10px;
|
||||||
|
background-color: var(--overlay-color);
|
||||||
|
border-radius: 10px;
|
||||||
|
}
|
||||||
|
</style>
|
@ -3,6 +3,7 @@
|
|||||||
export let title = "Loading...";
|
export let title = "Loading...";
|
||||||
import { onMount } from 'svelte'
|
import { onMount } from 'svelte'
|
||||||
import Loading from '$lib/navigation/loading.svelte';
|
import Loading from '$lib/navigation/loading.svelte';
|
||||||
|
import OverlayIsland from '$lib/islands/overlay-island.svelte';
|
||||||
|
|
||||||
let requestedStation;
|
let requestedStation;
|
||||||
$: requestedStation = station;
|
$: requestedStation = station;
|
||||||
@ -14,6 +15,7 @@
|
|||||||
let dataAge = null;
|
let dataAge = null;
|
||||||
let isLoading = true;
|
let isLoading = true;
|
||||||
let dataExists = false;
|
let dataExists = false;
|
||||||
|
let serviceDetail;
|
||||||
|
|
||||||
$: {
|
$: {
|
||||||
if (jsonData === null && requestedStation) {
|
if (jsonData === null && requestedStation) {
|
||||||
@ -73,6 +75,7 @@
|
|||||||
output = 'CANC'
|
output = 'CANC'
|
||||||
change = "cancelled"
|
change = "cancelled"
|
||||||
break
|
break
|
||||||
|
case 'On Time':
|
||||||
case 'On time':
|
case 'On time':
|
||||||
output = 'RT'
|
output = 'RT'
|
||||||
change = ""
|
change = ""
|
||||||
@ -100,6 +103,19 @@
|
|||||||
return {data: output, changed: change}
|
return {data: output, changed: change}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async function loadService(sid) {
|
||||||
|
console.log(`Loading: ${sid}`);
|
||||||
|
for (const service of services) {
|
||||||
|
if (service.serviceID == sid) {
|
||||||
|
serviceDetail = service
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
async function closeService() {
|
||||||
|
serviceDetail = null;
|
||||||
|
}
|
||||||
|
|
||||||
onMount(() => {
|
onMount(() => {
|
||||||
if (requestedStation && jsonData === null) {
|
if (requestedStation && jsonData === null) {
|
||||||
fetchData();
|
fetchData();
|
||||||
@ -125,7 +141,7 @@
|
|||||||
</tr>
|
</tr>
|
||||||
{#each services as service}
|
{#each services as service}
|
||||||
<tr>
|
<tr>
|
||||||
<td class="origdest from">
|
<td class="origdest from" on:click={loadService(service.serviceID)}>
|
||||||
{#if Array.isArray(service.origin?.location)}
|
{#if Array.isArray(service.origin?.location)}
|
||||||
{service.origin.location[0]['locationName'] +
|
{service.origin.location[0]['locationName'] +
|
||||||
" & " +
|
" & " +
|
||||||
@ -134,7 +150,7 @@
|
|||||||
{service.origin?.location?.locationName || ''}
|
{service.origin?.location?.locationName || ''}
|
||||||
{/if}
|
{/if}
|
||||||
</td>
|
</td>
|
||||||
<td class="origdest to">
|
<td class="origdest to" on:click={loadService(service.serviceID)}>
|
||||||
{#if Array.isArray(service.destination?.location)}
|
{#if Array.isArray(service.destination?.location)}
|
||||||
{service.destination.location[0]['locationName'] +
|
{service.destination.location[0]['locationName'] +
|
||||||
" & " +
|
" & " +
|
||||||
@ -244,6 +260,44 @@
|
|||||||
<p>Unable to find this station</p>
|
<p>Unable to find this station</p>
|
||||||
{/if}
|
{/if}
|
||||||
{/if}
|
{/if}
|
||||||
|
|
||||||
|
{#if serviceDetail}
|
||||||
|
<OverlayIsland>
|
||||||
|
<h6>Service Detail</h6>
|
||||||
|
<button type="button" id="closeService" on:click={closeService}>X</button>
|
||||||
|
<table id="detailTable">
|
||||||
|
<tr>
|
||||||
|
<th>Location</th>
|
||||||
|
<th>Sch</th>
|
||||||
|
<th>Exp</th>
|
||||||
|
</tr>
|
||||||
|
{#if serviceDetail?.previousCallingPoints?.callingPointList?.callingPoint}
|
||||||
|
{#each serviceDetail.previousCallingPoints.callingPointList.callingPoint as prevPoint}
|
||||||
|
<tr>
|
||||||
|
<td>{prevPoint.locationName}</td>
|
||||||
|
<td>{prevPoint.st}</td>
|
||||||
|
<td class="time {parseTime(prevPoint.at || prevPoint.et).changed}">{parseTime(prevPoint.at || prevPoint.et).data}</td>
|
||||||
|
</tr>
|
||||||
|
{/each}
|
||||||
|
{/if}
|
||||||
|
<tr class="thisStop">
|
||||||
|
<td>{title}</td>
|
||||||
|
<td>{serviceDetail.std || serviceDetail.sta}</td>
|
||||||
|
<td class="time {parseTime(serviceDetail.etd || serviceDetail.eta).changed}">{parseTime(serviceDetail.etd || serviceDetail.eta).data}</td>
|
||||||
|
</tr>
|
||||||
|
{#if serviceDetail?.subsequentCallingPoints?.callingPointList?.callingPoint}
|
||||||
|
{#each serviceDetail.subsequentCallingPoints.callingPointList.callingPoint as nextPoint}
|
||||||
|
<tr>
|
||||||
|
<td>{nextPoint.locationName}</td>
|
||||||
|
<td>{nextPoint.st}</td>
|
||||||
|
<td class="time {parseTime(nextPoint.et).changed}">{parseTime(nextPoint.et).data}</td>
|
||||||
|
</tr>
|
||||||
|
{/each}
|
||||||
|
{/if}
|
||||||
|
</table>
|
||||||
|
</OverlayIsland>
|
||||||
|
{/if}
|
||||||
|
|
||||||
<style>
|
<style>
|
||||||
#timestamp {
|
#timestamp {
|
||||||
margin: auto;
|
margin: auto;
|
||||||
@ -321,4 +375,29 @@
|
|||||||
color: var(--main-alert-color);
|
color: var(--main-alert-color);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
h6 {
|
||||||
|
position: absolute;
|
||||||
|
top: -25px;
|
||||||
|
left: 20px;
|
||||||
|
font-size: 18px;
|
||||||
|
}
|
||||||
|
#closeService {
|
||||||
|
position: absolute;
|
||||||
|
top: 10px;
|
||||||
|
right: 10px;
|
||||||
|
border: none;
|
||||||
|
border-radius: 60px;
|
||||||
|
width: 35px;
|
||||||
|
height: 35px;
|
||||||
|
background-color: var(--main-bg-color);
|
||||||
|
color: white;
|
||||||
|
font-weight: 700;
|
||||||
|
font-size: 16px;
|
||||||
|
}
|
||||||
|
#detailTable {
|
||||||
|
margin-top: 40px;
|
||||||
|
}
|
||||||
|
.thisStop {
|
||||||
|
color: yellow;
|
||||||
|
}
|
||||||
</style>
|
</style>
|
||||||
|
Loading…
Reference in New Issue
Block a user