feat(frontend): always-visible gun bays, idle/plugged/charging lamp language, self-service password
- Control renders every gun declared in the chargers registry, even when the charger is offline or has not reported that connector yet (state shows Offline / No status yet in gray) - owner-specified state language: gray = idle, pulsing blue = cable in the socket (Preparing), green = charging; suspended/finishing = steady blue; fault = red - POST /api/me/password (requires current password) + /account page, username in the topbar links to it - smoke test: 58 checks (password change round-trip incl. old-password invalidation)
This commit is contained in:
@@ -107,6 +107,27 @@ async def me(user: dict = Depends(current_user)):
|
|||||||
return users.public_view(user["name"], user)
|
return users.public_view(user["name"], user)
|
||||||
|
|
||||||
|
|
||||||
|
class PasswordBody(BaseModel):
|
||||||
|
current_password: str
|
||||||
|
new_password: str
|
||||||
|
|
||||||
|
|
||||||
|
@router.post("/me/password")
|
||||||
|
async def change_own_password(body: PasswordBody, user: dict = Depends(current_user)):
|
||||||
|
"""Self-service password change — requires the current password.
|
||||||
|
(Admins can still reset anyone's via PUT /api/users/<name>.)"""
|
||||||
|
entry = CONFIG["users"].get(user["name"])
|
||||||
|
if entry is None:
|
||||||
|
raise HTTPException(409, "no user account — the API is in open mode")
|
||||||
|
if not users.verify_password(body.current_password, entry.get("password", "")):
|
||||||
|
raise HTTPException(403, "current password is wrong")
|
||||||
|
if len(body.new_password) < 4:
|
||||||
|
raise HTTPException(400, "new password must be at least 4 characters")
|
||||||
|
users.set_user(user["name"], password=body.new_password)
|
||||||
|
log.info("password changed by %r", user["name"])
|
||||||
|
return {"changed": True}
|
||||||
|
|
||||||
|
|
||||||
# ---- status & journals ----
|
# ---- status & journals ----
|
||||||
@router.get("/status")
|
@router.get("/status")
|
||||||
async def api_status(user: dict = Depends(current_user)):
|
async def api_status(user: dict = Depends(current_user)):
|
||||||
|
|||||||
@@ -9,6 +9,7 @@ import Dashboard from "./pages/Dashboard";
|
|||||||
import History from "./pages/History";
|
import History from "./pages/History";
|
||||||
import Cards from "./pages/Cards";
|
import Cards from "./pages/Cards";
|
||||||
import Users from "./pages/Users";
|
import Users from "./pages/Users";
|
||||||
|
import Account from "./pages/Account";
|
||||||
|
|
||||||
export default function App() {
|
export default function App() {
|
||||||
const { me, authChecked, setMe } = useApp();
|
const { me, authChecked, setMe } = useApp();
|
||||||
@@ -46,6 +47,7 @@ export default function App() {
|
|||||||
<Route element={<Layout />}>
|
<Route element={<Layout />}>
|
||||||
<Route path="/" element={<Dashboard />} />
|
<Route path="/" element={<Dashboard />} />
|
||||||
<Route path="/history" element={<History />} />
|
<Route path="/history" element={<History />} />
|
||||||
|
<Route path="/account" element={<Account />} />
|
||||||
{admin && <Route path="/cards" element={<Cards />} />}
|
{admin && <Route path="/cards" element={<Cards />} />}
|
||||||
{admin && <Route path="/users" element={<Users />} />}
|
{admin && <Route path="/users" element={<Users />} />}
|
||||||
<Route path="*" element={<Navigate to="/" replace state={{ from: location }} />} />
|
<Route path="*" element={<Navigate to="/" replace state={{ from: location }} />} />
|
||||||
|
|||||||
@@ -1,13 +1,15 @@
|
|||||||
/** The signature element: a physical indicator lamp, like the ones on the
|
/** The signature element: a physical indicator lamp, like the ones on the
|
||||||
* charger cabinet itself. Tone encodes state everywhere in the app. */
|
* charger cabinet itself. Owner-specified state language:
|
||||||
export type LampTone = "off" | "green" | "amber" | "red" | "pulse";
|
* gray = idle · pulsing blue = cable plugged · green = charging · red = fault */
|
||||||
|
export type LampTone = "off" | "green" | "blue" | "bluepulse" | "amber" | "red";
|
||||||
|
|
||||||
const TONE_CLASS: Record<LampTone, string> = {
|
const TONE_CLASS: Record<LampTone, string> = {
|
||||||
off: "lamp",
|
off: "lamp",
|
||||||
green: "lamp lamp--green",
|
green: "lamp lamp--green",
|
||||||
|
blue: "lamp lamp--blue",
|
||||||
|
bluepulse: "lamp lamp--blue lamp--pulse-blue",
|
||||||
amber: "lamp lamp--amber",
|
amber: "lamp lamp--amber",
|
||||||
red: "lamp lamp--red",
|
red: "lamp lamp--red",
|
||||||
pulse: "lamp lamp--green lamp--pulse",
|
|
||||||
};
|
};
|
||||||
|
|
||||||
export function Lamp({ tone, title }: { tone: LampTone; title?: string }) {
|
export function Lamp({ tone, title }: { tone: LampTone; title?: string }) {
|
||||||
@@ -15,20 +17,20 @@ export function Lamp({ tone, title }: { tone: LampTone; title?: string }) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export function statusTone(ocppStatus: string, charging: boolean): LampTone {
|
export function statusTone(ocppStatus: string, charging: boolean): LampTone {
|
||||||
if (charging) return "pulse";
|
if (charging || ocppStatus === "Charging") return "green";
|
||||||
switch (ocppStatus) {
|
switch (ocppStatus) {
|
||||||
case "Charging":
|
|
||||||
return "pulse";
|
|
||||||
case "Preparing":
|
case "Preparing":
|
||||||
|
return "bluepulse"; // cable in the socket, waiting to start
|
||||||
|
case "SuspendedEV":
|
||||||
|
case "SuspendedEVSE":
|
||||||
case "Finishing":
|
case "Finishing":
|
||||||
|
return "blue"; // still plugged, not delivering
|
||||||
case "Reserved":
|
case "Reserved":
|
||||||
return "amber";
|
return "amber";
|
||||||
case "Available":
|
|
||||||
return "green";
|
|
||||||
case "Faulted":
|
case "Faulted":
|
||||||
case "Unavailable":
|
case "Unavailable":
|
||||||
return "red";
|
return "red";
|
||||||
default:
|
default:
|
||||||
return "off";
|
return "off"; // Available (idle), Offline, no status yet
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -55,7 +55,9 @@ export default function Layout() {
|
|||||||
))}
|
))}
|
||||||
</nav>
|
</nav>
|
||||||
<div className="topbar__user">
|
<div className="topbar__user">
|
||||||
<span className="topbar__who">{me?.name}</span>
|
<NavLink to="/account" className="topbar__who" title="Account settings">
|
||||||
|
{me?.name}
|
||||||
|
</NavLink>
|
||||||
<button className="btn btn--ghost btn--sm" onClick={logout}>
|
<button className="btn btn--ghost btn--sm" onClick={logout}>
|
||||||
Log out
|
Log out
|
||||||
</button>
|
</button>
|
||||||
|
|||||||
@@ -0,0 +1,79 @@
|
|||||||
|
import { FormEvent, useState } from "react";
|
||||||
|
import { api } from "../api";
|
||||||
|
import { useApp } from "../store";
|
||||||
|
|
||||||
|
export default function Account() {
|
||||||
|
const me = useApp((s) => s.me)!;
|
||||||
|
const toast = useApp((s) => s.toast);
|
||||||
|
const [current, setCurrent] = useState("");
|
||||||
|
const [next, setNext] = useState("");
|
||||||
|
const [repeat, setRepeat] = useState("");
|
||||||
|
const [busy, setBusy] = useState(false);
|
||||||
|
|
||||||
|
async function submit(e: FormEvent) {
|
||||||
|
e.preventDefault();
|
||||||
|
if (next !== repeat) {
|
||||||
|
toast("New passwords do not match", "error");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
setBusy(true);
|
||||||
|
try {
|
||||||
|
await api.post("/me/password", { current_password: current, new_password: next });
|
||||||
|
toast("Password changed");
|
||||||
|
setCurrent("");
|
||||||
|
setNext("");
|
||||||
|
setRepeat("");
|
||||||
|
} catch (err) {
|
||||||
|
toast((err as Error).message, "error");
|
||||||
|
} finally {
|
||||||
|
setBusy(false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return (
|
||||||
|
<section className="panel" style={{ maxWidth: 440 }}>
|
||||||
|
<header className="panel__head">
|
||||||
|
<h2>Account</h2>
|
||||||
|
<span className="panel__meta mono">{me.name}</span>
|
||||||
|
</header>
|
||||||
|
<form onSubmit={submit} className="cardform" style={{ marginTop: 0 }}>
|
||||||
|
<label className="field">
|
||||||
|
<span>Current password</span>
|
||||||
|
<input
|
||||||
|
type="password"
|
||||||
|
value={current}
|
||||||
|
onChange={(e) => setCurrent(e.target.value)}
|
||||||
|
autoComplete="current-password"
|
||||||
|
required
|
||||||
|
/>
|
||||||
|
</label>
|
||||||
|
<label className="field">
|
||||||
|
<span>New password</span>
|
||||||
|
<input
|
||||||
|
type="password"
|
||||||
|
value={next}
|
||||||
|
onChange={(e) => setNext(e.target.value)}
|
||||||
|
autoComplete="new-password"
|
||||||
|
required
|
||||||
|
minLength={4}
|
||||||
|
/>
|
||||||
|
</label>
|
||||||
|
<label className="field">
|
||||||
|
<span>Repeat new password</span>
|
||||||
|
<input
|
||||||
|
type="password"
|
||||||
|
value={repeat}
|
||||||
|
onChange={(e) => setRepeat(e.target.value)}
|
||||||
|
autoComplete="new-password"
|
||||||
|
required
|
||||||
|
/>
|
||||||
|
</label>
|
||||||
|
<div className="cardform__actions">
|
||||||
|
<button className="btn btn--primary" disabled={busy}>
|
||||||
|
{busy ? "Changing…" : "Change password"}
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
</form>
|
||||||
|
</section>
|
||||||
|
);
|
||||||
|
}
|
||||||
@@ -14,31 +14,80 @@ interface Gun {
|
|||||||
connector: number;
|
connector: number;
|
||||||
label: string;
|
label: string;
|
||||||
chargerLabel: string;
|
chargerLabel: string;
|
||||||
ocppStatus: string;
|
ocppStatus: string; // OCPP status, or "Offline" / "NoStatus" synthesized here
|
||||||
tx: (ActiveTx & { txId: string }) | null;
|
tx: (ActiveTx & { txId: string }) | null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** Every gun the system knows about is ALWAYS shown: the chargers registry
|
||||||
|
* defines the cards, live connector reports and transactions overlay state. */
|
||||||
function gunsFrom(status: Status): Gun[] {
|
function gunsFrom(status: Status): Gun[] {
|
||||||
const txByGun = new Map<string, ActiveTx & { txId: string }>();
|
const guns = new Map<string, Gun>();
|
||||||
for (const [txId, tx] of Object.entries(status.active_transactions))
|
|
||||||
txByGun.set(`${tx.cp}/${tx.connector}`, { ...tx, txId });
|
|
||||||
|
|
||||||
return Object.entries(status.connectors)
|
for (const [cp, meta] of Object.entries(status.chargers)) {
|
||||||
.map(([key, ocppStatus]) => {
|
const online = cp in status.connected;
|
||||||
const [cp, conn] = [key.slice(0, key.lastIndexOf("/")), key.slice(key.lastIndexOf("/") + 1)];
|
for (const [conn, label] of Object.entries(meta.guns ?? {})) {
|
||||||
return { cp, connector: Number(conn), ocppStatus };
|
guns.set(`${cp}/${conn}`, {
|
||||||
})
|
cp,
|
||||||
.filter((g) => g.connector > 0)
|
connector: Number(conn),
|
||||||
.sort((a, b) => a.cp.localeCompare(b.cp) || a.connector - b.connector)
|
label,
|
||||||
.map((g) => {
|
chargerLabel: meta.label ?? cp,
|
||||||
const meta = status.chargers[g.cp] ?? {};
|
ocppStatus: online ? "NoStatus" : "Offline",
|
||||||
return {
|
tx: null,
|
||||||
...g,
|
});
|
||||||
label: meta.guns?.[String(g.connector)] ?? `Gun ${g.connector}`,
|
}
|
||||||
chargerLabel: meta.label ?? g.cp,
|
}
|
||||||
tx: txByGun.get(`${g.cp}/${g.connector}`) ?? null,
|
|
||||||
};
|
for (const [key, ocppStatus] of Object.entries(status.connectors)) {
|
||||||
});
|
const cp = key.slice(0, key.lastIndexOf("/"));
|
||||||
|
const connector = Number(key.slice(key.lastIndexOf("/") + 1));
|
||||||
|
if (connector <= 0) continue; // connector 0 = the whole charge point
|
||||||
|
const existing = guns.get(`${cp}/${connector}`);
|
||||||
|
if (existing) existing.ocppStatus = ocppStatus;
|
||||||
|
else
|
||||||
|
guns.set(`${cp}/${connector}`, {
|
||||||
|
cp,
|
||||||
|
connector,
|
||||||
|
label: `Gun ${connector}`,
|
||||||
|
chargerLabel: status.chargers[cp]?.label ?? cp,
|
||||||
|
ocppStatus,
|
||||||
|
tx: null,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
for (const [txId, tx] of Object.entries(status.active_transactions)) {
|
||||||
|
const gun = guns.get(`${tx.cp}/${tx.connector}`);
|
||||||
|
if (gun) gun.tx = { ...tx, txId };
|
||||||
|
}
|
||||||
|
|
||||||
|
return [...guns.values()].sort(
|
||||||
|
(a, b) => a.cp.localeCompare(b.cp) || a.connector - b.connector,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Chip text + tone per the owner's state language. */
|
||||||
|
function gunState(gun: Gun): { label: string; cls: string } {
|
||||||
|
if (gun.tx) return { label: "Charging", cls: "charging" };
|
||||||
|
switch (gun.ocppStatus) {
|
||||||
|
case "Charging":
|
||||||
|
return { label: "Charging", cls: "charging" };
|
||||||
|
case "Preparing":
|
||||||
|
return { label: "Plugged in", cls: "plugged" };
|
||||||
|
case "SuspendedEV":
|
||||||
|
case "SuspendedEVSE":
|
||||||
|
return { label: "Paused", cls: "plugged" };
|
||||||
|
case "Finishing":
|
||||||
|
return { label: "Finishing", cls: "plugged" };
|
||||||
|
case "Available":
|
||||||
|
return { label: "Idle", cls: "idle" };
|
||||||
|
case "Offline":
|
||||||
|
return { label: "Offline", cls: "offline" };
|
||||||
|
case "NoStatus":
|
||||||
|
return { label: "No status yet", cls: "offline" };
|
||||||
|
case "Faulted":
|
||||||
|
return { label: "Fault", cls: "faulted" };
|
||||||
|
default:
|
||||||
|
return { label: gun.ocppStatus, cls: "idle" };
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function GunBay({ gun, scopes }: { gun: Gun; scopes: string[] }) {
|
function GunBay({ gun, scopes }: { gun: Gun; scopes: string[] }) {
|
||||||
@@ -60,19 +109,18 @@ function GunBay({ gun, scopes }: { gun: Gun; scopes: string[] }) {
|
|||||||
(r) => toast(`Stop command: ${r.remote_stop}`),
|
(r) => toast(`Stop command: ${r.remote_stop}`),
|
||||||
);
|
);
|
||||||
|
|
||||||
|
const state = gunState(gun);
|
||||||
return (
|
return (
|
||||||
<article className="bay">
|
<article className="bay">
|
||||||
<header className="bay__head">
|
<header className="bay__head">
|
||||||
<span className="bay__eyebrow">{gun.chargerLabel}</span>
|
<span className="bay__eyebrow">{gun.chargerLabel}</span>
|
||||||
<Lamp tone={statusTone(gun.ocppStatus, !!gun.tx)} title={gun.ocppStatus} />
|
<Lamp tone={statusTone(gun.ocppStatus, !!gun.tx)} title={state.label} />
|
||||||
</header>
|
</header>
|
||||||
<h2 className="bay__title">{gun.label}</h2>
|
<h2 className="bay__title">{gun.label}</h2>
|
||||||
<div className="bay__status">
|
<div className="bay__status">
|
||||||
<span className={`chip chip--${gun.tx ? "live" : gun.ocppStatus.toLowerCase()}`}>
|
<span className={`chip chip--${state.cls}`}>{state.label}</span>
|
||||||
{gun.tx ? "Charging" : gun.ocppStatus}
|
|
||||||
</span>
|
|
||||||
{gun.ocppStatus === "Preparing" && !gun.tx && (
|
{gun.ocppStatus === "Preparing" && !gun.tx && (
|
||||||
<span className="bay__hint">cable plugged — ready to start</span>
|
<span className="bay__hint">cable in the socket — ready to start</span>
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
@@ -184,10 +232,13 @@ export default function Dashboard() {
|
|||||||
<Lamp tone="red" />
|
<Lamp tone="red" />
|
||||||
<div>
|
<div>
|
||||||
<h2>Charger offline</h2>
|
<h2>Charger offline</h2>
|
||||||
<p>Waiting for the charge point to dial in. Guns appear here as soon as it connects.</p>
|
<p>Waiting for the charge point to dial in — controls enable as soon as it connects.</p>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
|
{!guns.length && !offline && (
|
||||||
|
<p className="empty">Connected, waiting for the first gun status report…</p>
|
||||||
|
)}
|
||||||
<div className="bays">
|
<div className="bays">
|
||||||
{guns.map((g) => (
|
{guns.map((g) => (
|
||||||
<GunBay key={`${g.cp}/${g.connector}`} gun={g} scopes={me.scopes} />
|
<GunBay key={`${g.cp}/${g.connector}`} gun={g} scopes={me.scopes} />
|
||||||
|
|||||||
+27
-8
@@ -14,7 +14,8 @@
|
|||||||
--line: #d8ddda;
|
--line: #d8ddda;
|
||||||
--copper: #b25c28; /* busbar copper — the accent */
|
--copper: #b25c28; /* busbar copper — the accent */
|
||||||
--copper-deep: #8f4a20;
|
--copper-deep: #8f4a20;
|
||||||
--live: #178a5c; /* DC-on green */
|
--live: #178a5c; /* DC-on green: charging */
|
||||||
|
--blue: #2160c4; /* plugged-in blue */
|
||||||
--amber: #c07f00;
|
--amber: #c07f00;
|
||||||
--red: #bf3527;
|
--red: #bf3527;
|
||||||
--lamp-off: #c4ccc8;
|
--lamp-off: #c4ccc8;
|
||||||
@@ -35,6 +36,7 @@
|
|||||||
--copper: #d07a3e;
|
--copper: #d07a3e;
|
||||||
--copper-deep: #b25c28;
|
--copper-deep: #b25c28;
|
||||||
--live: #2fae7c;
|
--live: #2fae7c;
|
||||||
|
--blue: #4f8ee8;
|
||||||
--amber: #d99a1b;
|
--amber: #d99a1b;
|
||||||
--red: #d8503f;
|
--red: #d8503f;
|
||||||
--lamp-off: #39433f;
|
--lamp-off: #39433f;
|
||||||
@@ -90,13 +92,23 @@ button, input, select { font: inherit; color: inherit; }
|
|||||||
background: radial-gradient(circle at 35% 30%, #ff9d8f, var(--red) 70%);
|
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);
|
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; }
|
.lamp--blue {
|
||||||
@keyframes lamp-pulse {
|
background: radial-gradient(circle at 35% 30%, #9ec4ff, var(--blue) 70%);
|
||||||
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); }
|
box-shadow: inset 0 0 2px rgb(0 0 0 / 0.25), 0 0 8px color-mix(in srgb, var(--blue) 55%, 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); }
|
}
|
||||||
|
.lamp--pulse-blue { animation: lamp-pulse-blue 1.5s ease-in-out infinite; }
|
||||||
|
@keyframes lamp-pulse-blue {
|
||||||
|
0%, 100% {
|
||||||
|
box-shadow: inset 0 0 2px rgb(0 0 0 / 0.25), 0 0 3px color-mix(in srgb, var(--blue) 35%, transparent);
|
||||||
|
filter: brightness(0.85);
|
||||||
|
}
|
||||||
|
50% {
|
||||||
|
box-shadow: inset 0 0 2px rgb(0 0 0 / 0.25), 0 0 15px color-mix(in srgb, var(--blue) 90%, transparent);
|
||||||
|
filter: brightness(1.15);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@media (prefers-reduced-motion: reduce) {
|
@media (prefers-reduced-motion: reduce) {
|
||||||
.lamp--pulse { animation: none; }
|
.lamp--pulse-blue { animation: none; }
|
||||||
* { transition: none !important; }
|
* { transition: none !important; }
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -140,7 +152,12 @@ button, input, select { font: inherit; color: inherit; }
|
|||||||
}
|
}
|
||||||
|
|
||||||
.topbar__user { display: flex; align-items: center; gap: 10px; }
|
.topbar__user { display: flex; align-items: center; gap: 10px; }
|
||||||
.topbar__who { font-family: var(--font-mono); font-size: 13px; color: var(--ink-dim); }
|
.topbar__who {
|
||||||
|
font-family: var(--font-mono); font-size: 13px; color: var(--ink-dim);
|
||||||
|
text-decoration: none; padding: 4px 8px; border-radius: 6px;
|
||||||
|
}
|
||||||
|
.topbar__who:hover { color: var(--ink); background: var(--panel-inset); }
|
||||||
|
.topbar__who.active { color: var(--copper-deep); }
|
||||||
|
|
||||||
.alert {
|
.alert {
|
||||||
display: flex; align-items: center; gap: 10px;
|
display: flex; align-items: center; gap: 10px;
|
||||||
@@ -263,7 +280,9 @@ button, input, select { font: inherit; color: inherit; }
|
|||||||
border: 1px solid var(--line);
|
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--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--plugged { background: color-mix(in srgb, var(--blue) 13%, transparent); color: var(--blue); border-color: color-mix(in srgb, var(--blue) 40%, transparent); }
|
||||||
|
.chip--idle { /* the quiet gray default */ }
|
||||||
|
.chip--offline { opacity: 0.7; }
|
||||||
.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--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--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); }
|
.chip--app { background: color-mix(in srgb, var(--live) 12%, transparent); color: var(--live); border-color: color-mix(in srgb, var(--live) 35%, transparent); }
|
||||||
|
|||||||
@@ -1 +1 @@
|
|||||||
{"root":["./src/app.tsx","./src/api.ts","./src/main.tsx","./src/queries.ts","./src/store.ts","./src/types.ts","./src/components/lamp.tsx","./src/components/layout.tsx","./src/pages/cards.tsx","./src/pages/dashboard.tsx","./src/pages/history.tsx","./src/pages/login.tsx","./src/pages/users.tsx"],"version":"5.9.3"}
|
{"root":["./src/app.tsx","./src/api.ts","./src/main.tsx","./src/queries.ts","./src/store.ts","./src/types.ts","./src/components/lamp.tsx","./src/components/layout.tsx","./src/pages/account.tsx","./src/pages/cards.tsx","./src/pages/dashboard.tsx","./src/pages/history.tsx","./src/pages/login.tsx","./src/pages/users.tsx"],"version":"5.9.3"}
|
||||||
@@ -26,7 +26,7 @@ backend/ (run: venv\Scripts\python -m backend.main, from the repo root)
|
|||||||
|
|
||||||
- `ws://<host>:9000/<ChargerID>` — OCPP WebSocket (catch-all path, the JC-6620 dials in)
|
- `ws://<host>:9000/<ChargerID>` — OCPP WebSocket (catch-all path, the JC-6620 dials in)
|
||||||
- `GET /` — **the [[frontend|React panel]]** served from `../frontend/dist/` with SPA fallback (deep links land on index.html; `/api/*` + `/docs` excluded; 503 with instructions if not built)
|
- `GET /` — **the [[frontend|React panel]]** served from `../frontend/dist/` with SPA fallback (deep links land on index.html; `/api/*` + `/docs` excluded; 503 with instructions if not built)
|
||||||
- `POST /api/login|logout`, `GET /api/me` — username/password → 30-day session (cookie + bearer)
|
- `POST /api/login|logout`, `GET /api/me`, `POST /api/me/password` (self-service change, current password required) — username/password → 30-day session (cookie + bearer)
|
||||||
- `GET /api/sessions?limit&cp&connector` — **charging history: who / when / kWh** (visibility: own sessions + guns within scope; admin sees all); `GET /api/sessions/{tx}/samples` — per-minute energy/power/SoC for charts
|
- `GET /api/sessions?limit&cp&connector` — **charging history: who / when / kWh** (visibility: own sessions + guns within scope; admin sees all); `GET /api/sessions/{tx}/samples` — per-minute energy/power/SoC for charts
|
||||||
- `GET /api/status` — connected chargers, gun states, active transactions, auth events + pending-card count (admin), relays (filtered to what the caller may control)
|
- `GET /api/status` — connected chargers, gun states, active transactions, auth events + pending-card count (admin), relays (filtered to what the caller may control)
|
||||||
- `GET /api/events?limit&event=` — tail the journal (admin)
|
- `GET /api/events?limit&event=` — tail the journal (admin)
|
||||||
|
|||||||
@@ -18,7 +18,8 @@ The React control panel (built 2026-07-11, replacing the single-file vanilla-JS
|
|||||||
|
|
||||||
| Route | Who | What |
|
| Route | Who | What |
|
||||||
|---|---|---|
|
|---|---|---|
|
||||||
| `/` (Control) | all | one "bay" card per gun (labels from the chargers registry): status lamp, Start/Stop gated by scope **and** gun readiness; live session shows who/via/duration; relay toggles with on-demand live read |
|
| `/` (Control) | all | one "bay" card per gun — **every registry-declared gun always renders**, even offline; status lamp, Start/Stop gated by scope **and** gun readiness; live session shows who/via/duration; relay toggles with on-demand live read |
|
||||||
|
| `/account` | all | self-service password change (current password required) |
|
||||||
| `/history` | all (filtered by scope) | the audit table: **who charged, via Card or In-app, which gun, when, duration, kWh**; total kWh; live sessions flagged |
|
| `/history` | all (filtered by scope) | the audit table: **who charged, via Card or In-app, which gun, when, duration, kWh**; total kWh; live sessions flagged |
|
||||||
| `/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 |
|
| `/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) |
|
| `/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) |
|
||||||
@@ -27,4 +28,4 @@ An amber **notification banner + nav badge** appears for admins whenever unknown
|
|||||||
|
|
||||||
## Design
|
## 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 — green=available, pulsing green=charging, amber=preparing/pending, red=fault/denied. Reduced motion respected; keyboard focus visible.
|
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.
|
||||||
|
|||||||
@@ -83,3 +83,7 @@ Owner pushback: two persistence stores (sessions.db + a config.json that doubled
|
|||||||
## [2026-07-11] meta | React frontend; pending-card review workflow; auth-method audit
|
## [2026-07-11] meta | React frontend; pending-card review workflow; auth-method audit
|
||||||
|
|
||||||
Owner: full frontend revision (React + routing + zustand + TanStack Query, Vite proxy in dev, static build served by backend, professional look) and backend fixes: permissions must be understandable, cards must connect to users, unknown card taps must notify the admin for approve/reject, and sessions must audit HOW authorization happened. Backend: learn mode REMOVED -> pending_cards/denied_cards workflow (unknown taps always refused, queued for review; pending count on /api/status as notification); sessions.method column (card|app); GET /api/permissions catalog. Frontend: new ../frontend/ (React 19, instrument-panel design, copper accent, indicator-lamp signature, bundled fonts); pages Control/History/Cards/Users; permission checkbox matrix; approve-with-owner-link in one step. Old backend/static vanilla panel deleted; seen_tags.json gone. Smoke: 54 checks. Created [[frontend]]; updated [[backend]], [[authorization]], [[overview]], [[architecture-plan]], [[index]], root CLAUDE.md.
|
Owner: full frontend revision (React + routing + zustand + TanStack Query, Vite proxy in dev, static build served by backend, professional look) and backend fixes: permissions must be understandable, cards must connect to users, unknown card taps must notify the admin for approve/reject, and sessions must audit HOW authorization happened. Backend: learn mode REMOVED -> pending_cards/denied_cards workflow (unknown taps always refused, queued for review; pending count on /api/status as notification); sessions.method column (card|app); GET /api/permissions catalog. Frontend: new ../frontend/ (React 19, instrument-panel design, copper accent, indicator-lamp signature, bundled fonts); pages Control/History/Cards/Users; permission checkbox matrix; approve-with-owner-link in one step. Old backend/static vanilla panel deleted; seen_tags.json gone. Smoke: 54 checks. Created [[frontend]]; updated [[backend]], [[authorization]], [[overview]], [[architecture-plan]], [[index]], root CLAUDE.md.
|
||||||
|
|
||||||
|
## [2026-07-12] meta | Panel live on the owner's phone; gun state language; password self-service
|
||||||
|
|
||||||
|
Owner confirmed the React panel loads on the phone after backend restart. Changes on request: (1) both guns ALWAYS render on Control — gun cards come from the chargers registry, live reports only overlay state (offline/no-status shown gray); (2) new lamp/chip language: gray=idle, pulsing blue=cable plugged, green=charging; (3) POST /api/me/password + /account page — any user changes their own password (current password required; admin reset via PUT /api/users stays). Smoke: 58 checks. Updated [[frontend]], [[backend]].
|
||||||
|
|||||||
Reference in New Issue
Block a user