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:
+3
-26
@@ -1,8 +1,6 @@
|
||||
"""Durable journals: events.jsonl (everything the charger tells us) and
|
||||
seen_tags.json (unknown idTags captured in learn mode).
|
||||
|
||||
JSONL now, SQLite later — the append-only line format survives crashes and is
|
||||
trivially greppable/ingestable, which is all the current phase needs.
|
||||
"""Durable journal: events.jsonl — everything the charger tells us (and what
|
||||
we told it), one JSON line per event. Append-only, crash-safe, greppable; the
|
||||
raw ground truth behind the queryable store (store.py).
|
||||
"""
|
||||
|
||||
import json
|
||||
@@ -13,7 +11,6 @@ from typing import Optional
|
||||
|
||||
HERE = Path(__file__).resolve().parent
|
||||
EVENTS_PATH = HERE / "events.jsonl"
|
||||
SEEN_PATH = HERE / "seen_tags.json"
|
||||
|
||||
log = logging.getLogger("journal")
|
||||
|
||||
@@ -39,23 +36,3 @@ def read_events(limit: int = 100, event: Optional[str] = None) -> list:
|
||||
if event is not None:
|
||||
entries = [e for e in entries if e.get("event") == event]
|
||||
return entries[-limit:]
|
||||
|
||||
|
||||
def record_seen(id_tag: str, context: str) -> None:
|
||||
try:
|
||||
seen = json.loads(SEEN_PATH.read_text(encoding="utf-8")) if SEEN_PATH.exists() else {}
|
||||
except Exception:
|
||||
seen = {}
|
||||
entry = seen.get(id_tag, {"count": 0, "first_seen": now(), "contexts": []})
|
||||
entry["count"] += 1
|
||||
entry["last_seen"] = now()
|
||||
if context not in entry["contexts"]:
|
||||
entry["contexts"].append(context)
|
||||
seen[id_tag] = entry
|
||||
SEEN_PATH.write_text(json.dumps(seen, indent=2), encoding="utf-8")
|
||||
|
||||
|
||||
def read_seen() -> dict:
|
||||
if not SEEN_PATH.exists():
|
||||
return {}
|
||||
return json.loads(SEEN_PATH.read_text(encoding="utf-8"))
|
||||
|
||||
Reference in New Issue
Block a user