Files
charging_station/wiki/entities/frontend.md
T

2.9 KiB

type, updated, tags
type updated tags
entity 2026-07-12
software
frontend
react

Frontend (../frontend/)

The React control panel — branded "Art IoT" by the owner (2026-07-12) — (built 2026-07-11, replacing the single-file vanilla-JS panel at the owner's request). Stack per the owner's spec: Vite + TypeScript + React 19, React Router 7 (routing), zustand (auth/UI state), TanStack Query 5 (server state, polling).

Dev / prod workflow

  • Dev: npm run dev in frontend/ → Vite on :5173, proxies /api to the backend on :9000 (vite.config.ts), so the session cookie flows normally.
  • Prod: npm run build → frontend/dist/; the backend serves it statically with an SPA fallback (exact files win, everything else gets index.html, /api/* and /docs excluded). No separate web server.
  • Fully self-contained: fonts (Archivo + IBM Plex Mono via Fontsource) are bundled into dist/ — nothing loads from a CDN, so it works over netbird without internet. ~95 kB gzipped JS.
  • ✅ Verified on the owner's phone against the live charger (2026-07-12): login, gun cards, and a real in-app remote start.

Pages

Route Who What
/ (Control) all one "bay" card per gun — every registry-declared gun always renders, even offline; status lamp, Start/Stop gated by scope and cable-plugged readiness; a charging bay shows the SoC battery gauge (red→blue→green fill), a big kW readout, delivered kWh, voltage, current, plus who/via/duration; relay toggles with on-demand live read
/account all your permissions in plain words (admin badge, or the guns/relays you may control) + self-service password change (current password required)
/history all admins: the full audit table (who charged, via Card or In-app, which gun, when, duration, kWh); everyone else: only their own sessions
/cards admin pending cards awaiting review (approve → name + owner + gun restrictions in one step; reject → silenced), enrolled cards with owner/guns editing, rejected list with un-reject
/users admin user CRUD with the permission matrix — admin toggle, per-gun and per-relay checkboxes rendered from GET /api/permissions (no raw scope strings in the UI)

An amber notification banner + nav badge appears for admins whenever unknown cards are pending (count polled via /api/status every 5 s).

Design

Instrument-panel direction grounded in the hardware: porcelain/graphite surfaces (light + dark via prefers-color-scheme), copper-busbar accent, IBM Plex Mono for telemetry/identifiers, Archivo for UI. Signature element: the indicator lamp (radial LED with glow) encoding state everywhere, in the owner-specified language (2026-07-12): gray = idle, pulsing blue = cable in the socket, green = charging, red = fault/offline banner, amber = pending cards. Reduced motion respected; keyboard focus visible.