Refactor and remove sqlite and replace with MySQL
This commit is contained in:
49
web/templates/admin/dashboard.html
Normal file
49
web/templates/admin/dashboard.html
Normal file
@@ -0,0 +1,49 @@
|
||||
{{ define "content" }}
|
||||
<h2>📊 Admin Dashboard</h2>
|
||||
<p class="text-sm text-gray-600">Welcome back, admin.</p>
|
||||
|
||||
<div class="grid grid-cols-1 md:grid-cols-3 gap-4 my-6">
|
||||
<div class="bg-white rounded-xl p-4 shadow">
|
||||
<h3 class="text-sm text-gray-500">Total Tickets</h3>
|
||||
<p class="text-2xl font-bold">{{ .Stats.TotalTickets }}</p>
|
||||
</div>
|
||||
<div class="bg-white rounded-xl p-4 shadow">
|
||||
<h3 class="text-sm text-gray-500">Total Winners</h3>
|
||||
<p class="text-2xl font-bold text-green-600">{{ .Stats.TotalWinners }}</p>
|
||||
</div>
|
||||
<div class="bg-white rounded-xl p-4 shadow">
|
||||
<h3 class="text-sm text-gray-500">Prize Fund Awarded</h3>
|
||||
<p class="text-2xl font-bold text-blue-600">£{{ printf "%.2f" .Stats.TotalPrizeAmount }}</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="my-6">
|
||||
<h3 class="text-lg font-semibold mb-2">Recent Ticket Matches</h3>
|
||||
<table class="w-full text-sm border">
|
||||
<thead>
|
||||
<tr class="bg-gray-100">
|
||||
<th class="px-2 py-1">Draw Date</th>
|
||||
<th class="px-2 py-1">Triggered By</th>
|
||||
<th class="px-2 py-1">Matched</th>
|
||||
<th class="px-2 py-1">Winners</th>
|
||||
<th class="px-2 py-1">Notes</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{{ range .MatchLogs }}
|
||||
<tr class="border-t">
|
||||
<td class="px-2 py-1">{{ .RunAt }}</td>
|
||||
<td class="px-2 py-1">{{ .TriggeredBy }}</td>
|
||||
<td class="px-2 py-1">{{ .TicketsMatched }}</td>
|
||||
<td class="px-2 py-1">{{ .WinnersFound }}</td>
|
||||
<td class="px-2 py-1 text-xs text-gray-500">{{ .Notes }}</td>
|
||||
</tr>
|
||||
{{ else }}
|
||||
<tr>
|
||||
<td colspan="5" class="text-center py-2 italic text-gray-400">No match history found</td>
|
||||
</tr>
|
||||
{{ end }}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
{{ end }}
|
||||
9
web/templates/admin/draws/delete_draw.html
Normal file
9
web/templates/admin/draws/delete_draw.html
Normal 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 }}
|
||||
46
web/templates/admin/draws/list_draws.html
Normal file
46
web/templates/admin/draws/list_draws.html
Normal 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 }}
|
||||
12
web/templates/admin/draws/modify_draw.html
Normal file
12
web/templates/admin/draws/modify_draw.html
Normal 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 }}
|
||||
42
web/templates/admin/draws/new_draw.html
Normal file
42
web/templates/admin/draws/new_draw.html
Normal 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 }} -->
|
||||
13
web/templates/admin/draws/prizes/add_prizes.html
Normal file
13
web/templates/admin/draws/prizes/add_prizes.html
Normal 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 }}
|
||||
13
web/templates/admin/draws/prizes/modify_prizes.html
Normal file
13
web/templates/admin/draws/prizes/modify_prizes.html
Normal 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 }}
|
||||
26
web/templates/admin/logs/access_logs.html
Normal file
26
web/templates/admin/logs/access_logs.html
Normal file
@@ -0,0 +1,26 @@
|
||||
{{ define "content" }}
|
||||
<h2>Admin Access Log</h2>
|
||||
|
||||
<table class="table-auto w-full text-sm mt-4">
|
||||
<thead>
|
||||
<tr class="bg-gray-200">
|
||||
<th class="px-2 py-1 text-left">Time</th>
|
||||
<th class="px-2 py-1">User ID</th>
|
||||
<th class="px-2 py-1">Path</th>
|
||||
<th class="px-2 py-1">IP</th>
|
||||
<th class="px-2 py-1">User Agent</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{{ range .AuditLogs }}
|
||||
<tr class="border-b">
|
||||
<td class="px-2 py-1">{{ .AccessedAt }}</td>
|
||||
<td class="px-2 py-1 text-center">{{ .UserID }}</td>
|
||||
<td class="px-2 py-1">{{ .Path }}</td>
|
||||
<td class="px-2 py-1">{{ .IP }}</td>
|
||||
<td class="px-2 py-1 text-xs text-gray-600">{{ .UserAgent }}</td>
|
||||
</tr>
|
||||
{{ end }}
|
||||
</tbody>
|
||||
</table>
|
||||
{{ end }}
|
||||
27
web/templates/admin/logs/audit.html
Normal file
27
web/templates/admin/logs/audit.html
Normal file
@@ -0,0 +1,27 @@
|
||||
{{ define "content" }}
|
||||
<h2>Audit Log</h2>
|
||||
<p>Recent sensitive admin events and system activity:</p>
|
||||
|
||||
<table>
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Time</th>
|
||||
<th>User ID</th>
|
||||
<th>Action</th>
|
||||
<th>IP</th>
|
||||
<th>User Agent</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{{ range .AuditLogs }}
|
||||
<tr>
|
||||
<td>{{ .Timestamp }}</td>
|
||||
<td>{{ .UserID }}</td>
|
||||
<td>{{ .Action }}</td>
|
||||
<td>{{ .IP }}</td>
|
||||
<td>{{ .UserAgent }}</td>
|
||||
</tr>
|
||||
{{ end }}
|
||||
</tbody>
|
||||
</table>
|
||||
{{ end }}
|
||||
29
web/templates/admin/triggers.html
Normal file
29
web/templates/admin/triggers.html
Normal file
@@ -0,0 +1,29 @@
|
||||
{{ define "content" }}
|
||||
<h2>Manual Admin Triggers</h2>
|
||||
|
||||
<form method="POST" action="/admin/triggers">
|
||||
{{ .CSRFField }}
|
||||
<input type="hidden" name="action" value="match">
|
||||
<button>Run Ticket Matching</button>
|
||||
</form>
|
||||
|
||||
<form method="POST" action="/admin/triggers" class="mt-4">
|
||||
{{ .CSRFField }}
|
||||
<input type="hidden" name="action" value="prizes">
|
||||
<button>Update Missing Prizes</button>
|
||||
</form>
|
||||
|
||||
<form method="POST" action="/admin/triggers" class="mt-4">
|
||||
{{ .CSRFField }}
|
||||
<input type="hidden" name="action" value="run_all">
|
||||
<button>Run All</button>
|
||||
</form>
|
||||
|
||||
<form method="POST" action="/admin/triggers" class="mt-4">
|
||||
{{ .CSRFField }}
|
||||
<input type="hidden" name="action" value="refresh_prizes">
|
||||
<button class="bg-indigo-500 text-white px-4 py-2 rounded hover:bg-indigo-600">
|
||||
Refresh Ticket Prizes
|
||||
</button>
|
||||
</form>
|
||||
{{ end }}
|
||||
Reference in New Issue
Block a user