Add bus and ferry to staffLDB

This commit is contained in:
Fred Boniface 2023-07-08 21:54:33 +01:00
parent b6dca2df78
commit 13d3bc4dbe
13 changed files with 404 additions and 128 deletions

View File

@ -1,8 +1,10 @@
<script> <script>
import { fade } from 'svelte/transition';
export let variables = { title: '' }; export let variables = { title: '' };
</script> </script>
<div> <div in:fade={{ duration: 250 }}>
<span>{variables.title}</span> <span>{variables.title}</span>
<slot /> <slot />
</div> </div>

View File

@ -5,6 +5,7 @@
import Loading from '$lib/navigation/loading.svelte'; import Loading from '$lib/navigation/loading.svelte';
import OverlayIsland from '$lib/islands/overlay-island.svelte'; import OverlayIsland from '$lib/islands/overlay-island.svelte';
import AlertBar from '$lib/ldb/nrcc/alert-bar.svelte'; import AlertBar from '$lib/ldb/nrcc/alert-bar.svelte';
import Island from '$lib/islands/island.svelte';
let requestedStation; let requestedStation;
$: requestedStation = station; $: requestedStation = station;
@ -54,7 +55,7 @@
isLoading = true; // Set loading state isLoading = true; // Set loading state
try { try {
console.log(`Requested Station: ${requestedStation}`); console.log(`Requested Station: ${requestedStation}`);
const data = await fetch(`https://owlboard.info/api/v1/ldb/${requestedStation}`); const data = await fetch(`https://owlboard.info/api/v2/live/station/${requestedStation}/public`);
jsonData = await data.json(); jsonData = await data.json();
} catch (error) { } catch (error) {
console.error('Error fetching data:', error); console.error('Error fetching data:', error);
@ -286,7 +287,9 @@
</table> </table>
{/if} {/if}
{:else} {:else}
<p>Unable to find this station</p> <Island>
<p style="font-weight:600">Unable to load data</p>
</Island>
{/if} {/if}
{#if serviceDetail} {#if serviceDetail}

View File

@ -3,20 +3,26 @@
export let title = 'Loading...'; export let title = 'Loading...';
import { onMount } from 'svelte'; import { onMount } from 'svelte';
import AlertBar from '$lib/ldb/nrcc/alert-bar.svelte'; import AlertBar from '$lib/ldb/nrcc/alert-bar.svelte';
import ServiceRow from './service-row.svelte'; //import ServiceRow from './service-row.svelte';
import StaffTrainDetail from '$lib/ldb/staff/train-detail.svelte'; import StaffTrainDetail from '$lib/ldb/staff/train-detail.svelte';
import Reason from '$lib/raw-fetchers/reason.svelte'; import Reason from '$lib/raw-fetchers/reason.svelte';
import Loading from '$lib/navigation/loading.svelte'; import Loading from '$lib/navigation/loading.svelte';
import Nav from '$lib/navigation/nav.svelte'; import Nav from '$lib/navigation/nav.svelte';
import { uuid } from '$lib/stores/uuid'; import { uuid } from '$lib/stores/uuid';
import Error from '../../../routes/+error.svelte';
import Island from '$lib/islands/island.svelte';
let requestedStation; let requestedStation;
$: requestedStation = station; $: requestedStation = station;
let jsonData = {}; let jsonData = {};
let services = []; let services = [],
busServices = [],
ferryServices = [];
let dataAge = null; let dataAge = null;
let isLoading = true; let isLoading = true;
let isErr = false;
let errMsg;
let alerts = []; let alerts = [];
let detail = { show: false, rid: '', uid: '', headcode: '' }; let detail = { show: false, rid: '', uid: '', headcode: '' };
@ -31,6 +37,18 @@
services = []; services = [];
} }
if (jsonData?.GetBoardResult?.busServices?.service) {
busServices = jsonData.GetBoardResult.busServices.service;
} else {
busServices = [];
}
if (jsonData?.GetBoardResult?.ferryServices?.service) {
ferryServices = jsonData.GetBoardResult.ferryServices.service;
} else {
ferryServices = [];
}
if (jsonData?.GetBoardResult?.locationName) { if (jsonData?.GetBoardResult?.locationName) {
title = jsonData.GetBoardResult.locationName; title = jsonData.GetBoardResult.locationName;
} else { } else {
@ -54,9 +72,18 @@
} }
}; };
const data = await fetch(url, opt); const data = await fetch(url, opt);
jsonData = await data.json(); const json = await data.json();
if (json.ERROR === 'NOT_FOUND') {
isErr = true;
errMsg = 'Unable to find this station';
} else {
jsonData = json;
}
} catch (error) { } catch (error) {
console.error('Error fetching data:', error); console.error('Error fetching data:', error);
isLoading = false;
isErr = true;
errMsg = 'Connection error, try again later';
} finally { } finally {
isLoading = false; // Clear loading state isLoading = false; // Clear loading state
} }
@ -251,74 +278,232 @@
{#if isLoading} {#if isLoading}
<Loading /> <Loading />
{:else if isErr}
<Island>
<p><strong>{errMsg}</strong></p>
</Island>
{:else} {:else}
{#if alerts.length} {#if alerts.length}
<AlertBar {alerts} /> <AlertBar {alerts} />
{/if} {/if}
<table> <table>
<tr><td colspan="8" id="timestamp">Updated: {dataAge.toLocaleTimeString()} - Staff Boards under development</td></tr> <tr><td colspan="8" id="timestamp">Updated: {dataAge.toLocaleTimeString()} - Staff Boards under development</td></tr>
<tr>
<th colspan="4" />
<th colspan="2">Arrival</th>
<th colspan="2">Departure</th>
</tr>
<tr> <tr>
<th class="id">ID</th> <th class="id">ID</th>
<th class="from">From</th> <th class="from">From</th>
<th class="to">To</th> <th class="to">To</th>
<th class="plat">Plat</th> <th class="plat">Plat</th>
<th class="time">Sch Arr</th> <th class="time">Sch</th>
<th class="time">Exp Arr</th> <th class="time">Exp</th>
<th class="time">Sch Dep</th> <th class="time">Sch</th>
<th class="time">Exp Dep</th> <th class="time">Exp</th>
</tr> </tr>
{#each services as service} {#if !services.length}
{#await generateServiceData(service)} <tr><td colspan="8">No Scheduled Train Services</td></tr>
<tr> {:else}
<td colspan="8"> Loading... </td> {#each services as service}
</tr> {#await generateServiceData(service)}
{:then serviceStats} <tr>
<tr class="{serviceStats.isCancelled && 'can-dat'} {serviceStats.isNonPublic && 'ecs'}"> <td colspan="8"> Loading... </td>
<td class="id id-data data" on:click={showDetails(service.rid, service.uid, service.trainid)} on:keypress={showDetails(service.rid, service.uid, service.trainid)} </tr>
>{service.trainid}</td {:then serviceStats}
> <tr class="{serviceStats.isCancelled && 'can-dat'} {serviceStats.isNonPublic && 'ecs'}">
<td <td class="id id-data data" on:click={showDetails(service.rid, service.uid, service.trainid)} on:keypress={showDetails(service.rid, service.uid, service.trainid)}
class="from from-data data {serviceStats.isCancelled && 'can-dat'} {serviceStats.isNonPublic && 'ecs'}" >{service.trainid}</td
on:click={showDetails(service.rid, service.uid, service.trainid)} >
on:keypress={showDetails(service.rid, service.uid, service.trainid)}>{serviceStats.from}</td <td
> class="from from-data data {serviceStats.isCancelled && 'can-dat'} {serviceStats.isNonPublic && 'ecs'}"
<td on:click={showDetails(service.rid, service.uid, service.trainid)}
class="to to-data data {serviceStats.isCancelled && 'can-dat'} {serviceStats.isNonPublic && 'ecs'}" on:keypress={showDetails(service.rid, service.uid, service.trainid)}>{serviceStats.from}</td
on:click={showDetails(service.rid, service.uid, service.trainid)} >
on:keypress={showDetails(service.rid, service.uid, service.trainid)}>{serviceStats.to}</td <td
> class="to to-data data {serviceStats.isCancelled && 'can-dat'} {serviceStats.isNonPublic && 'ecs'}"
<td class="plat plat-data data {serviceStats.platformHidden && 'hidden'}">{serviceStats.platform.number || '-'}</td> on:click={showDetails(service.rid, service.uid, service.trainid)}
<td class="time time-data data">{serviceStats.schArr}</td> on:keypress={showDetails(service.rid, service.uid, service.trainid)}>{serviceStats.to}</td
<td >
class="time time-data data {serviceStats.canArr && 'can-time'} {serviceStats.isArrDelayed && 'late'} {serviceStats.isEarlyArr && 'early'} {serviceStats.isLateArr && <td class="plat plat-data data {serviceStats.platformHidden && 'hidden'}">{serviceStats.platform.number || '-'}</td>
'late'}">{serviceStats.isArrDelayed ? 'LATE' : serviceStats.expArr}</td <td class="time time-data data">{serviceStats.schArr}</td>
> <td
<td class="time time-data data {serviceStats.isCancelled && 'can-dat'}">{serviceStats.schDep}</td> class="time time-data data {serviceStats.canArr && 'can-time'} {serviceStats.isArrDelayed && 'late'} {serviceStats.isEarlyArr && 'early'} {serviceStats.isLateArr &&
<td 'late'}">{serviceStats.isArrDelayed ? 'LATE' : serviceStats.expArr}</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 <td class="time time-data data {serviceStats.isCancelled && 'can-dat'}">{serviceStats.schDep}</td>
> <td
</tr> class="time time-data data {serviceStats.canDep && 'can-time'} {serviceStats.isDepDelayed && 'late'} {serviceStats.isEarlyDep && 'early'} {serviceStats.isLateDep &&
<tr class="text-row"> 'late'}">{serviceStats.isDepDelayed ? 'LATE' : serviceStats.expDep}</td
<td colspan="8" class="text-data"> >
{service.operator} </tr>
{#if serviceStats.length} | {serviceStats.length} carriages{/if} <tr class="text-row">
<br /> <td colspan="8" class="text-data">
{#if service.cancelReason} {service.operator}
<Reason type="cancel" code={service.cancelReason} /> {#if serviceStats.length} | {serviceStats.length} carriages{/if}
{/if} <br />
{#if service?.delayReason && !service.isCancelled} {#if service.cancelReason}
<Reason type="delay" code={service.delayReason} /> <Reason type="cancel" code={service.cancelReason} />
{/if} <br />
</td> {/if}
</tr> {#if service?.delayReason && !service.isCancelled}
{:catch} <Reason type="delay" code={service.delayReason} />
<tr> {/if}
<td colspan="8">Unable to load service</td> </td>
</tr> </tr>
{/await} {:catch}
{/each} <tr>
<td colspan="8">Unable to load service</td>
</tr>
{/await}
{/each}
{/if}
</table> </table>
{#if busServices.length}
<br />
<img class="transport-mode" src="/images/transport-modes/bus.svg" alt="Bus services" /><br />
<table>
<tr>
<th colspan="4" />
<th colspan="2">Arrival</th>
<th colspan="2">Departure</th>
</tr>
<tr>
<th class="id">ID</th>
<th class="from">From</th>
<th class="to">To</th>
<th class="plat">Plat</th>
<th class="time">Sch</th>
<th class="time">Exp</th>
<th class="time">Sch</th>
<th class="time">Exp</th>
</tr>
{#each busServices as service}
{#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>
{:catch}
<tr>
<td colspan="8">Unable to load service</td>
</tr>
{/await}
{/each}
</table>
{/if}
{#if ferryServices.length}
<br />
<img class="transport-mode" src="/images/transport-modes/ferry.svg" alt="Ferry services" /><br />
<table>
<tr>
<th colspan="4" />
<th colspan="2">Arrival</th>
<th colspan="2">Departure</th>
</tr>
<tr>
<th class="id">ID</th>
<th class="from">From</th>
<th class="to">To</th>
<th class="plat">Plat</th>
<th class="time">Sch</th>
<th class="time">Exp</th>
<th class="time">Sch</th>
<th class="time">Exp</th>
</tr>
{#each ferryServices as service}
{#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>
{:catch}
<tr>
<td colspan="8">Unable to load service</td>
</tr>
{/await}
{/each}
</table>
{/if}
{/if} {/if}
<Nav /> <Nav />
@ -328,6 +513,10 @@
color: var(--second-text-color); color: var(--second-text-color);
} }
.transport-mode {
width: 30px;
}
table { table {
color: white; color: white;
font-weight: normal; font-weight: normal;

View File

@ -1,10 +1,11 @@
<script> <script>
import OverlayIsland from '$lib/islands/overlay-island.svelte'; import { welcome } from '$lib/stores/welcome';
import { fade } from 'svelte/transition';
import { version } from '$lib/stores/version';
const variables = { const variables = {
title: 'Welcome to OwlBoard' title: 'Welcome to OwlBoard'
}; };
const version = '2023.7.1';
let pageNum = 0; let pageNum = 0;
function pageUp() { function pageUp() {
@ -17,31 +18,93 @@
console.log(`Welcome page: ${pageNum}`); console.log(`Welcome page: ${pageNum}`);
} }
function close() {
welcome.set(version);
}
const pageText = [ const pageText = [
'<h3>A brand new look</h3>' + '<h3>A brand new look</h3>' +
'<p>OwlBoard has a brand new look, making it even faster for you to access the data</p>' + "<p>OwlBoard has a brand new look, making it even faster for you to access the data - you won't have to register again.</p>" +
"<p>If you have signed up before, you won't have to to it again and any customised Quick Links are here waiting for you</p>", "<p><strong>Live station data</strong> is still available right from the homepage. If you are signed up, you'll get improved data from the <strong>Staff board</strong></p>" +
'<h3>Faster Access</h3>' + '<p><strong>Train Data & PIS</strong> is now available right from the homepage if you are searching by headcode, for other PIS searches, the PIS finder is in the bottom menu</p>',
'<p>Both live station data, and timetable search is available from the homepage. Making it faster to get the info you need</p>' + '<h3>Staff Station Boards</h3>' +
'<p>Search the timetable using a headcode to see a trains details - OwlBoard now shows data for all TOCs and FOCs.</p>' + '<p>If you are registered, staff station boards will be available.</p>' +
"<p>For GWR services: if a PIS code is available for a service, you'll see it alongside the train details.</p>", '<p>Staff boards will show hidden platform numbers as well as ECS moves</p>' +
'<h3>PIS Finder</h3>' + '<p>You can also tap on a train to see live train data.</p>',
"<p>Don't worry, the PIS finder hasn't gone away. It has even been moved to the new navigation bar for faster access</p>" + '<h3>Everything Else</h3>' +
"<p>If there isn't a PIS code available for a given headcode, you can use this tool to search by start and end stations, enabling you to utilise a different code and skipping stops as needed.</p>", "<p>Everything else has moved to the 'More' menu, where you'll find the Reference Code lookup and software details." +
'<h3>Everything Else</h3>' + "<p>Everything else has moved to the 'More' menu, where you'll find the Reference Code lookup and software details." '<br>' +
"<p>You won't see this welcome screen again</p>"
]; ];
</script> </script>
<OverlayIsland {variables}> <div id="popup" in:fade={{ delay: 500, duration: 300 }} out:fade={{ duration: 300 }}>
<h2>What's new in OwlBoard {version}</h2> <h2>What's new in OwlBoard {version}</h2>
<div> {#key pageNum}
{@html pageText[pageNum]} <div in:fade={{ delay: 300 }} out:fade={{ duration: 200 }}>
</div> {@html pageText[pageNum] || "You won't see this welcome message again"}
<button type="button" on:click={pageDn}>&lt;</button> </div>
<button type="button" on:click={pageUp}>&gt;</button> {/key}
</OverlayIsland> {#if pageNum >= pageText.length - 1}
<button in:fade={{ delay: 350, duration: 250 }} out:fade={{ duration: 250 }} class="navButton" id="buttonCentre" type="button" on:click={close}>X</button>
{/if}
{#if pageNum > 0 && pageNum < pageText.length}
<button in:fade={{ delay: 350, duration: 250 }} out:fade={{ duration: 250 }} class="navButton" id="buttonLeft" type="button" on:click={pageDn}>&lt;</button>
{/if}
{#if pageNum < pageText.length - 1}
<button in:fade={{ delay: 350, duration: 250 }} out:fade={{ duration: 250 }} class="navButton" id="buttonRight" type="button" on:click={pageUp}>&gt;</button>
{/if}
</div>
<style> <style>
#popup {
position: fixed;
top: 50%;
left: 50%;
transform: translateY(-50%) translateX(-50%);
width: 85%;
height: 85vh;
overflow-y: auto;
max-width: 400px;
margin: auto;
margin-top: 25px;
padding: 10px;
background-color: grey;
border-radius: 10px;
z-index: 2500;
}
.navButton {
border-radius: 50px;
border: none;
color: white;
background-color: var(--overlay-color);
width: 50px;
height: 50px;
font-size: 20px;
font-weight: 600;
bottom: 50px;
}
#buttonLeft {
position: absolute;
margin: auto;
left: 50px;
}
#buttonCentre {
position: absolute;
margin: auto;
left: 50%;
transform: translateX(-50%);
}
#buttonRight {
position: absolute;
margin: auto;
right: 50px;
}
div { div {
color: white; color: white;
} }

View File

@ -0,0 +1,3 @@
export const version = '2023.7.1';
export const versionTag = 'dev';
export const showWelcome = true;

23
src/lib/stores/welcome.js Normal file
View File

@ -0,0 +1,23 @@
import { writable } from 'svelte/store';
import { browser } from '$app/environment';
export const welcome = writable(fromLocalStorage('welcome', '0'));
toLocalStorage(welcome, 'welcome');
function fromLocalStorage(storageKey, fallback) {
if (browser) {
const storedValue = localStorage.getItem(storageKey);
if (storedValue !== 'undefined') {
return storedValue;
}
}
return fallback;
}
function toLocalStorage(store, storageKey) {
if (browser) {
store.subscribe((value) => {
localStorage.setItem(storageKey, value);
});
}
}

View File

@ -4,6 +4,8 @@
import InputIsland from '$lib/islands/input-island-form.svelte'; import InputIsland from '$lib/islands/input-island-form.svelte';
import QuickLinkIsland from '$lib/islands/quick-link-island.svelte'; import QuickLinkIsland from '$lib/islands/quick-link-island.svelte';
import Welcome from '$lib/overlays/welcome.svelte'; import Welcome from '$lib/overlays/welcome.svelte';
import { welcome } from '$lib/stores/welcome';
import { version, showWelcome } from '$lib/stores/version';
const title = 'OwlBoard'; const title = 'OwlBoard';
const inputIslands = [ const inputIslands = [
@ -20,11 +22,9 @@
queryName: 'headcode' queryName: 'headcode'
} }
]; ];
const isWelcomed = 'false'; // Usually a bool - <Welcome /> is incomplete so should be hidden for now.
</script> </script>
{#if !isWelcomed} {#if showWelcome && ($welcome === 'null' || !$welcome || parseInt($welcome.replace(/\./g, '')) < parseInt(version.replace(/\./g, '')))}
<Welcome /> <Welcome />
{/if} {/if}
<Header {title} /> <Header {title} />

View File

@ -9,13 +9,13 @@
<Header {title} /> <Header {title} />
<LargeLogo /> <LargeLogo />
<p class="neg">&copy; 2022-2023 Frederick Boniface</p> <p class="neg">&copy; 2022-2023 Frederick Boniface</p>
<p>OwlBoard was created by train-crew for train-crew</p> <p>OwlBoard was created by train crew for train crew.</p>
<p>I created OwlBoard in 2022 to freely give fast and easy access to the information that we need every day.</p> <p>I developed OwlBoard in 2022 with the aim of providing fast and easy access to the information we need on a daily basis.</p>
<p>Data sourced from: National Rail Enquiries, OwlBoard Project and Network Rail.</p> <p>Data is sourced from National Rail Enquiries, the OwlBoard Project, and Network Rail.</p>
<p> <p>
OwlBoard components are available under various Open Source licenses, see the OwlBoard components are available under various Open Source licenses. Please refer to the
<a href="https://git.fjla.uk/OwlBoard" target="_blank">code repository</a> <a href="https://git.fjla.uk/OwlBoard" target="_blank">code repository</a>
for more information. for more detailed information.
</p> </p>
<Nav /> <Nav />

View File

@ -59,7 +59,7 @@
<ul> <ul>
<li>Non-Passenger movements</li> <li>Non-Passenger movements</li>
<li>Hidden platform numbers</li> <li>Hidden platform numbers</li>
<li>Display up to 40 services</li> <li>Display up to 25 services</li>
</ul> </ul>
</ul> </ul>
<p>To register, you will need to enter a work email address to receive a confirmation email</p> <p>To register, you will need to enter a work email address to receive a confirmation email</p>

View File

@ -140,8 +140,8 @@
font-size: 16px; font-size: 16px;
border: none; border: none;
width: 50%; width: 50%;
max-width: 250px; max-width: 450px;
min-width: 100px; min-width: 250px;
} }
input { input {
text-align: center; text-align: center;

View File

@ -3,22 +3,13 @@
import Header from '$lib/navigation/header.svelte'; import Header from '$lib/navigation/header.svelte';
import Loading from '$lib/navigation/loading.svelte'; import Loading from '$lib/navigation/loading.svelte';
import Nav from '$lib/navigation/nav.svelte'; import Nav from '$lib/navigation/nav.svelte';
import { onMount } from 'svelte';
const title = 'Statistics'; const title = 'Statistics';
let isLoading = true;
let data, error; async function getData() {
onMount(async () => {
const url = 'https://owlboard.info/misc/server/stats'; const url = 'https://owlboard.info/misc/server/stats';
const res = await fetch(url); const res = await fetch(url);
if (res.status == 200) { return await res.json();
data = await res.json(); }
} else {
error = true;
}
isLoading = false;
});
function U2L(input) { function U2L(input) {
try { try {
@ -33,15 +24,9 @@
<Header {title} /> <Header {title} />
{#if error} {#await getData()}
<Island>
<p>Unable to connect to server</p>
</Island>
{/if}
{#if isLoading}
<Loading /> <Loading />
{:else if !isLoading && !error} {:then data}
<p>API Server:<br /><span>{data?.hostname}</span></p> <p>API Server:<br /><span>{data?.hostname}</span></p>
<p>Runtime Mode: <span>{data?.runtimeMode}</span></p> <p>Runtime Mode: <span>{data?.runtimeMode}</span></p>
<p>Stats Reset: <span>{U2L(data?.reset) || 'Unknown'}</span></p> <p>Stats Reset: <span>{U2L(data?.reset) || 'Unknown'}</span></p>
@ -68,7 +53,11 @@
<p>PIS: <span>{data?.dbLengths?.pis}</span></p> <p>PIS: <span>{data?.dbLengths?.pis}</span></p>
<p>Timetable: <span>{data?.dbLengths?.timetable}</span></p> <p>Timetable: <span>{data?.dbLengths?.timetable}</span></p>
<p>Reason Codes: <span>{data?.dbLengths?.reasonCodes}</span></p> <p>Reason Codes: <span>{data?.dbLengths?.reasonCodes}</span></p>
{/if} {:catch}
<Island>
<p style="font-weight:600">Unable to connect to server</p>
</Island>
{/await}
<Nav /> <Nav />

View File

@ -4,40 +4,39 @@
import Loading from '$lib/navigation/loading.svelte'; import Loading from '$lib/navigation/loading.svelte';
import Nav from '$lib/navigation/nav.svelte'; import Nav from '$lib/navigation/nav.svelte';
import LargeLogo from '$lib/images/large-logo.svelte'; import LargeLogo from '$lib/images/large-logo.svelte';
import { onMount } from 'svelte'; import { version, versionTag } from '$lib/stores/version.js';
const title = 'Versions'; const title = 'Versions';
const variable = { title: '' }; const variable = { title: '' };
let data,
isLoading = true;
async function getData() { async function getData() {
const url = 'https://owlboard.info/misc/server/versions'; const url = 'https://owlboard.info/misc/server/versions';
const res = await fetch(url); const res = await fetch(url);
data = await res.json(); return await res.json();
isLoading = false;
} }
onMount(() => {
getData();
});
</script> </script>
<Header {title} /> <Header {title} />
<LargeLogo /> <LargeLogo />
{#if isLoading} {#await getData()}
<Loading /> <Loading />
{:else} {:then data}
<Island> <Island>
<p> <p>
Web-app Version<br /><span class="data">{'2023.7.1-Svelte-Dev'}</span> Web-app Version<br /><span class="data">{version}-{versionTag}</span>
</p> </p>
<p>API Server Version<br /><span class="data">{data.backend}</span></p> <p>API Server Version<br /><span class="data">{data.backend}</span></p>
<p>DBManager Version<br /><span class="data">{data['db-manager']}</span></p> <p>DBManager Version<br /><span class="data">{data['db-manager']}</span></p>
</Island> </Island>
{/if} {:catch}
<Island>
<p>
Web-app Version<br /><span class="data">{version}-{versionTag}</span>
</p>
<p>Unable to fetch server versions</p>
</Island>
{/await}
<Nav /> <Nav />
<style> <style>

View File

@ -51,7 +51,12 @@
} }
}; };
const url = `https://owlboard.info/api/v2/timetable/train/${date}/${searchType}/${id}`; const url = `https://owlboard.info/api/v2/timetable/train/${date}/${searchType}/${id}`;
const res = await fetch(url, options); try {
const res = await fetch(url, options);
} catch (err) {
error = true;
errMsg = 'Connection error, try again later';
}
isLoading = false; isLoading = false;
if (res.status == 200) { if (res.status == 200) {
return await res.json(); return await res.json();
@ -72,7 +77,7 @@
{#if error} {#if error}
<Island> <Island>
<p class="error">{errMsg}</p> <p style="font-weight:600">{errMsg}</p>
</Island> </Island>
{/if} {/if}