From cdbac0e69a69b003d1056dc4ca4767bb480c80cd Mon Sep 17 00:00:00 2001 From: Dilan Gilluly Date: Wed, 1 Jul 2026 00:09:47 -0400 Subject: [PATCH] (add): Ticket counts report --- client/src/lib/client/styles.js | 11 ++- client/src/routes/+page.svelte | 10 ++- .../src/routes/api/reports/counts/+server.js | 22 ++++++ .../src/routes/reports/counts/+page.server.js | 5 ++ client/src/routes/reports/counts/+page.svelte | 73 +++++++++++++++++++ client/src/routes/settings/+page.svelte | 16 ++-- .../routes/settings/auth-keys/+page.svelte | 11 ++- 7 files changed, 128 insertions(+), 20 deletions(-) create mode 100644 client/src/routes/api/reports/counts/+server.js create mode 100644 client/src/routes/reports/counts/+page.server.js create mode 100644 client/src/routes/reports/counts/+page.svelte diff --git a/client/src/lib/client/styles.js b/client/src/lib/client/styles.js index c356ba9..4296ce2 100644 --- a/client/src/lib/client/styles.js +++ b/client/src/lib/client/styles.js @@ -1,7 +1,12 @@ export const tS = { - green: 'text-green-800 font-bold', - yellow: 'text-yellow-800 font-bold', - red: 'text-red-800 font-bold' + gray: 'text-gray-700 font-bold', + white: 'font-bold', + blue: 'text-blue-700 font-bold', + yellow: 'text-yellow-600 font-bold', + green: 'text-green-700 font-bold', + orange: 'text-orange-700 font-bold', + purple: 'text-purple-700 font-bold', + red: 'text-red-700 font-bold' }; export const bS = { diff --git a/client/src/routes/+page.svelte b/client/src/routes/+page.svelte index e635bf8..f7012bb 100644 --- a/client/src/routes/+page.svelte +++ b/client/src/routes/+page.svelte @@ -72,9 +72,9 @@ {/each} {#if curPrefix} -
+

Forms:

-
+
Tickets @@ -87,7 +87,7 @@ >
-
+ {#if adminMode} diff --git a/client/src/routes/api/reports/counts/+server.js b/client/src/routes/api/reports/counts/+server.js new file mode 100644 index 0000000..e7848aa --- /dev/null +++ b/client/src/routes/api/reports/counts/+server.js @@ -0,0 +1,22 @@ +import { db } from "$lib/server/db"; +import { reportCounts } from "$lib/server/db/schema"; +import { getPath, getSettings } from "$lib/server/settings" +import { error, json } from "@sveltejs/kit"; + +export const GET = async () => { + const s = getSettings(); + if (s.remote_server) { + const connStr = getPath(s); + try { + const res = await fetch(`${connStr}/api/reports/counts`, {headers: {'TAM-KEY': s.remote_key}}); + if (!res.ok) throw error(res.status); + const data = await res.json(); + return json(data); + } catch { + return json([]) + } + } else { + const data = await db.select().from(reportCounts); + return json(data); + } +} diff --git a/client/src/routes/reports/counts/+page.server.js b/client/src/routes/reports/counts/+page.server.js new file mode 100644 index 0000000..3b544e2 --- /dev/null +++ b/client/src/routes/reports/counts/+page.server.js @@ -0,0 +1,5 @@ +export const load = async ({ fetch }) => { + const res = await fetch('/api/prefixes'); + const prefixes = await res.json(); + return { prefixes }; +} diff --git a/client/src/routes/reports/counts/+page.svelte b/client/src/routes/reports/counts/+page.svelte new file mode 100644 index 0000000..e0b5680 --- /dev/null +++ b/client/src/routes/reports/counts/+page.svelte @@ -0,0 +1,73 @@ + + + + {pageTitle} + + +
+ + +

{pageTitle}

+ + + + + + + + + + {#each tableData as line (line.prefix)} + + + + + + {/each} + +
PrefixUnique BuyersTotal Buys
{line.prefix}{line.unique_buyers || 0}{line.total_buys || 0}
+
+ + +
Last refreshed: {lastRefreshed}
+
+
diff --git a/client/src/routes/settings/+page.svelte b/client/src/routes/settings/+page.svelte index aa67826..cf438e0 100644 --- a/client/src/routes/settings/+page.svelte +++ b/client/src/routes/settings/+page.svelte @@ -22,15 +22,14 @@ {pageTitle} - -
Settings Sections:
- {#if data.settings.remote_server} - Auth Keys - {/if} - Prefixes -
-
+ +
Settings Sections:
+ {#if data.settings.remote_server} + Auth Keys + {/if} + Prefixes +

{pageTitle}

Remote Mode:

@@ -84,6 +83,7 @@ settings = { ...resData }; status.message = 'Settings saved successfully!'; status.color = 'green'; + setTimeout(() => window.location.reload(), 3000); } }}>Save diff --git a/client/src/routes/settings/auth-keys/+page.svelte b/client/src/routes/settings/auth-keys/+page.svelte index 6936e1d..d8a90ed 100644 --- a/client/src/routes/settings/auth-keys/+page.svelte +++ b/client/src/routes/settings/auth-keys/+page.svelte @@ -20,13 +20,12 @@ {pageTitle} - - Back to Settings -
Other Settings:
- Prefixes -
-
+ + Back to Settings +
Other Settings:
+ Prefixes +

{pageTitle}

{#if !auth.toggle}