(change): Attribution can now be disabled, saving and cancelling

behavior
This commit is contained in:
dbob16 committed 2026-09-07 22:13:06 -04:00
1 parent 1b3c97516c
commit a11c313a8e
9 files changed
+52 -13

No files matched your search

+6 -3
View File
@@ -1,6 +1,9 @@
import { db } from "$lib/server/db";
import { db } from '$lib/server/db';
import { env } from '$env/dynamic/private';
export const init = async () => {
env.NODE_TLS_REJECT_UNAUTHORIZED = 0;
env.BODY_SIZE_LIMIT = 'Infinity';
await db.run(`CREATE TABLE IF NOT EXISTS baskets (
prefix text,
b_id integer,
@@ -31,11 +34,11 @@ export const init = async () => {
ORDER BY b.prefix, b.b_id`);
await db.run(`CREATE VIEW IF NOT EXISTS report_by_name AS SELECT t.last_name, t.first_name, t.phone_number, t.pref, b.prefix, b.b_id, b.description, b.donors, b.winning_ticket
FROM baskets b LEFT JOIN tickets t ON b.prefix = t.prefix AND b.winning_ticket = t.t_id
ORDER BY t.last_name, t.first_name, t.phone_number, b.prefix, b.b_id`)
ORDER BY t.last_name, t.first_name, t.phone_number, b.prefix, b.b_id`);
await db.run(`CREATE VIEW IF NOT EXISTS report_counts AS SELECT prefix, COUNT(DISTINCT(CONCAT(first_name, last_name, phone_number))) AS unique_buyers, COUNT(*) AS total_buys
FROM tickets
GROUP BY prefix
UNION ALL
SELECT 'Total', COUNT(DISTINCT(CONCAT(first_name, last_name, phone_number))), COUNT(*)
FROM tickets`);
}
};
@@ -77,6 +77,11 @@
<button class={bS[prefix.color]} title="Alt + S" onclick={() => functions.save()}
>Save Marked</button
>
{/if}
{#if functions.cancel}
<button class={bS[prefix.color]} title="Alt + S" onclick={() => functions.cancel()}
>Cancel Marked</button
>
{/if}
</div>
</div>
+2 -1
View File
@@ -7,7 +7,8 @@ const defaultSettings = {
remote_port: '8000',
remote_tls: false,
default_pref: 'CALL',
venue_name: 'TAM'
venue_name: 'Venue Name',
disable_attrib: false
};
export const getSettings = () => {
+2 -1
View File
@@ -2,9 +2,10 @@ import { getSettings } from '$lib/server/settings';
export const load = async ({ fetch }) => {
const settings = getSettings();
const disableAttrib = settings.disable_attrib || false;
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 };
return { ...data, venueName: settings.venue_name, prefixes: dataPrefixes, disableAttrib };
};
+5 -2
View File
@@ -134,12 +134,15 @@
{/if}
<div class="text-center text-xs">
<p>&copy; 2026 Ticket Auction Manager</p>
{#if !data.disableAttrib}
<p>
Created by Dilan Gilluly. Support me on <a
Created by Dilan Gilluly. <a
href="https://ko-fi.com/techguydilan"
class="text-blue-500">Ko-Fi</a
class="text-blue-500"
target="_blank">My Ko-Fi</a
>.
</p>
{/if}
</div>
</div>
</div>
@@ -64,6 +64,12 @@
focusIdx(0);
}, 1);
},
cancel(){
if (itemsBuffer.length > 0) {
itemsBuffer.forEach((i) => (i.changed = false));
this.getPage();
};
},
prevPage(){
((pager.idFrom -= itemsLength), (pager.idTo -= itemsLength));
this.getPage();
@@ -133,8 +139,8 @@
const headers = ['Basket ID', 'Description', 'Donors', 'Save?'];
if (browser) {
window.addEventListener('beforeunload', (e) => {
if (itemsBuffer.length > 0) e.preventDefault();
window.addEventListener('beforeunload', () => {
if (itemsBuffer.length > 0) functions.save();
});
}
</script>
@@ -61,6 +61,12 @@
focusIdx(0);
}, 1);
},
cancel(){
if (itemsBuffer.length > 0) {
itemsBuffer.forEach((i) => (i.changed = false));
this.getPage();
};
},
pagerFromUpdate(){
pager.idTo = pager.idFrom + (itemsLength - 1);
},
@@ -133,8 +139,8 @@
const headers = ['Basket ID', 'Description', 'Winning Ticket', 'Winner', 'Save?'];
if (browser) {
window.addEventListener('beforeunload', (e) => {
if (itemsBuffer.length > 0) e.preventDefault();
window.addEventListener('beforeunload', () => {
if (itemsBuffer.length > 0) functions.save();
});
}
</script>
+8
View File
@@ -73,6 +73,14 @@
<div>Venue Name:</div>
<input type="text" id="venue_name" class={iS.normal} bind:value={settings.venue_name} />
</div>
<div class="flex flex-row gap-1 items-center">
<div>Disable Attribution:</div>
<button
class={bS.gray}
onclick={() => {
settings.disable_attrib ? settings.disable_attrib = false : settings.disable_attrib = true
}}>{ settings.disable_attrib ? "Yes" : "No" }</button>
</div>
<div class="flex flex-row gap-1 items-center">
<button
class={bS.gray}
@@ -64,6 +64,12 @@
focusIdx(0);
}, 1);
},
cancel(){
if (itemsBuffer.length > 0) {
itemsBuffer.forEach((i) => (i.changed = false));
this.getPage();
};
},
prevPage(){
((pager.idFrom -= itemsLength), (pager.idTo -= itemsLength));
this.getPage();
@@ -133,8 +139,8 @@
const headers = ['Ticket ID', 'First Name', 'Last Name', 'Phone Number', 'Pref', 'Save?'];
if (browser) {
window.addEventListener('beforeunload', (e) => {
if (itemsBuffer.length > 0) e.preventDefault();
window.addEventListener('beforeunload', () => {
if (itemsBuffer.length > 0) functions.save();
});
}
</script>