Add bus and ferry to staffLDB
This commit is contained in:
parent
b6dca2df78
commit
13d3bc4dbe
@ -1,8 +1,10 @@
|
||||
<script>
|
||||
import { fade } from 'svelte/transition';
|
||||
|
||||
export let variables = { title: '' };
|
||||
</script>
|
||||
|
||||
<div>
|
||||
<div in:fade={{ duration: 250 }}>
|
||||
<span>{variables.title}</span>
|
||||
<slot />
|
||||
</div>
|
||||
|
@ -5,6 +5,7 @@
|
||||
import Loading from '$lib/navigation/loading.svelte';
|
||||
import OverlayIsland from '$lib/islands/overlay-island.svelte';
|
||||
import AlertBar from '$lib/ldb/nrcc/alert-bar.svelte';
|
||||
import Island from '$lib/islands/island.svelte';
|
||||
|
||||
let requestedStation;
|
||||
$: requestedStation = station;
|
||||
@ -54,7 +55,7 @@
|
||||
isLoading = true; // Set loading state
|
||||
try {
|
||||
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();
|
||||
} catch (error) {
|
||||
console.error('Error fetching data:', error);
|
||||
@ -286,7 +287,9 @@
|
||||
</table>
|
||||
{/if}
|
||||
{:else}
|
||||
<p>Unable to find this station</p>
|
||||
<Island>
|
||||
<p style="font-weight:600">Unable to load data</p>
|
||||
</Island>
|
||||
{/if}
|
||||
|
||||
{#if serviceDetail}
|
||||
|
@ -3,20 +3,26 @@
|
||||
export let title = 'Loading...';
|
||||
import { onMount } from '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 Reason from '$lib/raw-fetchers/reason.svelte';
|
||||
import Loading from '$lib/navigation/loading.svelte';
|
||||
import Nav from '$lib/navigation/nav.svelte';
|
||||
import { uuid } from '$lib/stores/uuid';
|
||||
import Error from '../../../routes/+error.svelte';
|
||||
import Island from '$lib/islands/island.svelte';
|
||||
|
||||
let requestedStation;
|
||||
$: requestedStation = station;
|
||||
|
||||
let jsonData = {};
|
||||
let services = [];
|
||||
let services = [],
|
||||
busServices = [],
|
||||
ferryServices = [];
|
||||
let dataAge = null;
|
||||
let isLoading = true;
|
||||
let isErr = false;
|
||||
let errMsg;
|
||||
let alerts = [];
|
||||
let detail = { show: false, rid: '', uid: '', headcode: '' };
|
||||
|
||||
@ -31,6 +37,18 @@
|
||||
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) {
|
||||
title = jsonData.GetBoardResult.locationName;
|
||||
} else {
|
||||
@ -54,9 +72,18 @@
|
||||
}
|
||||
};
|
||||
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) {
|
||||
console.error('Error fetching data:', error);
|
||||
isLoading = false;
|
||||
isErr = true;
|
||||
errMsg = 'Connection error, try again later';
|
||||
} finally {
|
||||
isLoading = false; // Clear loading state
|
||||
}
|
||||
@ -251,23 +278,108 @@
|
||||
|
||||
{#if isLoading}
|
||||
<Loading />
|
||||
{:else if isErr}
|
||||
<Island>
|
||||
<p><strong>{errMsg}</strong></p>
|
||||
</Island>
|
||||
{:else}
|
||||
{#if alerts.length}
|
||||
<AlertBar {alerts} />
|
||||
{/if}
|
||||
<table>
|
||||
<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>
|
||||
<th class="id">ID</th>
|
||||
<th class="from">From</th>
|
||||
<th class="to">To</th>
|
||||
<th class="plat">Plat</th>
|
||||
<th class="time">Sch Arr</th>
|
||||
<th class="time">Exp Arr</th>
|
||||
<th class="time">Sch Dep</th>
|
||||
<th class="time">Exp Dep</th>
|
||||
<th class="time">Sch</th>
|
||||
<th class="time">Exp</th>
|
||||
<th class="time">Sch</th>
|
||||
<th class="time">Exp</th>
|
||||
</tr>
|
||||
{#if !services.length}
|
||||
<tr><td colspan="8">No Scheduled Train Services</td></tr>
|
||||
{:else}
|
||||
{#each services 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} />
|
||||
<br />
|
||||
{/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}
|
||||
{/if}
|
||||
</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>
|
||||
@ -320,6 +432,79 @@
|
||||
{/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}
|
||||
|
||||
<Nav />
|
||||
|
||||
@ -328,6 +513,10 @@
|
||||
color: var(--second-text-color);
|
||||
}
|
||||
|
||||
.transport-mode {
|
||||
width: 30px;
|
||||
}
|
||||
|
||||
table {
|
||||
color: white;
|
||||
font-weight: normal;
|
||||
|
@ -1,10 +1,11 @@
|
||||
<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 = {
|
||||
title: 'Welcome to OwlBoard'
|
||||
};
|
||||
const version = '2023.7.1';
|
||||
let pageNum = 0;
|
||||
|
||||
function pageUp() {
|
||||
@ -17,31 +18,93 @@
|
||||
console.log(`Welcome page: ${pageNum}`);
|
||||
}
|
||||
|
||||
function close() {
|
||||
welcome.set(version);
|
||||
}
|
||||
|
||||
const pageText = [
|
||||
'<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>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>",
|
||||
'<h3>Faster Access</h3>' +
|
||||
'<p>Both live station data, and timetable search is available from the homepage. Making it faster to get the info you need</p>' +
|
||||
'<p>Search the timetable using a headcode to see a trains details - OwlBoard now shows data for all TOCs and FOCs.</p>' +
|
||||
"<p>For GWR services: if a PIS code is available for a service, you'll see it alongside the train details.</p>",
|
||||
'<h3>PIS Finder</h3>' +
|
||||
"<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>" +
|
||||
"<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>",
|
||||
'<h3>Everything Else</h3>' + "<p>Everything else has moved to the 'More' menu, where you'll find the Reference Code lookup and software details."
|
||||
"<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><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>" +
|
||||
'<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>',
|
||||
'<h3>Staff Station Boards</h3>' +
|
||||
'<p>If you are registered, staff station boards will be available.</p>' +
|
||||
'<p>Staff boards will show hidden platform numbers as well as ECS moves</p>' +
|
||||
'<p>You can also tap on a train to see live train data.</p>',
|
||||
'<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>
|
||||
|
||||
<OverlayIsland {variables}>
|
||||
<div id="popup" in:fade={{ delay: 500, duration: 300 }} out:fade={{ duration: 300 }}>
|
||||
<h2>What's new in OwlBoard {version}</h2>
|
||||
<div>
|
||||
{@html pageText[pageNum]}
|
||||
{#key pageNum}
|
||||
<div in:fade={{ delay: 300 }} out:fade={{ duration: 200 }}>
|
||||
{@html pageText[pageNum] || "You won't see this welcome message again"}
|
||||
</div>
|
||||
{/key}
|
||||
{#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}><</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}>></button>
|
||||
{/if}
|
||||
</div>
|
||||
<button type="button" on:click={pageDn}><</button>
|
||||
<button type="button" on:click={pageUp}>></button>
|
||||
</OverlayIsland>
|
||||
|
||||
<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 {
|
||||
color: white;
|
||||
}
|
||||
|
3
src/lib/stores/version.js
Normal file
3
src/lib/stores/version.js
Normal 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
23
src/lib/stores/welcome.js
Normal 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);
|
||||
});
|
||||
}
|
||||
}
|
@ -4,6 +4,8 @@
|
||||
import InputIsland from '$lib/islands/input-island-form.svelte';
|
||||
import QuickLinkIsland from '$lib/islands/quick-link-island.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 inputIslands = [
|
||||
@ -20,11 +22,9 @@
|
||||
queryName: 'headcode'
|
||||
}
|
||||
];
|
||||
|
||||
const isWelcomed = 'false'; // Usually a bool - <Welcome /> is incomplete so should be hidden for now.
|
||||
</script>
|
||||
|
||||
{#if !isWelcomed}
|
||||
{#if showWelcome && ($welcome === 'null' || !$welcome || parseInt($welcome.replace(/\./g, '')) < parseInt(version.replace(/\./g, '')))}
|
||||
<Welcome />
|
||||
{/if}
|
||||
<Header {title} />
|
||||
|
@ -9,13 +9,13 @@
|
||||
<Header {title} />
|
||||
<LargeLogo />
|
||||
<p class="neg">© 2022-2023 Frederick Boniface</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>Data sourced from: National Rail Enquiries, OwlBoard Project and Network Rail.</p>
|
||||
<p>OwlBoard was created by train crew for train crew.</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 is sourced from National Rail Enquiries, the OwlBoard Project, and Network Rail.</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>
|
||||
for more information.
|
||||
for more detailed information.
|
||||
</p>
|
||||
<Nav />
|
||||
|
||||
|
@ -59,7 +59,7 @@
|
||||
<ul>
|
||||
<li>Non-Passenger movements</li>
|
||||
<li>Hidden platform numbers</li>
|
||||
<li>Display up to 40 services</li>
|
||||
<li>Display up to 25 services</li>
|
||||
</ul>
|
||||
</ul>
|
||||
<p>To register, you will need to enter a work email address to receive a confirmation email</p>
|
||||
|
@ -140,8 +140,8 @@
|
||||
font-size: 16px;
|
||||
border: none;
|
||||
width: 50%;
|
||||
max-width: 250px;
|
||||
min-width: 100px;
|
||||
max-width: 450px;
|
||||
min-width: 250px;
|
||||
}
|
||||
input {
|
||||
text-align: center;
|
||||
|
@ -3,22 +3,13 @@
|
||||
import Header from '$lib/navigation/header.svelte';
|
||||
import Loading from '$lib/navigation/loading.svelte';
|
||||
import Nav from '$lib/navigation/nav.svelte';
|
||||
import { onMount } from 'svelte';
|
||||
const title = 'Statistics';
|
||||
let isLoading = true;
|
||||
|
||||
let data, error;
|
||||
|
||||
onMount(async () => {
|
||||
async function getData() {
|
||||
const url = 'https://owlboard.info/misc/server/stats';
|
||||
const res = await fetch(url);
|
||||
if (res.status == 200) {
|
||||
data = await res.json();
|
||||
} else {
|
||||
error = true;
|
||||
return await res.json();
|
||||
}
|
||||
isLoading = false;
|
||||
});
|
||||
|
||||
function U2L(input) {
|
||||
try {
|
||||
@ -33,15 +24,9 @@
|
||||
|
||||
<Header {title} />
|
||||
|
||||
{#if error}
|
||||
<Island>
|
||||
<p>Unable to connect to server</p>
|
||||
</Island>
|
||||
{/if}
|
||||
|
||||
{#if isLoading}
|
||||
{#await getData()}
|
||||
<Loading />
|
||||
{:else if !isLoading && !error}
|
||||
{:then data}
|
||||
<p>API Server:<br /><span>{data?.hostname}</span></p>
|
||||
<p>Runtime Mode: <span>{data?.runtimeMode}</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>Timetable: <span>{data?.dbLengths?.timetable}</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 />
|
||||
|
||||
|
@ -4,40 +4,39 @@
|
||||
import Loading from '$lib/navigation/loading.svelte';
|
||||
import Nav from '$lib/navigation/nav.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 variable = { title: '' };
|
||||
|
||||
let data,
|
||||
isLoading = true;
|
||||
|
||||
async function getData() {
|
||||
const url = 'https://owlboard.info/misc/server/versions';
|
||||
const res = await fetch(url);
|
||||
data = await res.json();
|
||||
isLoading = false;
|
||||
return await res.json();
|
||||
}
|
||||
|
||||
onMount(() => {
|
||||
getData();
|
||||
});
|
||||
</script>
|
||||
|
||||
<Header {title} />
|
||||
|
||||
<LargeLogo />
|
||||
|
||||
{#if isLoading}
|
||||
{#await getData()}
|
||||
<Loading />
|
||||
{:else}
|
||||
{:then data}
|
||||
<Island>
|
||||
<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>API Server Version<br /><span class="data">{data.backend}</span></p>
|
||||
<p>DBManager Version<br /><span class="data">{data['db-manager']}</span></p>
|
||||
</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 />
|
||||
|
||||
<style>
|
||||
|
@ -51,7 +51,12 @@
|
||||
}
|
||||
};
|
||||
const url = `https://owlboard.info/api/v2/timetable/train/${date}/${searchType}/${id}`;
|
||||
try {
|
||||
const res = await fetch(url, options);
|
||||
} catch (err) {
|
||||
error = true;
|
||||
errMsg = 'Connection error, try again later';
|
||||
}
|
||||
isLoading = false;
|
||||
if (res.status == 200) {
|
||||
return await res.json();
|
||||
@ -72,7 +77,7 @@
|
||||
|
||||
{#if error}
|
||||
<Island>
|
||||
<p class="error">{errMsg}</p>
|
||||
<p style="font-weight:600">{errMsg}</p>
|
||||
</Island>
|
||||
{/if}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user