2022-12-07 14:51:20 +00:00
|
|
|
import { Activity } from 'lucide-react';
|
2022-03-08 12:14:23 +00:00
|
|
|
|
|
|
|
import { isoDateFromTimestamp } from '@/portainer/filters/filters';
|
2022-10-23 06:53:25 +00:00
|
|
|
import { Environment } from '@/react/portainer/environments/types';
|
2023-08-27 10:30:45 +00:00
|
|
|
import heartbeatup from '@/assets/ico/heartbeat-up.svg?c';
|
|
|
|
import heartbeatdown from '@/assets/ico/heartbeat-down.svg?c';
|
2022-12-07 14:51:20 +00:00
|
|
|
|
|
|
|
import { EnvironmentStatusBadgeItem } from './EnvironmentStatusBadgeItem';
|
2022-03-08 12:14:23 +00:00
|
|
|
|
|
|
|
interface Props {
|
2022-05-23 14:32:51 +00:00
|
|
|
showLastCheckInDate?: boolean;
|
2022-06-22 17:11:46 +00:00
|
|
|
environment: Environment;
|
2022-03-08 12:14:23 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
export function EdgeIndicator({
|
2022-06-22 17:11:46 +00:00
|
|
|
environment,
|
2022-05-23 14:32:51 +00:00
|
|
|
showLastCheckInDate = false,
|
2022-03-08 12:14:23 +00:00
|
|
|
}: Props) {
|
2023-04-05 21:09:22 +00:00
|
|
|
const heartbeat = environment.Heartbeat;
|
2022-06-22 17:11:46 +00:00
|
|
|
|
2022-12-07 14:51:20 +00:00
|
|
|
const associated = !!environment.EdgeID;
|
2022-06-22 17:11:46 +00:00
|
|
|
if (!associated) {
|
2022-03-08 12:14:23 +00:00
|
|
|
return (
|
2022-06-22 17:11:46 +00:00
|
|
|
<span role="status" aria-label="edge-status">
|
2022-12-07 14:51:20 +00:00
|
|
|
<EnvironmentStatusBadgeItem aria-label="unassociated">
|
2023-01-22 20:14:06 +00:00
|
|
|
<span className="whitespace-nowrap">Not associated</span>
|
2022-12-07 14:51:20 +00:00
|
|
|
</EnvironmentStatusBadgeItem>
|
2022-03-08 12:14:23 +00:00
|
|
|
</span>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
return (
|
2022-12-07 14:51:20 +00:00
|
|
|
<span
|
|
|
|
role="status"
|
|
|
|
aria-label="edge-status"
|
|
|
|
className="flex items-center gap-1"
|
|
|
|
>
|
|
|
|
<EnvironmentStatusBadgeItem
|
2023-04-05 21:09:22 +00:00
|
|
|
color={heartbeat ? 'success' : 'danger'}
|
2023-08-27 10:30:45 +00:00
|
|
|
icon={heartbeat ? heartbeatup : heartbeatdown}
|
2022-03-08 12:14:23 +00:00
|
|
|
aria-label="edge-heartbeat"
|
|
|
|
>
|
|
|
|
heartbeat
|
2022-12-07 14:51:20 +00:00
|
|
|
</EnvironmentStatusBadgeItem>
|
2022-03-08 12:14:23 +00:00
|
|
|
|
2022-06-22 17:11:46 +00:00
|
|
|
{showLastCheckInDate && !!environment.LastCheckInDate && (
|
2022-03-08 12:14:23 +00:00
|
|
|
<span
|
2022-12-07 14:51:20 +00:00
|
|
|
className="small text-muted vertical-center"
|
2022-03-08 12:14:23 +00:00
|
|
|
aria-label="edge-last-checkin"
|
2022-12-07 14:51:20 +00:00
|
|
|
title="Last edge check-in"
|
2022-03-08 12:14:23 +00:00
|
|
|
>
|
2022-12-07 14:51:20 +00:00
|
|
|
<Activity className="icon icon-sm space-right" aria-hidden="true" />
|
2022-06-22 17:11:46 +00:00
|
|
|
{isoDateFromTimestamp(environment.LastCheckInDate)}
|
2022-03-08 12:14:23 +00:00
|
|
|
</span>
|
|
|
|
)}
|
|
|
|
</span>
|
|
|
|
);
|
|
|
|
}
|