Begin create staff ldb table

This commit is contained in:
Fred Boniface 2023-07-03 23:35:12 +01:00
parent 9729cc6c77
commit ef576051bd
2 changed files with 62 additions and 14 deletions

View File

@ -91,6 +91,15 @@
} }
return {data: output, changed: change} return {data: output, changed: change}
} }
function parseDateTime(input) {
const dt = new Date(input);
const output = dt.toLocaleTimeString([], {hour: '2-digit', minute:'2-digit'})
if (output !== "Invalid Date") {
return output
}
return '-'
}
onMount(() => { onMount(() => {
fetchData(); fetchData();
@ -102,18 +111,57 @@
{:else} {:else}
<p id="timestamp">Updated: {dataAge.toLocaleTimeString()}</p> <p id="timestamp">Updated: {dataAge.toLocaleTimeString()}</p>
<p>Staff LDB for {station}</p> <table>
<tr>
{#each services as service} <th class="id">ID</th>
<div class="service"> <th class="from">From</th>
<p class="service-operator">{service.operatorCode}</p> <th class="to">To</th>
<p class="service-headcode">{service.trainid}</p> <th class="plat">Plat</th>
<p class="service-origin">{service.origin.location.tiploc}</p> <th class="time">Sch Arr</th>
<p class="service-dest">{service.destination.location.tiploc}</p> <th class="time">Exp Arr</th>
<p class="service-plat">{service.platform}</p> <th class="time">Sch Dep</th>
<p class="service-expArr">{new Date(service.sta).toLocaleTimeString() || '-'}</p> <th class="time">Exp Dep</th>
</div> </tr>
{/each} {#each services as service}
<tr>
<th class="id id-data">{service.trainid}</th>
<th class="from from-data">{service.origin.location.tiploc}</th>
<th class="to to-data">{service.destination.location.tiploc}</th>
<th class="plat plat-data">{service.platform || '-'}</th>
<th class="time time-data">{parseDateTime(service.sta)}</th>
<th class="time time-data">{'-'}</th>
<th class="time time-data">{parseDateTime(service.std)}</th>
<th class="time time-data">{'-'}</th>
</tr>
<tr>
<td colspan="8" class="text-data">
{service.operator}
</td>
</tr>
{/each}
</table>
{/if} {/if}
<Nav /> <Nav />
<style>
table {
color: white;
font-weight: normal;
margin: auto;
}
.id-data {
color: lightgray;
}
.from-data, .to-data {
color: yellow;
text-decoration: none;
}
.text-data {
text-align: left;
color: cyan;
}
</style>

View File

@ -36,7 +36,7 @@
{#if !staff} {#if !staff}
<PublicLdb {station} bind:title={title} /> <PublicLdb {station} bind:title={title} />
{:else} {:else}
<PublicLdb {station} bind:title={title} /> <StaffLdb {station} bind:title={title} />
<!--<StaffLdb {station} bind:title={title} /> -- Temporary, Disable StaffLdb - it isn't implemented --> <!--<StaffLdb {station} bind:title={title} /> -- Temporary, Disable StaffLdb - it isn't implemented -->
{/if} {/if}