nightly - 2025-09-22
This commit is contained in:
11
README.md
Normal file
11
README.md
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
# TAM3 - Web Based
|
||||||
|
|
||||||
|
This is the new web based version of Ticket Auction Manager. I decided to delete and redo it to rehash some things.
|
||||||
|
|
||||||
|
Goals for this project:
|
||||||
|
|
||||||
|
- To get everything working from [TAM-API](https://www.github.com/dbob16/tam-api)
|
||||||
|
- Web-based version
|
||||||
|
- Also have a desktop app available (eventually, maybe Electron or Tauri based)
|
||||||
|
|
||||||
|
**This is under _active_ development**
|
||||||
35
webapp/src/lib/css/colors.css
Normal file
35
webapp/src/lib/css/colors.css
Normal file
@@ -0,0 +1,35 @@
|
|||||||
|
.white {
|
||||||
|
--button-fg: #333333;
|
||||||
|
--button-bg: #ffffff;
|
||||||
|
--button-border: #333333;
|
||||||
|
}
|
||||||
|
|
||||||
|
.blue {
|
||||||
|
--button-fg: #000000;
|
||||||
|
--button-bg: #add8e6;
|
||||||
|
--button-border: #000000;
|
||||||
|
}
|
||||||
|
|
||||||
|
.yellow {
|
||||||
|
--button-fg: #000000;
|
||||||
|
--button-bg: #f9f96c;
|
||||||
|
--button-border: #000000;
|
||||||
|
}
|
||||||
|
|
||||||
|
.orange {
|
||||||
|
--button-fg: #000000;
|
||||||
|
--button-bg: #ffba39;
|
||||||
|
--button-border: #000000;
|
||||||
|
}
|
||||||
|
|
||||||
|
.red {
|
||||||
|
--button-fg: #000000;
|
||||||
|
--button-bg: #fa7575;
|
||||||
|
--button-border: #000000;
|
||||||
|
}
|
||||||
|
|
||||||
|
.green {
|
||||||
|
--button-fg: #000000;
|
||||||
|
--button-bg: lightgreen;
|
||||||
|
--button-border: #000000;
|
||||||
|
}
|
||||||
@@ -1 +1,27 @@
|
|||||||
|
:root {
|
||||||
|
--button-fg: #333333;
|
||||||
|
--button-bg: #eeeeee;
|
||||||
|
--button-border: #333333;
|
||||||
|
}
|
||||||
|
|
||||||
|
a.styled, button.styled {
|
||||||
|
display: block;
|
||||||
|
font: bold 12pt Arial;
|
||||||
|
text-decoration: none;
|
||||||
|
background-color: var(--button-bg);
|
||||||
|
color: var(--button-fg);
|
||||||
|
padding: 0.5rem 0.25rem;
|
||||||
|
border: solid 1px var(--button-border);
|
||||||
|
border-radius: 0.25rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
a.styled:hover, button.styled:hover {
|
||||||
|
text-decoration: underline;
|
||||||
|
}
|
||||||
|
|
||||||
|
.flex-row {
|
||||||
|
display: flex;
|
||||||
|
flex-direction: row;
|
||||||
|
flex-wrap: wrap;
|
||||||
|
gap: 0.75rem;
|
||||||
|
}
|
||||||
@@ -1,6 +1,7 @@
|
|||||||
<script>
|
<script>
|
||||||
import favicon from "$lib/assets/favicon.svg";
|
import favicon from "$lib/assets/favicon.svg";
|
||||||
import "$lib/css/main.css";
|
import "$lib/css/main.css";
|
||||||
|
import "$lib/css/colors.css";
|
||||||
|
|
||||||
let { children } = $props();
|
let { children } = $props();
|
||||||
</script>
|
</script>
|
||||||
|
|||||||
9
webapp/src/routes/+page.js
Normal file
9
webapp/src/routes/+page.js
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
export async function load({ fetch }) {
|
||||||
|
const res = await fetch('/api/prefixes/');
|
||||||
|
if (res.ok) {
|
||||||
|
const data = await res.json();
|
||||||
|
return { prefixes: data, status: "Prefixes fetched successfully." }
|
||||||
|
} else {
|
||||||
|
return { prefixes: [], status: "Error fetching prefixes."}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,18 +1,39 @@
|
|||||||
<script>
|
<script>
|
||||||
|
import { browser } from "$app/environment";
|
||||||
|
|
||||||
|
let { data } = $props();
|
||||||
let prefix_name = $state("");
|
let prefix_name = $state("");
|
||||||
|
let all_prefixes = $state([]);
|
||||||
|
let current_prefix = $state({name: "", color: "", weight: 0})
|
||||||
|
|
||||||
|
$effect(() => {
|
||||||
|
const new_prefix = all_prefixes.find((prefix) => prefix.name === prefix_name);
|
||||||
|
if (new_prefix) {
|
||||||
|
current_prefix = {...new_prefix};
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
if (browser) {
|
||||||
|
all_prefixes = [...data.prefixes];
|
||||||
|
document.title = "TAM3 - Main Menu"
|
||||||
|
};
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<div class="main-menu">
|
<div class="main-menu">
|
||||||
<h1>TAM3 - Main Menu</h1>
|
<h1>TAM3 - Main Menu</h1>
|
||||||
<div class="prefix-selector">
|
<div class="prefix-selector">
|
||||||
<select bind:value={prefix_name}></select>
|
<select style="width: 100%; box-sizing: border-box;" bind:value={prefix_name}>
|
||||||
|
{#each all_prefixes as prefix}
|
||||||
|
<option value={prefix.name}>{prefix.name}</option>
|
||||||
|
{/each}
|
||||||
|
</select>
|
||||||
</div>
|
</div>
|
||||||
<div class="form-buttons">
|
<div><h2>Forms:</h2></div>
|
||||||
<a href="/tickets/" class="button">Tickets</a>
|
<div class="flex-row {current_prefix.color}">
|
||||||
<a href="/baskets/" class="button">Baskets</a>
|
<a href="/tickets/{current_prefix.name}/" target="_blank" class="styled">Tickets</a>
|
||||||
<a href="/drawing/" class="button">Drawing</a>
|
<a href="/baskets/{current_prefix.name}/" target="_blank" class="styled">Baskets</a>
|
||||||
|
<a href="/drawing/{current_prefix.name}/" target="_blank" class="styled">Drawing</a>
|
||||||
</div>
|
</div>
|
||||||
<button>Test</button>
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<style>
|
<style>
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ export async function GET() {
|
|||||||
const data = await res.json();
|
const data = await res.json();
|
||||||
return new Response(JSON.stringify(data), {status: 200, statusText: "Prefixes fetched from remote successfully."});
|
return new Response(JSON.stringify(data), {status: 200, statusText: "Prefixes fetched from remote successfully."});
|
||||||
} else {
|
} else {
|
||||||
const data = await db.select().from(prefixes);
|
const data = await db.select().from(prefixes).orderBy(prefixes.weight, prefixes.name);
|
||||||
return new Response(JSON.stringify(data), {status: 200, statusText: "Prefixes loaded successfully."});
|
return new Response(JSON.stringify(data), {status: 200, statusText: "Prefixes loaded successfully."});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -20,4 +20,19 @@ export async function GET({ params }) {
|
|||||||
return new Response(JSON.stringify({status: "Issue loading prefix"}), {status: 404, statusText: "Prefix not found."})
|
return new Response(JSON.stringify({status: "Issue loading prefix"}), {status: 404, statusText: "Prefix not found."})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
export async function DELETE({ params }) {
|
||||||
|
let { name } = params;
|
||||||
|
await db.delete(prefixes).where(eq(prefixes.name, name))
|
||||||
|
if (env.TAM3_REMOTE) {
|
||||||
|
const res = await fetch(`${env.TAM3_REMOTE}/prefixes/?api_key=${env.TAM3_REMOTE_KEY}&prefix_name=${name}`);
|
||||||
|
if (!res.ok) {
|
||||||
|
return new Response(JSON.stringify({status: "Issue deleting prefix."}), {status: res.status, statusText: res.statusText});
|
||||||
|
} else {
|
||||||
|
return new Response(JSON.stringify({status: "Prefix deleted from remote successfully"}), {status: 200, statusText: res.statusText});
|
||||||
|
};
|
||||||
|
} else {
|
||||||
|
return new Response(JSON.stringify({status: "Prefix deleted successfully"}), {status: 200, statusText: "Prefix deleted successfully."})
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -20,7 +20,6 @@
|
|||||||
|
|
||||||
async function savePrefix() {
|
async function savePrefix() {
|
||||||
const post_body = JSON.stringify({...prefix_form});
|
const post_body = JSON.stringify({...prefix_form});
|
||||||
console.log(post_body);
|
|
||||||
const res = await fetch("/api/prefixes/", {
|
const res = await fetch("/api/prefixes/", {
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
body: JSON.stringify({...prefix_form}),
|
body: JSON.stringify({...prefix_form}),
|
||||||
@@ -30,10 +29,20 @@
|
|||||||
status = `[${res.status}]: ${res.statusText}`;
|
status = `[${res.status}]: ${res.statusText}`;
|
||||||
} else {
|
} else {
|
||||||
status = `${res.statusText}`;
|
status = `${res.statusText}`;
|
||||||
getPrefixes()
|
getPrefixes();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async function delPrefix(name) {
|
||||||
|
const res = await fetch(`/api/prefixes/${name}`, { method: 'DELETE' });
|
||||||
|
if (!res.ok) {
|
||||||
|
status = `[${res.status}]: ${res.statusText}`;
|
||||||
|
} else {
|
||||||
|
status = `${res.statusText}`;
|
||||||
|
getPrefixes();
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
if (browser) {
|
if (browser) {
|
||||||
getPrefixes()
|
getPrefixes()
|
||||||
}
|
}
|
||||||
@@ -62,9 +71,13 @@
|
|||||||
</div>
|
</div>
|
||||||
<div>
|
<div>
|
||||||
<div>Commands</div>
|
<div>Commands</div>
|
||||||
<div>
|
<div class="flex-row {prefix_form.color}">
|
||||||
<button onclick={savePrefix}>Save/Update</button>
|
<button class="styled" onclick={() => {
|
||||||
<button onclick={() => {
|
if (prefix_form.name !== "") {
|
||||||
|
savePrefix();
|
||||||
|
};
|
||||||
|
}}>Save/Update</button>
|
||||||
|
<button class="styled" onclick={() => {
|
||||||
prefix_form = {name: "", color: "white", weight: 0};
|
prefix_form = {name: "", color: "white", weight: 0};
|
||||||
}}>Reset</button>
|
}}>Reset</button>
|
||||||
</div>
|
</div>
|
||||||
@@ -78,13 +91,17 @@
|
|||||||
<div>Commands</div>
|
<div>Commands</div>
|
||||||
</div>
|
</div>
|
||||||
{#each all_prefixes as prefix}
|
{#each all_prefixes as prefix}
|
||||||
<div>
|
<div class="row">
|
||||||
<div>{prefix.name}</div>
|
<div>{prefix.name}</div>
|
||||||
<div>{prefix.color}</div>
|
<div>{prefix.color}</div>
|
||||||
<div>{prefix.weight}</div>
|
<div>{prefix.weight}</div>
|
||||||
<div>
|
<div class="flex-row {prefix.color}">
|
||||||
<button>Edit</button>
|
<button class="styled" onclick={() => {
|
||||||
<button>Delete</button>
|
prefix_form = {...prefix}
|
||||||
|
}}>Edit</button>
|
||||||
|
<button class="styled" onclick={() => {
|
||||||
|
delPrefix(prefix.name);
|
||||||
|
}}>Delete</button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
{/each}
|
{/each}
|
||||||
@@ -108,12 +125,21 @@
|
|||||||
|
|
||||||
.prefix-list {
|
.prefix-list {
|
||||||
margin-top: 3rem;
|
margin-top: 3rem;
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
gap: 0.5rem;
|
||||||
}
|
}
|
||||||
|
|
||||||
.prefix-list div {
|
.prefix-list div {
|
||||||
display: grid;
|
display: grid;
|
||||||
grid-template-columns: repeat(4, 1fr);
|
grid-template-columns: repeat(4, 1fr);
|
||||||
|
align-items: center;
|
||||||
gap: 1rem;
|
gap: 1rem;
|
||||||
|
padding: 0.25rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
.prefix-list div.row:nth-child(2n) {
|
||||||
|
background: #ddd;
|
||||||
}
|
}
|
||||||
|
|
||||||
.status {
|
.status {
|
||||||
|
|||||||
Reference in New Issue
Block a user