refactor: convert admin pages to Tailwind and improve media uploads; fix TypeScript error in commandocentrum

This commit is contained in:
openhands committed 2026-07-02 17:26:16 +02:00
1 parent 72ef74fc87
commit 518c072491
22 files changed
+488 -430

No files matched your search

+160 -140
View File
@@ -1,4 +1,5 @@
import os from "node:os";
import { Activity } from 'lucide-react';
import {
hotelAlert,
updateCatalog,
@@ -85,10 +86,15 @@ export default async function CommandoCentrum() {
return (
<main>
<h1>Commandocentrum</h1>
<p className="muted" style={{ marginTop: "-0.25rem" }}>
Live hotel status, diagnostics and emulator control over RCON.
</p>
<div className="flex items-center gap-3 mb-6">
<div className="w-10 h-10 rounded-xl bg-gradient-to-br from-[var(--color-primary)]/20 to-[var(--color-primary)]/5 grid place-items-center">
<Activity size={20} className="text-[var(--color-primary)]" />
</div>
<div>
<h1 className="m-0 text-xl font-extrabold text-[var(--color-text)]">Commandocentrum</h1>
<p className="m-0 text-xs text-[var(--color-text-muted)] mt-0.5">Live hotel status, diagnostics and emulator control over RCON.</p>
</div>
</div>
{/* ── Live status ────────────────────────────────────────── */}
<div className="grid grid-cols-[repeat(auto-fit,minmax(180px,1fr))] gap-3.5 mb-6" style={{ marginTop: "1.1rem" }}>
@@ -123,8 +129,8 @@ export default async function CommandoCentrum() {
</div>
{/* ── Online users widget ───────────────────────────────── */}
<section className="card" style={{ marginBottom: "1.5rem" }}>
<h2 style={{ marginTop: 0 }}>Online Users</h2>
<section className="admin-card mb-6">
<h2 className="admin-section-title">Online Users</h2>
<OnlineUsersWidget
users={[]}
isLoading={false}
@@ -133,8 +139,8 @@ export default async function CommandoCentrum() {
{/* ── Server info + diagnostics ──────────────────────────── */}
<div className="grid cols-2">
<section className="card">
<h2 style={{ marginTop: 0 }}>Server info</h2>
<section className="admin-card p-5">
<h2 className="admin-section-title">Server info</h2>
<div className="grid grid-cols-[repeat(auto-fit,minmax(150px,1fr))] gap-2.5">
<InfoItem label="Node" value={process.version} />
<InfoItem label="Platform" value={`${process.platform} ${process.arch}`} />
@@ -147,8 +153,8 @@ export default async function CommandoCentrum() {
</div>
</section>
<section className="card">
<h2 style={{ marginTop: 0 }}>System diagnostics</h2>
<section className="admin-card p-5">
<h2 className="admin-section-title">System diagnostics</h2>
<div className="flex flex-col">
<DiagnosticRow
label="Database"
@@ -184,13 +190,12 @@ export default async function CommandoCentrum() {
</section>
</div>
{/* ── RCON controls ──────────────────────────────────────── */}
<section className="mt-6">
<h2>Emulator controls</h2>
<div className="grid cols-3">
<form action={updateCatalog} className="card">
<h3 style={{ marginTop: 0 }}>Update catalog</h3>
<p className="muted" style={{ margin: "0 0 0.85rem" }}>
<h2 className="admin-section-title">Emulator controls</h2>
<div className="grid grid-cols-1 sm:grid-cols-3 gap-4">
<form action={updateCatalog} className="admin-card">
<h3 className="text-sm font-bold text-[var(--color-text)] mb-2">Update catalog</h3>
<p className="text-xs text-[var(--color-text-muted)] mb-4">
Reload catalog pages and items on the live server.
</p>
<button type="submit" className="btn btn-primary">
@@ -198,9 +203,9 @@ export default async function CommandoCentrum() {
</button>
</form>
<form action={updateWordFilter} className="card">
<h3 style={{ marginTop: 0 }}>Update word filter</h3>
<p className="muted" style={{ margin: "0 0 0.85rem" }}>
<form action={updateWordFilter} className="admin-card">
<h3 className="text-sm font-bold text-[var(--color-text)] mb-2">Update word filter</h3>
<p className="text-xs text-[var(--color-text-muted)] mb-4">
Reload the chat word filter from the database.
</p>
<button type="submit" className="btn btn-primary">
@@ -208,9 +213,9 @@ export default async function CommandoCentrum() {
</button>
</form>
<form action={updateNavigator} className="card">
<h3 style={{ marginTop: 0 }}>Update navigator</h3>
<p className="muted" style={{ margin: "0 0 0.85rem" }}>
<form action={updateNavigator} className="admin-card">
<h3 className="text-sm font-bold text-[var(--color-text)] mb-2">Update navigator</h3>
<p className="text-xs text-[var(--color-text-muted)] mb-4">
Reload navigator categories and room listings.
</p>
<button type="submit" className="btn btn-primary">
@@ -219,18 +224,18 @@ export default async function CommandoCentrum() {
</form>
</div>
<form action={hotelAlert} className="card" style={{ marginTop: "1rem" }}>
<h3 style={{ marginTop: 0 }}>Hotel alert</h3>
<p className="muted" style={{ margin: "0 0 0.75rem" }}>
<form action={hotelAlert} className="admin-card mt-6">
<h3 className="text-sm font-bold text-[var(--color-text)] mb-2">Hotel alert</h3>
<p className="text-xs text-[var(--color-text-muted)] mb-3">
Broadcast a message to every connected user.
</p>
<div style={{ display: "flex", gap: "0.5rem", flexWrap: "wrap" }}>
<div className="flex gap-2">
<input
name="message"
required
maxLength={512}
placeholder="Message to broadcast…"
style={{ flex: 1, minWidth: 220 }}
className="flex-1 min-w-[220px]"
/>
<button type="submit" className="btn btn-danger">
Send alert
@@ -241,149 +246,173 @@ export default async function CommandoCentrum() {
{/* ── User RCON actions ──────────────────────────────────── */}
<section className="mt-6">
<h2>User actions (RCON)</h2>
<p className="muted" style={{ marginTop: "-0.4rem" }}>
<h2 className="admin-section-title">User actions (RCON)</h2>
<p className="text-xs text-[var(--color-text-muted)] mb-4">
Enter a User ID to perform actions on a specific user. Username required for disconnect.
</p>
<div className="grid cols-3">
<form action={disconnectUser} className="card">
<h3 style={{ marginTop: 0 }}>Disconnect / Kick</h3>
<p className="muted" style={{ margin: "0 0 0.75rem" }}>Force disconnect a user.</p>
<input name="userId" type="number" min={1} placeholder="User ID" required style={{ width: "100%", marginBottom: "0.5rem" }} />
<input name="username" type="text" placeholder="Username (required)" required style={{ width: "100%", marginBottom: "0.75rem" }} />
<button type="submit" className="btn btn-danger">Disconnect user</button>
<div className="grid grid-cols-1 sm:grid-cols-3 gap-4">
<form action={disconnectUser} className="admin-card">
<h3 className="text-sm font-bold text-[var(--color-text)] mb-2">Disconnect / Kick</h3>
<p className="text-xs text-[var(--color-text-muted)] mb-3">Force disconnect a user.</p>
<div className="space-y-2">
<input name="userId" type="number" min={1} placeholder="User ID" required className="w-full" />
<input name="username" type="text" placeholder="Username (required)" required className="w-full" />
<button type="submit" className="btn btn-danger w-full">Disconnect user</button>
</div>
</form>
<form action={alertUser} className="card">
<h3 style={{ marginTop: 0 }}>Alert user</h3>
<p className="muted" style={{ margin: "0 0 0.75rem" }}>Send a popup alert to a user.</p>
<input name="userId" type="number" min={1} placeholder="User ID" required style={{ width: "100%", marginBottom: "0.5rem" }} />
<input name="message" type="text" placeholder="Alert message" required maxLength={512} style={{ width: "100%", marginBottom: "0.75rem" }} />
<button type="submit" className="btn btn-primary">Send alert</button>
<form action={alertUser} className="admin-card">
<h3 className="text-sm font-bold text-[var(--color-text)] mb-2">Alert user</h3>
<p className="text-xs text-[var(--color-text-muted)] mb-3">Send a popup alert to a user.</p>
<div className="space-y-2">
<input name="userId" type="number" min={1} placeholder="User ID" required className="w-full" />
<input name="message" type="text" placeholder="Alert message" required maxLength={512} className="w-full" />
<button type="submit" className="btn btn-primary w-full">Send alert</button>
</div>
</form>
<form action={forwardUser} className="card">
<h3 style={{ marginTop: 0 }}>Forward to room</h3>
<p className="muted" style={{ margin: "0 0 0.75rem" }}>Teleport user to a room ID.</p>
<input name="userId" type="number" min={1} placeholder="User ID" required style={{ width: "100%", marginBottom: "0.5rem" }} />
<input name="roomId" type="number" min={1} placeholder="Room ID" required style={{ width: "100%", marginBottom: "0.75rem" }} />
<button type="submit" className="btn btn-primary">Forward user</button>
<form action={forwardUser} className="admin-card">
<h3 className="text-sm font-bold text-[var(--color-text)] mb-2">Forward to room</h3>
<p className="text-xs text-[var(--color-text-muted)] mb-3">Teleport user to a room ID.</p>
<div className="space-y-2">
<input name="userId" type="number" min={1} placeholder="User ID" required className="w-full" />
<input name="roomId" type="number" min={1} placeholder="Room ID" required className="w-full" />
<button type="submit" className="btn btn-primary w-full">Forward user</button>
</div>
</form>
</div>
<div className="grid cols-3" style={{ marginTop: "1rem" }}>
<form action={giveCredits} className="card">
<h3 style={{ marginTop: 0 }}>Give credits</h3>
<p className="muted" style={{ margin: "0 0 0.75rem" }}>Add credits to a user.</p>
<input name="userId" type="number" min={1} placeholder="User ID" required style={{ width: "100%", marginBottom: "0.5rem" }} />
<input name="credits" type="number" min={1} placeholder="Amount" required style={{ width: "100%", marginBottom: "0.75rem" }} />
<button type="submit" className="btn btn-primary">Give credits</button>
<div className="grid grid-cols-1 sm:grid-cols-3 gap-4 mt-4">
<form action={giveCredits} className="admin-card">
<h3 className="text-sm font-bold text-[var(--color-text)] mb-2">Give credits</h3>
<p className="text-xs text-[var(--color-text-muted)] mb-3">Add credits to a user.</p>
<div className="space-y-2">
<input name="userId" type="number" min={1} placeholder="User ID" required className="w-full" />
<input name="credits" type="number" min={1} placeholder="Amount" required className="w-full" />
<button type="submit" className="btn btn-primary w-full">Give credits</button>
</div>
</form>
<form action={giveDuckets} className="card">
<h3 style={{ marginTop: 0 }}>Give duckets</h3>
<p className="muted" style={{ margin: "0 0 0.75rem" }}>Add duckets to a user.</p>
<input name="userId" type="number" min={1} placeholder="User ID" required style={{ width: "100%", marginBottom: "0.5rem" }} />
<input name="amount" type="number" min={1} placeholder="Amount" required style={{ width: "100%", marginBottom: "0.75rem" }} />
<button type="submit" className="btn btn-primary">Give duckets</button>
<form action={giveDuckets} className="admin-card">
<h3 className="text-sm font-bold text-[var(--color-text)] mb-2">Give duckets</h3>
<p className="text-xs text-[var(--color-text-muted)] mb-3">Add duckets to a user.</p>
<div className="space-y-2">
<input name="userId" type="number" min={1} placeholder="User ID" required className="w-full" />
<input name="amount" type="number" min={1} placeholder="Amount" required className="w-full" />
<button type="submit" className="btn btn-primary w-full">Give duckets</button>
</div>
</form>
<form action={giveDiamonds} className="card">
<h3 style={{ marginTop: 0 }}>Give diamonds</h3>
<p className="muted" style={{ margin: "0 0 0.75rem" }}>Add diamonds to a user.</p>
<input name="userId" type="number" min={1} placeholder="User ID" required style={{ width: "100%", marginBottom: "0.5rem" }} />
<input name="amount" type="number" min={1} placeholder="Amount" required style={{ width: "100%", marginBottom: "0.75rem" }} />
<button type="submit" className="btn btn-primary">Give diamonds</button>
<form action={giveDiamonds} className="admin-card">
<h3 className="text-sm font-bold text-[var(--color-text)] mb-2">Give diamonds</h3>
<p className="text-xs text-[var(--color-text-muted)] mb-3">Add diamonds to a user.</p>
<div className="space-y-2">
<input name="userId" type="number" min={1} placeholder="User ID" required className="w-full" />
<input name="amount" type="number" min={1} placeholder="Amount" required className="w-full" />
<button type="submit" className="btn btn-primary w-full">Give diamonds</button>
</div>
</form>
</div>
<div className="grid cols-3" style={{ marginTop: "1rem" }}>
<form action={giveBadge} className="card">
<h3 style={{ marginTop: 0 }}>Give badge</h3>
<p className="muted" style={{ margin: "0 0 0.75rem" }}>Give a badge code (e.g. HOF1).</p>
<input name="userId" type="number" min={1} placeholder="User ID" required style={{ width: "100%", marginBottom: "0.5rem" }} />
<input name="badge" type="text" placeholder="Badge code" required maxLength={32} style={{ width: "100%", marginBottom: "0.75rem" }} />
<button type="submit" className="btn btn-primary">Give badge</button>
<div className="grid grid-cols-1 sm:grid-cols-3 gap-4 mt-4">
<form action={giveBadge} className="admin-card">
<h3 className="text-sm font-bold text-[var(--color-text)] mb-2">Give badge</h3>
<p className="text-xs text-[var(--color-text-muted)] mb-3">Give a badge code (e.g. HOF1).</p>
<div className="space-y-2">
<input name="userId" type="number" min={1} placeholder="User ID" required className="w-full" />
<input name="badge" type="text" placeholder="Badge code" required maxLength={32} className="w-full" />
<button type="submit" className="btn btn-primary w-full">Give badge</button>
</div>
</form>
<form action={setMotto} className="card">
<h3 style={{ marginTop: 0 }}>Set motto</h3>
<p className="muted" style={{ margin: "0 0 0.75rem" }}>Change user's motto (max 127 chars).</p>
<input name="userId" type="number" min={1} placeholder="User ID" required style={{ width: "100%", marginBottom: "0.5rem" }} />
<input name="motto" type="text" placeholder="New motto" required maxLength={127} style={{ width: "100%", marginBottom: "0.75rem" }} />
<button type="submit" className="btn btn-primary">Set motto</button>
<form action={setMotto} className="admin-card">
<h3 className="text-sm font-bold text-[var(--color-text)] mb-2">Set motto</h3>
<p className="text-xs text-[var(--color-text-muted)] mb-3">Change user's motto (max 127 chars).</p>
<div className="space-y-2">
<input name="userId" type="number" min={1} placeholder="User ID" required className="w-full" />
<input name="motto" type="text" placeholder="New motto" required maxLength={127} className="w-full" />
<button type="submit" className="btn btn-primary w-full">Set motto</button>
</div>
</form>
<form action={setRank} className="card">
<h3 style={{ marginTop: 0 }}>Set rank</h3>
<p className="muted" style={{ margin: "0 0 0.75rem" }}>Change user rank (0–10).</p>
<input name="userId" type="number" min={1} placeholder="User ID" required style={{ width: "100%", marginBottom: "0.5rem" }} />
<input name="rank" type="number" min={0} max={10} placeholder="Rank (0–10)" required style={{ width: "100%", marginBottom: "0.75rem" }} />
<button type="submit" className="btn btn-primary">Set rank</button>
<form action={setRank} className="admin-card">
<h3 className="text-sm font-bold text-[var(--color-text)] mb-2">Set rank</h3>
<p className="text-xs text-[var(--color-text-muted)] mb-3">Change user rank (0–10).</p>
<div className="space-y-2">
<input name="userId" type="number" min={1} placeholder="User ID" required className="w-full" />
<input name="rank" type="number" min={0} max={10} placeholder="Rank (0–10)" required className="w-full" />
<button type="submit" className="btn btn-primary w-full">Set rank</button>
</div>
</form>
</div>
<div className="grid cols-3" style={{ marginTop: "1rem" }}>
<form action={executeCommand} className="card">
<h3 style={{ marginTop: 0 }}>Execute command</h3>
<p className="muted" style={{ margin: "0 0 0.75rem" }}>Run a chat command as the user.</p>
<input name="userId" type="number" min={1} placeholder="User ID" required style={{ width: "100%", marginBottom: "0.5rem" }} />
<input name="command" type="text" placeholder="Command (e.g. :pickall)" required maxLength={100} style={{ width: "100%", marginBottom: "0.75rem" }} />
<button type="submit" className="btn btn-primary">Execute</button>
<div className="grid grid-cols-1 sm:grid-cols-3 gap-4 mt-4">
<form action={executeCommand} className="admin-card">
<h3 className="text-sm font-bold text-[var(--color-text)] mb-2">Execute command</h3>
<p className="text-xs text-[var(--color-text-muted)] mb-3">Run a chat command as the user.</p>
<div className="space-y-2">
<input name="userId" type="number" min={1} placeholder="User ID" required className="w-full" />
<input name="command" type="text" placeholder="Command (e.g. :pickall)" required maxLength={100} className="w-full" />
<button type="submit" className="btn btn-primary w-full">Execute</button>
</div>
</form>
<form action={sendGift} className="card">
<h3 style={{ marginTop: 0 }}>Send gift</h3>
<p className="muted" style={{ margin: "0 0 0.75rem" }}>Send a furniture item as gift.</p>
<input name="userId" type="number" min={1} placeholder="User ID" required style={{ width: "100%", marginBottom: "0.5rem" }} />
<input name="itemId" type="number" min={1} placeholder="Furni ID" required style={{ width: "100%", marginBottom: "0.5rem" }} />
<input name="message" type="text" placeholder="Gift message" maxLength={255} defaultValue="Here is a gift." style={{ width: "100%", marginBottom: "0.75rem" }} />
<button type="submit" className="btn btn-primary">Send gift</button>
<form action={sendGift} className="admin-card">
<h3 className="text-sm font-bold text-[var(--color-text)] mb-2">Send gift</h3>
<p className="text-xs text-[var(--color-text-muted)] mb-3">Send a furniture item as gift.</p>
<div className="space-y-2">
<input name="userId" type="number" min={1} placeholder="User ID" required className="w-full" />
<input name="itemId" type="number" min={1} placeholder="Furni ID" required className="w-full" />
<input name="message" type="text" placeholder="Gift message" maxLength={255} defaultValue="Here is a gift." className="w-full" />
<button type="submit" className="btn btn-primary w-full">Send gift</button>
</div>
</form>
</div>
</section>
{/* ── Staff activity ─────────────────────────────────────── */}
<section className="mt-6">
<h2>Recent staff activity</h2>
<h2 className="admin-section-title">Recent staff activity</h2>
{activity.length === 0 ? (
<p className="muted">No staff activity logged yet.</p>
<div className="admin-empty">No staff activity logged yet.</div>
) : (
<table>
<thead>
<tr>
<th>When</th>
<th>Staff</th>
<th>Action</th>
<th>Description</th>
</tr>
</thead>
<tbody>
{activity.map((a) => (
<tr key={String(a.id)}>
<td className="muted" style={{ whiteSpace: "nowrap" }}>
{fromDate(a.createdAt)}
</td>
<td>{nameById.get(Number(a.userId)) ?? `#${a.userId}`}</td>
<td>
<span className="inline-block text-[0.72rem] font-bold px-2 py-0.5 rounded-full bg-[var(--color-primary)]/18 text-[var(--color-text)]">{a.action}</span>
</td>
<td>{a.description}</td>
<div className="admin-card overflow-x-auto">
<table>
<thead>
<tr>
<th>When</th>
<th>Staff</th>
<th>Action</th>
<th>Description</th>
</tr>
))}
</tbody>
</table>
</thead>
<tbody>
{activity.map((a) => (
<tr key={String(a.id)}>
<td className="text-sm text-gray-500 dark:text-gray-400 whitespace-nowrap">
{fromDate(a.createdAt)}
</td>
<td>{nameById.get(Number(a.userId)) ?? `#${a.userId}`}</td>
<td>
<span className="inline-block text-[0.6rem] font-bold px-2 py-0.5 rounded-full bg-[var(--color-primary)]/18 text-[var(--color-text)]">{a.action}</span>
</td>
<td className="text-sm text-gray-500 dark:text-gray-400">{a.description}</td>
</tr>
))}
</tbody>
</table>
</div>
)}
</section>
{/* ── Emulator errors ────────────────────────────────────── */}
<section className="mt-6">
<h2>Recent emulator errors</h2>
<h2 className="admin-section-title">Recent emulator errors</h2>
{errors.length === 0 ? (
<p className="muted">No emulator errors logged.</p>
<div className="admin-empty">No emulator errors logged.</div>
) : (
<div className="card" style={{ overflowX: "auto" }}>
<div className="admin-card overflow-x-auto">
<table>
<thead>
<tr>
@@ -398,24 +427,15 @@ export default async function CommandoCentrum() {
const trace = decodeStacktrace(e.stacktrace);
return (
<tr key={e.id}>
<td className="muted" style={{ whiteSpace: "nowrap" }}>
<td className="text-sm text-gray-500 dark:text-gray-400 whitespace-nowrap">
{formatTimestamp(e.timestamp)}
</td>
<td>{e.type}</td>
<td className="muted" style={{ whiteSpace: "nowrap" }}>
<td className="text-sm text-gray-500 dark:text-gray-400 whitespace-nowrap">
{e.version}
</td>
<td>
<pre
style={{
margin: 0,
maxHeight: 160,
overflow: "auto",
fontSize: "0.75rem",
whiteSpace: "pre-wrap",
wordBreak: "break-word",
}}
>
<pre className="text-xs p-2 bg-gray-50 dark:bg-black/20 rounded overflow-auto max-h-[160px]">
{trace || "(empty)"}
</pre>
</td>