mirror of
https://github.com/awatertrevi/infisical.git
synced 2026-10-08 14:28:20 +00:00
misc: updated gateway table view
This commit is contained in:
+21
-5
@@ -13,7 +13,6 @@ import {
|
|||||||
} from "@fortawesome/free-solid-svg-icons";
|
} from "@fortawesome/free-solid-svg-icons";
|
||||||
import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
|
import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
|
||||||
import { useQuery } from "@tanstack/react-query";
|
import { useQuery } from "@tanstack/react-query";
|
||||||
import { formatRelative } from "date-fns";
|
|
||||||
|
|
||||||
import { createNotification } from "@app/components/notifications";
|
import { createNotification } from "@app/components/notifications";
|
||||||
import { OrgPermissionCan } from "@app/components/permissions";
|
import { OrgPermissionCan } from "@app/components/permissions";
|
||||||
@@ -50,6 +49,25 @@ import { useDeleteGatewayV2ById } from "@app/hooks/api/gateways-v2";
|
|||||||
|
|
||||||
import { EditGatewayDetailsModal } from "./components/EditGatewayDetailsModal";
|
import { EditGatewayDetailsModal } from "./components/EditGatewayDetailsModal";
|
||||||
|
|
||||||
|
const GatewayHealthStatus = ({ heartbeat }: { heartbeat?: string }) => {
|
||||||
|
const heartbeatDate = heartbeat ? new Date(heartbeat) : null;
|
||||||
|
const now = new Date();
|
||||||
|
const oneHourAgo = new Date(now.getTime() - 60 * 60 * 1000);
|
||||||
|
|
||||||
|
const isHealthy = heartbeatDate && heartbeatDate >= oneHourAgo;
|
||||||
|
const tooltipContent = heartbeatDate
|
||||||
|
? `Last heartbeat: ${heartbeatDate.toLocaleString()}`
|
||||||
|
: "No heartbeat data available";
|
||||||
|
|
||||||
|
return (
|
||||||
|
<Tooltip content={tooltipContent}>
|
||||||
|
<span className={`cursor-default ${isHealthy ? "text-green-400" : "text-red-400"}`}>
|
||||||
|
{isHealthy ? "Healthy" : "Unreachable"}
|
||||||
|
</span>
|
||||||
|
</Tooltip>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
export const GatewayTab = withPermission(
|
export const GatewayTab = withPermission(
|
||||||
() => {
|
() => {
|
||||||
const [search, setSearch] = useState("");
|
const [search, setSearch] = useState("");
|
||||||
@@ -120,8 +138,7 @@ export const GatewayTab = withPermission(
|
|||||||
<Table>
|
<Table>
|
||||||
<THead>
|
<THead>
|
||||||
<Tr>
|
<Tr>
|
||||||
<Th className="w-1/3">Name</Th>
|
<Th className="w-1/2">Name</Th>
|
||||||
<Th>Identity</Th>
|
|
||||||
<Th>
|
<Th>
|
||||||
Health Check
|
Health Check
|
||||||
<Tooltip
|
<Tooltip
|
||||||
@@ -149,9 +166,8 @@ export const GatewayTab = withPermission(
|
|||||||
</span>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
</Td>
|
</Td>
|
||||||
<Td>{el.identity.name}</Td>
|
|
||||||
<Td>
|
<Td>
|
||||||
{el.heartbeat ? formatRelative(new Date(el.heartbeat), new Date()) : "-"}
|
<GatewayHealthStatus heartbeat={el.heartbeat} />
|
||||||
</Td>
|
</Td>
|
||||||
<Td className="w-5">
|
<Td className="w-5">
|
||||||
<Tooltip className="max-w-sm text-center" content="Options">
|
<Tooltip className="max-w-sm text-center" content="Options">
|
||||||
|
|||||||
Reference in New Issue
Block a user