Refactor and remove sqlite and replace with MySQL

This commit is contained in:
2025-10-23 18:43:31 +01:00
parent d53e27eea8
commit 21ebc9c34b
139 changed files with 1013 additions and 529 deletions

View File

@@ -0,0 +1,9 @@
{{ define "delete_draw" }}
<h2 class="text-xl font-semibold mb-4">Delete Draw</h2>
<form method="POST" action="/admin/draws/delete">
{{ .CSRFField }}
<input type="hidden" name="id" value="{{ .Draw.ID }}">
<p>Are you sure you want to delete the draw on <strong>{{ .Draw.DrawDate }}</strong>?</p>
<button class="btn bg-red-600 hover:bg-red-700">Delete</button>
</form>
{{ end }}

View File

@@ -0,0 +1,46 @@
{{ define "draw_list" }}
<h2 class="text-xl font-bold mb-4">Draws Overview</h2>
<table class="w-full table-auto border">
<thead class="bg-gray-100">
<tr>
<th>ID</th>
<th>Game</th>
<th>Date</th>
<th>Ball Set</th>
<th>Machine</th>
<th>Prizes?</th>
<th>Actions</th>
</tr>
</thead>
<tbody>
{{ range .Draws }}
<tr class="border-t">
<td>{{ .ID }}</td>
<td>{{ .GameType }}</td>
<td>{{ .DrawDate }}</td>
<td>{{ .BallSet }}</td>
<td>{{ .Machine }}</td>
<td>
{{ if .PrizeSet }}
{{ else }}
{{ end }}
</td>
<td>
<a href="/admin/draws/modify?id={{ .ID }}" class="text-blue-600">Edit</a> |
<a href="/admin/draws/delete?id={{ .ID }}" class="text-red-600">Delete</a> |
{{ if .PrizeSet }}
<a href="/admin/draws/prizes/modify?draw_date={{ .DrawDate }}" class="text-green-600">Modify Prizes</a>
{{ else }}
<a href="/admin/draws/prizes/add?draw_date={{ .DrawDate }}" class="text-gray-600">Add Prizes</a>
{{ end }}
</td>
</tr>
{{ else }}
<tr><td colspan="7" class="text-center text-gray-500">No draws available.</td></tr>
{{ end }}
</tbody>
</table>
{{ end }}

View File

@@ -0,0 +1,12 @@
{{ define "modify_draw" }}
<h2 class="text-xl font-semibold mb-4">Modify Draw</h2>
<form method="POST" action="/admin/draws/modify">
{{ .CSRFField }}
<input type="hidden" name="id" value="{{ .Draw.ID }}">
<label class="block">Game Type: <input name="game_type" class="input" value="{{ .Draw.GameType }}"></label>
<label class="block">Draw Date: <input name="draw_date" type="date" class="input" value="{{ .Draw.DrawDate }}"></label>
<label class="block">Ball Set: <input name="ball_set" class="input" value="{{ .Draw.BallSet }}"></label>
<label class="block">Machine: <input name="machine" class="input" value="{{ .Draw.Machine }}"></label>
<button class="btn">Update Draw</button>
</form>
{{ end }}

View File

@@ -0,0 +1,42 @@
{{ define "new_draw" }}
<h2 class="text-xl font-semibold mb-4">Add New Draw</h2>
<form method="POST" action="/admin/draws/submit">
{{ .CSRFField }}
<label class="block">Game Type: <input name="game_type" class="input"></label>
<label class="block">Draw Date: <input name="draw_date" type="date" class="input"></label>
<label class="block">Ball Set: <input name="ball_set" class="input"></label>
<label class="block">Machine: <input name="machine" class="input"></label>
<button class="btn">Create Draw</button>
</form>
{{ end }}
<!-- Old new draw
{{ define "content" }}
<a href="/">← Back</a>
<h2>Add New Thunderball Draw</h2>
<form method="POST" action="/submit">
{{ .csrfField }}
<div class="form-section">
<label>Date: <input type="date" name="date" required></label>
</div>
<div class="form-section">
<label>Machine: <input type="text" name="machine" required></label>
</div>
<div class="form-section">
<label>Ball Set: <input type="text" name="ballset" required></label>
</div>
<div class="form-section">
<label>Ball 1: <input type="text" name="ball1" required></label>
<label>Ball 2: <input type="text" name="ball2" required></label>
<label>Ball 3: <input type="text" name="ball3" required></label>
<label>Ball 4: <input type="text" name="ball4" required></label>
<label>Ball 5: <input type="text" name="ball5" required></label>
</div>
<div class="form-section">
<label>Thunderball: <input type="text" name="thunderball" required></label>
</div>
<button type="submit">Save Draw</button>
</form>
{{ end }} -->

View File

@@ -0,0 +1,13 @@
{{ define "add_prizes" }}
<h2 class="text-xl font-semibold mb-4">Add Prize Breakdown</h2>
<form method="POST" action="/admin/draws/prizes/add">
{{ .CSRFField }}
<input type="hidden" name="draw_date" value="{{ .DrawDate }}">
{{ range $i, $ := .PrizeLabels }}
<label class="block">{{ . }}
<input name="prize{{ add $i 1 }}_per_winner" class="input">
</label>
{{ end }}
<button class="btn">Save Prizes</button>
</form>
{{ end }}

View File

@@ -0,0 +1,13 @@
{{ define "modify_prizes" }}
<h2 class="text-xl font-semibold mb-4">Modify Prize Breakdown</h2>
<form method="POST" action="/admin/draws/prizes/modify">
{{ .CSRFField }}
<input type="hidden" name="draw_date" value="{{ .DrawDate }}">
{{ range $i, $ := .PrizeLabels }}
<label class="block">{{ . }}
<input name="prize{{ add $i 1 }}_per_winner" class="input" value="{{ index $.Prizes (print "prize" (add $i 1) "_per_winner") }}">
</label>
{{ end }}
<button class="btn">Update Prizes</button>
</form>
{{ end }}