MM revamp, save prompt, upload fix
This commit is contained in:
@@ -7,6 +7,8 @@ COPY . .
|
|||||||
RUN npm install && npm run build
|
RUN npm install && npm run build
|
||||||
|
|
||||||
ENV DATABASE_URL=file:/data/local.db
|
ENV DATABASE_URL=file:/data/local.db
|
||||||
|
ENV BODY_SIZE_LIMIT=100M
|
||||||
|
ENV NODE_TLS_REJECT_UNAUTHORIZED=0
|
||||||
|
|
||||||
COPY deploy/start-server.sh start-server.sh
|
COPY deploy/start-server.sh start-server.sh
|
||||||
|
|
||||||
|
|||||||
@@ -15,6 +15,15 @@ a.styled, button.styled {
|
|||||||
border-radius: 0.25rem;
|
border-radius: 0.25rem;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.p025 {
|
||||||
|
padding: 0.25rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
.active {
|
||||||
|
border: 1px solid #000000;
|
||||||
|
border-radius: 0.13rem;
|
||||||
|
}
|
||||||
|
|
||||||
a.styled:hover, button.styled:hover {
|
a.styled:hover, button.styled:hover {
|
||||||
text-decoration: underline;
|
text-decoration: underline;
|
||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
|
|||||||
@@ -36,6 +36,7 @@
|
|||||||
<img src="{favicon}" alt="TAM3 Icon - Red ticket with TAM3 on it" class="icon">
|
<img src="{favicon}" alt="TAM3 Icon - Red ticket with TAM3 on it" class="icon">
|
||||||
<h1>{venue} - Main Menu</h1>
|
<h1>{venue} - Main Menu</h1>
|
||||||
</div>
|
</div>
|
||||||
|
{#if prefix_name !== ""}
|
||||||
<div class="universal-reports flex-row tb-margin">
|
<div class="universal-reports flex-row tb-margin">
|
||||||
<a href="/counts" target="_blank" class="styled">Counts</a>
|
<a href="/counts" target="_blank" class="styled">Counts</a>
|
||||||
</div>
|
</div>
|
||||||
@@ -47,7 +48,7 @@
|
|||||||
</div>
|
</div>
|
||||||
<div class="prefix-selector flex-row">
|
<div class="prefix-selector flex-row">
|
||||||
{#each all_prefixes as prefix}
|
{#each all_prefixes as prefix}
|
||||||
<div class={prefix.color}>
|
<div class="{prefix.color} p025{prefix.name === prefix_name ? " active" : ""}">
|
||||||
<button class="styled" onclick={() => {
|
<button class="styled" onclick={() => {
|
||||||
prefix_name = prefix.name;
|
prefix_name = prefix.name;
|
||||||
}}>{prefix.name}</button>
|
}}>{prefix.name}</button>
|
||||||
@@ -65,6 +66,7 @@
|
|||||||
<a href="/reports/byname/{current_prefix.name}/" target="_blank" class="styled">By Name</a>
|
<a href="/reports/byname/{current_prefix.name}/" target="_blank" class="styled">By Name</a>
|
||||||
<a href="/reports/bybasket/{current_prefix.name}/" target="_blank" class="styled">By Basket ID</a>
|
<a href="/reports/bybasket/{current_prefix.name}/" target="_blank" class="styled">By Basket ID</a>
|
||||||
</div>
|
</div>
|
||||||
|
{/if}
|
||||||
</div>
|
</div>
|
||||||
{#if admin_mode}
|
{#if admin_mode}
|
||||||
<div><h2>Admin Mode:</h2></div>
|
<div><h2>Admin Mode:</h2></div>
|
||||||
|
|||||||
@@ -1,6 +1,15 @@
|
|||||||
import { env } from "$env/dynamic/private";
|
import { env } from "$env/dynamic/private";
|
||||||
import { db } from "$lib/server/db";
|
import { db } from "$lib/server/db";
|
||||||
import { prefixes, tickets, baskets } from "$lib/server/db/schema";
|
import { prefixes, tickets, baskets } from "$lib/server/db/schema";
|
||||||
|
import { sql } from "drizzle-orm";
|
||||||
|
|
||||||
|
function chunkArray(arr, chunkSize) {
|
||||||
|
const chunks = [];
|
||||||
|
for (let i = 0; i < arr.length; i += chunkSize) {
|
||||||
|
chunks.push(arr.slice(i, i + chunkSize));
|
||||||
|
}
|
||||||
|
return chunks;
|
||||||
|
}
|
||||||
|
|
||||||
export async function GET() {
|
export async function GET() {
|
||||||
if (env.TAM3_REMOTE) {
|
if (env.TAM3_REMOTE) {
|
||||||
@@ -20,16 +29,16 @@ export async function GET() {
|
|||||||
|
|
||||||
export async function POST({ request }) {
|
export async function POST({ request }) {
|
||||||
const req = await request.json();
|
const req = await request.json();
|
||||||
for (let prefix of req.prefixes) {
|
for (let prefixChunk of chunkArray(req.prefixes, 300)) {
|
||||||
await db.insert(prefixes).values({name: prefix.name, color: prefix.color, weight: prefix.weight}).onConflictDoUpdate({target: prefixes.name, set: {color: prefix.color, weight: prefix.weight}});
|
await db.insert(prefixes).values(prefixChunk).onConflictDoUpdate({target: prefixes.name, set: {color: sql`excluded.color`, weight: sql`excluded.weight`}});
|
||||||
};
|
};
|
||||||
for (let ticket of req.tickets) {
|
for (let ticketChunk of chunkArray(req.tickets, 300)) {
|
||||||
await db.insert(tickets).values({prefix: ticket.prefix, t_id: ticket.t_id, first_name: ticket.first_name, last_name: ticket.last_name, phone_number: ticket.phone_number, preference: ticket.preference})
|
await db.insert(tickets).values(ticketChunk)
|
||||||
.onConflictDoUpdate({target: [tickets.prefix, tickets.t_id], set: {first_name: ticket.first_name, last_name: ticket.last_name, phone_number: ticket.phone_number, preference: ticket.preference}});
|
.onConflictDoUpdate({target: [tickets.prefix, tickets.t_id], set: {first_name: sql`excluded.first_name`, last_name: sql`excluded.last_name`, phone_number: sql`excluded.phone_number`, preference: sql`excluded.preference`}});
|
||||||
};
|
};
|
||||||
for (let basket of req.baskets) {
|
for (let basketChunk of chunkArray(req.baskets, 300)) {
|
||||||
await db.insert(baskets).values({prefix: basket.prefix, b_id: basket.b_id, description: basket.description, donors: basket.donors, winning_ticket: basket.winning_ticket})
|
await db.insert(baskets).values(basketChunk)
|
||||||
.onConflictDoUpdate({target: [baskets.prefix, baskets.b_id], set: {description: basket.description, donors: basket.donors, winning_ticket: basket.winning_ticket}})
|
.onConflictDoUpdate({target: [baskets.prefix, baskets.b_id], set: {description: sql`excluded.description`, donors: sql`excluded.donors`, winning_ticket: sql`excluded.winning_ticket`}})
|
||||||
};
|
};
|
||||||
if (env.TAM3_REMOTE) {
|
if (env.TAM3_REMOTE) {
|
||||||
const res = await fetch(`${env.TAM3_REMOTE}/api/backuprestore/?api_key=${env.TAM3_REMOTE_KEY}`, {
|
const res = await fetch(`${env.TAM3_REMOTE}/api/backuprestore/?api_key=${env.TAM3_REMOTE_KEY}`, {
|
||||||
|
|||||||
@@ -94,6 +94,11 @@
|
|||||||
|
|
||||||
if (browser) {
|
if (browser) {
|
||||||
document.title = `${prefix.name} Basket Entry`
|
document.title = `${prefix.name} Basket Entry`
|
||||||
|
window.addEventListener("beforeunload", function(e) {
|
||||||
|
if (current_baskets.filter(basket => basket.changed === true).length > 0) {
|
||||||
|
e.preventDefault();
|
||||||
|
}
|
||||||
|
})
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
|||||||
@@ -93,6 +93,11 @@
|
|||||||
|
|
||||||
if (browser) {
|
if (browser) {
|
||||||
document.title = `${prefix.name} Drawing Form`
|
document.title = `${prefix.name} Drawing Form`
|
||||||
|
window.addEventListener("beforeunload", function(e) {
|
||||||
|
if (current_drawings.filter(drawing => drawing.changed === true).length > 0) {
|
||||||
|
e.preventDefault();
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
|||||||
@@ -9,7 +9,7 @@
|
|||||||
let report_subject = $state("All Preferences");
|
let report_subject = $state("All Preferences");
|
||||||
|
|
||||||
if (browser) {
|
if (browser) {
|
||||||
document.title = `${prefix.name} Report By Name`
|
document.title = `${prefix.name} Report By Basket ID`
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
|||||||
@@ -95,6 +95,11 @@
|
|||||||
|
|
||||||
if (browser) {
|
if (browser) {
|
||||||
document.title = `${prefix.name} Ticket Entry`;
|
document.title = `${prefix.name} Ticket Entry`;
|
||||||
|
window.addEventListener("beforeunload", function(e) {
|
||||||
|
if (current_tickets.filter(ticket => ticket.changed === true).length > 0) {
|
||||||
|
e.preventDefault();
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user