Compare commits
5 Commits
v3.0.0-dev
...
fd213d6340
| Author | SHA1 | Date | |
|---|---|---|---|
| fd213d6340 | |||
| 3eceddf20a | |||
| 1d461780ab | |||
| ec4dd5dd3b | |||
| a7c244171c |
17
package-lock.json
generated
17
package-lock.json
generated
@@ -13,7 +13,8 @@
|
||||
"devDependencies": {
|
||||
"@eslint/compat": "^2.0.2",
|
||||
"@eslint/js": "^9.39.2",
|
||||
"@owlboard/owlboard-ts": "^3.0.0-dev.20260319T2004",
|
||||
"@owlboard/api-schema-types": "^3.0.2-alpha1",
|
||||
"@owlboard/owlboard-ts": "^3.0.0-dev.20260324T1240",
|
||||
"@playwright/test": "^1.58.1",
|
||||
"@sveltejs/adapter-static": "^3.0.10",
|
||||
"@sveltejs/kit": "^2.50.2",
|
||||
@@ -780,20 +781,20 @@
|
||||
}
|
||||
},
|
||||
"node_modules/@owlboard/api-schema-types": {
|
||||
"version": "3.0.1-alpha3",
|
||||
"resolved": "https://git.fjla.uk/api/packages/OwlBoard/npm/%40owlboard%2Fapi-schema-types/-/3.0.1-alpha3/api-schema-types-3.0.1-alpha3.tgz",
|
||||
"integrity": "sha512-5CVm1k/C++/VrtAw4NkvclDunH+RmYLnDZZMSWTM1mm+WlEVnmD+MVnTgC/FhcsAmsNHV8swm66RCqkCuhbOnA==",
|
||||
"version": "3.0.2-alpha1",
|
||||
"resolved": "https://git.fjla.uk/api/packages/OwlBoard/npm/%40owlboard%2Fapi-schema-types/-/3.0.2-alpha1/api-schema-types-3.0.2-alpha1.tgz",
|
||||
"integrity": "sha512-3yqWw28y2DZQmNXgAz8emCN5avX/upBXrTOXj9XLuay3gdVcdELd7BiYODBWfgtwZnSbT0fCgVXgKeTzbhHoSQ==",
|
||||
"dev": true,
|
||||
"license": "MIT"
|
||||
},
|
||||
"node_modules/@owlboard/owlboard-ts": {
|
||||
"version": "3.0.0-dev.20260319T2004",
|
||||
"resolved": "https://git.fjla.uk/api/packages/OwlBoard/npm/%40owlboard%2Fowlboard-ts/-/3.0.0-dev.20260319T2004/owlboard-ts-3.0.0-dev.20260319t2004.tgz",
|
||||
"integrity": "sha512-pphq1/l/8eOH4C0O7ocwBOUzt0HkCWGUlhy1itzKnQbmog7oPUEdyaxzS4Evw8onLsxZwkyqsLAyK7okYi+4XA==",
|
||||
"version": "3.0.0-dev.20260324T1240",
|
||||
"resolved": "https://git.fjla.uk/api/packages/OwlBoard/npm/%40owlboard%2Fowlboard-ts/-/3.0.0-dev.20260324T1240/owlboard-ts-3.0.0-dev.20260324t1240.tgz",
|
||||
"integrity": "sha512-s528RtkKLZmx6jZPdj159eKOBEmDHAjKDV0dSEU8/55JMt+7cSXYEqdXC3Cqs6t39wDxsOaPe8P0Q2z6P+d0jg==",
|
||||
"dev": true,
|
||||
"license": "GPL-3.0",
|
||||
"dependencies": {
|
||||
"@owlboard/api-schema-types": "^3.0.1-alpha3"
|
||||
"@owlboard/api-schema-types": "^3.0.2-alpha1"
|
||||
}
|
||||
},
|
||||
"node_modules/@playwright/test": {
|
||||
|
||||
@@ -19,7 +19,7 @@
|
||||
"devDependencies": {
|
||||
"@eslint/compat": "^2.0.2",
|
||||
"@eslint/js": "^9.39.2",
|
||||
"@owlboard/owlboard-ts": "^3.0.0-dev.20260319T2004",
|
||||
"@owlboard/owlboard-ts": "^3.0.0-dev.20260325T1023",
|
||||
"@playwright/test": "^1.58.1",
|
||||
"@sveltejs/adapter-static": "^3.0.10",
|
||||
"@sveltejs/kit": "^2.50.2",
|
||||
|
||||
@@ -4,7 +4,8 @@
|
||||
import { fade } from 'svelte/transition';
|
||||
import { goto } from '$app/navigation';
|
||||
|
||||
import { LOCATIONS } from '$lib/locations-object.svelte.ts';
|
||||
import { LOCATIONS } from '$lib/locations-object.svelte';
|
||||
import type { ApiLocationFilter } from '@owlboard/api-schema-types';
|
||||
|
||||
let { value = $bindable() } = $props();
|
||||
|
||||
@@ -26,13 +27,16 @@
|
||||
return LOCATIONS.data
|
||||
.filter((r) => tokens.every((t) => r.s.includes(t)))
|
||||
.sort((a, b) => {
|
||||
// Check if query matches CRS
|
||||
const aIsCrs = a.c?.toLowerCase() === lowerQuery;
|
||||
const bIsCrs = b.c?.toLowerCase() === lowerQuery;
|
||||
|
||||
// Sort matching CRS first
|
||||
if (aIsCrs && !bIsCrs) return -1;
|
||||
if (!aIsCrs && bIsCrs) return 1;
|
||||
// Priority One - Exact CRS Match
|
||||
const aExactCrs = a.c?.toLowerCase() === lowerQuery;
|
||||
const bExactCrs = b.c?.toLowerCase() === lowerQuery;
|
||||
if (aExactCrs && !bExactCrs) return -1;
|
||||
if (!aExactCrs && bExactCrs) return 1;
|
||||
|
||||
// Priority Two - 'Stations' with CRS
|
||||
if (!!a.c && !b.c) return -1;
|
||||
if (!a.c & !! b.c) return 1;
|
||||
|
||||
// Alphabetical Sort
|
||||
return a.n.localeCompare(b.n);
|
||||
@@ -59,7 +63,7 @@
|
||||
}
|
||||
});
|
||||
|
||||
function choose(loc: LocationRecord) {
|
||||
function choose(loc: ApiLocationFilter.LocationFilterObject) {
|
||||
showResults = false;
|
||||
selectedIndex = -1;
|
||||
value = '';
|
||||
@@ -195,6 +199,7 @@
|
||||
font-size: 1.1rem;
|
||||
font-weight: 700;
|
||||
text-align: right;
|
||||
text-transform: capitalize;
|
||||
}
|
||||
|
||||
.tiploc {
|
||||
|
||||
53
src/lib/components/ui/TocStyle.svelte
Normal file
53
src/lib/components/ui/TocStyle.svelte
Normal file
@@ -0,0 +1,53 @@
|
||||
<script lang="ts">
|
||||
interface Props {
|
||||
toc: string;
|
||||
}
|
||||
|
||||
let {
|
||||
toc
|
||||
}: Props = $props();
|
||||
|
||||
let code = $derived(toc.toUpperCase());
|
||||
</script>
|
||||
|
||||
<div class="toc-container {code}">
|
||||
{code}
|
||||
</div>
|
||||
|
||||
<style>
|
||||
.toc-container {
|
||||
border-radius: 10px;
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
padding: 2px 8px;
|
||||
font-weight: 800;
|
||||
background-color: #333;
|
||||
color: #fff;
|
||||
}
|
||||
|
||||
.GW { /* Great Western Railway */
|
||||
background: #004225;
|
||||
color: #E2E2E2;
|
||||
}
|
||||
|
||||
.GR { /* LNER */
|
||||
background-color: #C00000;
|
||||
color: #FFFFFF;
|
||||
}
|
||||
|
||||
.VT { /* Avanti West Coast */
|
||||
background-color: #004354;
|
||||
color: #FFFFFF;
|
||||
}
|
||||
|
||||
.SW { /* South Western Railway */
|
||||
background-color: #2A3389;
|
||||
color: #FFFFFF;
|
||||
}
|
||||
|
||||
.XC { /* CrossCountry */
|
||||
background-color: #660000;
|
||||
color: #E4D5B1;
|
||||
}
|
||||
</style>
|
||||
@@ -1,27 +1,23 @@
|
||||
interface LocationRecord {
|
||||
n: string; // name
|
||||
t: string; // tiploc
|
||||
c?: string; // crs
|
||||
s: string; // search string
|
||||
}
|
||||
import { OwlClient } from "./owlClient";
|
||||
import type { ApiLocationFilter } from '@owlboard/owlboard-ts'
|
||||
|
||||
class LocationStore {
|
||||
data = $state<LocationRecord[]>([]);
|
||||
data = $state<ApiLocationFilter.LocationFilterObject[]>([]);
|
||||
loaded = $state(false);
|
||||
|
||||
async init(fetcher = fetch) {
|
||||
async init() {
|
||||
if (this.loaded) return;
|
||||
|
||||
try {
|
||||
const res = await fetcher('/api/tiplocs');
|
||||
this.data = await res.json();
|
||||
const fetch = await OwlClient.locationFilter.getLocationFilterData()
|
||||
this.data = fetch.data;
|
||||
this.loaded = true;
|
||||
} catch (err) {
|
||||
console.error('Failed to load locations', err);
|
||||
}
|
||||
}
|
||||
|
||||
find(id: string | null): LocationRecord | undefined {
|
||||
find(id: string | null): ApiLocationFilter.LocationFilterObject | undefined {
|
||||
if (!id) return undefined;
|
||||
|
||||
const query = id.toUpperCase().trim();
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
import { slide, fade } from 'svelte/transition';
|
||||
import { onMount } from 'svelte';
|
||||
|
||||
import { LOCATIONS } from '$lib/locations-object.svelte.ts';
|
||||
import { LOCATIONS } from '$lib/locations-object.svelte';
|
||||
|
||||
import '$lib/global.css';
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
|
||||
import { IconHome, IconDialpad, IconSettings, IconHelp, IconDots } from '@tabler/icons-svelte';
|
||||
|
||||
onMount(() => LOCATIONS.init(fetch));
|
||||
onMount(() => LOCATIONS.init());
|
||||
|
||||
let { children } = $props();
|
||||
|
||||
@@ -167,6 +167,7 @@
|
||||
margin-left: 5px;
|
||||
padding-bottom: 2px;
|
||||
color: var(--color-title);
|
||||
text-transform: capitalize;
|
||||
}
|
||||
header,
|
||||
nav {
|
||||
|
||||
@@ -6,7 +6,7 @@ export const load: PageLoad = async ({ url }) => {
|
||||
const locId = url.searchParams.get('loc');
|
||||
|
||||
if (!LOCATIONS.loaded) {
|
||||
await LOCATIONS.init(fetch);
|
||||
await LOCATIONS.init();
|
||||
}
|
||||
|
||||
let title: string = '';
|
||||
|
||||
@@ -2,11 +2,11 @@
|
||||
import PisStartEndCard from '$lib/components/ui/cards/pis/PisStartEndCard.svelte';
|
||||
import PisCode from '$lib/components/ui/cards/pis/PisCode.svelte';
|
||||
import Button from '$lib/components/ui/Button.svelte';
|
||||
import type { PisObjects } from '@owlboard/api-schema-types';
|
||||
import type { ApiPisObject } from '@owlboard/owlboard-ts';
|
||||
import { OwlClient, ApiError, ValidationError } from '$lib/owlClient';
|
||||
import TocStyle from '$lib/components/ui/TocStyle.svelte';
|
||||
|
||||
|
||||
let results = $state<PisObjects[]>([]);
|
||||
let results = $state<ApiPisObject.PisObjects[]>([]);
|
||||
let resultsLoaded = $state<boolean>(false);
|
||||
let errorState = $state<{status: number, message: string} | null>(null);
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
|
||||
try {
|
||||
const response = await OwlClient.pis.getByStartEndCrs(start, end);
|
||||
results = await response.data || [];
|
||||
results = response.data || [];
|
||||
} catch (e) {
|
||||
if (e instanceof ValidationError) {
|
||||
errorState = { status: 400, message: e.message };
|
||||
@@ -70,10 +70,22 @@
|
||||
<span class="errMsg">{errorState.message}</span>
|
||||
{:else}
|
||||
{#if results.length}
|
||||
<h2 class="result-title">{results.length} Result{#if results.length > 1}s{/if} found:</h2>
|
||||
{#each results as result}
|
||||
<p>{JSON.stringify(result)}</p>
|
||||
{/each}
|
||||
<h2 class="result-title">{results.length} Result{#if results.length > 1}s{/if} found</h2>
|
||||
<table class="result-table">
|
||||
<thead>
|
||||
<tr>
|
||||
<th style="width:16%">TOC</th>
|
||||
<th style="width:14%">Code</th>
|
||||
<th style="width:70%">Locations</th>
|
||||
</tr></thead>
|
||||
{#each results as result}
|
||||
<tbody><tr>
|
||||
<td><TocStyle toc={result.toc || ""} /></td>
|
||||
<td>{result.code}</td>
|
||||
<td class="locations-row">{result.crsStops?.join(' ') || ''}</td>
|
||||
</tr></tbody>
|
||||
{/each}
|
||||
</table>
|
||||
{:else}
|
||||
<p class="no-results">No matching results</p>
|
||||
{/if}
|
||||
@@ -107,11 +119,33 @@
|
||||
padding: 20px 0 20px 0;
|
||||
margin: auto;
|
||||
margin-top: 25px;
|
||||
margin-bottom: 25px;
|
||||
width: 90%;
|
||||
max-width: 1000px;
|
||||
max-width: 500px;
|
||||
box-shadow: var(--shadow-std);
|
||||
}
|
||||
|
||||
.result-title {
|
||||
color: var(--color-brand);
|
||||
}
|
||||
|
||||
.result-table {
|
||||
width: 90%;
|
||||
max-width: 350px;
|
||||
margin: auto;
|
||||
text-align: center;
|
||||
table-layout: fixed;
|
||||
border-collapse: separate;
|
||||
border-spacing: 0 20px;
|
||||
font-weight: 400;
|
||||
}
|
||||
|
||||
.locations-row {
|
||||
font-family:'Courier New', Courier, monospace;
|
||||
text-align: left;
|
||||
padding-left: 20px;
|
||||
}
|
||||
|
||||
.errCode {
|
||||
color: rgb(255, 54, 54);
|
||||
font-weight: 600;
|
||||
|
||||
Reference in New Issue
Block a user