feat(web): add tooltip for charge point status with online/offline indication
This commit is contained in:
@@ -13,6 +13,7 @@ import {
|
|||||||
Spinner,
|
Spinner,
|
||||||
Table,
|
Table,
|
||||||
TextField,
|
TextField,
|
||||||
|
Tooltip,
|
||||||
} from "@heroui/react";
|
} from "@heroui/react";
|
||||||
import {
|
import {
|
||||||
Plus,
|
Plus,
|
||||||
@@ -424,12 +425,33 @@ export default function ChargePointsPage() {
|
|||||||
{chargePoints.map((cp) => (
|
{chargePoints.map((cp) => (
|
||||||
<Table.Row key={cp.id} id={String(cp.id)} className={"group"}>
|
<Table.Row key={cp.id} id={String(cp.id)} className={"group"}>
|
||||||
<Table.Cell>
|
<Table.Cell>
|
||||||
|
<Tooltip delay={0}>
|
||||||
|
<Tooltip.Trigger>
|
||||||
|
<div className="flex items-center gap-2">
|
||||||
|
<span
|
||||||
|
className={`size-2 shrink-0 rounded-full ${
|
||||||
|
cp.lastHeartbeatAt &&
|
||||||
|
dayjs().diff(dayjs(cp.lastHeartbeatAt), "second") < 120
|
||||||
|
? "bg-success"
|
||||||
|
: "bg-gray-300"
|
||||||
|
}`}
|
||||||
|
/>
|
||||||
<Link
|
<Link
|
||||||
href={`/dashboard/charge-points/${cp.id}`}
|
href={`/dashboard/charge-points/${cp.id}`}
|
||||||
className="font-medium text-accent"
|
className="font-medium text-accent"
|
||||||
>
|
>
|
||||||
{cp.chargePointIdentifier}
|
{cp.chargePointIdentifier}
|
||||||
</Link>
|
</Link>
|
||||||
|
</div>
|
||||||
|
</Tooltip.Trigger>
|
||||||
|
<Tooltip.Content placement="start">
|
||||||
|
{cp.lastHeartbeatAt
|
||||||
|
? dayjs().diff(dayjs(cp.lastHeartbeatAt), "second") < 120
|
||||||
|
? "在线"
|
||||||
|
: "离线"
|
||||||
|
: "从未连接"}
|
||||||
|
</Tooltip.Content>
|
||||||
|
</Tooltip>
|
||||||
</Table.Cell>
|
</Table.Cell>
|
||||||
{isAdmin && (
|
{isAdmin && (
|
||||||
<Table.Cell>
|
<Table.Cell>
|
||||||
|
|||||||
@@ -265,7 +265,7 @@ export default function ChargePage() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
const selectedCp = chargePoints.find((cp) => cp.id === selectedCpId) ?? null;
|
const selectedCp = chargePoints.find((cp) => cp.id === selectedCpId) ?? null;
|
||||||
const myTags = idTags.filter((t) => t.status === "Accepted");
|
const myTags = idTags?.filter((t) => t.status === "Accepted") ?? [];
|
||||||
|
|
||||||
const startMutation = useMutation({
|
const startMutation = useMutation({
|
||||||
mutationFn: async () => {
|
mutationFn: async () => {
|
||||||
|
|||||||
Reference in New Issue
Block a user