aboutsummaryrefslogtreecommitdiffstats
path: root/src/routes
diff options
context:
space:
mode:
authorAdrien Hopkins <[email protected]>2026-01-23 10:28:34 -0500
committerAdrien Hopkins <[email protected]>2026-01-23 10:28:34 -0500
commit0b6b65c1ab1e415969135c0bdbe3d37d0e3bb92a (patch)
tree4e57b4a6329afe44630436318aacd2e37dc75ca4 /src/routes
parent7325a623cf398dbab138ed6c8a1c9f61a508773d (diff)
parent3e7f4613c7133b3de17e785b8b8461355ef807c6 (diff)
downloadcoinos-ui-0b6b65c1ab1e415969135c0bdbe3d37d0e3bb92a.tar.gz
coinos-ui-0b6b65c1ab1e415969135c0bdbe3d37d0e3bb92a.zip
Merge branch 'master' into nip17dm
Diffstat (limited to 'src/routes')
-rw-r--r--src/routes/(app)/pos/+page.server.ts21
-rw-r--r--src/routes/(app)/pos/+page.svelte105
-rw-r--r--src/routes/(static)/bounties/+page.server.ts34
-rw-r--r--src/routes/(static)/bounties/+page.svelte6
4 files changed, 158 insertions, 8 deletions
diff --git a/src/routes/(app)/pos/+page.server.ts b/src/routes/(app)/pos/+page.server.ts
new file mode 100644
index 00000000..f7a3fda3
--- /dev/null
+++ b/src/routes/(app)/pos/+page.server.ts
@@ -0,0 +1,21 @@
+import { PUBLIC_COINOS_URL } from "$env/static/public";
+import { fd } from "$lib/utils";
+import { hex } from "@scure/base";
+
+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),
+ headers: {
+ "content-type": "application/json",
+ accept: "application/octet-stream",
+ },
+ });
+
+ const buf = new Uint8Array(await res.arrayBuffer());
+ return { data: hex.encode(buf) };
+ },
+};
diff --git a/src/routes/(app)/pos/+page.svelte b/src/routes/(app)/pos/+page.svelte
new file mode 100644
index 00000000..760a89b4
--- /dev/null
+++ b/src/routes/(app)/pos/+page.svelte
@@ -0,0 +1,105 @@
+<script>
+ import { enhance } from "$app/forms";
+ import { ESPLoader, Transport } from "esptool-js";
+ import { hex } from "@scure/base";
+
+ function bs(uint8Array) {
+ let binaryString = "";
+ const chunkSize = 0x8000; // 32,768 bytes (safe limit)
+
+ for (let i = 0; i < uint8Array.length; i += chunkSize) {
+ const chunk = uint8Array.subarray(i, i + chunkSize);
+ binaryString += String.fromCharCode(...chunk);
+ }
+
+ return binaryString;
+ }
+
+ let { form } = $props();
+
+ const address = 0x3d0000;
+ const baudrate = 921600;
+
+ 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 chip, transport;
+ // let data = $state();
+ let connect = async () => {
+ try {
+ let device = await navigator.serial.requestPort({});
+ transport = new Transport(device, true);
+
+ esploader = new ESPLoader({
+ transport,
+ baudrate,
+ });
+
+ chip = await esploader.main();
+ } catch (e) {
+ console.log(e);
+ }
+ };
+
+ let progress = $state();
+ let flash = async () => {
+ let fileArray = [{ data: bs(data), address }];
+
+ const flashOptions = {
+ fileArray,
+ flashSize: "keep",
+ eraseAll: false,
+ compress: true,
+ reportProgress: (fileIndex, written, total) => {
+ progress = parseInt((written / total) * 100);
+ },
+ };
+
+ await esploader.writeFlash(flashOptions);
+ };
+</script>
+
+<div class="container px-4 max-w-lg mx-auto space-y-5 mt-20">
+ <h1 class="px-3 md:px-0 text-center text-3xl md:text-4xl font-semibold">
+ Flash config
+ </h1>
+
+ {#if esploader}
+ {#if data}
+ {#if progress}
+ <div class="text-center text-2xl">Done!</div>
+ {:else}
+ <div>Generated config file (<b>{data.length * 2} bytes</b>)</div>
+ <button class="btn" onclick={flash}>Flash</button>
+ {/if}
+ {:else}
+ <form method="POST" use:enhance class="space-y-2">
+ <input
+ name="ssid"
+ bind:value={ssid}
+ placeholder="Wifi SSID"
+ class="input"
+ />
+ <input
+ name="key"
+ bind:value={key}
+ placeholder="Wifi password"
+ class="input"
+ />
+ <input
+ name="token"
+ bind:value={token}
+ placeholder="Coinos API token"
+ class="input"
+ />
+ <button type="submit" class="btn">Generate Config</button>
+ </form>
+ {/if}
+ {:else}
+ <button class="btn" onclick={connect}>Connect</button>
+ {/if}
+</div>
diff --git a/src/routes/(static)/bounties/+page.server.ts b/src/routes/(static)/bounties/+page.server.ts
index c9d872b0..8378e2f2 100644
--- a/src/routes/(static)/bounties/+page.server.ts
+++ b/src/routes/(static)/bounties/+page.server.ts
@@ -1,10 +1,36 @@
import { get } from "$lib/utils";
export const load = async () => {
const users = [
- { username: "fustler", merchant: "rrdrive", type: "Bakery" },
- { username: "laluna", merchant: "butchersguild", type: "Butcher Shop" },
- { username: "ica547", merchant: "vanlove", type: "Sushi Restaurant" },
- { username: "reverendhodl", merchant: "laughingbean", type: "Cafe" },
+ {
+ username: "fustler",
+ merchant: "rrdrive",
+ type: "Bakery",
+ amount: 1000000,
+ },
+ {
+ username: "laluna",
+ merchant: "butchersguild",
+ type: "Butcher Shop",
+ amount: 1000000,
+ },
+ {
+ username: "ica547",
+ merchant: "vanlove",
+ type: "Sushi Restaurant",
+ amount: 1000000,
+ },
+ {
+ username: "reverendhodl",
+ merchant: "laughingbean",
+ type: "Cafe",
+ amount: 1000000,
+ },
+ {
+ username: "kimsrepair",
+ merchant: "kimsrepair",
+ type: "Kims Repair",
+ amount: 100000,
+ },
];
for (const user of users) {
diff --git a/src/routes/(static)/bounties/+page.svelte b/src/routes/(static)/bounties/+page.svelte
index db7a012b..695eae3e 100644
--- a/src/routes/(static)/bounties/+page.svelte
+++ b/src/routes/(static)/bounties/+page.svelte
@@ -7,10 +7,8 @@
let { users } = data;
let bounties = [
- "Clothing Store",
"Hardware Store",
"Gas Station",
- "Shoe Repair",
"Dollar Store",
"Book Store",
"Gift Shop",
@@ -71,7 +69,7 @@
<h2 class="text-2xl font-bold">Previously Awarded</h2>
<div class="flex flex-col gap-4">
- {#each users as { user, merchant, type }}
+ {#each users as { user, merchant, type, amount }}
<article
class="rounded-2xl border border-neutral-200 bg-white/70 p-4 shadow-sm transition hover:shadow-md dark:border-neutral-800 dark:bg-neutral-900/60 sm:max-w-xl"
>
@@ -117,7 +115,7 @@
class="text-yellow-300"
/>
<span class="text-sm font-semibold tabular-nums">
- {s(1000000, "en-CA")}
+ {s(amount, "en-CA")}
</span>
</div>
</div>