ydb-embedded-ui 4.8.2 → 4.10.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +27 -0
- package/dist/components/BasicNodeViewer/BasicNodeViewer.tsx +7 -4
- package/dist/components/EntityStatus/EntityStatus.js +3 -1
- package/dist/components/FormattedBytes/FormattedBytes.tsx +10 -0
- package/dist/components/FormattedBytes/utils.tsx +13 -0
- package/dist/components/FullNodeViewer/FullNodeViewer.tsx +73 -0
- package/dist/components/InfoViewer/formatters/table.ts +6 -5
- package/dist/components/NodeHostWrapper/NodeHostWrapper.tsx +2 -2
- package/dist/components/ProblemFilter/ProblemFilter.tsx +2 -2
- package/dist/components/SpeedMultiMeter/SpeedMultiMeter.tsx +4 -4
- package/dist/components/TruncatedQuery/{TruncatedQuery.js → TruncatedQuery.tsx} +10 -8
- package/dist/containers/AsideNavigation/AsideNavigation.tsx +6 -6
- package/dist/containers/Cluster/Cluster.tsx +10 -6
- package/dist/containers/Node/Node.tsx +3 -3
- package/dist/containers/Nodes/Nodes.tsx +3 -3
- package/dist/containers/Nodes/getNodesColumns.tsx +2 -2
- package/dist/containers/Storage/PDisk/PDisk.tsx +2 -7
- package/dist/containers/Storage/Storage.tsx +240 -0
- package/dist/containers/Storage/StorageGroups/StorageGroups.tsx +59 -57
- package/dist/containers/Storage/StorageNodes/StorageNodes.tsx +23 -25
- package/dist/containers/Storage/StorageTypeFilter/StorageTypeFilter.tsx +27 -0
- package/dist/containers/Storage/StorageVisibleEntityFilter/StorageVisibleEntityFilter.tsx +31 -0
- package/dist/containers/Storage/UsageFilter/UsageFilter.scss +1 -0
- package/dist/containers/Storage/UsageFilter/UsageFilter.tsx +17 -17
- package/dist/containers/Tenant/Diagnostics/Diagnostics.tsx +3 -3
- package/dist/containers/Tenant/Diagnostics/TenantOverview/TenantOverview.js +7 -4
- package/dist/containers/Tenant/Diagnostics/TenantOverview/TenantOverview.scss +0 -15
- package/dist/containers/Tenant/Diagnostics/TopQueries/TopQueries.tsx +10 -3
- package/dist/containers/Tenant/{Preview → Query/Preview}/Preview.scss +1 -1
- package/dist/containers/Tenant/Query/Preview/Preview.tsx +121 -0
- package/dist/containers/Tenant/Query/QueriesHistory/QueriesHistory.tsx +1 -1
- package/dist/containers/Tenant/Query/QueryEditor/QueryEditor.js +23 -51
- package/dist/containers/Tenant/Query/QueryEditorControls/QueryEditorControls.scss +20 -15
- package/dist/containers/Tenant/Query/QueryEditorControls/QueryEditorControls.tsx +74 -27
- package/dist/containers/Tenant/Query/SavedQueries/SavedQueries.tsx +1 -1
- package/dist/containers/Tenant/Query/i18n/en.json +9 -2
- package/dist/containers/Tenant/Query/i18n/ru.json +9 -2
- package/dist/containers/Tenants/Tenants.tsx +269 -0
- package/dist/containers/UserSettings/i18n/en.json +1 -1
- package/dist/containers/UserSettings/i18n/ru.json +1 -1
- package/dist/services/api.ts +14 -16
- package/dist/store/reducers/executeQuery.ts +2 -3
- package/dist/store/reducers/explainQuery.ts +2 -2
- package/dist/store/reducers/index.ts +2 -2
- package/dist/store/reducers/{nodes.ts → nodes/nodes.ts} +33 -32
- package/dist/{types/store/nodes.ts → store/reducers/nodes/types.ts} +24 -27
- package/dist/store/reducers/partitions/types.ts +3 -3
- package/dist/store/reducers/settings/settings.ts +14 -4
- package/dist/store/reducers/settings/types.ts +3 -1
- package/dist/store/reducers/storage/constants.ts +10 -0
- package/dist/store/reducers/storage/selectors.ts +279 -0
- package/dist/store/reducers/storage/storage.ts +191 -0
- package/dist/store/reducers/storage/types.ts +92 -0
- package/dist/store/reducers/tenants/selectors.ts +46 -0
- package/dist/store/reducers/tenants/tenants.ts +21 -14
- package/dist/store/reducers/tenants/types.ts +20 -5
- package/dist/store/reducers/tenants/utils.ts +68 -0
- package/dist/types/additionalProps.ts +8 -0
- package/dist/types/api/storage.ts +1 -1
- package/dist/types/store/query.ts +5 -6
- package/dist/types/store/topic.ts +3 -3
- package/dist/utils/bytesParsers/__test__/formatBytes.test.ts +38 -0
- package/dist/utils/bytesParsers/convertBytesObjectToSpeed.ts +2 -2
- package/dist/utils/bytesParsers/formatBytes.ts +132 -0
- package/dist/utils/bytesParsers/i18n/en.json +1 -0
- package/dist/utils/bytesParsers/i18n/ru.json +1 -0
- package/dist/utils/bytesParsers/index.ts +1 -1
- package/dist/utils/constants.ts +1 -0
- package/dist/utils/index.js +5 -10
- package/dist/utils/nodes.ts +2 -2
- package/dist/utils/numeral.ts +8 -0
- package/dist/utils/query.ts +12 -0
- package/package.json +1 -1
- package/dist/components/FullNodeViewer/FullNodeViewer.js +0 -89
- package/dist/containers/Node/NodeOverview/NodeOverview.scss +0 -0
- package/dist/containers/Node/NodeOverview/NodeOverview.tsx +0 -21
- package/dist/containers/Storage/Storage.js +0 -372
- package/dist/containers/Tenant/Preview/Preview.js +0 -168
- package/dist/containers/Tenant/Query/QueryEditorControls/OldQueryEditorControls.tsx +0 -90
- package/dist/containers/Tenant/Query/QueryEditorControls/shared.ts +0 -18
- package/dist/containers/Tenants/Tenants.js +0 -363
- package/dist/store/reducers/storage.js +0 -438
- package/dist/utils/bytesParsers/formatBytesCustom.ts +0 -57
@@ -2,23 +2,24 @@ import type {Reducer} from 'redux';
|
|
2
2
|
import {createSelector, Selector} from 'reselect';
|
3
3
|
import {escapeRegExp} from 'lodash/fp';
|
4
4
|
|
5
|
-
import '
|
6
|
-
import {HOUR_IN_SECONDS} from '
|
7
|
-
import {calcUptime, calcUptimeInSeconds} from '
|
8
|
-
import {NodesUptimeFilterValues} from '
|
5
|
+
import '../../../services/api';
|
6
|
+
import {HOUR_IN_SECONDS} from '../../../utils/constants';
|
7
|
+
import {calcUptime, calcUptimeInSeconds} from '../../../utils';
|
8
|
+
import {NodesUptimeFilterValues} from '../../../utils/nodes';
|
9
|
+
import {EFlag} from '../../../types/api/enums';
|
10
|
+
|
11
|
+
import type {ProblemFilterValue} from '../settings/types';
|
12
|
+
import {createRequestActionTypes, createApiRequest} from '../../utils';
|
13
|
+
import {ProblemFilterValues} from '../settings/settings';
|
14
|
+
|
9
15
|
import type {
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
} from '
|
17
|
-
import type {ValueOf} from '../../types/common';
|
18
|
-
import {EFlag} from '../../types/api/enums';
|
19
|
-
|
20
|
-
import {createRequestActionTypes, createApiRequest} from '../utils';
|
21
|
-
import {ProblemFilterValues} from './settings/settings';
|
16
|
+
NodesAction,
|
17
|
+
NodesApiRequestParams,
|
18
|
+
NodesHandledResponse,
|
19
|
+
NodesPreparedEntity,
|
20
|
+
NodesStateSlice,
|
21
|
+
NodesState,
|
22
|
+
} from './types';
|
22
23
|
|
23
24
|
export const FETCH_NODES = createRequestActionTypes('nodes', 'FETCH_NODES');
|
24
25
|
|
@@ -34,7 +35,7 @@ const initialState = {
|
|
34
35
|
searchValue: '',
|
35
36
|
};
|
36
37
|
|
37
|
-
const nodes: Reducer<
|
38
|
+
const nodes: Reducer<NodesState, NodesAction> = (state = initialState, action) => {
|
38
39
|
switch (action.type) {
|
39
40
|
case FETCH_NODES.REQUEST: {
|
40
41
|
return {
|
@@ -92,11 +93,11 @@ const nodes: Reducer<INodesState, INodesAction> = (state = initialState, action)
|
|
92
93
|
}
|
93
94
|
};
|
94
95
|
|
95
|
-
export function getNodes({tenant,
|
96
|
+
export function getNodes({tenant, visibleEntities, type = 'any'}: NodesApiRequestParams) {
|
96
97
|
return createApiRequest({
|
97
|
-
request: window.api.getNodes({tenant,
|
98
|
+
request: window.api.getNodes({tenant, visibleEntities, type}),
|
98
99
|
actions: FETCH_NODES,
|
99
|
-
dataHandler: (data):
|
100
|
+
dataHandler: (data): NodesHandledResponse => {
|
100
101
|
const rawNodes = data.Nodes || [];
|
101
102
|
|
102
103
|
const preparedNodes = rawNodes.map((node) => {
|
@@ -121,8 +122,8 @@ export function getComputeNodes(path: string) {
|
|
121
122
|
return createApiRequest({
|
122
123
|
request: window.api.getCompute(path),
|
123
124
|
actions: FETCH_NODES,
|
124
|
-
dataHandler: (data):
|
125
|
-
const preparedNodes:
|
125
|
+
dataHandler: (data): NodesHandledResponse => {
|
126
|
+
const preparedNodes: NodesPreparedEntity[] = [];
|
126
127
|
|
127
128
|
if (data.Tenants) {
|
128
129
|
for (const tenant of data.Tenants) {
|
@@ -174,13 +175,13 @@ export const setSearchValue = (value: string) => {
|
|
174
175
|
} as const;
|
175
176
|
};
|
176
177
|
|
177
|
-
const getNodesUptimeFilter = (state:
|
178
|
-
const getSearchValue = (state:
|
179
|
-
const getNodesList = (state:
|
178
|
+
const getNodesUptimeFilter = (state: NodesStateSlice) => state.nodes.nodesUptimeFilter;
|
179
|
+
const getSearchValue = (state: NodesStateSlice) => state.nodes.searchValue;
|
180
|
+
const getNodesList = (state: NodesStateSlice) => state.nodes.data;
|
180
181
|
|
181
182
|
const filterNodesByProblemsStatus = (
|
182
|
-
nodesList:
|
183
|
-
problemFilter:
|
183
|
+
nodesList: NodesPreparedEntity[] = [],
|
184
|
+
problemFilter: ProblemFilterValue,
|
184
185
|
) => {
|
185
186
|
if (problemFilter === ProblemFilterValues.ALL) {
|
186
187
|
return nodesList;
|
@@ -191,8 +192,8 @@ const filterNodesByProblemsStatus = (
|
|
191
192
|
});
|
192
193
|
};
|
193
194
|
|
194
|
-
export const filterNodesByUptime = (
|
195
|
-
nodesList:
|
195
|
+
export const filterNodesByUptime = <T extends {StartTime?: string}>(
|
196
|
+
nodesList: T[] = [],
|
196
197
|
nodesUptimeFilter: NodesUptimeFilterValues,
|
197
198
|
) => {
|
198
199
|
if (nodesUptimeFilter === NodesUptimeFilterValues.All) {
|
@@ -203,7 +204,7 @@ export const filterNodesByUptime = (
|
|
203
204
|
});
|
204
205
|
};
|
205
206
|
|
206
|
-
const filterNodesBySearchValue = (nodesList:
|
207
|
+
const filterNodesBySearchValue = (nodesList: NodesPreparedEntity[] = [], searchValue: string) => {
|
207
208
|
if (!searchValue) {
|
208
209
|
return nodesList;
|
209
210
|
}
|
@@ -215,8 +216,8 @@ const filterNodesBySearchValue = (nodesList: INodesPreparedEntity[] = [], search
|
|
215
216
|
};
|
216
217
|
|
217
218
|
export const getFilteredPreparedNodesList: Selector<
|
218
|
-
|
219
|
-
|
219
|
+
NodesStateSlice,
|
220
|
+
NodesPreparedEntity[] | undefined
|
220
221
|
> = createSelector(
|
221
222
|
[getNodesList, getNodesUptimeFilter, getSearchValue, (state) => state.settings.problemFilter],
|
222
223
|
(nodesList, uptimeFilter, searchValue, problemFilter) => {
|
@@ -1,22 +1,23 @@
|
|
1
|
-
import type {IResponseError} from '
|
2
|
-
import type {TEndpoint, TPoolStats} from '
|
3
|
-
import type {TTabletStateInfo as TComputeTabletStateInfo} from '
|
4
|
-
import type {TTabletStateInfo as TFullTabletStateInfo} from '
|
5
|
-
import type {EFlag} from '
|
1
|
+
import type {IResponseError} from '../../../types/api/error';
|
2
|
+
import type {TEndpoint, TPoolStats} from '../../../types/api/nodes';
|
3
|
+
import type {TTabletStateInfo as TComputeTabletStateInfo} from '../../../types/api/compute';
|
4
|
+
import type {TTabletStateInfo as TFullTabletStateInfo} from '../../../types/api/tablet';
|
5
|
+
import type {EFlag} from '../../../types/api/enums';
|
6
|
+
import type {ApiRequestAction} from '../../utils';
|
7
|
+
import type {VisibleEntities} from '../storage/types';
|
6
8
|
|
7
|
-
import {NodesUptimeFilterValues} from '
|
9
|
+
import {NodesUptimeFilterValues} from '../../../utils/nodes';
|
8
10
|
import {
|
9
11
|
FETCH_NODES,
|
10
12
|
resetNodesState,
|
11
13
|
setDataWasNotLoaded,
|
12
14
|
setNodesUptimeFilter,
|
13
15
|
setSearchValue,
|
14
|
-
} from '
|
15
|
-
import {ApiRequestAction} from '../../store/utils';
|
16
|
+
} from './nodes';
|
16
17
|
|
17
18
|
// Since nodes from different endpoints can have different types,
|
18
19
|
// This type describes fields, that are expected by tables with nodes
|
19
|
-
export interface
|
20
|
+
export interface NodesPreparedEntity {
|
20
21
|
NodeId: number;
|
21
22
|
Host?: string;
|
22
23
|
SystemState?: EFlag;
|
@@ -33,43 +34,39 @@ export interface INodesPreparedEntity {
|
|
33
34
|
Endpoints?: TEndpoint[];
|
34
35
|
}
|
35
36
|
|
36
|
-
export interface
|
37
|
+
export interface NodesState {
|
37
38
|
loading: boolean;
|
38
39
|
wasLoaded: boolean;
|
39
40
|
nodesUptimeFilter: NodesUptimeFilterValues;
|
40
41
|
searchValue: string;
|
41
|
-
data?:
|
42
|
+
data?: NodesPreparedEntity[];
|
42
43
|
totalNodes?: number;
|
43
44
|
error?: IResponseError;
|
44
45
|
}
|
45
46
|
|
46
|
-
type
|
47
|
+
export type NodeType = 'static' | 'dynamic' | 'any';
|
47
48
|
|
48
|
-
|
49
|
-
// Missing - nodes with missing disks
|
50
|
-
type INodesApiRequestProblemType = 'missing' | 'space';
|
51
|
-
|
52
|
-
export interface INodesApiRequestParams {
|
49
|
+
export interface NodesApiRequestParams {
|
53
50
|
tenant?: string;
|
54
|
-
type?:
|
55
|
-
|
51
|
+
type?: NodeType;
|
52
|
+
visibleEntities?: VisibleEntities;
|
56
53
|
storage?: boolean;
|
57
54
|
tablets?: boolean;
|
58
55
|
}
|
59
56
|
|
60
|
-
export interface
|
61
|
-
Nodes?:
|
57
|
+
export interface NodesHandledResponse {
|
58
|
+
Nodes?: NodesPreparedEntity[];
|
62
59
|
TotalNodes: number;
|
63
60
|
}
|
64
61
|
|
65
|
-
type
|
62
|
+
type NodesApiRequestAction = ApiRequestAction<
|
66
63
|
typeof FETCH_NODES,
|
67
|
-
|
64
|
+
NodesHandledResponse,
|
68
65
|
IResponseError
|
69
66
|
>;
|
70
67
|
|
71
|
-
export type
|
72
|
-
|
|
68
|
+
export type NodesAction =
|
69
|
+
| NodesApiRequestAction
|
73
70
|
| (
|
74
71
|
| ReturnType<typeof setDataWasNotLoaded>
|
75
72
|
| ReturnType<typeof setNodesUptimeFilter>
|
@@ -77,6 +74,6 @@ export type INodesAction =
|
|
77
74
|
| ReturnType<typeof resetNodesState>
|
78
75
|
);
|
79
76
|
|
80
|
-
export interface
|
81
|
-
nodes:
|
77
|
+
export interface NodesStateSlice {
|
78
|
+
nodes: NodesState;
|
82
79
|
}
|
@@ -1,5 +1,5 @@
|
|
1
1
|
import type {IResponseError} from '../../../types/api/error';
|
2
|
-
import type {
|
2
|
+
import type {ProcessSpeedStats} from '../../../utils/bytesParsers';
|
3
3
|
import type {ApiRequestAction} from '../../utils';
|
4
4
|
|
5
5
|
import {FETCH_PARTITIONS, setDataWasNotLoaded, setSelectedConsumer} from './partitions';
|
@@ -9,8 +9,8 @@ export interface PreparedPartitionData {
|
|
9
9
|
partitionId: string;
|
10
10
|
storeSize: string;
|
11
11
|
|
12
|
-
writeSpeed:
|
13
|
-
readSpeed?:
|
12
|
+
writeSpeed: ProcessSpeedStats;
|
13
|
+
readSpeed?: ProcessSpeedStats;
|
14
14
|
|
15
15
|
partitionWriteLag: number;
|
16
16
|
partitionWriteIdleTime: number;
|
@@ -1,7 +1,6 @@
|
|
1
1
|
import type {Reducer} from 'redux';
|
2
2
|
import type {ThunkAction} from 'redux-thunk';
|
3
3
|
|
4
|
-
import type {ValueOf} from '../../../types/common';
|
5
4
|
import {
|
6
5
|
SAVED_QUERIES_KEY,
|
7
6
|
THEME_KEY,
|
@@ -13,15 +12,17 @@ import {
|
|
13
12
|
QUERY_INITIAL_MODE_KEY,
|
14
13
|
ENABLE_ADDITIONAL_QUERY_MODES,
|
15
14
|
CLUSTER_INFO_HIDDEN_KEY,
|
15
|
+
LAST_USED_QUERY_ACTION_KEY,
|
16
16
|
} from '../../../utils/constants';
|
17
17
|
import '../../../services/api';
|
18
18
|
import {getValueFromLS, parseJson} from '../../../utils/utils';
|
19
|
-
import {
|
19
|
+
import {QUERY_ACTIONS, QUERY_MODES} from '../../../utils/query';
|
20
20
|
|
21
21
|
import {TENANT_PAGES_IDS} from '../tenant/constants';
|
22
22
|
|
23
23
|
import type {RootState} from '..';
|
24
24
|
import type {
|
25
|
+
ProblemFilterValue,
|
25
26
|
SetSettingValueAction,
|
26
27
|
SettingsAction,
|
27
28
|
SettingsRootStateSlice,
|
@@ -64,7 +65,14 @@ export const initialState = {
|
|
64
65
|
TENANT_INITIAL_PAGE_KEY,
|
65
66
|
TENANT_PAGES_IDS.query,
|
66
67
|
),
|
67
|
-
[QUERY_INITIAL_MODE_KEY]: readSavedSettingsValue(
|
68
|
+
[QUERY_INITIAL_MODE_KEY]: readSavedSettingsValue(
|
69
|
+
QUERY_INITIAL_MODE_KEY,
|
70
|
+
QUERY_MODES.script,
|
71
|
+
),
|
72
|
+
[LAST_USED_QUERY_ACTION_KEY]: readSavedSettingsValue(
|
73
|
+
LAST_USED_QUERY_ACTION_KEY,
|
74
|
+
QUERY_ACTIONS.execute,
|
75
|
+
),
|
68
76
|
[ASIDE_HEADER_COMPACT_KEY]: readSavedSettingsValue(ASIDE_HEADER_COMPACT_KEY, 'true'),
|
69
77
|
[PARTITIONS_HIDDEN_COLUMNS_KEY]: readSavedSettingsValue(PARTITIONS_HIDDEN_COLUMNS_KEY),
|
70
78
|
[CLUSTER_INFO_HIDDEN_KEY]: readSavedSettingsValue(CLUSTER_INFO_HIDDEN_KEY, 'true'),
|
@@ -125,11 +133,13 @@ export const getParsedSettingValue = (state: SettingsRootStateSlice, name: strin
|
|
125
133
|
return parseJson(value);
|
126
134
|
};
|
127
135
|
|
128
|
-
export const changeFilter = (filter:
|
136
|
+
export const changeFilter = (filter: ProblemFilterValue) => {
|
129
137
|
return {
|
130
138
|
type: CHANGE_PROBLEM_FILTER,
|
131
139
|
data: filter,
|
132
140
|
} as const;
|
133
141
|
};
|
134
142
|
|
143
|
+
export const selectProblemFilter = (state: SettingsRootStateSlice) => state.settings.problemFilter;
|
144
|
+
|
135
145
|
export default settings;
|
@@ -1,8 +1,10 @@
|
|
1
1
|
import type {ValueOf} from '../../../types/common';
|
2
2
|
import {changeFilter, ProblemFilterValues, SET_SETTING_VALUE} from './settings';
|
3
3
|
|
4
|
+
export type ProblemFilterValue = ValueOf<typeof ProblemFilterValues>;
|
5
|
+
|
4
6
|
export interface SettingsState {
|
5
|
-
problemFilter:
|
7
|
+
problemFilter: ProblemFilterValue;
|
6
8
|
userSettings: Record<string, string | undefined>;
|
7
9
|
systemSettings: Record<string, string | undefined>;
|
8
10
|
}
|
@@ -0,0 +1,279 @@
|
|
1
|
+
import {Selector, createSelector} from 'reselect';
|
2
|
+
import {getUsage} from '../../../utils/storage';
|
3
|
+
|
4
|
+
import type {TNodeInfo} from '../../../types/api/nodes';
|
5
|
+
import {TPDiskState} from '../../../types/api/pdisk';
|
6
|
+
import {EVDiskState, TVDiskStateInfo} from '../../../types/api/vdisk';
|
7
|
+
import {EFlag} from '../../../types/api/enums';
|
8
|
+
import {getPDiskType} from '../../../utils/pdisk';
|
9
|
+
import {calcUptime} from '../../../utils';
|
10
|
+
|
11
|
+
import type {
|
12
|
+
PreparedStorageGroup,
|
13
|
+
PreparedStorageNode,
|
14
|
+
RawStorageGroup,
|
15
|
+
StorageStateSlice,
|
16
|
+
UsageFilter,
|
17
|
+
} from './types';
|
18
|
+
import {filterNodesByUptime} from '../nodes/nodes';
|
19
|
+
|
20
|
+
// ==== Prepare data ====
|
21
|
+
const FLAGS_POINTS = {
|
22
|
+
[EFlag.Green]: 1,
|
23
|
+
[EFlag.Yellow]: 100,
|
24
|
+
[EFlag.Orange]: 10_000,
|
25
|
+
[EFlag.Red]: 1_000_000,
|
26
|
+
};
|
27
|
+
|
28
|
+
const prepareStorageGroupData = (
|
29
|
+
group: RawStorageGroup,
|
30
|
+
poolName?: string,
|
31
|
+
): PreparedStorageGroup => {
|
32
|
+
let missing = 0;
|
33
|
+
let usedSpaceFlag = 0;
|
34
|
+
let usedSpaceBytes = 0;
|
35
|
+
let limitSizeBytes = 0;
|
36
|
+
let readSpeedBytesPerSec = 0;
|
37
|
+
let writeSpeedBytesPerSec = 0;
|
38
|
+
let mediaType = '';
|
39
|
+
|
40
|
+
if (group.VDisks) {
|
41
|
+
for (const vDisk of group.VDisks) {
|
42
|
+
const {
|
43
|
+
Replicated,
|
44
|
+
VDiskState,
|
45
|
+
AvailableSize,
|
46
|
+
AllocatedSize,
|
47
|
+
PDisk,
|
48
|
+
DiskSpace,
|
49
|
+
ReadThroughput,
|
50
|
+
WriteThroughput,
|
51
|
+
} = vDisk;
|
52
|
+
|
53
|
+
if (
|
54
|
+
!Replicated ||
|
55
|
+
PDisk?.State !== TPDiskState.Normal ||
|
56
|
+
VDiskState !== EVDiskState.OK
|
57
|
+
) {
|
58
|
+
missing += 1;
|
59
|
+
}
|
60
|
+
|
61
|
+
if (DiskSpace && DiskSpace !== EFlag.Grey) {
|
62
|
+
usedSpaceFlag += FLAGS_POINTS[DiskSpace];
|
63
|
+
}
|
64
|
+
|
65
|
+
const available = Number(AvailableSize ?? PDisk?.AvailableSize) || 0;
|
66
|
+
const allocated = Number(AllocatedSize) || 0;
|
67
|
+
|
68
|
+
usedSpaceBytes += allocated;
|
69
|
+
limitSizeBytes += available + allocated;
|
70
|
+
|
71
|
+
readSpeedBytesPerSec += Number(ReadThroughput) || 0;
|
72
|
+
writeSpeedBytesPerSec += Number(WriteThroughput) || 0;
|
73
|
+
|
74
|
+
const currentType = getPDiskType(PDisk || {});
|
75
|
+
mediaType =
|
76
|
+
currentType && (currentType === mediaType || mediaType === '')
|
77
|
+
? currentType
|
78
|
+
: 'Mixed';
|
79
|
+
}
|
80
|
+
}
|
81
|
+
|
82
|
+
// VDisk doesn't have its own StoragePoolName when located inside StoragePool data
|
83
|
+
const vDisks = group.VDisks?.map((vdisk) => ({
|
84
|
+
...vdisk,
|
85
|
+
StoragePoolName: poolName,
|
86
|
+
Donors: vdisk.Donors?.map((donor) => ({
|
87
|
+
...donor,
|
88
|
+
StoragePoolName: poolName,
|
89
|
+
})),
|
90
|
+
}));
|
91
|
+
|
92
|
+
return {
|
93
|
+
...group,
|
94
|
+
VDisks: vDisks,
|
95
|
+
Read: readSpeedBytesPerSec,
|
96
|
+
Write: writeSpeedBytesPerSec,
|
97
|
+
PoolName: poolName,
|
98
|
+
Used: usedSpaceBytes,
|
99
|
+
Limit: limitSizeBytes,
|
100
|
+
Missing: missing,
|
101
|
+
UsedSpaceFlag: usedSpaceFlag,
|
102
|
+
Type: mediaType || null,
|
103
|
+
};
|
104
|
+
};
|
105
|
+
|
106
|
+
const prepareStorageNodeData = (node: TNodeInfo): PreparedStorageNode => {
|
107
|
+
const systemState = node.SystemState ?? {};
|
108
|
+
const missing =
|
109
|
+
node.PDisks?.filter((pDisk) => {
|
110
|
+
return pDisk.State !== TPDiskState.Normal;
|
111
|
+
}).length || 0;
|
112
|
+
|
113
|
+
return {
|
114
|
+
NodeId: node.NodeId,
|
115
|
+
SystemState: systemState.SystemState,
|
116
|
+
DataCenter: systemState.DataCenter,
|
117
|
+
Rack: systemState.Rack,
|
118
|
+
Host: systemState.Host,
|
119
|
+
Endpoints: systemState.Endpoints,
|
120
|
+
Uptime: calcUptime(systemState.StartTime),
|
121
|
+
StartTime: systemState.StartTime,
|
122
|
+
PDisks: node.PDisks,
|
123
|
+
Missing: missing,
|
124
|
+
};
|
125
|
+
};
|
126
|
+
|
127
|
+
// ==== Filters ====
|
128
|
+
|
129
|
+
const prepareSearchText = (text: string) => text.trim().toLowerCase();
|
130
|
+
|
131
|
+
const filterNodesByText = (entities: PreparedStorageNode[], text: string) => {
|
132
|
+
const preparedSearch = prepareSearchText(text);
|
133
|
+
|
134
|
+
if (!preparedSearch) {
|
135
|
+
return entities;
|
136
|
+
}
|
137
|
+
|
138
|
+
return entities.filter((entity) => {
|
139
|
+
return (
|
140
|
+
entity.NodeId?.toString().includes(preparedSearch) ||
|
141
|
+
entity.Host?.toLowerCase().includes(preparedSearch)
|
142
|
+
);
|
143
|
+
});
|
144
|
+
};
|
145
|
+
const filterGroupsByText = (entities: PreparedStorageGroup[], text: string) => {
|
146
|
+
const preparedSearch = prepareSearchText(text);
|
147
|
+
|
148
|
+
if (!preparedSearch) {
|
149
|
+
return entities;
|
150
|
+
}
|
151
|
+
|
152
|
+
return entities.filter((entity) => {
|
153
|
+
return (
|
154
|
+
entity.PoolName?.toLowerCase().includes(preparedSearch) ||
|
155
|
+
entity.GroupID?.toString().includes(preparedSearch)
|
156
|
+
);
|
157
|
+
});
|
158
|
+
};
|
159
|
+
|
160
|
+
const filterGroupsByUsage = (entities: PreparedStorageGroup[], usage?: string[]) => {
|
161
|
+
if (!Array.isArray(usage) || usage.length === 0) {
|
162
|
+
return entities;
|
163
|
+
}
|
164
|
+
|
165
|
+
return entities.filter((entity) => {
|
166
|
+
const entityUsage = getUsage(entity, 5);
|
167
|
+
return usage.some((val) => Number(val) <= entityUsage && entityUsage < Number(val) + 5);
|
168
|
+
});
|
169
|
+
};
|
170
|
+
|
171
|
+
// ==== Simple selectors ====
|
172
|
+
|
173
|
+
export const selectStoragePools = (state: StorageStateSlice) => state.storage.groups?.StoragePools;
|
174
|
+
export const selectStorageGroupsCount = (state: StorageStateSlice) => ({
|
175
|
+
total: state.storage.groups?.TotalGroups || 0,
|
176
|
+
found: state.storage.groups?.FoundGroups || 0,
|
177
|
+
});
|
178
|
+
export const selectStorageNodes = (state: StorageStateSlice) => state.storage.nodes?.Nodes;
|
179
|
+
export const selectStorageNodesCount = (state: StorageStateSlice) => ({
|
180
|
+
total: state.storage.nodes?.TotalNodes || 0,
|
181
|
+
found: state.storage.nodes?.FoundNodes || 0,
|
182
|
+
});
|
183
|
+
|
184
|
+
export const selectStorageFilter = (state: StorageStateSlice) => state.storage.filter;
|
185
|
+
export const selectUsageFilter = (state: StorageStateSlice) => state.storage.usageFilter;
|
186
|
+
export const selectVisibleEntities = (state: StorageStateSlice) => state.storage.visible;
|
187
|
+
export const selectNodesUptimeFilter = (state: StorageStateSlice) =>
|
188
|
+
state.storage.nodesUptimeFilter;
|
189
|
+
export const selectStorageType = (state: StorageStateSlice) => state.storage.type;
|
190
|
+
|
191
|
+
// ==== Complex selectors ====
|
192
|
+
|
193
|
+
const selectPreparedStorageNodes: Selector<StorageStateSlice, PreparedStorageNode[]> =
|
194
|
+
createSelector(selectStorageNodes, (storageNodes) => {
|
195
|
+
if (!storageNodes) {
|
196
|
+
return [];
|
197
|
+
}
|
198
|
+
|
199
|
+
return storageNodes.map(prepareStorageNodeData);
|
200
|
+
});
|
201
|
+
|
202
|
+
export const selectPreparedStorageGroups: Selector<StorageStateSlice, PreparedStorageGroup[]> =
|
203
|
+
createSelector(selectStoragePools, (storagePools) => {
|
204
|
+
const preparedGroups: PreparedStorageGroup[] = [];
|
205
|
+
|
206
|
+
storagePools?.forEach((pool) => {
|
207
|
+
pool.Groups?.forEach((group) => {
|
208
|
+
preparedGroups.push(prepareStorageGroupData(group, pool.Name));
|
209
|
+
});
|
210
|
+
});
|
211
|
+
|
212
|
+
return preparedGroups;
|
213
|
+
});
|
214
|
+
|
215
|
+
export const selectVDisksForPDisk: Selector<
|
216
|
+
StorageStateSlice,
|
217
|
+
TVDiskStateInfo[] | undefined,
|
218
|
+
[number | undefined, number | undefined]
|
219
|
+
> = createSelector(
|
220
|
+
[
|
221
|
+
selectStorageNodes,
|
222
|
+
(_state, nodeId: number | undefined) => nodeId,
|
223
|
+
(_state, _nodeId, pdiskId: number | undefined) => pdiskId,
|
224
|
+
],
|
225
|
+
(storageNodes, nodeId, pdiskId) => {
|
226
|
+
const targetNode = storageNodes?.find((node) => node.NodeId === nodeId);
|
227
|
+
return targetNode?.VDisks?.filter((vdisk) => vdisk.PDiskId === pdiskId).map((data) => ({
|
228
|
+
...data,
|
229
|
+
NodeId: nodeId,
|
230
|
+
}));
|
231
|
+
},
|
232
|
+
);
|
233
|
+
|
234
|
+
export const selectUsageFilterOptions: Selector<StorageStateSlice, UsageFilter[]> = createSelector(
|
235
|
+
selectPreparedStorageGroups,
|
236
|
+
(groups) => {
|
237
|
+
const items: Record<number, number> = {};
|
238
|
+
|
239
|
+
groups.forEach((group) => {
|
240
|
+
const usage = getUsage(group, 5);
|
241
|
+
|
242
|
+
if (!Object.prototype.hasOwnProperty.call(items, usage)) {
|
243
|
+
items[usage] = 0;
|
244
|
+
}
|
245
|
+
|
246
|
+
items[usage] += 1;
|
247
|
+
});
|
248
|
+
|
249
|
+
return Object.entries(items)
|
250
|
+
.map(([threshold, count]) => ({threshold: Number(threshold), count}))
|
251
|
+
.sort((a, b) => b.threshold - a.threshold);
|
252
|
+
},
|
253
|
+
);
|
254
|
+
|
255
|
+
// ==== Complex selectors with filters ====
|
256
|
+
|
257
|
+
export const selectFilteredNodes: Selector<StorageStateSlice, PreparedStorageNode[]> =
|
258
|
+
createSelector(
|
259
|
+
[selectPreparedStorageNodes, selectStorageFilter, selectNodesUptimeFilter],
|
260
|
+
(storageNodes, textFilter, uptimeFilter) => {
|
261
|
+
let result = storageNodes;
|
262
|
+
result = filterNodesByText(result, textFilter);
|
263
|
+
result = filterNodesByUptime(result, uptimeFilter);
|
264
|
+
|
265
|
+
return result;
|
266
|
+
},
|
267
|
+
);
|
268
|
+
|
269
|
+
export const selectFilteredGroups: Selector<StorageStateSlice, PreparedStorageGroup[]> =
|
270
|
+
createSelector(
|
271
|
+
[selectPreparedStorageGroups, selectStorageFilter, selectUsageFilter],
|
272
|
+
(storageGroups, textFilter, usageFilter) => {
|
273
|
+
let result = storageGroups;
|
274
|
+
result = filterGroupsByText(result, textFilter);
|
275
|
+
result = filterGroupsByUsage(result, usageFilter);
|
276
|
+
|
277
|
+
return result;
|
278
|
+
},
|
279
|
+
);
|