diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/routes/(app)/pos/+page.server.ts | 10 | ||||
| -rw-r--r-- | src/routes/(app)/pos/+page.svelte | 13 |
2 files changed, 13 insertions, 10 deletions
diff --git a/src/routes/(app)/pos/+page.server.ts b/src/routes/(app)/pos/+page.server.ts index f7a3fda3..59f2d923 100644 --- a/src/routes/(app)/pos/+page.server.ts +++ b/src/routes/(app)/pos/+page.server.ts @@ -1,11 +1,15 @@ import { PUBLIC_COINOS_URL } from "$env/static/public"; -import { fd } from "$lib/utils"; +import { auth, fd, get } from "$lib/utils"; import { hex } from "@scure/base"; +export async function load({ cookies }) { + const token = await get("/ro", auth(cookies)); + return { token }; +} + export const actions = { default: async ({ fetch, request }) => { const body = await fd(request); - console.log("POSTING", body); const res = await fetch(`${PUBLIC_COINOS_URL}/flash`, { method: "POST", body: JSON.stringify(body), @@ -16,6 +20,6 @@ export const actions = { }); const buf = new Uint8Array(await res.arrayBuffer()); - return { data: hex.encode(buf) }; + return { bytes: hex.encode(buf) }; }, }; diff --git a/src/routes/(app)/pos/+page.svelte b/src/routes/(app)/pos/+page.svelte index 760a89b4..be9a9719 100644 --- a/src/routes/(app)/pos/+page.svelte +++ b/src/routes/(app)/pos/+page.svelte @@ -15,7 +15,8 @@ return binaryString; } - let { form } = $props(); + let { data, form } = $props(); + let { token } = $state(data); const address = 0x3d0000; const baudrate = 921600; @@ -23,12 +24,10 @@ let file = $state(); let ssid = $state(); let key = $state(); - let token = $state(); let esploader = $state(); - let data = $derived(form ? hex.decode(form.data) : undefined); + let bytes = $derived(form ? hex.decode(form.bytes) : undefined); let chip, transport; - // let data = $state(); let connect = async () => { try { let device = await navigator.serial.requestPort({}); @@ -47,7 +46,7 @@ let progress = $state(); let flash = async () => { - let fileArray = [{ data: bs(data), address }]; + let fileArray = [{ data: bs(bytes), address }]; const flashOptions = { fileArray, @@ -69,11 +68,11 @@ </h1> {#if esploader} - {#if data} + {#if bytes} {#if progress} <div class="text-center text-2xl">Done!</div> {:else} - <div>Generated config file (<b>{data.length * 2} bytes</b>)</div> + <div>Generated config file (<b>{bytes.length * 2} bytes</b>)</div> <button class="btn" onclick={flash}>Flash</button> {/if} {:else} |
