From 64bc5b979dbbe1d98d6e84392f9448dd19f25dbd Mon Sep 17 00:00:00 2001 From: Fred Boniface Date: Tue, 17 Mar 2026 20:04:38 +0000 Subject: [PATCH] Add initial logic for 'boards' --- src/app.html | 2 +- src/lib/locations-object.svelte.ts | 16 +++++++++++-- src/routes/+error.svelte | 6 +++-- src/routes/+layout.svelte | 12 +++++----- src/routes/+layout.ts | 1 + src/routes/board/+page.svelte | 15 ++++++++++++ src/routes/board/+page.ts | 37 ++++++++++++++++++++++++++++++ static/api/tiplocs | 1 + 8 files changed, 79 insertions(+), 11 deletions(-) create mode 100644 src/routes/board/+page.svelte create mode 100644 src/routes/board/+page.ts diff --git a/src/app.html b/src/app.html index 7c40556..c7e23ff 100644 --- a/src/app.html +++ b/src/app.html @@ -4,7 +4,7 @@ - + ([]); loaded = $state(false); - async init() { + async init(fetcher = fetch) { if (this.loaded) return; try { - const res = await fetch('/api/tiplocs'); + const res = await fetcher('/api/tiplocs'); this.data = await res.json(); this.loaded = true; } catch (err) { @@ -21,6 +21,18 @@ class LocationStore { } } + find(id: string | null): LocationRecord | undefined { + if (!id) return undefined; + + const query = id.toUpperCase().trim(); + + console.log(query); + + return this.data.find((loc) => { + return loc.t === query || loc.c === query; + }); + } + } export const LOCATIONS = new LocationStore(); \ No newline at end of file diff --git a/src/routes/+error.svelte b/src/routes/+error.svelte index 779f0e5..5feeae3 100644 --- a/src/routes/+error.svelte +++ b/src/routes/+error.svelte @@ -59,12 +59,14 @@ color: var(--color-title); max-width: 300px; margin-top: 5px; - margin-bottom: 30px; + margin-bottom: 20px; } .debug-info { background: rgba(255, 255, 255, 0.05); - padding: 5px 12px; + padding: 5px 15px; + margin-top: 0; + margin-bottom: 20px; border-radius: 4px; font-size: 0.8rem; opacity: 0.6; diff --git a/src/routes/+layout.svelte b/src/routes/+layout.svelte index 6a81584..e59e8e1 100644 --- a/src/routes/+layout.svelte +++ b/src/routes/+layout.svelte @@ -13,7 +13,7 @@ import { IconHome, IconDialpad, IconSettings, IconHelp, IconDots } from '@tabler/icons-svelte'; - onMount(() => LOCATIONS.init()); + onMount(() => LOCATIONS.init(fetch)); let { children } = $props(); @@ -23,9 +23,9 @@ const navItems = [ { label: 'Home', path: '/', icon: IconHome }, - { label: 'PIS', path: '/pis', icon: IconDialpad }, - { label: 'Options', path: '/preferences', icon: IconSettings }, - { label: 'About', path: '/about', icon: IconHelp } + { label: 'PIS', path: '/pis/', icon: IconDialpad }, + { label: 'Options', path: '/preferences/', icon: IconSettings }, + { label: 'About', path: '/about/', icon: IconHelp } ]; let navWidth = $state(0); @@ -83,7 +83,7 @@