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:
+11
-5
@@ -43,7 +43,8 @@ CREATE TABLE IF NOT EXISTS sessions (
|
||||
meter_start REAL NOT NULL,
|
||||
meter_stop REAL,
|
||||
wh REAL,
|
||||
reason TEXT
|
||||
reason TEXT,
|
||||
method TEXT
|
||||
);
|
||||
CREATE TABLE IF NOT EXISTS samples (
|
||||
tx INTEGER NOT NULL,
|
||||
@@ -63,6 +64,10 @@ def _db():
|
||||
con = sqlite3.connect(DB_PATH)
|
||||
con.row_factory = sqlite3.Row
|
||||
con.executescript(_SCHEMA)
|
||||
# migration for dbs created before the audit column existed
|
||||
cols = [row[1] for row in con.execute("PRAGMA table_info(sessions)")]
|
||||
if "method" not in cols:
|
||||
con.execute("ALTER TABLE sessions ADD COLUMN method TEXT")
|
||||
return closing(con)
|
||||
|
||||
|
||||
@@ -89,12 +94,13 @@ def max_tx() -> int:
|
||||
|
||||
|
||||
def start_session(tx: int, cp: str, connector: int, id_tag: str, who: str,
|
||||
started: str, meter_start: float) -> None:
|
||||
started: str, meter_start: float, method: str = "unknown") -> None:
|
||||
with _db() as con, con:
|
||||
con.execute(
|
||||
"INSERT OR REPLACE INTO sessions (tx, cp, connector, id_tag, who, started, meter_start)"
|
||||
" VALUES (?, ?, ?, ?, ?, ?, ?)",
|
||||
(tx, cp, connector, id_tag, who, started, meter_start),
|
||||
"INSERT OR REPLACE INTO sessions"
|
||||
" (tx, cp, connector, id_tag, who, started, meter_start, method)"
|
||||
" VALUES (?, ?, ?, ?, ?, ?, ?, ?)",
|
||||
(tx, cp, connector, id_tag, who, started, meter_start, method),
|
||||
)
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user