Unify charge point command channel status
This commit is contained in:
@@ -26,7 +26,8 @@ import { Clock, EvCharger, Plug, Zap } from "lucide-react";
|
||||
type ConnectionStatus = "online" | "stale" | "offline";
|
||||
|
||||
function getStatus(cp: ChargePoint, connected: string[]): ConnectionStatus {
|
||||
if (!connected.includes(cp.chargePointIdentifier)) return "offline";
|
||||
if (cp.transportStatus === "unavailable") return "stale";
|
||||
if (cp.transportStatus !== "online" || !connected.includes(cp.chargePointIdentifier)) return "offline";
|
||||
if (!cp.lastHeartbeatAt) return "stale";
|
||||
return dayjs().diff(dayjs(cp.lastHeartbeatAt), "minute") < 5 ? "online" : "stale";
|
||||
}
|
||||
@@ -36,7 +37,7 @@ const STATUS_CONFIG: Record<
|
||||
{ color: string; edgeColor: string; label: string; animated: boolean }
|
||||
> = {
|
||||
online: { color: "#22c55e", edgeColor: "#22c55e", label: "在线", animated: true },
|
||||
stale: { color: "#f59e0b", edgeColor: "#f59e0b", label: "心跳超时", animated: true },
|
||||
stale: { color: "#f59e0b", edgeColor: "#f59e0b", label: "通道异常", animated: true },
|
||||
offline: { color: "#71717a", edgeColor: "#9ca3af", label: "离线", animated: false },
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user