Skip to content

Commit 0d87cd4

Browse files
feat(StorageGroups): add latency and allocation units columns
1 parent e63d22b commit 0d87cd4

File tree

5 files changed

+47
-6
lines changed

5 files changed

+47
-6
lines changed

src/containers/Storage/StorageGroups/columns/columns.tsx

Lines changed: 31 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,12 @@ import {InternalLink} from '../../../../components/InternalLink';
1010
import {UsageLabel} from '../../../../components/UsageLabel/UsageLabel';
1111
import {VDiskWithDonorsStack} from '../../../../components/VDisk/VDiskWithDonorsStack';
1212
import {getStorageGroupPath} from '../../../../routes';
13+
import {valueIsDefined} from '../../../../utils';
1314
import {cn} from '../../../../utils/cn';
14-
import {stringifyVdiskId} from '../../../../utils/dataFormatters/dataFormatters';
15+
import {EMPTY_DATA_PLACEHOLDER} from '../../../../utils/constants';
16+
import {formatNumber, stringifyVdiskId} from '../../../../utils/dataFormatters/dataFormatters';
1517
import {isSortableStorageProperty} from '../../../../utils/storage';
18+
import {formatToMs, parseUsToMs} from '../../../../utils/timeParsers';
1619
import {bytesToGB, bytesToSpeed} from '../../../../utils/utils';
1720
import {Disks} from '../../Disks/Disks';
1821
import {getDegradedSeverity, getUsageSeverityForStorageGroup, isVdiskActive} from '../../utils';
@@ -183,6 +186,30 @@ const writeColumn: StorageGroupsColumn = {
183186
align: DataTable.RIGHT,
184187
};
185188

189+
const latencyColumn: StorageGroupsColumn = {
190+
name: STORAGE_GROUPS_COLUMNS_IDS.Latency,
191+
header: STORAGE_GROUPS_COLUMNS_TITLES.Latency,
192+
width: 100,
193+
render: ({row}) => {
194+
return valueIsDefined(row.LatencyPutTabletLog)
195+
? formatToMs(parseUsToMs(row.LatencyPutTabletLog))
196+
: EMPTY_DATA_PLACEHOLDER;
197+
},
198+
align: DataTable.RIGHT,
199+
};
200+
201+
const allocationUnitsColumn: StorageGroupsColumn = {
202+
name: STORAGE_GROUPS_COLUMNS_IDS.AllocationUnits,
203+
header: STORAGE_GROUPS_COLUMNS_TITLES.AllocationUnits,
204+
width: 150,
205+
render: ({row}) => {
206+
return valueIsDefined(row.AllocationUnits)
207+
? formatNumber(row.AllocationUnits)
208+
: EMPTY_DATA_PLACEHOLDER;
209+
},
210+
align: DataTable.RIGHT,
211+
};
212+
186213
const getVDisksColumn = (data?: GetStorageColumnsData): StorageGroupsColumn => ({
187214
name: STORAGE_GROUPS_COLUMNS_IDS.VDisks,
188215
header: STORAGE_GROUPS_COLUMNS_TITLES.VDisks,
@@ -236,7 +263,7 @@ export const getStorageTopGroupsColumns: StorageColumnsGetter = () => {
236263
});
237264
};
238265

239-
export const getStorageGroupsColumns: StorageColumnsGetter = (data?: GetStorageColumnsData) => {
266+
export const getStorageGroupsColumns: StorageColumnsGetter = (data) => {
240267
const columns = [
241268
groupIdColumn,
242269
poolNameColumn,
@@ -249,6 +276,8 @@ export const getStorageGroupsColumns: StorageColumnsGetter = (data?: GetStorageC
249276
usedSpaceFlagColumn,
250277
readColumn,
251278
writeColumn,
279+
latencyColumn,
280+
allocationUnitsColumn,
252281
getVDisksColumn(data),
253282
getDisksColumn(data),
254283
];

src/containers/Storage/StorageGroups/columns/constants.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ export const STORAGE_GROUPS_COLUMNS_IDS = {
2323
Read: 'Read',
2424
Write: 'Write',
2525
Latency: 'Latency',
26+
AllocationUnits: 'AllocationUnits',
2627
VDisks: 'VDisks',
2728
VDisksPDisks: 'VDisksPDisks',
2829
MissingDisks: 'MissingDisks',
@@ -89,6 +90,9 @@ export const STORAGE_GROUPS_COLUMNS_TITLES = {
8990
get Latency() {
9091
return i18n('latency');
9192
},
93+
get AllocationUnits() {
94+
return i18n('allocation-units');
95+
},
9296
get VDisks() {
9397
return i18n('vdisks');
9498
},

src/containers/Storage/StorageGroups/columns/i18n/en.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
"read": "Read",
1616
"write": "Write",
1717
"latency": "Latency",
18+
"allocation-units": "Allocation Units",
1819
"vdisks": "VDisks",
1920
"vdisks-pdisks": "VDisks with PDisks"
2021
}

src/types/api/storage.ts

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -219,7 +219,13 @@ export type StorageV2SortValue =
219219
| 'Used'
220220
| 'Limit'
221221
| 'Read'
222-
| 'Write';
222+
| 'Write'
223+
224+
// These fields are not present in storage v2
225+
// So this sort does nothing
226+
// Added them here for types compatibility
227+
| 'AllocationUnits'
228+
| 'Latency';
223229

224230
/**
225231
* Values to sort /storage/groups response
@@ -230,9 +236,7 @@ export type GroupsSortField =
230236
| 'State'
231237
| 'Available'
232238
| 'DiskSpaceUsage'
233-
| 'Encryption'
234-
| 'AllocationUnits'
235-
| 'Latency';
239+
| 'Encryption';
236240

237241
export type StorageV2Sort = BackendSortParam<StorageV2SortValue>;
238242
export type GroupsSort = BackendSortParam<GroupsSortField>;

src/utils/storage.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,9 @@ const STORAGE_SORT_VALUES: StorageV2SortValue[] = [
2424
'Limit',
2525
'Read',
2626
'Write',
27+
28+
'AllocationUnits',
29+
'Latency',
2730
];
2831

2932
export const isSortableStorageProperty = (value: unknown): value is StorageV2SortValue =>

0 commit comments

Comments
 (0)