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:
@@ -0,0 +1,368 @@
|
||||
/* ============================================================
|
||||
Charge Control — instrument-panel design system
|
||||
Surfaces like enameled switchgear, copper-busbar accent,
|
||||
indicator lamps as the signature element.
|
||||
Type: Archivo (UI) + IBM Plex Mono (telemetry & identifiers).
|
||||
============================================================ */
|
||||
|
||||
:root {
|
||||
--paper: #eef0ef; /* porcelain enamel */
|
||||
--panel: #f9faf9;
|
||||
--panel-inset: #f1f3f2;
|
||||
--ink: #1d2523; /* deep green-black, like cabinet paint */
|
||||
--ink-dim: #5d6b67;
|
||||
--line: #d8ddda;
|
||||
--copper: #b25c28; /* busbar copper — the accent */
|
||||
--copper-deep: #8f4a20;
|
||||
--live: #178a5c; /* DC-on green */
|
||||
--amber: #c07f00;
|
||||
--red: #bf3527;
|
||||
--lamp-off: #c4ccc8;
|
||||
--shadow: 0 1px 2px rgb(29 37 35 / 0.06), 0 4px 16px rgb(29 37 35 / 0.05);
|
||||
--radius: 10px;
|
||||
--font-ui: "Archivo", "Segoe UI", system-ui, sans-serif;
|
||||
--font-mono: "IBM Plex Mono", ui-monospace, Consolas, monospace;
|
||||
}
|
||||
|
||||
@media (prefers-color-scheme: dark) {
|
||||
:root {
|
||||
--paper: #131816;
|
||||
--panel: #1b211f;
|
||||
--panel-inset: #161c1a;
|
||||
--ink: #e4e9e7;
|
||||
--ink-dim: #93a09b;
|
||||
--line: #2c3531;
|
||||
--copper: #d07a3e;
|
||||
--copper-deep: #b25c28;
|
||||
--live: #2fae7c;
|
||||
--amber: #d99a1b;
|
||||
--red: #d8503f;
|
||||
--lamp-off: #39433f;
|
||||
--shadow: 0 1px 2px rgb(0 0 0 / 0.4), 0 4px 18px rgb(0 0 0 / 0.35);
|
||||
}
|
||||
}
|
||||
|
||||
* { box-sizing: border-box; margin: 0; }
|
||||
|
||||
html { color-scheme: light dark; }
|
||||
|
||||
body {
|
||||
background: var(--paper);
|
||||
color: var(--ink);
|
||||
font-family: var(--font-ui);
|
||||
font-size: 15.5px;
|
||||
line-height: 1.5;
|
||||
-webkit-font-smoothing: antialiased;
|
||||
}
|
||||
|
||||
button, input, select { font: inherit; color: inherit; }
|
||||
|
||||
:focus-visible {
|
||||
outline: 2px solid var(--copper);
|
||||
outline-offset: 2px;
|
||||
border-radius: 4px;
|
||||
}
|
||||
|
||||
.mono { font-family: var(--font-mono); font-size: 0.92em; }
|
||||
.strong { font-weight: 600; }
|
||||
.dim { color: var(--ink-dim); }
|
||||
.num { text-align: right; }
|
||||
|
||||
/* ---------- indicator lamp (signature element) ---------- */
|
||||
.lamp {
|
||||
display: inline-block;
|
||||
width: 11px; height: 11px;
|
||||
border-radius: 50%;
|
||||
background: radial-gradient(circle at 35% 30%, color-mix(in srgb, var(--lamp-off) 60%, white 25%), var(--lamp-off) 70%);
|
||||
box-shadow: inset 0 0 2px rgb(0 0 0 / 0.35);
|
||||
vertical-align: baseline;
|
||||
flex: none;
|
||||
}
|
||||
.lamp--green {
|
||||
background: radial-gradient(circle at 35% 30%, #8fe8c2, var(--live) 70%);
|
||||
box-shadow: inset 0 0 2px rgb(0 0 0 / 0.25), 0 0 8px color-mix(in srgb, var(--live) 55%, transparent);
|
||||
}
|
||||
.lamp--amber {
|
||||
background: radial-gradient(circle at 35% 30%, #ffd98a, var(--amber) 70%);
|
||||
box-shadow: inset 0 0 2px rgb(0 0 0 / 0.25), 0 0 8px color-mix(in srgb, var(--amber) 55%, transparent);
|
||||
}
|
||||
.lamp--red {
|
||||
background: radial-gradient(circle at 35% 30%, #ff9d8f, var(--red) 70%);
|
||||
box-shadow: inset 0 0 2px rgb(0 0 0 / 0.25), 0 0 8px color-mix(in srgb, var(--red) 55%, transparent);
|
||||
}
|
||||
.lamp--pulse { animation: lamp-pulse 1.6s ease-in-out infinite; }
|
||||
@keyframes lamp-pulse {
|
||||
0%, 100% { box-shadow: inset 0 0 2px rgb(0 0 0 / 0.25), 0 0 4px color-mix(in srgb, var(--live) 40%, transparent); }
|
||||
50% { box-shadow: inset 0 0 2px rgb(0 0 0 / 0.25), 0 0 14px color-mix(in srgb, var(--live) 85%, transparent); }
|
||||
}
|
||||
@media (prefers-reduced-motion: reduce) {
|
||||
.lamp--pulse { animation: none; }
|
||||
* { transition: none !important; }
|
||||
}
|
||||
|
||||
/* ---------- app shell ---------- */
|
||||
.shell { min-height: 100dvh; display: flex; flex-direction: column; }
|
||||
|
||||
.topbar {
|
||||
display: flex; align-items: center; gap: 20px;
|
||||
padding: 10px clamp(14px, 4vw, 32px);
|
||||
background: var(--panel);
|
||||
border-bottom: 1px solid var(--line);
|
||||
position: sticky; top: 0; z-index: 10;
|
||||
}
|
||||
|
||||
.brand { display: flex; align-items: center; gap: 10px; }
|
||||
.brand__mark { width: 30px; height: 30px; }
|
||||
.brand__mark path { fill: var(--copper); }
|
||||
.brand__name { display: block; font-weight: 700; letter-spacing: 0.01em; line-height: 1.15; }
|
||||
.brand__sub {
|
||||
display: block; font-family: var(--font-mono); font-size: 10.5px;
|
||||
text-transform: uppercase; letter-spacing: 0.14em; color: var(--ink-dim);
|
||||
}
|
||||
|
||||
.nav { display: flex; gap: 4px; flex: 1; overflow-x: auto; }
|
||||
.nav__link {
|
||||
display: inline-flex; align-items: center; gap: 7px;
|
||||
padding: 7px 13px;
|
||||
border-radius: 8px;
|
||||
color: var(--ink-dim);
|
||||
text-decoration: none;
|
||||
font-weight: 500;
|
||||
white-space: nowrap;
|
||||
}
|
||||
.nav__link:hover { color: var(--ink); background: var(--panel-inset); }
|
||||
.nav__link.active { color: var(--copper-deep); background: color-mix(in srgb, var(--copper) 12%, transparent); font-weight: 600; }
|
||||
|
||||
.badge {
|
||||
background: var(--amber); color: #fff;
|
||||
font-family: var(--font-mono); font-size: 11px; font-weight: 600;
|
||||
border-radius: 999px; padding: 1px 7px;
|
||||
}
|
||||
|
||||
.topbar__user { display: flex; align-items: center; gap: 10px; }
|
||||
.topbar__who { font-family: var(--font-mono); font-size: 13px; color: var(--ink-dim); }
|
||||
|
||||
.alert {
|
||||
display: flex; align-items: center; gap: 10px;
|
||||
margin: 14px clamp(14px, 4vw, 32px) 0;
|
||||
padding: 11px 16px;
|
||||
border: 1px solid color-mix(in srgb, var(--amber) 45%, var(--line));
|
||||
background: color-mix(in srgb, var(--amber) 9%, var(--panel));
|
||||
border-radius: var(--radius);
|
||||
color: var(--ink);
|
||||
text-decoration: none;
|
||||
font-weight: 500;
|
||||
}
|
||||
.alert:hover { border-color: var(--amber); }
|
||||
|
||||
.content {
|
||||
width: min(1060px, 100%);
|
||||
margin: 0 auto;
|
||||
padding: 22px clamp(14px, 4vw, 32px) 60px;
|
||||
display: flex; flex-direction: column; gap: 18px;
|
||||
}
|
||||
|
||||
.boot, .empty {
|
||||
display: flex; align-items: center; justify-content: center; gap: 10px;
|
||||
padding: 48px 20px; color: var(--ink-dim); text-align: center;
|
||||
}
|
||||
|
||||
/* ---------- login ---------- */
|
||||
.login {
|
||||
min-height: 100dvh; display: grid; place-items: center;
|
||||
padding: 20px;
|
||||
background:
|
||||
radial-gradient(800px 400px at 80% -10%, color-mix(in srgb, var(--copper) 9%, transparent), transparent),
|
||||
var(--paper);
|
||||
}
|
||||
.login__panel {
|
||||
width: min(380px, 100%);
|
||||
background: var(--panel);
|
||||
border: 1px solid var(--line);
|
||||
border-radius: 14px;
|
||||
box-shadow: var(--shadow);
|
||||
padding: 30px 28px;
|
||||
display: flex; flex-direction: column; gap: 14px;
|
||||
}
|
||||
.login__head { text-align: center; margin-bottom: 6px; }
|
||||
.login__mark { width: 44px; height: 44px; margin-bottom: 10px; }
|
||||
.login__mark path { fill: var(--copper); }
|
||||
.login__head h1 { font-size: 22px; font-weight: 700; letter-spacing: -0.01em; }
|
||||
.login__head p { color: var(--ink-dim); font-size: 13.5px; margin-top: 4px; }
|
||||
|
||||
/* ---------- panels & bays ---------- */
|
||||
.panel {
|
||||
background: var(--panel);
|
||||
border: 1px solid var(--line);
|
||||
border-radius: var(--radius);
|
||||
box-shadow: var(--shadow);
|
||||
padding: 18px 20px;
|
||||
}
|
||||
.panel--attention { border-color: color-mix(in srgb, var(--amber) 50%, var(--line)); }
|
||||
.panel--offline { display: flex; gap: 14px; align-items: center; }
|
||||
.panel--offline p { color: var(--ink-dim); font-size: 14px; }
|
||||
|
||||
.panel__head {
|
||||
display: flex; align-items: baseline; justify-content: space-between; gap: 12px;
|
||||
margin-bottom: 12px; flex-wrap: wrap;
|
||||
}
|
||||
.panel__head h2 { font-size: 16px; font-weight: 700; display: flex; align-items: center; gap: 9px; }
|
||||
.panel__meta { color: var(--ink-dim); font-size: 13px; }
|
||||
.panel__inset {
|
||||
margin-top: 14px; padding: 16px;
|
||||
background: var(--panel-inset);
|
||||
border: 1px solid var(--line);
|
||||
border-radius: 8px;
|
||||
}
|
||||
.panel__inset h3 { font-size: 14px; margin-bottom: 10px; }
|
||||
|
||||
.bays {
|
||||
display: grid; gap: 18px;
|
||||
grid-template-columns: repeat(auto-fit, minmax(290px, 1fr));
|
||||
}
|
||||
|
||||
.bay {
|
||||
background: var(--panel);
|
||||
border: 1px solid var(--line);
|
||||
border-radius: var(--radius);
|
||||
box-shadow: var(--shadow);
|
||||
padding: 18px 20px;
|
||||
display: flex; flex-direction: column; gap: 10px;
|
||||
border-top: 3px solid var(--copper);
|
||||
}
|
||||
.bay__head { display: flex; justify-content: space-between; align-items: center; }
|
||||
.bay__eyebrow {
|
||||
font-family: var(--font-mono); font-size: 11px;
|
||||
text-transform: uppercase; letter-spacing: 0.14em; color: var(--ink-dim);
|
||||
}
|
||||
.bay__title { font-size: 21px; font-weight: 700; letter-spacing: -0.01em; }
|
||||
.bay__status { display: flex; align-items: center; gap: 10px; min-height: 26px; }
|
||||
.bay__hint { color: var(--ink-dim); font-size: 13px; }
|
||||
|
||||
.bay__telemetry {
|
||||
display: flex; gap: 22px;
|
||||
padding: 10px 12px;
|
||||
background: var(--panel-inset);
|
||||
border-radius: 8px;
|
||||
}
|
||||
.bay__telemetry dt {
|
||||
font-family: var(--font-mono); font-size: 10.5px;
|
||||
text-transform: uppercase; letter-spacing: 0.12em; color: var(--ink-dim);
|
||||
}
|
||||
.bay__telemetry dd { font-weight: 600; font-size: 14px; }
|
||||
|
||||
.bay__actions { display: flex; align-items: center; gap: 12px; margin-top: 2px; }
|
||||
|
||||
/* ---------- chips ---------- */
|
||||
.chip {
|
||||
display: inline-block;
|
||||
font-family: var(--font-mono); font-size: 11.5px; font-weight: 600;
|
||||
text-transform: uppercase; letter-spacing: 0.07em;
|
||||
padding: 3px 9px; border-radius: 999px;
|
||||
background: var(--panel-inset); color: var(--ink-dim);
|
||||
border: 1px solid var(--line);
|
||||
}
|
||||
.chip--live, .chip--charging { background: color-mix(in srgb, var(--live) 14%, transparent); color: var(--live); border-color: color-mix(in srgb, var(--live) 40%, transparent); }
|
||||
.chip--preparing, .chip--finishing { background: color-mix(in srgb, var(--amber) 14%, transparent); color: var(--amber); border-color: color-mix(in srgb, var(--amber) 40%, transparent); }
|
||||
.chip--faulted, .chip--unavailable { background: color-mix(in srgb, var(--red) 12%, transparent); color: var(--red); border-color: color-mix(in srgb, var(--red) 40%, transparent); }
|
||||
.chip--card { background: color-mix(in srgb, var(--copper) 13%, transparent); color: var(--copper-deep); border-color: color-mix(in srgb, var(--copper) 40%, transparent); }
|
||||
.chip--app { background: color-mix(in srgb, var(--live) 12%, transparent); color: var(--live); border-color: color-mix(in srgb, var(--live) 35%, transparent); }
|
||||
|
||||
/* ---------- buttons ---------- */
|
||||
.btn {
|
||||
border: 1px solid transparent;
|
||||
border-radius: 8px;
|
||||
padding: 9px 18px;
|
||||
font-weight: 600;
|
||||
cursor: pointer;
|
||||
background: var(--panel-inset);
|
||||
transition: background 0.15s, border-color 0.15s, transform 0.05s;
|
||||
}
|
||||
.btn:active:not(:disabled) { transform: translateY(1px); }
|
||||
.btn:disabled { opacity: 0.45; cursor: default; }
|
||||
.btn--primary { background: var(--copper); color: #fff; }
|
||||
.btn--primary:hover:not(:disabled) { background: var(--copper-deep); }
|
||||
.btn--danger { background: var(--red); color: #fff; }
|
||||
.btn--danger:hover:not(:disabled) { background: color-mix(in srgb, var(--red) 85%, black); }
|
||||
.btn--ghost { background: transparent; border-color: var(--line); color: var(--ink); }
|
||||
.btn--ghost:hover:not(:disabled) { background: var(--panel-inset); }
|
||||
.btn--sm { padding: 5px 12px; font-size: 13.5px; }
|
||||
.btn--block { width: 100%; }
|
||||
.btn--dangertext { color: var(--red); }
|
||||
|
||||
/* ---------- forms ---------- */
|
||||
.field { display: flex; flex-direction: column; gap: 5px; }
|
||||
.field > span, .field__label {
|
||||
font-family: var(--font-mono); font-size: 11px;
|
||||
text-transform: uppercase; letter-spacing: 0.12em; color: var(--ink-dim);
|
||||
}
|
||||
.field input, .field select {
|
||||
background: var(--paper);
|
||||
border: 1px solid var(--line);
|
||||
border-radius: 8px;
|
||||
padding: 9px 12px;
|
||||
width: 100%;
|
||||
}
|
||||
.field input:focus, .field select:focus { border-color: var(--copper); outline: none; }
|
||||
.field-error { color: var(--red); font-size: 13.5px; }
|
||||
|
||||
.formrow { display: grid; gap: 12px; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); margin-bottom: 12px; }
|
||||
|
||||
.check { display: flex; align-items: center; gap: 9px; padding: 4px 0; cursor: pointer; }
|
||||
.check input { accent-color: var(--copper); width: 16px; height: 16px; }
|
||||
.check--strong { font-weight: 600; }
|
||||
|
||||
.cardform { display: flex; flex-direction: column; gap: 12px; margin-top: 12px; }
|
||||
.cardform__actions { display: flex; gap: 10px; }
|
||||
|
||||
.gunpicker, .matrix { display: flex; flex-direction: column; gap: 6px; }
|
||||
.matrix__group { margin-top: 8px; }
|
||||
|
||||
/* ---------- tables & lists ---------- */
|
||||
.table-wrap { overflow-x: auto; }
|
||||
.table { width: 100%; border-collapse: collapse; font-size: 14px; }
|
||||
.table th {
|
||||
text-align: left; padding: 8px 10px;
|
||||
font-family: var(--font-mono); font-size: 10.5px;
|
||||
text-transform: uppercase; letter-spacing: 0.12em; color: var(--ink-dim);
|
||||
border-bottom: 1px solid var(--line);
|
||||
}
|
||||
.table th.num { text-align: right; }
|
||||
.table td { padding: 9px 10px; border-bottom: 1px solid var(--line); vertical-align: middle; }
|
||||
.table tr:last-child td { border-bottom: none; }
|
||||
|
||||
.relay-list, .pending-list { list-style: none; padding: 0; display: flex; flex-direction: column; }
|
||||
.relay {
|
||||
display: flex; align-items: center; gap: 12px;
|
||||
padding: 10px 2px; border-bottom: 1px solid var(--line);
|
||||
}
|
||||
.relay:last-child { border-bottom: none; }
|
||||
.relay__label { font-weight: 600; flex: 1; min-width: 0; }
|
||||
.relay__state { font-family: var(--font-mono); font-size: 12.5px; color: var(--ink-dim); }
|
||||
|
||||
.pending { padding: 12px 2px; border-bottom: 1px solid var(--line); }
|
||||
.pending:last-child { border-bottom: none; }
|
||||
.pending__row { display: flex; justify-content: space-between; gap: 12px; align-items: center; flex-wrap: wrap; }
|
||||
.pending__meta { display: block; color: var(--ink-dim); font-size: 13px; }
|
||||
.pending__actions { display: flex; gap: 8px; }
|
||||
|
||||
/* ---------- toasts ---------- */
|
||||
.toasts {
|
||||
position: fixed; bottom: 18px; left: 50%; transform: translateX(-50%);
|
||||
display: flex; flex-direction: column; gap: 8px; z-index: 50;
|
||||
width: min(480px, calc(100vw - 28px));
|
||||
}
|
||||
.toast {
|
||||
background: var(--ink); color: var(--paper);
|
||||
border-radius: 9px; padding: 11px 16px;
|
||||
font-size: 14px; box-shadow: var(--shadow);
|
||||
}
|
||||
.toast--error { background: var(--red); color: #fff; }
|
||||
|
||||
/* ---------- responsive ---------- */
|
||||
@media (max-width: 640px) {
|
||||
.topbar { flex-wrap: wrap; row-gap: 6px; }
|
||||
.nav { order: 3; width: 100%; }
|
||||
.bay__telemetry { flex-wrap: wrap; gap: 12px 20px; }
|
||||
.content { padding-top: 14px; }
|
||||
}
|
||||
Reference in New Issue
Block a user