Begin work on StaffLDB
This commit is contained in:
parent
5b1daf31e6
commit
475746300e
@ -1,9 +1,10 @@
|
||||
<script>
|
||||
export let station = "";
|
||||
export let title = "";
|
||||
export let title = "Loading...";
|
||||
import { onMount } from 'svelte'
|
||||
import Loading from '$lib/navigation/loading.svelte';
|
||||
import Nav from '$lib/navigation/nav.svelte';
|
||||
import { uuid } from '$lib/stores/uuid';
|
||||
|
||||
let requestedStation;
|
||||
$: requestedStation = station;
|
||||
@ -14,22 +15,18 @@
|
||||
let isLoading = true;
|
||||
|
||||
$: {
|
||||
if (jsonData === null && requestedStation) {
|
||||
fetchData();
|
||||
if (jsonData?.GetBoardResult?.generatedAt) {
|
||||
dataAge = new Date(jsonData.GetBoardResult.generatedAt);
|
||||
}
|
||||
|
||||
if (jsonData?.GetStationBoardResult?.generatedAt) {
|
||||
dataAge = new Date(jsonData.GetStationBoardResult.generatedAt);
|
||||
}
|
||||
|
||||
if (jsonData?.GetStationBoardResult?.trainServices?.service) {
|
||||
services = jsonData.GetStationBoardResult.trainServices.service;
|
||||
if (jsonData?.GetBoardResult?.trainServices?.service) {
|
||||
services = jsonData.GetBoardResult.trainServices.service;
|
||||
} else {
|
||||
services = [];
|
||||
}
|
||||
|
||||
if (jsonData?.GetStationBoardResult?.locationName) {
|
||||
title = jsonData.GetStationBoardResult.locationName
|
||||
if (jsonData?.GetBoardResult?.locationName) {
|
||||
title = jsonData.GetBoardResult.locationName
|
||||
} else {
|
||||
title = "Loading Board"
|
||||
}
|
||||
@ -39,7 +36,14 @@
|
||||
isLoading = true; // Set loading state
|
||||
try {
|
||||
console.log(`Requested Station: ${requestedStation}`);
|
||||
const data = await fetch(`https://owlboard.info/api/v1/ldb/${requestedStation}`);
|
||||
const url = `https://owlboard.info/api/v2/live/station/${requestedStation}/staff`;
|
||||
const opt = {
|
||||
method: "GET",
|
||||
headers: {
|
||||
"uuid": $uuid
|
||||
}
|
||||
}
|
||||
const data = await fetch(url, opt);
|
||||
jsonData = await data.json();
|
||||
} catch (error) {
|
||||
console.error("Error fetching data:", error);
|
||||
@ -88,9 +92,7 @@
|
||||
}
|
||||
|
||||
onMount(() => {
|
||||
if (requestedStation && jsonData === null) {
|
||||
fetchData();
|
||||
}
|
||||
});
|
||||
</script>
|
||||
<p>Staff Boards not yet implemented</p>
|
||||
@ -101,7 +103,16 @@
|
||||
<p id="timestamp">Updated: {dataAge.toLocaleTimeString()}</p>
|
||||
<p>Staff LDB for {station}</p>
|
||||
|
||||
<!-- REST OF PAGE HERE -->
|
||||
{#each services as service}
|
||||
<div class="service">
|
||||
<p class="service-operator">{service.operatorCode}</p>
|
||||
<p class="service-headcode">{service.trainid}</p>
|
||||
<p class="service-origin">{service.origin.location.tiploc}</p>
|
||||
<p class="service-dest">{service.destination.location.tiploc}</p>
|
||||
<p class="service-plat">{service.platform}</p>
|
||||
<p class="service-expArr">{new Date(service.sta).toLocaleTimeString() || '-'}</p>
|
||||
</div>
|
||||
{/each}
|
||||
{/if}
|
||||
|
||||
<Nav />
|
Loading…
Reference in New Issue
Block a user