This commit is contained in:
2026-05-14 17:17:11 +00:00
parent dc83364b1b
commit c29f85752b
8 changed files with 796 additions and 39 deletions

View File

@@ -0,0 +1,31 @@
<div>
<h2 class="text-2xl font-bold mb-4">
Active Anomalies
</h2>
<div class="space-y-4">
{% for a in anomalies %}
<div class="bg-red-950 border border-red-800 p-4 rounded-xl">
<div class="font-bold text-lg">
{{ a.type }}
</div>
<div class="text-gray-300">
UID: {{ a.uid }}
</div>
<div class="text-gray-400 text-sm">
{{ a.timestamp }}
</div>
</div>
{% endfor %}
</div>
</div>

View File

@@ -0,0 +1,77 @@
<!doctype html>
<html>
<head>
<script src="https://unpkg.com/htmx.org"></script>
<script src="https://cdn.tailwindcss.com"></script>
<title>RFID Admin</title>
</head>
<body class="bg-gray-950 text-white min-h-screen">
<div class="flex">
<!-- SIDEBAR -->
<div class="w-72 bg-gray-900 min-h-screen p-4 border-r border-gray-800">
<h1 class="text-3xl font-bold mb-6">
RFID Admin
</h1>
<div class="space-y-2">
<button
hx-get="/admin/students"
hx-target="#content"
class="w-full bg-gray-800 hover:bg-gray-700 p-3 rounded text-left"
>
Students
</button>
<button
hx-get="/admin/unknown"
hx-target="#content"
class="w-full bg-gray-800 hover:bg-gray-700 p-3 rounded text-left"
>
Unknown Cards
</button>
<button
hx-get="/admin/rooms"
hx-target="#content"
class="w-full bg-gray-800 hover:bg-gray-700 p-3 rounded text-left"
>
Rooms
</button>
<button
hx-get="/admin/anomalies"
hx-target="#content"
class="w-full bg-gray-800 hover:bg-gray-700 p-3 rounded text-left"
>
Anomalies
</button>
</div>
</div>
<!-- MAIN -->
<div class="flex-1 p-6">
<div
id="content"
hx-get="/admin/students"
hx-trigger="load"
hx-swap="innerHTML"
>
</div>
</div>
</div>
</body>
</html>

114
templates/admin/rooms.html Normal file
View File

@@ -0,0 +1,114 @@
<div>
<div class="flex justify-between items-center mb-4">
<h2 class="text-2xl font-bold">
Rooms
</h2>
</div>
<div class="grid grid-cols-3 gap-4">
{% for r in rooms %}
<div class="bg-gray-900 p-4 rounded-xl border border-gray-800">
<div class="flex justify-between items-center">
<div>
<div class="font-bold text-xl">
{{ r.room }}
</div>
<div class="text-gray-400 text-sm">
Current Occupancy:
{{ r.count }}
</div>
</div>
{% if r.bathroom %}
<span class="bg-blue-700 px-2 py-1 rounded text-sm">
Bathroom Tracking
</span>
{% endif %}
</div>
<form
hx-post="/admin/room/update/{{ r.id }}"
hx-target="#content"
class="mt-4 space-y-3"
>
<!-- MAX OCCUPANCY -->
<div>
<label class="block text-sm mb-1">
Max Occupancy
</label>
<input
type="number"
name="max"
value="{{ r.max }}"
class="bg-gray-800 p-2 rounded w-full"
>
</div>
<!-- BATHROOM GROUP -->
<div>
<label class="block text-sm mb-1">
Bathroom Group ID
</label>
<input
type="text"
name="bathroom_id"
value="{{ r.bathroom_id }}"
placeholder="example: floor2_west"
class="bg-gray-800 p-2 rounded w-full"
>
</div>
<!-- TRACK BATHROOM -->
<div class="flex items-center gap-2">
<input
type="checkbox"
name="bathroom"
{% if r.bathroom %}
checked
{% endif %}
class="w-5 h-5"
>
<label>
Track Bathroom Usage
</label>
</div>
<button
class="bg-blue-700 hover:bg-blue-600 px-4 py-2 rounded w-full"
>
Save Room
</button>
</form>
</div>
{% endfor %}
</div>
</div>

View File

@@ -0,0 +1,70 @@
<div>
<h2 class="text-2xl font-bold mb-4">
Students
</h2>
<div class="grid grid-cols-3 gap-4">
{% for s in students %}
<div class="bg-gray-900 rounded-xl p-4 border border-gray-800">
<div class="flex justify-between">
<div>
<div class="text-xl font-bold">
{{ s.name }}
</div>
<div class="text-gray-400">
{{ s.uid }}
</div>
</div>
<div>
<span class="bg-blue-700 px-2 py-1 rounded">
{{ s.state }}
</span>
</div>
</div>
<div class="mt-4 text-sm space-y-1">
<div>
Current Room:
<b>{{ s.current_room }}</b>
</div>
<div>
Previous Room:
<b>{{ s.previous_room }}</b>
</div>
<div>
Expected Return:
<b>{{ s.expected_return }}</b>
</div>
</div>
<div class="mt-4 flex gap-2">
<button
hx-post="/admin/student/reset/{{ s.id }}"
hx-target="closest div"
class="bg-red-700 hover:bg-red-600 px-3 py-1 rounded"
>
Reset State
</button>
</div>
</div>
{% endfor %}
</div>
</div>

View File

@@ -0,0 +1,85 @@
<div>
<h2 class="text-2xl font-bold mb-4">
Unknown RFID Cards
</h2>
<div class="space-y-4">
{% for s in students %}
{% if s.name == "Unknown" %}
<div class="bg-gray-900 p-4 rounded-xl border border-gray-800">
<div class="font-bold text-lg">
{{ s.uid }}
</div>
<!-- ASSIGN -->
<form
hx-post="/admin/student/assign"
hx-target="#content"
class="mt-4 flex gap-2"
>
<input
type="hidden"
name="uid"
value="{{ s.uid }}"
>
<input
type="text"
name="name"
placeholder="Student Name"
class="bg-gray-800 p-2 rounded w-full"
>
<button
class="bg-green-700 px-4 rounded"
>
Assign
</button>
</form>
<!-- MERGE -->
<form
hx-post="/admin/student/merge"
hx-target="#content"
class="mt-4 flex gap-2"
>
<input
type="hidden"
name="new_uid"
value="{{ s.uid }}"
>
<input
type="text"
name="old_uid"
placeholder="Old UID"
class="bg-gray-800 p-2 rounded w-full"
>
<button
class="bg-yellow-700 px-4 rounded"
>
Merge
</button>
</form>
</div>
{% endif %}
{% endfor %}
</div>
</div>