aboutsummaryrefslogtreecommitdiffstats
path: root/src/routes/(app)/pos
diff options
context:
space:
mode:
authorAdam Soltys <[email protected]>2026-02-11 17:51:24 -0800
committerAdam Soltys <[email protected]>2026-02-11 17:51:24 -0800
commit13466248004327e9a026cb89f94926f9b060d1c1 (patch)
tree47b4972c33809ccdf866b043c92cd3e0ecf5dcd0 /src/routes/(app)/pos
parent3aa9ce1b5985397d7f568887ec6f881df13c1034 (diff)
downloadcoinos-ui-13466248004327e9a026cb89f94926f9b060d1c1.tar.gz
coinos-ui-13466248004327e9a026cb89f94926f9b060d1c1.zip
linting
Diffstat (limited to 'src/routes/(app)/pos')
-rw-r--r--src/routes/(app)/pos/+page.server.ts36
-rw-r--r--src/routes/(app)/pos/+page.svelte73
2 files changed, 69 insertions, 40 deletions
diff --git a/src/routes/(app)/pos/+page.server.ts b/src/routes/(app)/pos/+page.server.ts
index 1df1bb33..b8f8410c 100644
--- a/src/routes/(app)/pos/+page.server.ts
+++ b/src/routes/(app)/pos/+page.server.ts
@@ -3,28 +3,28 @@ import { auth, fd, get } from "$lib/utils";
import { hex } from "@scure/base";
export async function load({ cookies }) {
- let token;
+ let token;
- try {
- token = await get("/ro", auth(cookies));
- } catch (e) {}
+ try {
+ token = await get("/ro", auth(cookies));
+ } catch {}
- return { token };
+ return { token };
}
export const actions = {
- default: async ({ fetch, request }) => {
- const body = await fd(request);
- const res = await fetch(`${PUBLIC_COINOS_URL}/flash`, {
- method: "POST",
- body: JSON.stringify(body),
- headers: {
- "content-type": "application/json",
- accept: "application/octet-stream",
- },
- });
+ default: async ({ fetch, request }) => {
+ const body = await fd(request);
+ const res = await fetch(`${PUBLIC_COINOS_URL}/flash`, {
+ method: "POST",
+ body: JSON.stringify(body),
+ headers: {
+ "content-type": "application/json",
+ accept: "application/octet-stream",
+ },
+ });
- const buf = new Uint8Array(await res.arrayBuffer());
- return { bytes: hex.encode(buf) };
- },
+ const buf = new Uint8Array(await res.arrayBuffer());
+ return { bytes: hex.encode(buf) };
+ },
};
diff --git a/src/routes/(app)/pos/+page.svelte b/src/routes/(app)/pos/+page.svelte
index 6806fec3..056a9254 100644
--- a/src/routes/(app)/pos/+page.svelte
+++ b/src/routes/(app)/pos/+page.svelte
@@ -18,9 +18,9 @@
// --- Defaults ---
const LITTLEFS_ADDRESS_DEFAULT = 0x3d0000; // your existing LittleFS offset
- const FW_ADDRESS_DEFAULT = 0x10000; // typical app offset on ESP32-C3
- const CONNECT_BAUD = 115200; // initial
- const WORK_BAUD = 921600; // fast flashing
+ const FW_ADDRESS_DEFAULT = 0x10000; // typical app offset on ESP32-C3
+ const CONNECT_BAUD = 115200; // initial
+ const WORK_BAUD = 921600; // fast flashing
// --- Shared state ---
let esploader: any = $state();
@@ -38,7 +38,7 @@
// --- New firmware flashing path ---
let fwFile: any = $state(null);
- let fwBytes: Uint8Array | undefined = $state(); // Uint8Array
+ let fwBytes: Uint8Array | undefined = $state(); // Uint8Array
let fwAddress = $state(FW_ADDRESS_DEFAULT);
let fwEraseAll = $state(false);
let fwProgress = $state(0);
@@ -63,7 +63,9 @@
chip = await esploader.main();
connected = true;
- portInfo = (await device.getInfo?.()) ? JSON.stringify(await device.getInfo()) : "Connected";
+ portInfo = (await device.getInfo?.())
+ ? JSON.stringify(await device.getInfo())
+ : "Connected";
} catch (e) {
console.log(e);
connected = false;
@@ -151,17 +153,25 @@
</h1>
{#if !connected}
- <div class="text-center">
- <button class="btn" onclick={connect}>Connect</button>
- <div class="text-sm mt-2 opacity-70">{portInfo}</div>
- </div>
-{/if}
+ <div class="text-center">
+ <button class="btn" onclick={connect}>Connect</button>
+ <div class="text-sm mt-2 opacity-70">{portInfo}</div>
+ </div>
+ {/if}
{#if connected}
<!-- Tabs -->
<div class="flex gap-2 justify-center">
- <button class="btn" class:btn-neutral={tab === "config"} onclick={() => (tab = "config")}>Flash config</button>
- <button class="btn" class:btn-neutral={tab === "firmware"} onclick={() => (tab = "firmware")}>Flash firmware</button>
+ <button
+ class="btn"
+ class:btn-neutral={tab === "config"}
+ onclick={() => (tab = "config")}>Flash config</button
+ >
+ <button
+ class="btn"
+ class:btn-neutral={tab === "firmware"}
+ onclick={() => (tab = "firmware")}>Flash firmware</button
+ >
</div>
{#if tab === "config"}
@@ -178,18 +188,26 @@
id="littlefs-address"
class="input"
bind:value={littlefsAddress}
- onchange={(e) => (littlefsAddress = Number((e.target as HTMLInputElement).value))}
+ onchange={(e) =>
+ (littlefsAddress = Number((e.target as HTMLInputElement).value))}
/>
<div class="mt-3">
<button class="btn" onclick={flashConfig}>Flash config</button>
</div>
- {#if configProgress > 0}<div class="mt-2">Progress: {configProgress}%</div>{/if}
+ {#if configProgress > 0}<div class="mt-2">
+ Progress: {configProgress}%
+ </div>{/if}
{/if}
{:else}
<form method="POST" use:enhance class="space-y-2">
<input name="ssid" placeholder="Wifi SSID" class="input" />
<input name="key" placeholder="Wifi password" class="input" />
- <input name="token" bind:value={token} placeholder="Coinos API token" class="input" />
+ <input
+ name="token"
+ bind:value={token}
+ placeholder="Coinos API token"
+ class="input"
+ />
<button type="submit" class="btn">Generate Config</button>
</form>
{/if}
@@ -214,7 +232,8 @@
id="firmware-address"
class="input"
bind:value={fwAddress}
- onchange={(e) => (fwAddress = Number((e.target as HTMLInputElement).value))}
+ onchange={(e) =>
+ (fwAddress = Number((e.target as HTMLInputElement).value))}
/>
<label class="flex items-center gap-2 mt-2">
@@ -223,8 +242,10 @@
</label>
<div class="mt-3">
- <button class="btn" disabled={!fwBytes} onclick={flashFirmware}>Flash firmware</button>
- </div>
+ <button class="btn" disabled={!fwBytes} onclick={flashFirmware}
+ >Flash firmware</button
+ >
+ </div>
{#if fwProgress > 0 && !fwDone}
<div>Progress: {fwProgress}%</div>
@@ -243,8 +264,16 @@
<style>
@reference "../../../app.css";
- .btn { @apply px-4 py-2 rounded-2xl shadow; }
- .btn-neutral { @apply bg-gray-200; }
- .input { @apply w-full px-3 py-2 border rounded-xl; }
- .label { @apply text-sm opacity-70; }
+ .btn {
+ @apply px-4 py-2 rounded-2xl shadow;
+ }
+ .btn-neutral {
+ @apply bg-gray-200;
+ }
+ .input {
+ @apply w-full px-3 py-2 border rounded-xl;
+ }
+ .label {
+ @apply text-sm opacity-70;
+ }
</style>