Begin work on public board component
This commit is contained in:
parent
ed3dd38769
commit
bf8dea7bcd
@ -1,29 +1,39 @@
|
|||||||
<script>
|
<script>
|
||||||
export let station = "";
|
export let station = "";
|
||||||
import {onMount} from 'svelte'
|
import { onMount } from 'svelte'
|
||||||
|
|
||||||
let requestedStation = "";
|
let requestedStation;
|
||||||
$: requestedStation = station;
|
$: requestedStation = station;
|
||||||
|
|
||||||
let jsonData = {};
|
let jsonData = null;
|
||||||
/**
|
|
||||||
* @type {any[]}
|
|
||||||
*/
|
|
||||||
let services = [];
|
let services = [];
|
||||||
|
|
||||||
$: {
|
$: {
|
||||||
if (jsonData && jsonData.GetStationBoardResult && jsonData.GetStationBoardResult.trainServices && jsonData.GetStationBoardResult.trainServices.service) {
|
if (jsonData === null && requestedStation) {
|
||||||
services = [...jsonData.GetStationBoardResult.trainServices.service];
|
fetchData();
|
||||||
} else {
|
}
|
||||||
services = ["No train services available"];
|
|
||||||
}
|
if (jsonData && jsonData.GetStationBoardResult && jsonData.GetStationBoardResult.trainServices && jsonData.GetStationBoardResult.trainServices.service) {
|
||||||
|
services = [...jsonData.GetStationBoardResult.trainServices.service];
|
||||||
|
} else {
|
||||||
|
services = ["No train services available"];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
onMount(async () => {
|
async function fetchData() {
|
||||||
const data = await fetch(`https://owlboard.info/api/v1/ldb/${station}`);
|
console.log(`Requested Station: ${requestedStation}`);
|
||||||
jsonData = await data.json();
|
const data = await fetch(`https://owlboard.info/api/v1/ldb/${requestedStation}`);
|
||||||
})
|
jsonData = await data.json();
|
||||||
|
}
|
||||||
</script>
|
|
||||||
|
onMount(() => {
|
||||||
|
if (requestedStation && jsonData === null) {
|
||||||
|
fetchData();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
</script>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<p>{requestedStation.toUpperCase()}</p>
|
<p>{requestedStation.toUpperCase()}</p>
|
||||||
|
|
||||||
@ -47,7 +57,7 @@
|
|||||||
<tr>
|
<tr>
|
||||||
<td>{service.origin?.location?.locationName || ''}</td>
|
<td>{service.origin?.location?.locationName || ''}</td>
|
||||||
<td>{service.destination?.location?.locationName || ''}</td>
|
<td>{service.destination?.location?.locationName || ''}</td>
|
||||||
<td>{service.platform || ''}</td>
|
<td>{service.platform || '-'}</td>
|
||||||
</tr>
|
</tr>
|
||||||
{/each}
|
{/each}
|
||||||
</table>
|
</table>
|
||||||
@ -56,5 +66,6 @@
|
|||||||
table {
|
table {
|
||||||
width: 100%;
|
width: 100%;
|
||||||
margin: auto;
|
margin: auto;
|
||||||
|
color: white;
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
@ -9,10 +9,12 @@
|
|||||||
return new URLSearchParams(window.location.search).get('station');
|
return new URLSearchParams(window.location.search).get('station');
|
||||||
}
|
}
|
||||||
|
|
||||||
let station = ""
|
let station;
|
||||||
|
let staff;
|
||||||
|
|
||||||
onMount(async () => {
|
onMount(async () => {
|
||||||
station = await getHeadcode() || "";
|
station = await getHeadcode() || "";
|
||||||
|
staff = false;
|
||||||
})
|
})
|
||||||
|
|
||||||
</script>
|
</script>
|
||||||
@ -20,6 +22,8 @@
|
|||||||
<Header {title} />
|
<Header {title} />
|
||||||
|
|
||||||
<!-- If 'uuid' exists in store then load StaffLdb else load PublicLdb -->
|
<!-- If 'uuid' exists in store then load StaffLdb else load PublicLdb -->
|
||||||
|
{#if !staff}
|
||||||
<PublicLdb {station} />
|
<PublicLdb {station} />
|
||||||
|
{/if}
|
||||||
|
|
||||||
<Nav />
|
<Nav />
|
||||||
|
@ -5,7 +5,7 @@ export default {
|
|||||||
adapter: adapter({
|
adapter: adapter({
|
||||||
pages: 'build',
|
pages: 'build',
|
||||||
assets: 'build',
|
assets: 'build',
|
||||||
fallback: '/',
|
fallback: 'undefined',
|
||||||
precompress: true,
|
precompress: true,
|
||||||
strict: true
|
strict: true
|
||||||
})
|
})
|
||||||
|
Loading…
Reference in New Issue
Block a user