diff --git a/src/hooks/useClusterNodes.ts b/src/hooks/useClusterNodes.ts index 017c90899..ecac9d97a 100644 --- a/src/hooks/useClusterNodes.ts +++ b/src/hooks/useClusterNodes.ts @@ -4,6 +4,8 @@ import _ from 'lodash' import { compareVersions } from 'compare-versions' import { loadNodes } from '@/api/common' import { NodeInfo } from '@/types/dashboard' +import { getClusterNodes } from '@/api/common' +import type { GetCluster200 } from '@/types/schemas/cluster.schemas' interface UseClusterNodesOptions { loadByDefault?: boolean @@ -18,6 +20,7 @@ export default function useClusterNodes( getVersion: false, }, ): { + clusterName: Ref nodes: Ref> lockTable: Ref hasMemory: Ref @@ -34,6 +37,7 @@ export default function useClusterNodes( latestVersion: '', isMutiVersion: false, }) + const clusterName = ref('') const handleVersions = (nodes: NodeInfo[]) => { const versionList = nodes.map((node) => node.version.split('-')[0]) @@ -67,5 +71,13 @@ export default function useClusterNodes( if (loadByDefault) { loadData() } - return { nodes, lockTable, hasMemory, loadData, versionInfo } + + const getClusterName = async () => { + const res: GetCluster200 = await getClusterNodes() + clusterName.value = res.name ?? '' + } + + getClusterName() + + return { nodes, lockTable, hasMemory, loadData, versionInfo, clusterName } } diff --git a/src/views/Dashboard/components/NodesGraphCard.vue b/src/views/Dashboard/components/NodesGraphCard.vue index 4c97aa2bd..597ab7871 100644 --- a/src/views/Dashboard/components/NodesGraphCard.vue +++ b/src/views/Dashboard/components/NodesGraphCard.vue @@ -4,6 +4,7 @@
node + {{ clusterName ? `${clusterName} -` : '' }} {{ $t('Dashboard.node', { n: nodes.length }) }} @@ -146,7 +147,11 @@ const { locale } = useI18n() const POLLING_INTERVAL = 2000 // const { nodes, loadData: getNodes } = useClusterNodes(false, true, 25000) -const { nodes, loadData: getNodes } = useClusterNodes({ +const { + nodes, + loadData: getNodes, + clusterName, +} = useClusterNodes({ loadByDefault: false, hideProgress: true, timeout: 25000,