feat: React control panel; pending-card review workflow; auth-method audit

Frontend rewrite (frontend/, replacing backend/static/):
- Vite + TypeScript + React 19, React Router 7, zustand, TanStack Query 5
- dev: vite proxy /api -> :9000; prod: npm run build -> dist/, served by
  the backend with SPA fallback
- pages: Control (gun bays w/ scope+readiness-gated start/stop, relays),
  History (who/via/gun/when/duration/kWh audit), Cards (pending review,
  enrolled, rejected), Users (permission checkbox matrix)
- self-contained: fonts bundled, no CDN; light/dark; reduced-motion safe

Backend:
- learn mode removed: unknown cards are always refused and queued in
  pending_cards; admin approves (name + owner + gun restrictions in one
  step) or rejects (denied_cards, silent, un-rejectable); pending count
  rides /api/status as the notification signal
- sessions record the auth method (card tap vs in-app button) for audit
- GET /api/permissions: grantable-permission catalog driving the UI matrix
- SPA static serving with path-traversal guard; 503 hint when not built

Smoke test: 54 checks incl. approve/reject round-trips over a fake charge
point and method audit assertions.
This commit is contained in:
2026-07-11 20:52:20 +02:00
parent 56c9020d9f
commit 75869364b0
41 changed files with 4057 additions and 610 deletions
+64
View File
@@ -0,0 +1,64 @@
import { FormEvent, useState } from "react";
import { api } from "../api";
import { useApp } from "../store";
import type { Me } from "../types";
export default function Login() {
const setMe = useApp((s) => s.setMe);
const [username, setUsername] = useState("");
const [password, setPassword] = useState("");
const [error, setError] = useState<string | null>(null);
const [busy, setBusy] = useState(false);
async function submit(e: FormEvent) {
e.preventDefault();
setBusy(true);
setError(null);
try {
const r = await api.post<{ user: Me }>("/login", { username, password });
setMe(r.user);
} catch (err) {
setError((err as Error).message);
} finally {
setBusy(false);
}
}
return (
<div className="login">
<form className="login__panel" onSubmit={submit}>
<div className="login__head">
<svg viewBox="0 0 100 100" className="login__mark" aria-hidden>
<path d="M55 12 L28 56 L46 56 L41 88 L72 42 L52 42 Z" />
</svg>
<h1>Charge Control</h1>
<p>Private charging backend — sign in to operate.</p>
</div>
<label className="field">
<span>Username</span>
<input
value={username}
onChange={(e) => setUsername(e.target.value)}
autoComplete="username"
autoFocus
required
/>
</label>
<label className="field">
<span>Password</span>
<input
type="password"
value={password}
onChange={(e) => setPassword(e.target.value)}
autoComplete="current-password"
required
/>
</label>
{error && <p className="field-error">{error}</p>}
<button className="btn btn--primary btn--block" disabled={busy}>
{busy ? "Signing in…" : "Sign in"}
</button>
</form>
</div>
);
}