= ({ clusterId }) => {
+ const { systemLoad, fetchClusterSystemLoad } = useClusterSystemLoad();
+
+ useEffect(() => {
+ if (clusterId) {
+ fetchClusterSystemLoad({ cluster_id: clusterId });
+ }
+ }, [clusterId]);
+
+ return Cluster System Load Component
;
+};
+
+export default ClusterSystemLoad;
diff --git a/src/pages/cluster-management/hooks/use-cluster-columns.tsx b/src/pages/cluster-management/hooks/use-cluster-columns.tsx
index 536af659..b5d1b49e 100644
--- a/src/pages/cluster-management/hooks/use-cluster-columns.tsx
+++ b/src/pages/cluster-management/hooks/use-cluster-columns.tsx
@@ -6,7 +6,7 @@ import StatusTag from '@/components/status-tag';
import { tableSorter } from '@/config/settings';
import { StarFilled } from '@ant-design/icons';
import { useIntl } from '@umijs/max';
-import { Tooltip } from 'antd';
+import { Tooltip, Typography } from 'antd';
import dayjs from 'dayjs';
import { useMemo } from 'react';
import {
@@ -42,7 +42,9 @@ const useClusterColumns = (
render: (text: string, record: ClusterListItem) => (
<>
- {text}
+ onCellClick?.(record, 'name')}>
+ {record.name}
+
{record.is_default && (
{
+ const [systemLoad, setSystemLoad] = useState<{
+ current: {
+ cpu: number;
+ ram: number;
+ gpu: number;
+ vram: number;
+ };
+ history: Record;
+ }>({
+ current: {
+ cpu: 0,
+ ram: 0,
+ gpu: 0,
+ vram: 0
+ },
+ history: {}
+ });
+ const axiosTokenRef = useRef(null);
+
+ const {
+ run: fetchClusterSystemLoad,
+ loading,
+ cancel
+ } = useRequest(
+ async (params) => {
+ axiosTokenRef.current?.cancel();
+ axiosTokenRef.current = createAxiosToken();
+ return await queryClusterDetail(params, {
+ token: axiosTokenRef.current.token
+ });
+ },
+ {
+ manual: true,
+ onSuccess: (response) => {
+ setSystemLoad({
+ current: response.system_load?.current,
+ history: response.system_load?.history
+ });
+ },
+ onError: () => {
+ setSystemLoad({
+ current: {
+ cpu: 0,
+ ram: 0,
+ gpu: 0,
+ vram: 0
+ },
+ history: {}
+ });
+ }
+ }
+ );
+
+ useEffect(() => {
+ return () => {
+ cancel();
+ axiosTokenRef.current?.cancel();
+ };
+ }, []);
+
+ return {
+ systemLoad,
+ loading,
+ fetchClusterSystemLoad
+ };
+};