Add bus & ferry to public ldb

This commit is contained in:
Fred Boniface 2023-06-19 14:21:17 +01:00
parent 3c191c4793
commit 7df190220f
7 changed files with 200 additions and 63 deletions

View File

@ -19,7 +19,7 @@
{link.toUpperCase()}
</a>
{:else if link.length === 4}
<a class="link" href="/result-timetable?headcode={link}">
<a class="link" href="/train?headcode={link}">
{link.toUpperCase()}
</a>
{/if}

View File

@ -19,3 +19,9 @@
{/each}
</Island>
<style>
p {
color: white;
}
</style>

View File

@ -1,5 +1,6 @@
<script>
export let station = "";
export let title = "Loading...";
import { onMount } from 'svelte'
import Loading from '$lib/navigation/loading.svelte';
@ -8,6 +9,8 @@
let jsonData = null;
let services = [];
let busServices = [];
let ferryServices = [];
let dataAge = null;
let isLoading = true;
@ -16,15 +19,29 @@
fetchData();
}
if (jsonData && jsonData.GetStationBoardResult && jsonData.GetStationBoardResult.generatedAt) {
if (jsonData?.GetStationBoardResult?.generatedAt) {
dataAge = new Date(jsonData.GetStationBoardResult.generatedAt);
}
if (jsonData && jsonData.GetStationBoardResult && jsonData.GetStationBoardResult.trainServices && jsonData.GetStationBoardResult.trainServices.service) {
if (jsonData?.GetStationBoardResult?.trainServices?.service) {
services = jsonData.GetStationBoardResult.trainServices.service;
} else {
services = [];
}
if (jsonData?.GetStationBoardResult?.busServices?.service) {
busServices = jsonData.GetStationBoardResult.busServices.service;
}
if (jsonData?.GetStationBoardResult?.ferryServices?.service) {
ferryServices = jsonData.GetStationBoardResult.ferryServices.service;
}
if (jsonData?.GetStationBoardResult?.locationName) {
title = jsonData.GetStationBoardResult.locationName
} else {
title = "Loading Board"
}
}
async function fetchData() {
@ -90,8 +107,7 @@
<Loading />
{:else}
<p id="timestamp">Updated: {dataAge.toLocaleTimeString()}</p>
<p>Public LDB for {station}</p>
{#if services.length}
<table>
<tr>
<th class="from">From</th>
@ -112,10 +128,7 @@
<td class="time">{parseTime(service.std).data}</td>
<td class="time {parseTime(service.etd).changed}">{parseTime(service.etd).data}</td>
</tr>
<!-- service-detail elements are currently contained within the 'From' column
It should be underneath the row. I will need to look at the vanilla interface
to establish what I did differently there. Or, I can insert a new row
with colspan="7" to add a row spanning all columns.-->
<tr><td colspan="7">
<p class="service-detail">
A {service.operator || 'Unknown'} service
@ -132,6 +145,81 @@
</td></tr>
{/each}
</table>
{:else}
<p>No Scheduled Train Services</p>
{/if}
{#if busServices.length}
<table>
<tr>
<th class="from">From</th>
<th class="to">To</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>
</tr>
{#each busServices as service}
<tr>
<td class="origdest from">{service.origin?.location?.locationName || ''}</td>
<td class="origdest to">{service.destination?.location?.locationName || ''}</td>
<td class="time">{parseTime(service.sta).data}</td>
<td class="time {parseTime(service.eta).changed}">{parseTime(service.eta).data}</td>
<td class="time">{parseTime(service.std).data}</td>
<td class="time {parseTime(service.etd).changed}">{parseTime(service.etd).data}</td>
</tr>
<tr><td colspan="7">
<p class="service-detail">
A {service.operator || 'Unknown'} service
</p>
{#if service.delayReason}
<p class="service-detail">{service.delayReason}</p>
{/if}
{#if service.cancelReason}
<p class="service-detail">{service.cancelReason}</p>
{/if}
</td></tr>
{/each}
</table>
{:else}
<p>No Scheduled Bus Services</p>
{/if}
{#if ferryServices.length}
<table>
<tr>
<th class="from">From</th>
<th class="to">To</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>
</tr>
{#each ferryServices as service}
<tr>
<td class="origdest from">{service.origin?.location?.locationName || ''}</td>
<td class="origdest to">{service.destination?.location?.locationName || ''}</td>
<td class="time">{parseTime(service.sta).data}</td>
<td class="time {parseTime(service.eta).changed}">{parseTime(service.eta).data}</td>
<td class="time">{parseTime(service.std).data}</td>
<td class="time {parseTime(service.etd).changed}">{parseTime(service.etd).data}</td>
</tr>
<tr><td colspan="7">
<p class="service-detail">
A {service.operator || 'Unknown'} service
</p>
{#if service.delayReason}
<p class="service-detail">{service.delayReason}</p>
{/if}
{#if service.cancelReason}
<p class="service-detail">{service.cancelReason}</p>
{/if}
</td></tr>
{/each}
</table>
{:else}
<p>No Scheduled Ferry Serices</p>
{/if}
{/if}
<style>
#timestamp {

View File

@ -14,7 +14,7 @@ const inputIslands = [
},
{
title: "Train Details & PIS",
action: "/result-timetable",
action: "/train",
placeholder: "Enter Headcode",
queryName: "headcode"
}

View File

@ -6,23 +6,25 @@
import { uuid } from '$lib/stores/uuid.js';
import {onMount} from 'svelte'
const title = "Public Board"
let title = "Loading"
async function getHeadcode() {
return new URLSearchParams(window.location.search).get('station');
}
let station;
let staff;
let uuidValue;
let station = "";
let staff = false;
let uuidValue = "";
$: uuidValue = $uuid;
onMount(async () => {
station = await getHeadcode() || "";
if (uuidValue !== null) {
if (uuidValue !== null && uuidValue !== "" && uuidValue !== "null") {
staff = true;
title = "Staff Board"
} else {
staff = false;
title = "Public Board"
}
})
@ -32,7 +34,7 @@
<!-- If 'uuid' exists in store then load StaffLdb else load PublicLdb -->
{#if !staff}
<PublicLdb {station} />
<PublicLdb {station} bind:title={title} />
{:else}
<StaffLdb {station} />
{/if}

View File

@ -6,7 +6,48 @@
</script>
<Header {title} />
<div>
<p>OwlBoard stores as little data as possible to offer its functions for you to use.
OwlBoard does not use any cookies, any data that is required is stored in your browser.
</p>
<p>Owlboard does not log IP addresses or browser fingerprints.</p>
<h2>If you do not sign up</h2>
<p>If you do not sign up, no personal data is processed or stored unless you report an issue.
</p>
<h2>If you do sign up</h2>
<p>If you do sign up for the rail staff version of OwlBoard, then we do need to store some data
but none of it can be used to personally identify you.
</p>
<p>When you sign up, you will need to provide a work email address which is checked to confirm that
it originates from a railway company. You are then sent an email with a registration link, OwlBoard
at this point, the username portion of the email address is discarted - for example 'a-user@owlboard.info'
would be stored at '@owlboard.info'. This host part of your email address is stored so that the data that
is displayed to you can be filtered, showing relevent results more prominently.
</p>
<p>The email-server may store the address and message content per it's usual operation and you consent to this
when you sign up.
</p>
<p>Alongside the host poriton of your email address, we store a randomly generated UUID which is used to authorize
access to the rail staff data.
</p>
<h2>Reporting an Issue</h2>
<p>When you report an issue, some data is collected - This data is: your browsers User Agent string and the size of the window you
are viewing the website in.</p>
<p>Any data that is submitted when you report an issue will be publically viewable alongside the
<a href="https://git.fjla.uk/owlboard/backend/issues" target="_blank">OwlBoard/backend git repository</a>.</p>
</div>
<Nav />
<style>
div {
text-align: left;
}
h2 {
color: var(--second-text-color);
}
p {
color: white;
}
</style>