2022-11-28 02:00:28 +00:00
|
|
|
import { List, Settings, Boxes, Gauge } from 'lucide-react';
|
|
|
|
|
2022-11-13 10:29:25 +00:00
|
|
|
import { useEnvironmentId } from '@/react/hooks/useEnvironmentId';
|
|
|
|
|
|
|
|
import { DashboardItem } from '@@/DashboardItem';
|
|
|
|
import { Widget, WidgetTitle, WidgetBody } from '@@/Widget';
|
|
|
|
import { PageHeader } from '@@/PageHeader';
|
|
|
|
import { DashboardGrid } from '@@/DashboardItem/DashboardGrid';
|
2022-11-28 02:00:28 +00:00
|
|
|
import { Icon } from '@@/Icon';
|
2022-11-13 10:29:25 +00:00
|
|
|
|
|
|
|
import { useDashboard } from './useDashboard';
|
|
|
|
import { RunningStatus } from './RunningStatus';
|
|
|
|
|
|
|
|
export function DashboardView() {
|
|
|
|
const environmentId = useEnvironmentId();
|
|
|
|
const dashboardQuery = useDashboard(environmentId);
|
|
|
|
|
|
|
|
const running = dashboardQuery.data?.RunningTaskCount || 0;
|
|
|
|
const stopped = (dashboardQuery.data?.TaskCount || 0) - running;
|
|
|
|
|
|
|
|
return (
|
|
|
|
<>
|
|
|
|
<PageHeader
|
|
|
|
title="Dashboard"
|
|
|
|
breadcrumbs={[{ label: 'Environment summary' }]}
|
|
|
|
/>
|
|
|
|
|
|
|
|
{dashboardQuery.isLoading ? (
|
|
|
|
<div className="text-center" style={{ marginTop: '30%' }}>
|
|
|
|
Connecting to the Edge environment...
|
2023-02-12 21:04:24 +00:00
|
|
|
<Icon icon={Settings} className="!ml-1 animate-spin-slow" />
|
2022-11-13 10:29:25 +00:00
|
|
|
</div>
|
|
|
|
) : (
|
|
|
|
<>
|
|
|
|
<div className="row">
|
|
|
|
<div className="col-sm-12">
|
|
|
|
{/* cluster info */}
|
|
|
|
<Widget>
|
2022-11-28 02:00:28 +00:00
|
|
|
<WidgetTitle icon={Gauge} title="Cluster information" />
|
2022-11-13 10:29:25 +00:00
|
|
|
<WidgetBody className="no-padding">
|
|
|
|
<table className="table">
|
|
|
|
<tbody>
|
|
|
|
<tr>
|
|
|
|
<td>Nodes in the cluster</td>
|
|
|
|
<td>{dashboardQuery.data?.NodeCount ?? '-'}</td>
|
|
|
|
</tr>
|
|
|
|
</tbody>
|
|
|
|
</table>
|
|
|
|
</WidgetBody>
|
|
|
|
</Widget>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<div className="mx-4">
|
|
|
|
<DashboardGrid>
|
|
|
|
{/* jobs */}
|
|
|
|
<DashboardItem
|
|
|
|
value={dashboardQuery.data?.JobCount}
|
2022-11-28 02:00:28 +00:00
|
|
|
icon={List}
|
2022-11-13 10:29:25 +00:00
|
|
|
type="Nomad Job"
|
|
|
|
/>
|
|
|
|
{/* groups */}
|
|
|
|
<DashboardItem
|
|
|
|
value={dashboardQuery.data?.GroupCount}
|
2022-11-28 02:00:28 +00:00
|
|
|
icon={List}
|
2022-11-13 10:29:25 +00:00
|
|
|
type="Group"
|
|
|
|
/>
|
|
|
|
{/* tasks */}
|
|
|
|
<DashboardItem
|
|
|
|
value={dashboardQuery.data?.TaskCount}
|
2022-11-28 02:00:28 +00:00
|
|
|
icon={Boxes}
|
2022-11-13 10:29:25 +00:00
|
|
|
type="Task"
|
|
|
|
>
|
|
|
|
{/* running status of tasks */}
|
|
|
|
<RunningStatus running={running} stopped={stopped} />
|
|
|
|
</DashboardItem>
|
|
|
|
</DashboardGrid>
|
|
|
|
</div>
|
|
|
|
</>
|
|
|
|
)}
|
|
|
|
</>
|
|
|
|
);
|
|
|
|
}
|