Skip to content
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

feat: set pdisks column width #1793

Merged
merged 6 commits into from
Dec 27, 2024
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 2 additions & 8 deletions src/containers/Storage/PDisk/PDisk.scss
Original file line number Diff line number Diff line change
@@ -1,18 +1,12 @@
.pdisk-storage {
--pdisk-vdisk-width: 3px;
--pdisk-gap-width: 2px;

position: relative;

display: flex;
flex-direction: column;
justify-content: flex-end;

width: calc(
var(--pdisk-max-slots, 1) * var(--pdisk-vdisk-width) + (var(--pdisk-max-slots, 1) - 1) *
var(--pdisk-gap-width)
);
min-width: 120px;
width: var(--pdisk-width);
min-width: var(--pdisk-min-width);

&__content {
position: relative;
Expand Down
16 changes: 1 addition & 15 deletions src/containers/Storage/PDisk/PDisk.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,6 @@ import './PDisk.scss';

const b = cn('pdisk-storage');

const PDISK_MAX_SLOTS_CSS_VAR = '--pdisk-max-slots';

interface PDiskProps {
data?: PreparedPDisk;
vDisks?: PreparedVDisk[];
Expand All @@ -27,7 +25,6 @@ interface PDiskProps {
className?: string;
progressBarClassName?: string;
viewContext?: StorageViewContext;
maximumSlotsPerDisk?: string;
}

export const PDisk = ({
Expand All @@ -39,7 +36,6 @@ export const PDisk = ({
className,
progressBarClassName,
viewContext,
maximumSlotsPerDisk,
}: PDiskProps) => {
const {NodeId, PDiskId} = data;
const pDiskIdsDefined = valueIsDefined(NodeId) && valueIsDefined(PDiskId);
Expand Down Expand Up @@ -77,17 +73,7 @@ export const PDisk = ({
}

return (
<div
className={b(null, className)}
ref={anchorRef}
style={
maximumSlotsPerDisk
? ({
[PDISK_MAX_SLOTS_CSS_VAR]: maximumSlotsPerDisk,
} as React.CSSProperties)
: undefined
}
>
<div className={b(null, className)} ref={anchorRef}>
{renderVDisks()}
<HoverPopup
showPopup={showPopup}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,18 @@
@import '../../../../styles/mixins.scss';

.ydb-storage-nodes-columns {
&__pdisks-column {
overflow: visible; // to enable stacked disks overflow the row
}

&__pdisks-wrapper {
display: flex;
gap: 10px;
gap: var(--pdisk-margin);

width: 100%;
width: var(--pdisks-container-width);
height: 40px;

@include calculate-storage-pdisk-variables();
}

&__pdisks-item {
Expand Down
18 changes: 10 additions & 8 deletions src/containers/Storage/StorageNodes/columns/columns.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,27 +30,30 @@ import './StorageNodesColumns.scss';

const b = cn('ydb-storage-nodes-columns');

const MAX_SLOTS_CSS_VAR = '--maximum-slots';
const MAX_DISKS_CSS_VAR = '--maximum-disks';

const getPDisksColumn = ({viewContext}: GetStorageNodesColumnsParams): StorageNodesColumn => {
return {
name: NODES_COLUMNS_IDS.PDisks,
header: NODES_COLUMNS_TITLES.PDisks,
className: b('pdisks-column'),
render: ({row}) => {
const pDiskStyles = {
[MAX_SLOTS_CSS_VAR]: row.MaximumSlotsPerDisk,
[MAX_DISKS_CSS_VAR]: row.MaximumDisksPerNode,
} as React.CSSProperties;

return (
<div className={b('pdisks-wrapper')}>
<div className={b('pdisks-wrapper')} style={pDiskStyles}>
{row.PDisks?.map((pDisk) => {
const vDisks = row.VDisks?.filter(
(vdisk) => vdisk.PDiskId === pDisk.PDiskId,
);

return (
<div className={b('pdisks-item')} key={pDisk.PDiskId}>
<PDisk
data={pDisk}
vDisks={vDisks}
viewContext={viewContext}
maximumSlotsPerDisk={row.MaximumSlotsPerDisk}
/>
<PDisk data={pDisk} vDisks={vDisks} viewContext={viewContext} />
</div>
);
})}
Expand All @@ -59,7 +62,6 @@ const getPDisksColumn = ({viewContext}: GetStorageNodesColumnsParams): StorageNo
},
align: DataTable.CENTER,
sortable: false,
width: 900,
resizeable: false,
};
};
Expand Down
50 changes: 32 additions & 18 deletions src/containers/Storage/StorageNodes/getNodes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import {
NODES_COLUMNS_TO_DATA_FIELDS,
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will delete mocks right before merge

getNodesColumnSortField,
} from '../../../components/nodesColumns/constants';
import {generateNodes} from '../../../mocks/storage/nodes';
import type {
PreparedStorageNode,
PreparedStorageNodeFilters,
Expand All @@ -12,7 +13,6 @@ import type {NodesRequestParams} from '../../../types/api/nodes';
import {prepareSortValue} from '../../../utils/filters';
import {getUptimeParamValue} from '../../../utils/nodes';
import {getRequiredDataFields} from '../../../utils/tableUtils/getRequiredDataFields';

export const getStorageNodes: FetchData<
PreparedStorageNode,
PreparedStorageNodeFilters,
Expand All @@ -38,28 +38,42 @@ export const getStorageNodes: FetchData<
filterGroupBy,
} = filters ?? {};
const {sortOrder, columnId} = sortParams ?? {};

const sortField = getNodesColumnSortField(columnId);
const sort = sortField ? prepareSortValue(sortField, sortOrder) : undefined;

const dataFieldsRequired = getRequiredDataFields(columnsIds, NODES_COLUMNS_TO_DATA_FIELDS);

const response = await window.api.viewer.getNodes({
type,
storage,
limit,
offset,
sort,
filter: searchValue,
uptime: getUptimeParamValue(nodesUptimeFilter),
with: visibleEntities,
database,
node_id: nodeId,
group_id: groupId,
filter_group: filterGroup,
filter_group_by: filterGroupBy,
fieldsRequired: dataFieldsRequired,
});
let response;
const urlParams = new URLSearchParams(window.location.search);
if (urlParams.get('mocks')) {
// Get mock configuration from URL parameters or use defaults
const pdisks = parseInt(urlParams.get('pdisks') || '10', 10);
const vdisksPerPDisk = parseInt(urlParams.get('vdisksPerPDisk') || '2', 10);
const totalNodes = parseInt(urlParams.get('totalNodes') || '50', 10);
response = generateNodes(totalNodes, {
maxVdisksPerPDisk: vdisksPerPDisk,
maxPdisks: pdisks,
offset,
limit,
});
} else {
response = await window.api.viewer.getNodes({
type,
storage,
limit,
offset,
sort,
filter: searchValue,
uptime: getUptimeParamValue(nodesUptimeFilter),
with: visibleEntities,
database,
node_id: nodeId,
group_id: groupId,
filter_group: filterGroup,
filter_group_by: filterGroupBy,
fieldsRequired: dataFieldsRequired,
});
}
const preparedResponse = prepareStorageNodesResponse(response);
return {
data: preparedResponse.nodes || [],
Expand Down
Loading
Loading