app

Local-first trade for farms and co-ops
git clone https://radroots.dev/git/app.git
Log | Files | Refs | README | LICENSE

commit 8ea6d17f6eebbf2a533efa6695e45384cbde535d
parent 95cb01dc0c79e608338f6dd4f247f6f953a44a5e
Author: triesap <137732411+triesap@users.noreply.github.com>
Date:   Wed, 28 Aug 2024 09:46:58 +0000

Add `/models` and location gcs test methods, update root layout with app_sql subscription

Diffstat:
Mpackage.json | 1+
Msrc/routes/(app)/+page.svelte | 8++++++++
Asrc/routes/(app)/models/location-gcs/+page.svelte | 104+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Msrc/routes/(app)/settings/+page.svelte | 4++--
Msrc/routes/+layout.svelte | 5+++++
5 files changed, 120 insertions(+), 2 deletions(-)

diff --git a/package.json b/package.json @@ -53,6 +53,7 @@ "@radroots/jeep-sqlite": "workspace:*", "@radroots/svelte-lib": "workspace:*", "@radroots/theme": "workspace:*", + "@radroots/utils": "workspace:*", "sql.js": "^1.11.0" } } \ No newline at end of file diff --git a/src/routes/(app)/+page.svelte b/src/routes/(app)/+page.svelte @@ -24,6 +24,14 @@ <button class={`button-simple`} onclick={async () => { + await goto(`/models/location-gcs`); + }} + > + {"models location_gcs"} + </button> + <button + class={`button-simple`} + onclick={async () => { const url = `https://radroots.org`; const res = await cl.browser.open(url); await cl.dialog.alert(JSON.stringify(res)); diff --git a/src/routes/(app)/models/location-gcs/+page.svelte b/src/routes/(app)/models/location-gcs/+page.svelte @@ -0,0 +1,104 @@ +<script lang="ts"> + import { goto } from "$app/navigation"; + import { cl } from "$lib/client"; + import LayoutTrellis from "$lib/components/layout-trellis.svelte"; + import { type LocationGcsFormFields } from "@radroots/client/src/capacitor/sql"; + import { trellis } from "@radroots/svelte-lib"; + import { location_geohash } from "@radroots/utils"; +</script> + +<svelte:component this={LayoutTrellis}> + <svelte:component + this={trellis} + basis={{ + args: { + layer: 1, + title: { + value: `Location GCS`, + }, + list: [ + { + offset: { + mod: { + key: `caret-left`, + }, + }, + touch: { + label: { + left: [ + { + value: "Back", + }, + ], + }, + callback: async () => { + await goto(`/`); + }, + }, + }, + { + touch: { + label: { + left: [ + { + value: `Read Logs`, + classes: `capitalize`, + }, + ], + }, + callback: async () => { + await cl.dialog.alert(JSON.stringify(cl.db.logs)); + }, + }, + }, + { + touch: { + label: { + left: [ + { + value: `Add Current Location`, + classes: `capitalize`, + }, + ], + }, + callback: async () => { + const pos = await cl.geo.current(); + console.log(JSON.stringify(pos,null,4), `pos`) + if (pos) { + const { lat, lng } = pos; + const geohash = location_geohash(lat, lng); + const fields: LocationGcsFormFields = { + lat: lat.toString(), + lng: lng.toString(), + geohash + }; + console.log(JSON.stringify(fields,null,4), `fields`) + const res = await cl.db.location_gcs_add(fields); + await cl.dialog.alert(JSON.stringify(res)); + } + }, + }, + }, + { + touch: { + label: { + left: [ + { + value: `Read All`, + classes: `capitalize`, + }, + ], + }, + callback: async () => { + const res = await cl.db.location_gcs_get({ + list: [`all`], + }); + await cl.dialog.alert(JSON.stringify(res)); + }, + }, + }, + ], + }, + }} + /> +</svelte:component> diff --git a/src/routes/(app)/settings/+page.svelte b/src/routes/(app)/settings/+page.svelte @@ -7,7 +7,7 @@ import { toggle_color_mode, trellis } from "@radroots/svelte-lib"; </script> -<LayoutTrellis> +<svelte:component this={LayoutTrellis}> <svelte:component this={trellis} basis={{ @@ -370,4 +370,4 @@ }, }} /> -</LayoutTrellis> +</svelte:component> diff --git a/src/routes/+layout.svelte b/src/routes/+layout.svelte @@ -59,6 +59,11 @@ cl.window.status_style(color_mode); }); + app_sqlite.subscribe((app_sqlite) => { + if(!app_sqlite) return; + console.log(`(app_sqlite) connected`); + }); + app_config.subscribe(async (app_config) => { try { if (!app_config) return;