-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add storage group page (#1289)
- Loading branch information
Showing
21 changed files
with
587 additions
and
38 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,168 @@ | ||
import {Flex} from '@gravity-ui/uikit'; | ||
|
||
import type {PreparedStorageGroup} from '../../store/reducers/storage/types'; | ||
import {valueIsDefined} from '../../utils'; | ||
import {formatStorageValuesToGb} from '../../utils/dataFormatters/dataFormatters'; | ||
import {formatToMs} from '../../utils/timeParsers'; | ||
import {bytesToSpeed} from '../../utils/utils'; | ||
import {EntityStatus} from '../EntityStatus/EntityStatus'; | ||
import {InfoViewer} from '../InfoViewer'; | ||
import type {InfoViewerProps} from '../InfoViewer/InfoViewer'; | ||
import {ProgressViewer} from '../ProgressViewer/ProgressViewer'; | ||
|
||
import {storageGroupInfoKeyset} from './i18n'; | ||
|
||
interface StorageGroupInfoProps extends Omit<InfoViewerProps, 'info'> { | ||
data?: PreparedStorageGroup; | ||
className?: string; | ||
} | ||
|
||
// eslint-disable-next-line complexity | ||
export function StorageGroupInfo({data, className, ...infoViewerProps}: StorageGroupInfoProps) { | ||
const { | ||
Encryption, | ||
Overall, | ||
DiskSpace, | ||
MediaType, | ||
ErasureSpecies, | ||
Used, | ||
Limit, | ||
Usage, | ||
Read, | ||
Write, | ||
GroupGeneration, | ||
Latency, | ||
AllocationUnits, | ||
State, | ||
MissingDisks, | ||
Available, | ||
LatencyPutTabletLog, | ||
LatencyPutUserData, | ||
LatencyGetFast, | ||
} = data || {}; | ||
|
||
const storageGroupInfoFirstColumn = []; | ||
|
||
if (valueIsDefined(GroupGeneration)) { | ||
storageGroupInfoFirstColumn.push({ | ||
label: storageGroupInfoKeyset('group-generation'), | ||
value: GroupGeneration, | ||
}); | ||
} | ||
if (valueIsDefined(ErasureSpecies)) { | ||
storageGroupInfoFirstColumn.push({ | ||
label: storageGroupInfoKeyset('erasure-species'), | ||
value: ErasureSpecies, | ||
}); | ||
} | ||
if (valueIsDefined(MediaType)) { | ||
storageGroupInfoFirstColumn.push({ | ||
label: storageGroupInfoKeyset('media-type'), | ||
value: MediaType, | ||
}); | ||
} | ||
if (valueIsDefined(Encryption)) { | ||
storageGroupInfoFirstColumn.push({ | ||
label: storageGroupInfoKeyset('encryption'), | ||
value: Encryption ? storageGroupInfoKeyset('yes') : storageGroupInfoKeyset('no'), | ||
}); | ||
} | ||
if (valueIsDefined(Overall)) { | ||
storageGroupInfoFirstColumn.push({ | ||
label: storageGroupInfoKeyset('overall'), | ||
value: <EntityStatus status={Overall} />, | ||
}); | ||
} | ||
if (valueIsDefined(State)) { | ||
storageGroupInfoFirstColumn.push({label: storageGroupInfoKeyset('state'), value: State}); | ||
} | ||
if (valueIsDefined(MissingDisks)) { | ||
storageGroupInfoFirstColumn.push({ | ||
label: storageGroupInfoKeyset('missing-disks'), | ||
value: MissingDisks, | ||
}); | ||
} | ||
|
||
const storageGroupInfoSecondColumn = []; | ||
|
||
if (valueIsDefined(Used) && valueIsDefined(Limit)) { | ||
storageGroupInfoSecondColumn.push({ | ||
label: storageGroupInfoKeyset('used-space'), | ||
value: ( | ||
<ProgressViewer | ||
value={Number(Used)} | ||
capacity={Number(Limit)} | ||
formatValues={formatStorageValuesToGb} | ||
colorizeProgress={true} | ||
/> | ||
), | ||
}); | ||
} | ||
if (valueIsDefined(Available)) { | ||
storageGroupInfoSecondColumn.push({ | ||
label: storageGroupInfoKeyset('available'), | ||
value: formatStorageValuesToGb(Number(Available)), | ||
}); | ||
} | ||
if (valueIsDefined(Usage)) { | ||
storageGroupInfoSecondColumn.push({ | ||
label: storageGroupInfoKeyset('usage'), | ||
value: `${Usage.toFixed(2)}%`, | ||
}); | ||
} | ||
if (valueIsDefined(DiskSpace)) { | ||
storageGroupInfoSecondColumn.push({ | ||
label: storageGroupInfoKeyset('disk-space'), | ||
value: <EntityStatus status={DiskSpace} />, | ||
}); | ||
} | ||
if (valueIsDefined(Latency)) { | ||
storageGroupInfoSecondColumn.push({ | ||
label: storageGroupInfoKeyset('latency'), | ||
value: <EntityStatus status={Latency} />, | ||
}); | ||
} | ||
if (valueIsDefined(LatencyPutTabletLog)) { | ||
storageGroupInfoSecondColumn.push({ | ||
label: storageGroupInfoKeyset('latency-put-tablet-log'), | ||
value: formatToMs(LatencyPutTabletLog), | ||
}); | ||
} | ||
if (valueIsDefined(LatencyPutUserData)) { | ||
storageGroupInfoSecondColumn.push({ | ||
label: storageGroupInfoKeyset('latency-put-user-data'), | ||
value: formatToMs(LatencyPutUserData), | ||
}); | ||
} | ||
if (valueIsDefined(LatencyGetFast)) { | ||
storageGroupInfoSecondColumn.push({ | ||
label: storageGroupInfoKeyset('latency-get-fast'), | ||
value: formatToMs(LatencyGetFast), | ||
}); | ||
} | ||
if (valueIsDefined(AllocationUnits)) { | ||
storageGroupInfoSecondColumn.push({ | ||
label: storageGroupInfoKeyset('allocation-units'), | ||
value: AllocationUnits, | ||
}); | ||
} | ||
if (valueIsDefined(Read)) { | ||
storageGroupInfoSecondColumn.push({ | ||
label: storageGroupInfoKeyset('read-throughput'), | ||
value: bytesToSpeed(Number(Read)), | ||
}); | ||
} | ||
if (valueIsDefined(Write)) { | ||
storageGroupInfoSecondColumn.push({ | ||
label: storageGroupInfoKeyset('write-throughput'), | ||
value: bytesToSpeed(Number(Write)), | ||
}); | ||
} | ||
|
||
return ( | ||
<Flex className={className} gap={2} direction="row" wrap> | ||
<InfoViewer info={storageGroupInfoFirstColumn} {...infoViewerProps} /> | ||
<InfoViewer info={storageGroupInfoSecondColumn} {...infoViewerProps} /> | ||
</Flex> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
{ | ||
"encryption": "Encryption", | ||
"overall": "Overall", | ||
"disk-space": "Disk Space", | ||
"media-type": "Media Type", | ||
"erasure-species": "Erasure Species", | ||
"used-space": "Used Space", | ||
"usage": "Usage", | ||
"read-throughput": "Read Throughput", | ||
"write-throughput": "Write Throughput", | ||
"yes": "Yes", | ||
"no": "No", | ||
"group-generation": "Group Generation", | ||
"latency": "Latency", | ||
"allocation-units": "Units", | ||
"state": "State", | ||
"missing-disks": "Missing Disks", | ||
"available": "Available Space", | ||
"latency-put-tablet-log": "Latency (Put Tablet Log)", | ||
"latency-put-user-data": "Latency (Put User Data)", | ||
"latency-get-fast": "Latency (Get Fast)" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
import {registerKeysets} from '../../../utils/i18n'; | ||
|
||
import en from './en.json'; | ||
|
||
const COMPONENT = 'storage-group-info'; | ||
|
||
export const storageGroupInfoKeyset = registerKeysets(COMPONENT, {en}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.