-
Notifications
You must be signed in to change notification settings - Fork 11
/
Copy pathFullNodeViewer.tsx
79 lines (67 loc) · 2.71 KB
/
FullNodeViewer.tsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
import type {PreparedNode} from '../../store/reducers/node/types';
import {cn} from '../../utils/cn';
import {LOAD_AVERAGE_TIME_INTERVALS} from '../../utils/constants';
import InfoViewer from '../InfoViewer/InfoViewer';
import type {InfoViewerItem} from '../InfoViewer/InfoViewer';
import {PoolUsage} from '../PoolUsage/PoolUsage';
import {ProgressViewer} from '../ProgressViewer/ProgressViewer';
import './FullNodeViewer.scss';
const b = cn('full-node-viewer');
interface FullNodeViewerProps {
node: PreparedNode | undefined;
className?: string;
}
export const FullNodeViewer = ({node, className}: FullNodeViewerProps) => {
const endpointsInfo = node?.Endpoints?.map(({Name, Address}) => ({
label: Name,
value: Address,
}));
const commonInfo: InfoViewerItem[] = [];
// Do not add DB field for static nodes (they have no Tenants)
if (node?.Tenants?.length) {
commonInfo.push({label: 'Database', value: node.Tenants[0]});
}
commonInfo.push(
{label: 'Version', value: node?.Version},
{label: 'Uptime', value: node?.Uptime},
{label: 'DC', value: node?.DataCenterDescription || node?.DC},
{label: 'Rack', value: node?.Rack},
);
const averageInfo = node?.LoadAveragePercents?.map((load, loadIndex) => ({
label: LOAD_AVERAGE_TIME_INTERVALS[loadIndex],
value: (
<ProgressViewer value={load} percents={true} colorizeProgress={true} capacity={100} />
),
}));
return (
<div className={`${b()} ${className}`}>
{node ? (
<div className={b('common-info')}>
<div>
<div className={b('section-title')}>Pools</div>
<div className={b('section', {pools: true})}>
{node?.PoolStats?.map((pool, poolIndex) => (
<PoolUsage key={poolIndex} data={pool} />
))}
</div>
</div>
{endpointsInfo && endpointsInfo.length && (
<InfoViewer
title="Endpoints"
className={b('section')}
info={endpointsInfo}
/>
)}
<InfoViewer title="Common info" className={b('section')} info={commonInfo} />
<InfoViewer
title="Load average"
className={b('section', {average: true})}
info={averageInfo}
/>
</div>
) : (
<div className="error">no data</div>
)}
</div>
);
};