Skip to content

Commit f3b573a

Browse files
feat(Tenants): add network column (#2478)
1 parent d6f23a3 commit f3b573a

File tree

1 file changed

+44
-3
lines changed

1 file changed

+44
-3
lines changed

src/containers/Tenants/Tenants.tsx

Lines changed: 44 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,15 +35,26 @@ import {setSearchValue, tenantsApi} from '../../store/reducers/tenants/tenants';
3535
import type {PreparedTenant} from '../../store/reducers/tenants/types';
3636
import type {AdditionalTenantsProps} from '../../types/additionalProps';
3737
import {uiFactory} from '../../uiFactory/uiFactory';
38+
import {formatBytes} from '../../utils/bytesParsers';
3839
import {cn} from '../../utils/cn';
39-
import {DEFAULT_TABLE_SETTINGS} from '../../utils/constants';
40+
import {
41+
DEFAULT_TABLE_SETTINGS,
42+
EMPTY_DATA_PLACEHOLDER,
43+
SHOW_NETWORK_UTILIZATION,
44+
} from '../../utils/constants';
4045
import {
4146
formatCPU,
4247
formatNumber,
4348
formatStorageValuesToGb,
4449
} from '../../utils/dataFormatters/dataFormatters';
45-
import {useAutoRefreshInterval, useTypedDispatch, useTypedSelector} from '../../utils/hooks';
50+
import {
51+
useAutoRefreshInterval,
52+
useSetting,
53+
useTypedDispatch,
54+
useTypedSelector,
55+
} from '../../utils/hooks';
4656
import {useClusterNameFromQuery} from '../../utils/hooks/useDatabaseFromQuery';
57+
import {isNumeric} from '../../utils/utils';
4758

4859
import i18n from './i18n';
4960

@@ -84,6 +95,8 @@ export const Tenants = ({additionalTenantsProps, scrollContainerRef}: TenantsPro
8495
const filteredTenants = useTypedSelector((state) => selectFilteredTenants(state, clusterName));
8596
const problemFilter = useTypedSelector(selectProblemFilter);
8697

98+
const [showNetworkUtilization] = useSetting<boolean>(SHOW_NETWORK_UTILIZATION);
99+
87100
const handleProblemFilterChange = (value: ProblemFilterValue) => {
88101
dispatch(changeFilter(value));
89102
};
@@ -214,6 +227,34 @@ export const Tenants = ({additionalTenantsProps, scrollContainerRef}: TenantsPro
214227
align: DataTable.RIGHT,
215228
defaultOrder: DataTable.DESCENDING,
216229
},
230+
];
231+
232+
if (showNetworkUtilization) {
233+
columns.push({
234+
name: 'Network',
235+
header: 'Network',
236+
width: 120,
237+
align: DataTable.RIGHT,
238+
defaultOrder: DataTable.DESCENDING,
239+
sortAccessor: ({NetworkWriteThroughput = 0}) => Number(NetworkWriteThroughput),
240+
render: ({row}) => {
241+
const {NetworkWriteThroughput} = row;
242+
243+
if (!isNumeric(NetworkWriteThroughput)) {
244+
return EMPTY_DATA_PLACEHOLDER;
245+
}
246+
247+
return formatBytes({
248+
value: NetworkWriteThroughput,
249+
size: 'mb',
250+
withSpeedLabel: true,
251+
precision: 2,
252+
});
253+
},
254+
});
255+
}
256+
257+
columns.push(
217258
{
218259
name: 'nodesCount',
219260
header: 'Nodes',
@@ -241,7 +282,7 @@ export const Tenants = ({additionalTenantsProps, scrollContainerRef}: TenantsPro
241282
align: DataTable.LEFT,
242283
render: ({row}) => <PoolsGraph pools={row.PoolStats} />,
243284
},
244-
];
285+
);
245286

246287
if (clusterName && (isDeleteDBAvailable || isEditDBAvailable)) {
247288
const actionsColumn = getDBActionsColumn({

0 commit comments

Comments
 (0)