(add): Baskets function

This commit is contained in:
2026-06-25 17:31:56 -04:00
parent e5b6fbd7c5
commit 9d6473d4bf
33 changed files with 987 additions and 463 deletions
+1 -1
View File
@@ -1,6 +1,6 @@
import { defineConfig } from 'drizzle-kit';
const dbURL = (process.env.TAM_DATA_DIR || "./data") + "/tam-local.db"
const dbURL = (process.env.TAM_DATA_DIR || './data') + '/tam-local.db';
export default defineConfig({
schema: './src/lib/server/db/schema.js',
+1 -1
View File
@@ -6,7 +6,7 @@
<meta name="text-scale" content="scale" />
%sveltekit.head%
</head>
<body data-sveltekit-preload-data="hover">
<body data-sveltekit-preload-data="tap">
<div style="display: contents">%sveltekit.body%</div>
</body>
</html>
@@ -1,67 +1,82 @@
<script>
import { bS } from "../styles";
import { browser } from "$app/environment";
import hotkeys from "hotkeys-js";
import { bS } from '../styles';
import { browser } from '$app/environment';
import hotkeys from 'hotkeys-js';
let { prefix, functions } = $props();
let { prefix, functions } = $props();
if (browser) {
hotkeys.filter = () => {return true};
hotkeys('alt+l', (e) => {
e.preventDefault();
if (functions.nextLine) functions.nextLine();
});
hotkeys('alt+o', (e) => {
e.preventDefault();
if (functions.prevLine) functions.prevLine();
});
hotkeys('alt+j', (e) => {
e.preventDefault();
if (functions.dupDown) functions.dupDown();
});
hotkeys('alt+u', (e) => {
e.preventDefault();
if (functions.dupUp) functions.dupUp();
});
hotkeys('alt+c', (e) => {
e.preventDefault();
if (functions.copy) functions.copy();
});
hotkeys('alt+v', (e) => {
e.preventDefault();
if (functions.paste) functions.paste();
});
hotkeys('alt+s', (e) => {
e.preventDefault();
if (functions.save) functions.save();
});
}
if (browser) {
hotkeys.filter = () => {
return true;
};
hotkeys('alt+l', (e) => {
e.preventDefault();
if (functions.nextLine) functions.nextLine();
});
hotkeys('alt+o', (e) => {
e.preventDefault();
if (functions.prevLine) functions.prevLine();
});
hotkeys('alt+j', (e) => {
e.preventDefault();
if (functions.dupDown) functions.dupDown();
});
hotkeys('alt+u', (e) => {
e.preventDefault();
if (functions.dupUp) functions.dupUp();
});
hotkeys('alt+c', (e) => {
e.preventDefault();
if (functions.copy) functions.copy();
});
hotkeys('alt+v', (e) => {
e.preventDefault();
if (functions.paste) functions.paste();
});
hotkeys('alt+s', (e) => {
e.preventDefault();
if (functions.save) functions.save();
});
}
</script>
<div class="flex flex-row gap-1 py-1 justify-between">
<div class="flex flex-row gap-1">
{#if functions.dupDown}
<button class={bS[prefix.color]} title="Alt + J" onclick={() => functions.dupDown()}>Duplicate Down</button>
{/if}
{#if functions.dupUp}
<button class={bS[prefix.color]} title="Alt + U" onclick={() => functions.dupUp()}>Duplicate Up</button>
{/if}
{#if functions.nextLine}
<button class={bS[prefix.color]} title="Alt + L" onclick={() => functions.nextLine()}>Next Line</button>
{/if}
{#if functions.prevLine}
<button class={bS[prefix.color]} title="Alt + O" onclick={() => functions.prevLine()}>Previous Line</button>
{/if}
{#if functions.copy}
<button class={bS[prefix.color]} title="Alt + C" onclick={() => functions.copy()}>Copy</button>
{/if}
{#if functions.paste}
<button class={bS[prefix.color]} title="Alt + V" onclick={() => functions.paste()}>Paste</button>
{/if}
</div>
<div class="flex flex-row gap-1">
{#if functions.save}
<button class={bS[prefix.color]} title="Alt + S" onclick={() => functions.save()}>Save Marked</button>
{/if}
</div>
<div class="flex flex-row gap-1">
{#if functions.dupDown}
<button class={bS[prefix.color]} title="Alt + J" onclick={() => functions.dupDown()}
>Duplicate Down</button
>
{/if}
{#if functions.dupUp}
<button class={bS[prefix.color]} title="Alt + U" onclick={() => functions.dupUp()}
>Duplicate Up</button
>
{/if}
{#if functions.nextLine}
<button class={bS[prefix.color]} title="Alt + L" onclick={() => functions.nextLine()}
>Next Line</button
>
{/if}
{#if functions.prevLine}
<button class={bS[prefix.color]} title="Alt + O" onclick={() => functions.prevLine()}
>Previous Line</button
>
{/if}
{#if functions.copy}
<button class={bS[prefix.color]} title="Alt + C" onclick={() => functions.copy()}>Copy</button
>
{/if}
{#if functions.paste}
<button class={bS[prefix.color]} title="Alt + V" onclick={() => functions.paste()}
>Paste</button
>
{/if}
</div>
<div class="flex flex-row gap-1">
{#if functions.save}
<button class={bS[prefix.color]} title="Alt + S" onclick={() => functions.save()}
>Save Marked</button
>
{/if}
</div>
</div>
@@ -1,13 +1,13 @@
<script>
import { resolve } from '$app/paths';
import { bS } from '../styles';
import { resolve } from '$app/paths';
import { bS } from '../styles';
let { children } = $props();
let { children } = $props();
</script>
<div id="header_bar" class="p-1 flex flex-row gap-1 items-center">
<a href={resolve('/')} class="{bS.gray} font-bold">Main Menu</a>
{#if children}
{@render children()}
{/if}
<div id="header_bar" class="py-1 flex flex-row gap-1 items-center">
<a href={resolve('/')} class="{bS.gray} font-bold">Main Menu</a>
{#if children}
{@render children()}
{/if}
</div>
+27 -22
View File
@@ -1,29 +1,34 @@
export const tS = {
green: 'text-green-800 font-bold',
yellow: 'text-yellow-800 font-bold',
red: 'text-red-800 font-bold'
}
green: 'text-green-800 font-bold',
yellow: 'text-yellow-800 font-bold',
red: 'text-red-800 font-bold'
};
export const bS = {
gray: 'px-2 py-1 bg-gray-300 border border-gray-800 rounded hover:bg-gray-400 cursor-pointer',
white: 'px-2 py-1 bg-white border border-gray-700 rounded hover:bg-gray-200 cursor-pointer',
blue: 'px-2 py-1 bg-blue-300 border border-gray-700 rounded hover:bg-blue-400 cursor-pointer',
yellow: 'px-2 py-1 bg-yellow-300 border border-gray-700 rounded hover:bg-yellow-400 cursor-pointer',
green: 'px-2 py-1 bg-green-300 border border-gray-700 rounded hover:bg-green-400 cursor-pointer',
orange: 'px-2 py-1 bg-orange-300 border border-gray-700 rounded hover:bg-orange-400 cursor-pointer',
red: 'px-2 py-1 bg-red-300 border border-gray-700 rounded hover:bg-red-400 cursor-pointer'
}
gray: 'px-2 py-1 bg-gray-300 border border-gray-800 rounded hover:bg-gray-400 cursor-pointer',
white: 'px-2 py-1 bg-white border border-gray-700 rounded hover:bg-gray-200 cursor-pointer',
blue: 'px-2 py-1 bg-blue-300 border border-gray-700 rounded hover:bg-blue-400 cursor-pointer',
yellow:
'px-2 py-1 bg-yellow-300 border border-gray-700 rounded hover:bg-yellow-400 cursor-pointer',
green: 'px-2 py-1 bg-green-300 border border-gray-700 rounded hover:bg-green-400 cursor-pointer',
orange:
'px-2 py-1 bg-orange-300 border border-gray-700 rounded hover:bg-orange-400 cursor-pointer',
red: 'px-2 py-1 bg-red-300 border border-gray-700 rounded hover:bg-red-400 cursor-pointer'
};
export const bAS = {
gray: 'px-2 py-1 bg-gray-300 border-4 border-gray-800 rounded hover:bg-gray-400 cursor-pointer',
white: 'px-2 py-1 bg-white border-4 border-gray-700 rounded hover:bg-gray-200 cursor-pointer',
blue: 'px-2 py-1 bg-blue-300 border-4 border-gray-700 rounded hover:bg-blue-400 cursor-pointer',
yellow: 'px-2 py-1 bg-yellow-300 border-4 border-gray-700 rounded hover:bg-yellow-400 cursor-pointer',
green: 'px-2 py-1 bg-green-300 border-4 border-gray-700 rounded hover:bg-green-400 cursor-pointer',
orange: 'px-2 py-1 bg-orange-300 border-4 border-gray-700 rounded hover:bg-orange-400 cursor-pointer',
red: 'px-2 py-1 bg-red-300 border-4 border-gray-700 rounded hover:bg-red-400 cursor-pointer'
}
gray: 'px-2 py-1 bg-gray-300 border-4 border-gray-800 rounded hover:bg-gray-400 cursor-pointer',
white: 'px-2 py-1 bg-white border-4 border-gray-700 rounded hover:bg-gray-200 cursor-pointer',
blue: 'px-2 py-1 bg-blue-300 border-4 border-gray-700 rounded hover:bg-blue-400 cursor-pointer',
yellow:
'px-2 py-1 bg-yellow-300 border-4 border-gray-700 rounded hover:bg-yellow-400 cursor-pointer',
green:
'px-2 py-1 bg-green-300 border-4 border-gray-700 rounded hover:bg-green-400 cursor-pointer',
orange:
'px-2 py-1 bg-orange-300 border-4 border-gray-700 rounded hover:bg-orange-400 cursor-pointer',
red: 'px-2 py-1 bg-red-300 border-4 border-gray-700 rounded hover:bg-red-400 cursor-pointer'
};
export const iS = {
normal: 'p-1 border border-black'
}
normal: 'p-1 border border-black'
};
+1 -1
View File
@@ -3,7 +3,7 @@ import Database from 'better-sqlite3';
import * as schema from './schema';
import { env } from '$env/dynamic/private';
const dbURL = (env.TAM_DATA_DIR || "./data") + "/tam-local.db";
const dbURL = (env.TAM_DATA_DIR || './data') + '/tam-local.db';
const client = new Database(dbURL);
+27 -11
View File
@@ -1,16 +1,32 @@
import { integer, sqliteTable, text, primaryKey } from 'drizzle-orm/sqlite-core';
export const prefixes = sqliteTable('prefixes', {
prefix: text('prefix').primaryKey(),
color: text('color'),
weight: integer('weight')
prefix: text('prefix').primaryKey(),
color: text('color'),
weight: integer('weight')
});
export const tickets = sqliteTable('tickets', {
prefix: text('prefix'),
t_id: integer('t_id'),
first_name: text('first_name'),
last_name: text('last_name'),
phone_number: text('phone_number'),
pref: text('pref')
}, (t) => [primaryKey({columns: [t.prefix, t.t_id]})])
export const tickets = sqliteTable(
'tickets',
{
prefix: text('prefix'),
t_id: integer('t_id'),
first_name: text('first_name'),
last_name: text('last_name'),
phone_number: text('phone_number'),
pref: text('pref')
},
(t) => [primaryKey({ columns: [t.prefix, t.t_id] })]
);
export const baskets = sqliteTable(
'baskets',
{
prefix: text('prefix'),
b_id: integer('b_id'),
description: text('description'),
donors: text('donors'),
winning_ticket: integer('winning_ticket')
},
(b) => [primaryKey({ columns: [b.prefix, b.b_id] })]
);
+3 -3
View File
@@ -5,7 +5,7 @@ const defaultSettings = {
remote_server: '',
remote_key: '',
remote_port: '8000',
remote_tls: false,
remote_tls: false,
default_pref: 'CALL',
venue_name: 'TAM'
};
@@ -15,8 +15,8 @@ export const getSettings = () => {
try {
const settings = JSON.parse(readFileSync(settingsPath, 'utf-8'));
return settings;
} catch {
mkdirSync(env.TAM_DATA_DIR || './data', {recursive: true})
} catch {
mkdirSync(env.TAM_DATA_DIR || './data', { recursive: true });
writeFileSync(settingsPath, JSON.stringify(defaultSettings, null, 2), 'utf-8');
return defaultSettings;
}
+2 -2
View File
@@ -6,7 +6,7 @@
</script>
<svelte:head>
<link rel="icon" href={favicon} />
<link rel="manifest" href="/manifest.json">
<link rel="icon" href={favicon} />
<link rel="manifest" href="/manifest.json" />
</svelte:head>
{@render children()}
+5 -5
View File
@@ -1,10 +1,10 @@
import { getSettings } from '$lib/server/settings';
export const load = async ({ fetch }) => {
const settings = getSettings();
const res = await fetch('/api');
const data = await res.json();
const resPrefixes = await fetch('/api/prefixes');
const dataPrefixes = await resPrefixes.json();
const settings = getSettings();
const res = await fetch('/api');
const data = await res.json();
const resPrefixes = await fetch('/api/prefixes');
const dataPrefixes = await resPrefixes.json();
return { ...data, venueName: settings.venue_name, prefixes: dataPrefixes };
};
+94 -80
View File
@@ -1,94 +1,108 @@
<script>
import { tS, bS, bAS } from '$lib/client/styles.js';
import { browser } from '$app/environment';
import { resolve } from '$app/paths';
import hotkeys from 'hotkeys-js';
import { tS, bS, bAS } from '$lib/client/styles.js';
import { browser } from '$app/environment';
import { resolve } from '$app/paths';
import hotkeys from 'hotkeys-js';
const pageTitle = 'Main Menu | TAM'
const { data } = $props();
let adminMode = $state(false);
let prefixes = $derived(data.prefixes);
let curPrefix = $state("");
let pColor = $derived.by(() => {
if (curPrefix) return prefixes.find(p => curPrefix == p.prefix).color
else return "gray";
})
const pageTitle = 'Main Menu | TAM';
const { data } = $props();
let adminMode = $state(false);
let prefixes = $derived(data.prefixes);
let curPrefix = $state('');
let pColor = $derived.by(() => {
if (curPrefix) return prefixes.find((p) => curPrefix == p.prefix).color;
else return 'gray';
});
const status = $derived.by(() => {
if (data.whoami === 'TAM Server') {
return {
mode: 'Remote',
auth: data.authenticated ? 'green' : 'red',
healthy: data.healthy ? 'green' : 'red'
};
} else if (data.whoami === 'TAM Client') {
return {
mode: 'Standalone'
};
} else {
return {
mode: 'Unknown'
}
}
})
const status = $derived.by(() => {
if (data.whoami === 'TAM Server') {
return {
mode: 'Remote',
auth: data.authenticated ? 'green' : 'red',
healthy: data.healthy ? 'green' : 'red'
};
} else if (data.whoami === 'TAM Client') {
return {
mode: 'Standalone'
};
} else {
return {
mode: 'Unknown'
};
}
});
if (browser) {
hotkeys.filter = () => {return true};
hotkeys('alt+a', (event) => {
event.preventDefault();
adminMode = !adminMode;
})
}
if (browser) {
hotkeys.filter = () => {
return true;
};
hotkeys('alt+a', (event) => {
event.preventDefault();
adminMode = !adminMode;
});
}
</script>
<svelte:head>
<title>{pageTitle}</title>
<title>{pageTitle}</title>
</svelte:head>
<div class="p-1" id="app_container">
<h1 class="text-xl font-bold">{pageTitle}</h1>
<p class="text-lg italic">{data.venueName}</p>
<h1 class="text-xl font-bold">{pageTitle}</h1>
<p class="text-lg italic">{data.venueName}</p>
<div class="flex flex-col md:flex-row md:flex-wrap gap-1 py-1">
<div id="prefixes" class="flex flex-col gap-1 p-2 border border-black rounded">
<h2 class="text-lg font-bold">Prefix Selection:</h2>
{#each prefixes as prefix (prefix.prefix)}
<button class={curPrefix == prefix.prefix ? bAS[prefix.color] : bS[prefix.color]} onclick={() => curPrefix = prefix.prefix}>{prefix.prefix}</button>
{/each}
</div>
{#if curPrefix}
<div class="flex flex-col gap-1 items-center border border-black rounded">
<h2 class="text-lg font-bold">Forms:</h2>
<div class="grid grid-cols-2 gap-1 p-1 min-w-2xs">
<a href={resolve('/tickets/[prefix]', {prefix: curPrefix})} class="{bS[pColor]}">Tickets</a>
</div>
</div>
{:else}
<div class="flex flex-col gap-1 items-center justify-center p-2 border border-black rounded">
<h2 class="text-lg font-bold">Please select a prefix to continue.</h2>
</div>
{/if}
</div>
<div class="flex flex-col md:flex-row md:flex-wrap gap-1 py-1">
<div id="prefixes" class="flex flex-col gap-1 p-2 border border-black rounded">
<h2 class="text-lg font-bold">Prefix Selection:</h2>
{#each prefixes as prefix (prefix.prefix)}
<button
class={curPrefix == prefix.prefix ? bAS[prefix.color] : bS[prefix.color]}
onclick={() => (curPrefix = prefix.prefix)}>{prefix.prefix}</button
>
{/each}
</div>
{#if curPrefix}
<div class="flex flex-col gap-1 items-center border border-black rounded">
<h2 class="text-lg font-bold">Forms:</h2>
<div class="grid grid-cols-2 gap-1 p-1 min-w-2xs">
<a href={resolve('/tickets/[prefix]', { prefix: curPrefix })} class={bS[pColor]}
>Tickets</a
>
<a href={resolve('/baskets/[prefix]', { prefix: curPrefix })} class={bS[pColor]}
>Baskets</a
>
</div>
</div>
{:else}
<div class="flex flex-col gap-1 items-center justify-center p-2 border border-black rounded">
<h2 class="text-lg font-bold">Please select a prefix to continue.</h2>
</div>
{/if}
</div>
{#if adminMode}
<div id="admin_mode" class="py-1">
<h2 class="text-lg font-bold">Admin Mode:</h2>
<div class="flex flex-row gap-1">
<a href={resolve('/settings')} class={bS.gray}>Settings</a>
</div>
</div>
{/if}
{#if adminMode}
<div id="admin_mode" class="py-1">
<h2 class="text-lg font-bold">Admin Mode:</h2>
<div class="flex flex-row gap-1">
<a href={resolve('/settings')} class={bS.gray}>Settings</a>
</div>
</div>
{/if}
<div id="footer">
<div>Mode: {status.mode}</div>
{#if data.authenticated !== undefined}
<div>Authenticated: <span class={tS[status.auth]}>{data.authenticated ? 'Yes' : 'No'}</span></div>
{/if}
{#if data.healthy !== undefined}
<div>Server Healthy: <span class={tS[status.healthy]}>{data.healthy ? 'Yes' : 'No'}</span></div>
{/if}
<div class="text-center text-xs">
<p>&copy; 2026 Ticket Auction Manager</p>
</div>
</div>
<div id="footer">
<div>Mode: {status.mode}</div>
{#if data.authenticated !== undefined}
<div>
Authenticated: <span class={tS[status.auth]}>{data.authenticated ? 'Yes' : 'No'}</span>
</div>
{/if}
{#if data.healthy !== undefined}
<div>
Server Healthy: <span class={tS[status.healthy]}>{data.healthy ? 'Yes' : 'No'}</span>
</div>
{/if}
<div class="text-center text-xs">
<p>&copy; 2026 Ticket Auction Manager</p>
</div>
</div>
</div>
+10 -10
View File
@@ -5,16 +5,16 @@ export const GET = async () => {
const s = getSettings();
if (s.remote_server) {
const connStr = getPath(s);
try {
const res = await fetch(`${connStr}/api`, {
headers: { 'TAM-KEY': s.remote_key }
});
if (!res.ok) throw error(res.status);
const data = await res.json()
return json(data);
} catch {
const data = { whoami: 'TAM Server', authenticated: false, healthy: false };
return json(data);
try {
const res = await fetch(`${connStr}/api`, {
headers: { 'TAM-KEY': s.remote_key }
});
if (!res.ok) throw error(res.status);
const data = await res.json();
return json(data);
} catch {
const data = { whoami: 'TAM Server', authenticated: false, healthy: false };
return json(data);
}
} else {
const data = { whoami: 'TAM Client' };
+61 -61
View File
@@ -1,67 +1,67 @@
import { getSettings, getPath } from "$lib/server/settings";
import { json, error } from "@sveltejs/kit";
import { getSettings, getPath } from '$lib/server/settings';
import { json, error } from '@sveltejs/kit';
export const GET = async ({ request }) => {
const tamPwd = request.headers.get('TAM-PWD');
const s = getSettings();
if (s.remote_server) {
const connStr = getPath(s);
try {
const res = await fetch(`${connStr}/api/auth`, {
headers: { 'TAM-PW': tamPwd }
});
if (!res.ok) throw error(res.status);
const data = await res.json();
return json(data);
} catch {
throw error(502)
}
} else {
throw error(500, 'Not configured.')
}
}
const tamPwd = request.headers.get('TAM-PWD');
const s = getSettings();
if (s.remote_server) {
const connStr = getPath(s);
try {
const res = await fetch(`${connStr}/api/auth`, {
headers: { 'TAM-PW': tamPwd }
});
if (!res.ok) throw error(res.status);
const data = await res.json();
return json(data);
} catch {
throw error(502);
}
} else {
throw error(500, 'Not configured.');
}
};
export const POST = async ({ request }) => {
const tamPwd = request.headers.get('TAM-PWD');
const reqBody = await request.json();
const s = getSettings();
if (s.remote_server) {
const connStr = getPath(s);
try {
const res = await fetch(`${connStr}/api/auth`, {
headers: { 'TAM-PW': tamPwd, 'Content-Type': 'application/json' },
method: 'POST',
body: JSON.stringify(reqBody)
});
if (!res.ok) throw error(res.status);
const data = await res.json();
return json(data);
} catch {
throw error(502);
}
} else {
throw error(500, 'Not configured.')
}
}
const tamPwd = request.headers.get('TAM-PWD');
const reqBody = await request.json();
const s = getSettings();
if (s.remote_server) {
const connStr = getPath(s);
try {
const res = await fetch(`${connStr}/api/auth`, {
headers: { 'TAM-PW': tamPwd, 'Content-Type': 'application/json' },
method: 'POST',
body: JSON.stringify(reqBody)
});
if (!res.ok) throw error(res.status);
const data = await res.json();
return json(data);
} catch {
throw error(502);
}
} else {
throw error(500, 'Not configured.');
}
};
export const DELETE = async ({ request, url }) => {
const tamPwd = request.headers.get('TAM-PWD');
const keyToDel = url.searchParams.get('key_to_del');
const s = getSettings();
if (s.remote_server) {
const connStr = getPath(s);
try {
const res = await fetch(`${connStr}/api/auth?key_to_del=${keyToDel}`, {
headers: { 'TAM-PW': tamPwd },
method: 'DELETE'
})
if (!res.ok) throw error(res.status)
const data = await res.json();
return json(data);
} catch {
throw error(502);
}
} else {
throw error(500, 'Not configured.')
}
}
const tamPwd = request.headers.get('TAM-PWD');
const keyToDel = url.searchParams.get('key_to_del');
const s = getSettings();
if (s.remote_server) {
const connStr = getPath(s);
try {
const res = await fetch(`${connStr}/api/auth?key_to_del=${keyToDel}`, {
headers: { 'TAM-PW': tamPwd },
method: 'DELETE'
});
if (!res.ok) throw error(res.status);
const data = await res.json();
return json(data);
} catch {
throw error(502);
}
} else {
throw error(500, 'Not configured.');
}
};
+45
View File
@@ -0,0 +1,45 @@
import { db } from '$lib/server/db';
import { baskets } from '$lib/server/db/schema';
import { getSettings, getPath } from '$lib/server/settings';
import { error, json } from '@sveltejs/kit';
import { sql } from 'drizzle-orm';
export const GET = async () => {
const s = getSettings();
if (s.remote_server) {
const connStr = getPath(s);
try {
const res = await fetch(`${connStr}/api/baskets`, { 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(baskets).orderBy(baskets.prefix, baskets.b_id);
return json(data);
}
};
export const POST = async ({ request }) => {
const reqData = await request.json();
const s = getSettings();
if (s.remote_server) {
const connStr = getPath(s);
const res = await fetch(`${connStr}/api/baskets`, {
method: 'POST',
headers: { 'TAM-KEY': s.remote_key, 'Content-Type': 'application/json' },
body: JSON.stringify(reqData)
});
if (!res.ok) throw error(res.status);
}
await db
.insert(baskets)
.values(reqData)
.onConflictDoUpdate({
target: [baskets.prefix, baskets.b_id],
set: { description: sql`EXCLUDED.description`, donors: sql`EXCLUDED.donors` }
});
return json(reqData);
};
@@ -0,0 +1,30 @@
import { db } from '$lib/server/db/index.js';
import { baskets } from '$lib/server/db/schema.js';
import { getPath, getSettings } from '$lib/server/settings';
import { error, json } from '@sveltejs/kit';
import { eq } from 'drizzle-orm';
export const GET = async ({ params }) => {
const { prefix } = params;
const s = getSettings();
if (s.remote_server) {
const connStr = getPath(s);
try {
const req = await fetch(`${connStr}/api/baskets/${prefix}`, {
headers: { 'TAM-KEY': s.remote_key }
});
if (!req.ok) throw error(req.status);
const data = await req.json();
return json(data);
} catch {
return json([]);
}
} else {
const data = await db
.select()
.from(baskets)
.where(eq(baskets.prefix, prefix))
.orderBy(baskets.prefix, baskets.b_id);
return json(data);
}
};
@@ -0,0 +1,38 @@
import { db } from '$lib/server/db/index.js';
import { baskets } from '$lib/server/db/schema.js';
import { getPath, getSettings } from '$lib/server/settings';
import { error, json } from '@sveltejs/kit';
import { and, eq } from 'drizzle-orm';
export const GET = async ({ params }) => {
const [prefix, b_id] = [params.prefix, parseInt(params.b_id)];
const s = getSettings();
if (s.remote_server) {
const connStr = getPath(s);
try {
const res = await fetch(`${connStr}/api/tickets/${prefix}/${b_id}`, {
headers: { 'TAM-KEY': s.remote_key }
});
if (!res.ok) throw error(res.status);
const [data] = await res.json();
if (data) {
return json(data);
} else {
return json({ prefix, b_id, description: '', donors: '', winning_ticket: 0 });
}
} catch {
return json({ prefix, b_id, description: '', donors: '', winning_ticket: 0 });
}
} else {
const [data] = await db
.select()
.from(baskets)
.where(and(eq(baskets.prefix, prefix), eq(baskets.b_id, b_id)))
.orderBy(baskets.prefix, baskets.b_id);
if (data) {
return json(data);
} else {
return json({ prefix, b_id, descrption: '', donors: '', winning_ticket: 0 });
}
}
};
@@ -0,0 +1,39 @@
import { db } from '$lib/server/db/index.js';
import { baskets } from '$lib/server/db/schema.js';
import { getPath, getSettings } from '$lib/server/settings';
import { error, json } from '@sveltejs/kit';
import { and, between, eq } from 'drizzle-orm';
export const GET = async ({ params }) => {
const s = getSettings();
const [prefix, id_from, id_to] = [
params.prefix,
parseInt(params.id_from),
parseInt(params.id_to)
];
const rtnData = {};
for (let i = id_from; i <= id_to; i++) {
rtnData[i] = { prefix, b_id: i, description: '', donors: '', winning_ticket: 0 };
}
if (s.remote_server) {
const connStr = getPath(s);
try {
const res = await fetch(`${connStr}/api/baskets/${prefix}/${id_from}/${id_to}`, {
headers: { 'TAM-KEY': s.remote_key }
});
if (!res.ok) throw error(res.status);
const data = Array.from(await res.json());
data.forEach((b) => (rtnData[b.b_id] = b));
} catch {
return json([]);
}
} else {
const data = await db
.select()
.from(baskets)
.where(and(eq(baskets.prefix, prefix), between(baskets.b_id, id_from, id_to)))
.orderBy(baskets.prefix, baskets.b_id);
data.forEach((b) => (rtnData[b.b_id] = b));
}
return json(Object.values(rtnData));
};
+56 -50
View File
@@ -1,56 +1,62 @@
import { getSettings, getPath } from "$lib/server/settings"
import { json, error } from "@sveltejs/kit";
import { db } from "$lib/server/db";
import { prefixes } from "$lib/server/db/schema";
import { sql, eq } from "drizzle-orm";
import { getSettings, getPath } from '$lib/server/settings';
import { json, error } from '@sveltejs/kit';
import { db } from '$lib/server/db';
import { prefixes } from '$lib/server/db/schema';
import { sql, eq } from 'drizzle-orm';
export const GET = async () => {
const s = getSettings();
if (s.remote_server) {
const connStr = getPath(s);
try {
const res = await fetch(`${connStr}/api/prefixes`, {
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(prefixes).orderBy(prefixes.weight, prefixes.prefix);
return json(data);
}
}
const s = getSettings();
if (s.remote_server) {
const connStr = getPath(s);
try {
const res = await fetch(`${connStr}/api/prefixes`, {
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(prefixes).orderBy(prefixes.weight, prefixes.prefix);
return json(data);
}
};
export const POST = async ({ request }) => {
const reqData = await request.json();
const s = getSettings();
if (s.remote_server) {
const connStr = getPath(s);
const res = await fetch(`${connStr}/api/prefixes`, {
method: 'POST',
headers: { 'TAM-KEY': s.remote_key, 'Content-Type': 'application/json' },
body: JSON.stringify(reqData)
})
if (!res.ok) throw error(res.status);
}
await db.insert(prefixes).values(reqData).onConflictDoUpdate({ target: prefixes.prefix, set: { color: sql`EXCLUDED.color`, weight: sql`EXCLUDED.weight` } });
return json(reqData);
}
const reqData = await request.json();
const s = getSettings();
if (s.remote_server) {
const connStr = getPath(s);
const res = await fetch(`${connStr}/api/prefixes`, {
method: 'POST',
headers: { 'TAM-KEY': s.remote_key, 'Content-Type': 'application/json' },
body: JSON.stringify(reqData)
});
if (!res.ok) throw error(res.status);
}
await db
.insert(prefixes)
.values(reqData)
.onConflictDoUpdate({
target: prefixes.prefix,
set: { color: sql`EXCLUDED.color`, weight: sql`EXCLUDED.weight` }
});
return json(reqData);
};
export const DELETE = async ({ url }) => {
const p = url.searchParams.get('p');
const s = getSettings();
if (s.remote_server) {
const connStr = getPath(s);
const res = await fetch(`${connStr}/api/prefixes?p=${p}`, {
method: 'DELETE',
headers: { 'TAM-KEY': s.remote_key }
});
if (!res.ok) throw error(res.status);
}
await db.delete(prefixes).where(eq(prefixes.prefix, p));
return json({ message: "Deleted successfully."});
}
const p = url.searchParams.get('p');
const s = getSettings();
if (s.remote_server) {
const connStr = getPath(s);
const res = await fetch(`${connStr}/api/prefixes?p=${p}`, {
method: 'DELETE',
headers: { 'TAM-KEY': s.remote_key }
});
if (!res.ok) throw error(res.status);
}
await db.delete(prefixes).where(eq(prefixes.prefix, p));
return json({ message: 'Deleted successfully.' });
};
+6 -6
View File
@@ -1,8 +1,8 @@
import { setSettings } from "$lib/server/settings";
import { json } from "@sveltejs/kit";
import { setSettings } from '$lib/server/settings';
import { json } from '@sveltejs/kit';
export const POST = async ({ request }) => {
const newSettings = await request.json();
setSettings(newSettings);
return json(newSettings);
}
const newSettings = await request.json();
setSettings(newSettings);
return json(newSettings);
};
@@ -31,8 +31,12 @@ export const GET = async ({ params }) => {
} catch {
return json([]);
}
} else {
const data = await db.select().from(tickets).where(and(eq(tickets.prefix, prefix), between(tickets.t_id, id_from, id_to))).orderBy(tickets.prefix, tickets.t_id);
} else {
const data = await db
.select()
.from(tickets)
.where(and(eq(tickets.prefix, prefix), between(tickets.t_id, id_from, id_to)))
.orderBy(tickets.prefix, tickets.t_id);
data.forEach((t) => (rtnData[t.t_id] = t));
}
return json(Object.values(rtnData));
@@ -0,0 +1,7 @@
export const load = async ({ params, fetch }) => {
const { prefix } = params;
const res = await fetch('/api/prefixes');
const prefixes = await res.json();
const prefixObj = Array.from(prefixes).find((p) => p.prefix == prefix);
return { prefix: prefixObj, prefixes };
};
@@ -0,0 +1,220 @@
<script>
import { resolve } from '$app/paths';
import { afterNavigate, beforeNavigate } from '$app/navigation';
import { browser } from '$app/environment';
import { bS, bAS, iS } from '$lib/client/styles';
import HeaderBar from '$lib/client/components/HeaderBar.svelte';
import PagerBar from '$lib/client/components/PagerBar.svelte';
import CommandBar from '$lib/client/components/CommandBar.svelte';
let { data } = $props();
let { prefix, prefixes } = $derived(data);
let pageTitle = $derived(`${prefix.prefix} Baskets | TAM`);
let curIdx = $state(0),
nextIdx = $derived(curIdx + 1),
prevIdx = $derived(curIdx - 1);
const changeIdx = (idx) => {
curIdx = idx;
};
const focusIdx = (idx) => {
curIdx = idx;
const elemIdx = document.getElementById(`${idx}_first`);
if (elemIdx) {
elemIdx.focus();
}
};
let pager = $state({ idFrom: 0, idTo: 0 });
let items = $state([]);
let itemsLength = $derived(items.length);
let itemsBuffer = $derived(items.filter((i) => i.changed));
const functions = {
getPage: async () => {
functions.save();
if (pager.idFrom > pager.idTo) {
[pager.idFrom, pager.idTo] = [pager.idTo, pager.idFrom];
}
if (pager.idTo - pager.idFrom > 300) {
pager.idTo = pager.idFrom + 300;
}
const res = await fetch(`/api/baskets/${prefix.prefix}/${pager.idFrom}/${pager.idTo}`);
const resData = await res.json();
resData.map((i) => (i.changed = false));
items = [...resData];
setTimeout(() => focusIdx(0));
},
save: async () => {
if (itemsBuffer.length > 0) {
const res = await fetch('/api/baskets', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify(itemsBuffer)
});
if (res.ok) {
itemsBuffer.forEach((i) => (i.changed = false));
} else {
alert('Error saving items.');
}
}
setTimeout(() => {
focusIdx(0);
}, 1);
},
prevPage: () => {
((pager.idFrom -= itemsLength), (pager.idTo -= itemsLength));
functions.getPage();
},
nextPage: () => {
((pager.idFrom += itemsLength), (pager.idTo += itemsLength));
functions.getPage();
},
nextLine: () => {
if (items[nextIdx]) {
setTimeout(() => {
focusIdx(nextIdx);
}, 1);
} else {
setTimeout(() => {
focusIdx(curIdx);
}, 1);
}
},
prevLine: () => {
if (items[prevIdx]) {
setTimeout(() => {
focusIdx(prevIdx);
}, 1);
} else {
setTimeout(() => {
focusIdx(curIdx);
}, 1);
}
},
dupDown: () => {
if (items[nextIdx]) {
const buffer = { ...items[curIdx] };
['prefix', 't_id'].forEach((key) => delete buffer[key]);
items[nextIdx] = { ...items[nextIdx], ...buffer, changed: true };
functions.nextLine();
} else {
focusIdx(curIdx);
}
},
dupUp: () => {
if (curIdx > 0) {
const buffer = { ...items[curIdx] };
['prefix', 't_id'].forEach((key) => delete buffer[key]);
items[prevIdx] = { ...items[prevIdx], ...buffer, changed: true };
functions.prevLine();
} else {
focusIdx(curIdx);
}
},
copy: () => {
if (items[curIdx]) {
const buffer = { ...items[curIdx] };
['prefix', 't_id'].forEach((key) => delete buffer[key]);
window.localStorage.setItem('tam-ticket', JSON.stringify(buffer));
}
focusIdx(curIdx);
},
paste: () => {
if (items[curIdx]) {
const buffer = JSON.parse(window.localStorage.getItem('tam-ticket'));
items[curIdx] = { ...items[curIdx], ...buffer, changed: true };
}
focusIdx(curIdx);
}
};
const headers = ['Basket ID', 'Description', 'Donors', 'Save?'];
beforeNavigate(({ cancel }) => {
if (itemsBuffer.length > 0) {
if (!confirm('Are you sure you want to leave this page? There are unsaved changes!'))
cancel();
}
});
afterNavigate(() => {
items = [];
pager = { idFrom: 0, idTo: 0 };
curIdx = 0;
});
if (browser) {
window.addEventListener('beforeunload', (e) => {
if (itemsBuffer.length > 0) e.preventDefault();
});
}
</script>
<svelte:head>
<title>{pageTitle}</title>
</svelte:head>
<table class="w-full box-border border-separate p-1">
<thead class="sticky top-1 bg-white">
<tr>
<td colspan="50">
<HeaderBar>
<div>Baskets:</div>
{#each prefixes as p (p.prefix)}
<a
href={resolve('/baskets/[prefix]', { prefix: p.prefix })}
class={prefix.prefix == p.prefix ? bAS[p.color] : bS[p.color]}>{p.prefix}</a
>
{/each}
</HeaderBar>
<h1 class="text-xl font-bold p-1">{pageTitle}</h1>
<PagerBar {prefix} {functions} bind:pager />
<CommandBar {prefix} {functions} /></td
>
</tr>
<tr>
{#each headers as header (header)}
<th class="border text-left p-0.5">{header}</th>
{/each}
</tr>
</thead>
<tbody>
{#each items as item, idx (item.b_id)}
<tr
class="focus-within:font-bold"
onfocusin={(e) => {
changeIdx(idx);
e.target.scrollIntoView({ block: 'center' });
}}
>
<td class="p-0.5 border">{item.b_id}</td>
<td class="p-0.5 border"
><input
type="text"
class="{iS.normal} w-full"
id="{idx}_first"
onchangecapture={() => (item.changed = true)}
bind:value={item.description}
/></td
>
<td class="p-0.5 border"
><input
type="text"
class="{iS.normal} w-full"
id="{idx}_second"
onchangecapture={() => (item.changed = true)}
bind:value={item.donors}
/></td
>
<td class="p-0.5 border"
><button
class={bS[prefix.color]}
onclick={() => {
item.changed ? (item.changed = false) : (item.changed = true);
}}>{item.changed ? 'Yes' : 'No'}</button
></td
>
</tr>
{/each}
</tbody>
</table>
+4 -4
View File
@@ -1,6 +1,6 @@
import { getSettings } from "$lib/server/settings";
import { getSettings } from '$lib/server/settings';
export const load = () => {
const settings = getSettings();
return { settings };
}
const settings = getSettings();
return { settings };
};
+82 -71
View File
@@ -1,85 +1,96 @@
<script>
import { onMount } from 'svelte';
import { resolve } from '$app/paths'
import { bS, iS, tS } from '$lib/client/styles';
import HeaderBar from '$lib/client/components/HeaderBar.svelte'
import { onMount } from 'svelte';
import { resolve } from '$app/paths';
import { bS, iS, tS } from '$lib/client/styles';
import HeaderBar from '$lib/client/components/HeaderBar.svelte';
let { data } = $props();
let settings = $state({});
let status = $state({
message: '',
color: 'green'
})
let { data } = $props();
let settings = $state({});
let status = $state({
message: '',
color: 'green'
});
const pageTitle = 'Settings | TAM';
const pageTitle = 'Settings | TAM';
onMount(() => {
settings = {...data.settings};
})
onMount(() => {
settings = { ...data.settings };
});
</script>
<svelte:head>
<title>{pageTitle}</title>
<title>{pageTitle}</title>
</svelte:head>
<HeaderBar>
<div>Settings Sections:</div>
{#if data.settings.remote_server}
<a href={resolve('/settings/auth-keys')} class={bS.gray}>Auth Keys</a>
{/if}
<a href={resolve('/settings/prefixes')} class={bS.gray}>Prefixes</a>
<div>Settings Sections:</div>
{#if data.settings.remote_server}
<a href={resolve('/settings/auth-keys')} class={bS.gray}>Auth Keys</a>
{/if}
<a href={resolve('/settings/prefixes')} class={bS.gray}>Prefixes</a>
</HeaderBar>
<div id="app_container" class="p-1">
<h1 class="text-xl font-bold">{pageTitle}</h1>
<div class="flex flex-col gap-1 w-full py-1">
<h2 class="text-lg font-bold">Remote Mode:</h2>
<div class="flex flex-row gap-1 items-center">
<div>Remote Server:</div>
<input type="text" class={iS.normal} bind:value={settings.remote_server}>
</div>
<div class="flex flex-row gap-1 items-center">
<div>Remote Port:</div>
<input type="text" class={iS.normal} bind:value={settings.remote_port}>
</div>
<div class="flex flex-row gap-1 items-center">
<div>Remote TLS:</div>
<button class={bS.gray} onclick={() => {
settings.remote_tls = !settings.remote_tls
}}>{settings.remote_tls ? 'Yes' : 'No'}</button>
</div>
<h2 class="text-lg font-bold">Default Preferences:</h2>
<div class="flex flex-row gap-1 items-center">
<div>Contact Preference:</div>
<button class={bS.gray} onclick={() => {
settings.default_pref === 'CALL' ? settings.default_pref = 'TEXT' : settings.default_pref = 'CALL';
}}>{settings.default_pref}</button>
</div>
<div class="flex flex-row gap-1 items-center">
<div>Venue Name:</div>
<input type="text" class={iS.normal} bind:value={settings.venue_name}>
</div>
<div class="flex flex-row gap-1 items-center">
<button class={bS.gray} onclick={async () => {
const res = await fetch('/api/settings', {
method: 'POST',
body: JSON.stringify(settings),
headers: {'Content-Type': 'application/json'}
})
if (!res.ok) {
status.message = `Error Code: ${res.status}`;
status.color = 'red';
} else {
const resData = await res.json();
settings = {...resData};
status.message = 'Settings saved successfully!';
status.color = 'green';
}
}}>Save</button>
<button class={bS.gray}>Cancel</button>
</div>
<div>
<p class={tS[status.color]}>{status.message}</p>
</div>
</div>
<h1 class="text-xl font-bold">{pageTitle}</h1>
<div class="flex flex-col gap-1 w-full py-1">
<h2 class="text-lg font-bold">Remote Mode:</h2>
<div class="flex flex-row gap-1 items-center">
<div>Remote Server:</div>
<input type="text" class={iS.normal} bind:value={settings.remote_server} />
</div>
<div class="flex flex-row gap-1 items-center">
<div>Remote Port:</div>
<input type="text" class={iS.normal} bind:value={settings.remote_port} />
</div>
<div class="flex flex-row gap-1 items-center">
<div>Remote TLS:</div>
<button
class={bS.gray}
onclick={() => {
settings.remote_tls = !settings.remote_tls;
}}>{settings.remote_tls ? 'Yes' : 'No'}</button
>
</div>
<h2 class="text-lg font-bold">Default Preferences:</h2>
<div class="flex flex-row gap-1 items-center">
<div>Contact Preference:</div>
<button
class={bS.gray}
onclick={() => {
settings.default_pref === 'CALL'
? (settings.default_pref = 'TEXT')
: (settings.default_pref = 'CALL');
}}>{settings.default_pref}</button
>
</div>
<div class="flex flex-row gap-1 items-center">
<div>Venue Name:</div>
<input type="text" class={iS.normal} bind:value={settings.venue_name} />
</div>
<div class="flex flex-row gap-1 items-center">
<button
class={bS.gray}
onclick={async () => {
const res = await fetch('/api/settings', {
method: 'POST',
body: JSON.stringify(settings),
headers: { 'Content-Type': 'application/json' }
});
if (!res.ok) {
status.message = `Error Code: ${res.status}`;
status.color = 'red';
} else {
const resData = await res.json();
settings = { ...resData };
status.message = 'Settings saved successfully!';
status.color = 'green';
}
}}>Save</button
>
<button class={bS.gray}>Cancel</button>
</div>
<div>
<p class={tS[status.color]}>{status.message}</p>
</div>
</div>
</div>
@@ -1,6 +1,6 @@
import { getSettings } from "$lib/server/settings";
import { getSettings } from '$lib/server/settings';
export const load = () => {
const s = getSettings();
return { authKey: s.remote_key };
}
const s = getSettings();
return { authKey: s.remote_key };
};
@@ -91,10 +91,10 @@
headers: { 'TAM-PWD': auth.pwd }
});
if (res.ok) {
setTimeout(() => {
const newKeys = authKeys.filter(i => i.auth_key !== key.auth_key);
authKeys = [...newKeys];
}, 1)
setTimeout(() => {
const newKeys = authKeys.filter((i) => i.auth_key !== key.auth_key);
authKeys = [...newKeys];
}, 1);
}
}}>Delete</button
>
@@ -109,17 +109,17 @@
<button
class={bS.gray}
onclick={async () => {
if (newDesc) {
const res = await fetch('/api/auth', {
method: 'POST',
headers: { 'TAM-PWD': auth.pwd, 'Content-Type': 'application/json' },
body: JSON.stringify({ description: newDesc })
});
if (res.ok) {
newDesc = '';
const data = await res.json();
authKeys = [...authKeys, data];
}
if (newDesc) {
const res = await fetch('/api/auth', {
method: 'POST',
headers: { 'TAM-PWD': auth.pwd, 'Content-Type': 'application/json' },
body: JSON.stringify({ description: newDesc })
});
if (res.ok) {
newDesc = '';
const data = await res.json();
authKeys = [...authKeys, data];
}
}
}}>New Key</button
>
@@ -1,5 +1,5 @@
export const load = async ({ fetch }) => {
const res = await fetch('/api/prefixes');
const prefixes = await res.json();
return { prefixes };
}
const res = await fetch('/api/prefixes');
const prefixes = await res.json();
return { prefixes };
};
@@ -1,7 +1,7 @@
export const load = async ({ params, fetch }) => {
const { prefix } = params;
const res = await fetch('/api/prefixes');
const prefixes = await res.json();
const prefixObj = Array.from(prefixes).find(p => p.prefix == prefix);
return { prefix: prefixObj, prefixes};
}
const { prefix } = params;
const res = await fetch('/api/prefixes');
const prefixes = await res.json();
const prefixObj = Array.from(prefixes).find((p) => p.prefix == prefix);
return { prefix: prefixObj, prefixes };
};
+41 -36
View File
@@ -76,55 +76,55 @@
focusIdx(nextIdx);
}, 1);
} else {
setTimeout(() => {
setTimeout(() => {
focusIdx(curIdx);
}, 1)
}, 1);
}
},
prevLine: () => {
if (items[prevIdx]) {
if (items[prevIdx]) {
setTimeout(() => {
focusIdx(prevIdx);
focusIdx(prevIdx);
}, 1);
} else {
setTimeout(() => {
focusIdx(curIdx)
setTimeout(() => {
focusIdx(curIdx);
}, 1);
};
}
},
dupDown: () => {
if (items[nextIdx]) {
const buffer = {...items[curIdx]};
["prefix", "t_id"].forEach(key => delete buffer[key]);
items[nextIdx] = {...items[nextIdx], ...buffer, changed: true};
if (items[nextIdx]) {
const buffer = { ...items[curIdx] };
['prefix', 't_id'].forEach((key) => delete buffer[key]);
items[nextIdx] = { ...items[nextIdx], ...buffer, changed: true };
functions.nextLine();
} else {
focusIdx(curIdx);
focusIdx(curIdx);
}
},
dupUp: () => {
if (curIdx > 0) {
const buffer = {...items[curIdx]};
["prefix", "t_id"].forEach(key => delete buffer[key]);
items[prevIdx] = {...items[prevIdx], ...buffer, changed: true};
if (curIdx > 0) {
const buffer = { ...items[curIdx] };
['prefix', 't_id'].forEach((key) => delete buffer[key]);
items[prevIdx] = { ...items[prevIdx], ...buffer, changed: true };
functions.prevLine();
} else {
focusIdx(curIdx);
focusIdx(curIdx);
}
},
copy: () => {
if (items[curIdx]) {
const buffer = {...items[curIdx]};
["prefix", "t_id"].forEach(key => delete buffer[key]);
if (items[curIdx]) {
const buffer = { ...items[curIdx] };
['prefix', 't_id'].forEach((key) => delete buffer[key]);
window.localStorage.setItem('tam-ticket', JSON.stringify(buffer));
};
}
focusIdx(curIdx);
},
paste: () => {
if (items[curIdx]) {
if (items[curIdx]) {
const buffer = JSON.parse(window.localStorage.getItem('tam-ticket'));
items[curIdx] = {...items[curIdx], ...buffer, changed: true};
};
items[curIdx] = { ...items[curIdx], ...buffer, changed: true };
}
focusIdx(curIdx);
}
};
@@ -154,8 +154,8 @@
<title>{pageTitle}</title>
</svelte:head>
<table class="w-full box-border border-separate">
<thead class="sticky top-1 box-border bg-white">
<table class="w-full box-border border-separate p-1">
<thead class="sticky top-1 bg-white">
<tr>
<td colspan="50">
<HeaderBar>
@@ -167,16 +167,10 @@
>
{/each}
</HeaderBar>
</td>
</tr>
<tr>
<td colspan="50"><h1 class="text-xl font-bold p-1">{pageTitle}</h1></td>
</tr>
<tr>
<td colspan="50"><PagerBar {prefix} {functions} bind:pager /></td>
</tr>
<tr>
<td colspan="50"><CommandBar {prefix} {functions} /></td>
<h1 class="text-xl font-bold p-1">{pageTitle}</h1>
<PagerBar {prefix} {functions} bind:pager />
<CommandBar {prefix} {functions} /></td
>
</tr>
<tr>
{#each headers as header (header)}
@@ -207,6 +201,7 @@
><input
type="text"
class="{iS.normal} w-full"
id="{idx}_second"
onchangecapture={() => (item.changed = true)}
bind:value={item.last_name}
/></td
@@ -215,6 +210,7 @@
><input
type="text"
class="{iS.normal} w-full"
id="{idx}_third"
onchangecapture={() => (item.changed = true)}
bind:value={item.phone_number}
/></td
@@ -225,6 +221,15 @@
onclick={() => {
item.pref == 'CALL' ? (item.pref = 'TEXT') : (item.pref = 'CALL');
item.changed = true;
}}
onkeydown={(e) => {
if (e.key == 't') {
if (item.pref != 'TEXT') item.changed = true;
item.pref = 'TEXT';
} else if (e.key == 'c') {
if (item.pref != 'CALL') item.changed = true;
item.pref = 'CALL';
}
}}>{item.pref}</button
></td
>