From 8bbd39fec2ceca9998fed5e777700af4bd7eb799 Mon Sep 17 00:00:00 2001 From: core Date: Sat, 26 Oct 2024 22:41:12 -0400 Subject: [PATCH] web client - command system --- bun.lockb | Bin 0 -> 1244 bytes package.json | 1 + wxbox-web/src/lib/Map.svelte | 84 ++++++++++ wxbox-web/src/routes/+page.svelte | 269 +++++++++++++++++++++++++++--- 4 files changed, 329 insertions(+), 25 deletions(-) create mode 100755 bun.lockb create mode 100644 package.json create mode 100644 wxbox-web/src/lib/Map.svelte diff --git a/bun.lockb b/bun.lockb new file mode 100755 index 0000000000000000000000000000000000000000..bded5171cab60b91783595cbf62273e6e64274e9 GIT binary patch literal 1244 zcmY#Z)GsYA(of3F(@)JSQ%EY!;{sycoc!eMw9K4T-L(9o+{6;yG6OCq1_p+nO}g%L zdqtK^`8-AHF8{^-OHAJI?YW=s{Ac3h`Sb5jvh`sBDgpwKS`grXP;j~d%CCYcfbt;} z4+8^C0fT=$&zzFPn`;{D1uakR^#Sk$@tg zd5jDYbCHc^sh;mt$m}B$<{6>Dc3!ct=xAzbdP$+*vG-Bi(&VC^e7pDV*$(Lqy^e=A zKM!Ki{mXmi%|!7%Is%wI)k2W%kEwunT(+qBhA%-&jW ziC%GKUUEiBNkOrdzJ5_^dS-D+QKep9L2g#DUVc%!KC&`>T@ + import type {ActionReturn} from "svelte/action"; + import type {TileLayer, Map as LeafletMap} from "leaflet"; + + interface Props { + map: LeafletMap | null, + selected: boolean, + baseLayer: "osm", + dataLayer: "noaa_mrms_merged_composite_reflectivity_qc" | null, + overlayLayers: string[] + } + let { map = $bindable(null), selected, baseLayer, dataLayer, overlayLayers } = $props(); + + let mapEl: HTMLElement; + let L; + let layer0: TileLayer; + let layer1: TileLayer; + + $inspect(dataLayer); + + $effect(() => { + console.log("layer0", layer0, map, baseLayer); + if (!L) return; + + if (layer0 && map) { + layer0.removeFrom(map); + } + + if (baseLayer === "osm") { + layer0 = L.tileLayer( + 'https://tile.openstreetmap.org/{z}/{x}/{y}.png', + { + attribution: '© OpenStreetMap contributors' + } + ); + layer0.addTo(map); + } + }); + + $effect(() => { + console.log("layer1", layer1, map, dataLayer); + if (!L) return; + + if (layer1 && map) { + layer1.removeFrom(map); + } + + if (dataLayer === "noaa_mrms_merged_composite_reflectivity_qc") { + layer1 = L.tileLayer( + 'http://localhost:8080/noaa_mrms_merged_composite_reflectivity_qc/{z}/{x}/{y}.png', + { + attribution: '© NOAA, © wxbox' + } + ); + layer1.addTo(map); + } + }); + + async function mapAction(node: HTMLElement): Promise { + L = await import('leaflet'); + await import("leaflet.sync"); + + map = L.map(mapEl, { + center: [39.83, -98.583], + zoom: 5 + }); + + if (!map) return {}; + } + + +
+ + \ No newline at end of file diff --git a/wxbox-web/src/routes/+page.svelte b/wxbox-web/src/routes/+page.svelte index bcd4402..2acedca 100644 --- a/wxbox-web/src/routes/+page.svelte +++ b/wxbox-web/src/routes/+page.svelte @@ -1,51 +1,270 @@ -
-
+ + +
+
+

wxbox

+ {status} + {#each currentMenu as menuItem} + {#if menuItem.visible} + {@const index = menuItem.display.indexOf(menuItem.keyboard)} + + {/if} + {/each} +
+
+ + {#if view === "two" || view === "four"} + + {/if} +
+ {#if view === "four"} +
+ + +
+ {/if} +
\ No newline at end of file