Adapt + improve all admin pages to the new design system

Swept the whole housekeeping panel (34 pages) so it's a consistent,
improved adaptation of the old Filament admin rather than bare tables:
- Live status tiles (StatusCard) summarising each page's data — counts
  and stateful metrics (users online, active/permanent bans, pending
  applications, settings, radio shouts, etc.).
- Status pills (admin-badge ok/danger) replacing ad-hoc text: online/
  offline, account/ip ban types, permanent vs timed, command OK/FAIL,
  alert severity & read/new, enabled/disabled, open/closed.
- Sections wrapped in .admin-section with h2 headers; redundant inline
  table styling removed (the global .admin layer handles it).
- alerts/logs/emulator hand-built as the reference pattern; the rest
  via parallel agents that read the schema and preserved every server
  action, query and field name.

Behaviour unchanged (same actions, queries, field names). Verified in a
real authed admin session (prod, amx_test): pages render with live data
(Users tiles show 7 real accounts + online/offline pills), no errors.
tsc 0, vitest 49/49, next build 0.
This commit is contained in:
Simo committed 2026-06-28 19:07:48 +02:00
1 parent d419731566
commit 0de0ac6a3c
34 files changed
+2357 -1396

No files matched your search

+78 -51
View File
@@ -1,4 +1,5 @@
import { deletePermission, upsertPermission } from "@/actions/admin-housekeeping";
import { StatusCard } from "@/components/admin/dashboard";
import { prisma } from "@/lib/prisma";
export const dynamic = "force-dynamic";
@@ -15,65 +16,91 @@ export default async function AdminHousekeeping() {
permissions = [];
}
const ranks = permissions.map((p) => p.minRank);
const maxRank = ranks.length ? Math.max(...ranks) : 0;
return (
<main>
<h1>Housekeeping Permissions</h1>
<p className="muted">
<p className="muted" style={{ marginTop: "-0.4rem" }}>
Minimum rank required to access each housekeeping permission key. Saving an
existing key overwrites its min rank and description.
</p>
<form action={upsertPermission} className="card" style={{ marginBottom: "1.5rem" }}>
<h3 style={{ marginTop: 0 }}>Add / overwrite permission</h3>
<div style={{ display: "flex", gap: "0.5rem", flexWrap: "wrap" }}>
<input name="permission" placeholder="permission key" required style={{ minWidth: 200 }} />
<input name="minRank" type="number" min={0} placeholder="Min rank" required style={{ width: 110 }} />
<input name="description" placeholder="description" style={{ flex: 1, minWidth: 160 }} />
<button type="submit" className="btn btn-primary">Save</button>
</div>
</form>
<div className="admin-stats">
<StatusCard label="Permissions" value={permissions.length} icon="🔑" />
<StatusCard label="Highest min rank" value={maxRank} icon="⬆️" />
</div>
<table>
<thead>
<tr>
<th>Permission</th>
<th>Description</th>
<th style={{ width: 200 }}>Min rank</th>
<th style={{ width: 80 }} />
</tr>
</thead>
<tbody>
{permissions.map((p) => (
<tr key={String(p.id)}>
<td><strong>{p.permission}</strong></td>
<td className="muted">{p.description ?? "—"}</td>
<td>
<form action={upsertPermission} style={{ display: "flex", gap: "0.5rem" }}>
<input type="hidden" name="permission" value={p.permission} />
<input type="hidden" name="description" value={p.description ?? ""} />
<input
name="minRank"
type="number"
min={0}
defaultValue={p.minRank}
style={{ width: 90 }}
/>
<button type="submit" className="btn btn-outline">Save</button>
</form>
</td>
<td>
<form action={deletePermission}>
<input type="hidden" name="id" value={String(p.id)} />
<button type="submit" className="btn btn-danger">✕</button>
</form>
</td>
</tr>
))}
</tbody>
</table>
{permissions.length === 0 ? (
<p className="muted">No housekeeping permissions defined yet.</p>
) : null}
<section className="admin-section">
<h2>Add / overwrite permission</h2>
<form action={upsertPermission} className="card">
<div style={{ display: "flex", gap: "0.5rem", flexWrap: "wrap" }}>
<input name="permission" placeholder="permission key" required style={{ minWidth: 200 }} />
<input name="minRank" type="number" min={0} placeholder="Min rank" required style={{ width: 110 }} />
<input name="description" placeholder="description" style={{ flex: 1, minWidth: 160 }} />
<button type="submit" className="btn btn-primary">
Save
</button>
</div>
</form>
</section>
<section className="admin-section">
<h2>
Permissions <span className="admin-badge">{permissions.length}</span>
</h2>
{permissions.length === 0 ? (
<p className="muted">No housekeeping permissions defined yet.</p>
) : (
<div className="card" style={{ padding: 0, overflowX: "auto" }}>
<table>
<thead>
<tr>
<th>Permission</th>
<th>Description</th>
<th style={{ width: 200 }}>Min rank</th>
<th style={{ width: 80 }} />
</tr>
</thead>
<tbody>
{permissions.map((p) => (
<tr key={String(p.id)}>
<td>
<strong>{p.permission}</strong>
</td>
<td className="muted">{p.description ?? "—"}</td>
<td>
<form action={upsertPermission} style={{ display: "flex", gap: "0.5rem" }}>
<input type="hidden" name="permission" value={p.permission} />
<input type="hidden" name="description" value={p.description ?? ""} />
<input
name="minRank"
type="number"
min={0}
defaultValue={p.minRank}
style={{ width: 90 }}
/>
<button type="submit" className="btn btn-outline">
Save
</button>
</form>
</td>
<td>
<form action={deletePermission}>
<input type="hidden" name="id" value={String(p.id)} />
<button type="submit" className="btn btn-danger">
✕
</button>
</form>
</td>
</tr>
))}
</tbody>
</table>
</div>
)}
</section>
</main>
);
}