1
+ import { orderBy } from 'lodash'
1
2
import React , { useEffect , useState } from 'react'
2
3
import { useSelector , useDispatch } from 'react-redux'
3
4
import { useParams } from 'react-router-dom'
5
+ import { ClusterNodeDetails } from 'src/modules/cluster-monitor/models'
4
6
5
7
import InstanceHeader from 'uiSrc/components/instance-header'
8
+ import ClusterNodesTable from 'uiSrc/pages/clusterDetails/components/cluser-nodes-table'
6
9
import { clusterDetailsSelector , fetchClusterDetailsAction } from 'uiSrc/slices/analytics/clusterDetails'
7
10
import { analyticsSettingsSelector , setAnalyticsViewTab } from 'uiSrc/slices/analytics/settings'
8
11
import { appAnalyticsInfoSelector } from 'uiSrc/slices/app/info'
9
12
import { connectedInstanceSelector } from 'uiSrc/slices/instances/instances'
10
13
import { AnalyticsViewTab } from 'uiSrc/slices/interfaces/analytics'
11
14
import { sendPageViewTelemetry , TelemetryPageView } from 'uiSrc/telemetry'
12
- import { formatLongName , getDbIndex , setTitle , } from 'uiSrc/utils'
15
+ import { formatLongName , getDbIndex , getLetterByIndex , Nullable , setTitle , } from 'uiSrc/utils'
13
16
14
17
import ClusterDetailsHeader from './components/cluster-details-header'
15
18
import styles from './styles.module.scss'
16
19
20
+ export interface ModifiedClusterNodes extends ClusterNodeDetails {
21
+ letter : string
22
+ index : number
23
+ }
24
+
17
25
const POLLING_INTERVAL = 5_000
18
26
19
27
const ClusterDetailsPage = ( ) => {
@@ -25,9 +33,10 @@ const ClusterDetailsPage = () => {
25
33
} = useSelector ( connectedInstanceSelector )
26
34
const { viewTab } = useSelector ( analyticsSettingsSelector )
27
35
const { identified : analyticsIdentified } = useSelector ( appAnalyticsInfoSelector )
28
- const { loading } = useSelector ( clusterDetailsSelector )
36
+ const { loading, data } = useSelector ( clusterDetailsSelector )
29
37
30
38
const [ isPageViewSent , setIsPageViewSent ] = useState ( false )
39
+ const [ nodes , setNodes ] = useState < Nullable < ModifiedClusterNodes [ ] > > ( null )
31
40
32
41
const dispatch = useDispatch ( )
33
42
@@ -61,6 +70,14 @@ const ClusterDetailsPage = () => {
61
70
return ( ) => clearInterval ( interval )
62
71
} , [ instanceId , loading ] )
63
72
73
+ useEffect ( ( ) => {
74
+ if ( data ) {
75
+ const nodes = orderBy ( data . nodes , [ 'asc' , 'host' ] )
76
+ const modifiedNodes = nodes . map ( ( d , index ) => ( { ...d , letter : getLetterByIndex ( index ) , index } ) )
77
+ setNodes ( modifiedNodes )
78
+ }
79
+ } , [ data ] )
80
+
64
81
useEffect ( ( ) => {
65
82
if ( connectedInstanceName && ! isPageViewSent && analyticsIdentified ) {
66
83
sendPageView ( instanceId )
@@ -80,6 +97,7 @@ const ClusterDetailsPage = () => {
80
97
< InstanceHeader />
81
98
< div className = { styles . main } data-testid = "cluster-details-page" >
82
99
< ClusterDetailsHeader />
100
+ < ClusterNodesTable nodes = { nodes } loading = { loading } />
83
101
</ div >
84
102
</ >
85
103
)
0 commit comments