-
Notifications
You must be signed in to change notification settings - Fork 14
feat: implement simple and narrow vertical progress bar #1560
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. Weβll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
808b0c4
feat: implement simple and narrow vertical progress bar
astandrik ec7832b
fix: lint
astandrik 19db2bb
fix: informative popups
astandrik 72232ed
Merge branch 'main' into astandrik.vertical-progress-bar-1190
astandrik 2de5093
Merge branch 'main' into astandrik.vertical-progress-bar-1190
astandrik ea5aa01
fix: review fixes
astandrik c16f024
Merge branch 'main' into astandrik.vertical-progress-bar-1190
astandrik 214d389
fix: tests fix
astandrik File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 |
---|---|---|
|
@@ -16,5 +16,9 @@ | |
.g-popover__handler { | ||
display: inline; | ||
} | ||
|
||
&_full-width { | ||
width: 100%; | ||
} | ||
} | ||
} |
This file contains hidden or 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 hidden or 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
2 changes: 1 addition & 1 deletion
2
src/components/TooltipsContent/PoolTooltipContent/PoolTooltipContent.tsx
This file contains hidden or 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 hidden or 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,6 @@ | ||
.ydb-nodes-columns { | ||
&__column-ram, | ||
&__column-cpu { | ||
min-width: 40px; | ||
} | ||
} |
This file contains hidden or 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 |
---|---|---|
@@ -1,24 +1,36 @@ | ||
import DataTable from '@gravity-ui/react-data-table'; | ||
import {DefinitionList} from '@gravity-ui/uikit'; | ||
|
||
import {getLoadSeverityForNode} from '../../store/reducers/nodes/utils'; | ||
import type {TPoolStats} from '../../types/api/nodes'; | ||
import type {TTabletStateInfo} from '../../types/api/tablet'; | ||
import {valueIsDefined} from '../../utils'; | ||
import {cn} from '../../utils/cn'; | ||
import {EMPTY_DATA_PLACEHOLDER} from '../../utils/constants'; | ||
import {formatStorageValuesToGb} from '../../utils/dataFormatters/dataFormatters'; | ||
import { | ||
formatStorageValues, | ||
formatStorageValuesToGb, | ||
} from '../../utils/dataFormatters/dataFormatters'; | ||
import {getSpaceUsageSeverity} from '../../utils/storage'; | ||
import type {Column} from '../../utils/tableUtils/types'; | ||
import {isNumeric} from '../../utils/utils'; | ||
import {CellWithPopover} from '../CellWithPopover/CellWithPopover'; | ||
import {NodeHostWrapper} from '../NodeHostWrapper/NodeHostWrapper'; | ||
import type {NodeHostData} from '../NodeHostWrapper/NodeHostWrapper'; | ||
import {PoolsGraph} from '../PoolsGraph/PoolsGraph'; | ||
import {ProgressViewer} from '../ProgressViewer/ProgressViewer'; | ||
import {TabletsStatistic} from '../TabletsStatistic'; | ||
import {formatPool} from '../TooltipsContent'; | ||
import {UsageLabel} from '../UsageLabel/UsageLabel'; | ||
|
||
import {NODES_COLUMNS_IDS, NODES_COLUMNS_TITLES} from './constants'; | ||
import i18n from './i18n'; | ||
import type {GetNodesColumnsParams} from './types'; | ||
|
||
import './NodesColumns.scss'; | ||
|
||
const b = cn('ydb-nodes-columns'); | ||
|
||
export function getNodeIdColumn<T extends {NodeId?: string | number}>(): Column<T> { | ||
return { | ||
name: NODES_COLUMNS_IDS.NodeId, | ||
|
@@ -111,6 +123,57 @@ export function getMemoryColumn< | |
resizeMinWidth: 170, | ||
}; | ||
} | ||
|
||
export function getRAMColumn<T extends {MemoryUsed?: string; MemoryLimit?: string}>(): Column<T> { | ||
return { | ||
name: NODES_COLUMNS_IDS.RAM, | ||
header: NODES_COLUMNS_TITLES.RAM, | ||
sortAccessor: ({MemoryUsed = 0}) => Number(MemoryUsed), | ||
defaultOrder: DataTable.DESCENDING, | ||
render: ({row}) => { | ||
const [memoryUsed, memoryLimit] = | ||
isNumeric(row.MemoryUsed) && isNumeric(row.MemoryLimit) | ||
? formatStorageValues( | ||
Number(row.MemoryUsed), | ||
Number(row.MemoryLimit), | ||
'gb', | ||
undefined, | ||
true, | ||
) | ||
: [0, 0]; | ||
return ( | ||
<CellWithPopover | ||
placement={['top', 'auto']} | ||
fullWidth | ||
content={ | ||
<DefinitionList responsive> | ||
<DefinitionList.Item name={i18n('field_memory-used')}> | ||
{memoryUsed} | ||
</DefinitionList.Item> | ||
<DefinitionList.Item name={i18n('field_memory-limit')}> | ||
{memoryLimit} | ||
</DefinitionList.Item> | ||
</DefinitionList> | ||
} | ||
> | ||
<ProgressViewer | ||
value={row.MemoryUsed} | ||
capacity={row.MemoryLimit} | ||
formatValues={(value, total) => | ||
formatStorageValues(value, total, 'gb', undefined, true) | ||
} | ||
className={b('column-ram')} | ||
colorizeProgress | ||
hideCapacity | ||
/> | ||
</CellWithPopover> | ||
); | ||
}, | ||
align: DataTable.LEFT, | ||
width: 80, | ||
resizeMinWidth: 40, | ||
}; | ||
} | ||
export function getSharedCacheUsageColumn< | ||
T extends {SharedCacheUsed?: string | number; SharedCacheLimit?: string | number}, | ||
>(): Column<T> { | ||
|
@@ -130,10 +193,10 @@ export function getSharedCacheUsageColumn< | |
resizeMinWidth: 170, | ||
}; | ||
} | ||
export function getCpuColumn<T extends {PoolStats?: TPoolStats[]}>(): Column<T> { | ||
export function getPoolsColumn<T extends {PoolStats?: TPoolStats[]}>(): Column<T> { | ||
return { | ||
name: NODES_COLUMNS_IDS.CPU, | ||
header: NODES_COLUMNS_TITLES.CPU, | ||
name: NODES_COLUMNS_IDS.Pools, | ||
header: NODES_COLUMNS_TITLES.Pools, | ||
sortAccessor: ({PoolStats = []}) => Math.max(...PoolStats.map(({Usage}) => Number(Usage))), | ||
defaultOrder: DataTable.DESCENDING, | ||
render: ({row}) => | ||
|
@@ -143,6 +206,65 @@ export function getCpuColumn<T extends {PoolStats?: TPoolStats[]}>(): Column<T> | |
resizeMinWidth: 60, | ||
}; | ||
} | ||
export function getCpuColumn< | ||
T extends {PoolStats?: TPoolStats[]; CoresUsed?: number; CoresTotal?: number}, | ||
>(): Column<T> { | ||
return { | ||
name: NODES_COLUMNS_IDS.CPU, | ||
header: NODES_COLUMNS_TITLES.CPU, | ||
sortAccessor: ({PoolStats = []}) => Math.max(...PoolStats.map(({Usage}) => Number(Usage))), | ||
defaultOrder: DataTable.DESCENDING, | ||
render: ({row}) => { | ||
if (!row.PoolStats) { | ||
return EMPTY_DATA_PLACEHOLDER; | ||
} | ||
|
||
let totalPoolUsage = | ||
isNumeric(row.CoresUsed) && isNumeric(row.CoresTotal) | ||
? row.CoresUsed / row.CoresTotal | ||
: undefined; | ||
|
||
if (totalPoolUsage === undefined) { | ||
let totalThreadsCount = 0; | ||
totalPoolUsage = row.PoolStats.reduce((acc, pool) => { | ||
totalThreadsCount += Number(pool.Threads); | ||
return acc + Number(pool.Usage) * Number(pool.Threads); | ||
}, 0); | ||
|
||
totalPoolUsage = totalPoolUsage / totalThreadsCount; | ||
} | ||
|
||
return ( | ||
<CellWithPopover | ||
placement={['top', 'auto']} | ||
fullWidth | ||
content={ | ||
<DefinitionList responsive> | ||
{row.PoolStats.map((pool) => | ||
isNumeric(pool.Usage) ? ( | ||
<DefinitionList.Item key={pool.Name} name={pool.Name}> | ||
{formatPool('Usage', pool.Usage).value} | ||
</DefinitionList.Item> | ||
) : null, | ||
)} | ||
</DefinitionList> | ||
} | ||
> | ||
<ProgressViewer | ||
className={b('column-cpu')} | ||
value={totalPoolUsage} | ||
capacity={1} | ||
colorizeProgress | ||
percents | ||
/> | ||
</CellWithPopover> | ||
); | ||
}, | ||
align: DataTable.LEFT, | ||
width: 80, | ||
resizeMinWidth: 40, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. reworked |
||
}; | ||
} | ||
export function getLoadAverageColumn<T extends {LoadAveragePercents?: number[]}>(): Column<T> { | ||
return { | ||
name: NODES_COLUMNS_IDS.LoadAverage, | ||
|
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is no sorting for new columns if table is paginated.
Currently, for every column
name
is checked withisSortableNodesProperty
, ifname
is in the list, the column is sortable and it's name is sent to backend as sort param.I'm not sure what's to do in this case, since there are two columns with different ids, but they have the same sort fields (
CPU
andMemory
).Probably, you can use not column
name
, but add separatesortField
property to every column object (in such case it's better to do it in a separate PR, since it's a lot of refactoring). Maybe there is a better and easier solutionUh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
created dictionary for sort values
not sure if it's the best solution in the world, but as far as we decided to rename CPU to Pools looks like there are not so many choices left...