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

@ -92,6 +92,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>
<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>
</tr>
{#each services as service} {#each services as service}
<div class="service"> <tr>
<p class="service-operator">{service.operatorCode}</p> <th class="id id-data">{service.trainid}</th>
<p class="service-headcode">{service.trainid}</p> <th class="from from-data">{service.origin.location.tiploc}</th>
<p class="service-origin">{service.origin.location.tiploc}</p> <th class="to to-data">{service.destination.location.tiploc}</th>
<p class="service-dest">{service.destination.location.tiploc}</p> <th class="plat plat-data">{service.platform || '-'}</th>
<p class="service-plat">{service.platform}</p> <th class="time time-data">{parseDateTime(service.sta)}</th>
<p class="service-expArr">{new Date(service.sta).toLocaleTimeString() || '-'}</p> <th class="time time-data">{'-'}</th>
</div> <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} {/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}