ydb-embedded-ui 4.5.1 → 4.6.0
Sign up to get free protection for your applications and to get access to all the features.
- package/CHANGELOG.md +20 -0
- package/dist/components/FullNodeViewer/FullNodeViewer.js +1 -1
- package/dist/components/NodeHostWrapper/NodeHostWrapper.tsx +1 -1
- package/dist/components/PoolUsage/PoolUsage.scss +1 -1
- package/dist/components/PoolUsage/PoolUsage.tsx +50 -0
- package/dist/containers/App/Content.js +3 -2
- package/dist/containers/AsideNavigation/AsideNavigation.tsx +4 -50
- package/dist/containers/Cluster/Cluster.scss +7 -48
- package/dist/containers/Cluster/Cluster.tsx +136 -20
- package/dist/containers/Cluster/ClusterInfo/ClusterInfo.scss +34 -17
- package/dist/containers/Cluster/ClusterInfo/ClusterInfo.tsx +57 -91
- package/dist/containers/Cluster/ClusterInfoSkeleton/ClusterInfoSkeleton.scss +48 -0
- package/dist/containers/Cluster/ClusterInfoSkeleton/ClusterInfoSkeleton.tsx +34 -0
- package/dist/containers/Cluster/utils.ts +34 -0
- package/dist/containers/Header/Header.scss +0 -24
- package/dist/containers/Header/Header.tsx +14 -44
- package/dist/containers/Node/Node.tsx +23 -21
- package/dist/containers/Node/NodeStructure/NodeStructure.tsx +19 -17
- package/dist/containers/Nodes/Nodes.tsx +0 -16
- package/dist/containers/Nodes/getNodesColumns.tsx +1 -1
- package/dist/containers/Storage/Storage.js +1 -11
- package/dist/containers/Tablet/Tablet.tsx +28 -0
- package/dist/containers/TabletsFilters/TabletsFilters.js +16 -1
- package/dist/containers/Tenant/Diagnostics/Describe/Describe.tsx +1 -1
- package/dist/containers/Tenant/Diagnostics/DetailedOverview/DetailedOverview.scss +3 -0
- package/dist/containers/Tenant/Diagnostics/Diagnostics.tsx +3 -3
- package/dist/containers/Tenant/Diagnostics/Network/Network.js +2 -2
- package/dist/containers/Tenant/Diagnostics/Overview/ChangefeedInfo/ChangefeedInfo.tsx +4 -6
- package/dist/containers/Tenant/Diagnostics/Overview/Overview.tsx +56 -53
- package/dist/containers/Tenant/Diagnostics/TenantOverview/TenantOverview.js +1 -1
- package/dist/containers/Tenant/Diagnostics/TopShards/TopShards.tsx +1 -1
- package/dist/containers/Tenant/ObjectSummary/ObjectSummary.tsx +1 -1
- package/dist/containers/Tenant/Preview/Preview.js +1 -1
- package/dist/containers/Tenant/QueryEditor/QueryEditor.js +26 -22
- package/dist/containers/Tenant/QueryEditor/QueryEditorControls/OldQueryEditorControls.tsx +10 -3
- package/dist/containers/Tenant/QueryEditor/QueryEditorControls/QueryEditorControls.tsx +8 -1
- package/dist/containers/Tenant/QueryEditor/QueryEditorControls/shared.ts +1 -6
- package/dist/containers/Tenant/Schema/SchemaTree/SchemaTree.tsx +1 -1
- package/dist/containers/Tenant/Tenant.tsx +8 -13
- package/dist/containers/Tenant/utils/schemaActions.ts +1 -1
- package/dist/containers/Tenants/Tenants.js +18 -28
- package/dist/containers/Tenants/Tenants.scss +2 -4
- package/dist/containers/UserSettings/i18n/en.json +2 -2
- package/dist/containers/UserSettings/i18n/ru.json +2 -2
- package/dist/containers/UserSettings/settings.ts +4 -4
- package/dist/containers/Versions/GroupedNodesTree/GroupedNodesTree.scss +1 -0
- package/dist/containers/Versions/NodesTable/NodesTable.tsx +2 -3
- package/dist/containers/Versions/Versions.scss +0 -4
- package/dist/containers/Versions/Versions.tsx +74 -66
- package/dist/routes.ts +0 -7
- package/dist/services/api.ts +8 -4
- package/dist/store/reducers/clusterNodes/clusterNodes.tsx +4 -0
- package/dist/store/reducers/index.ts +6 -4
- package/dist/store/reducers/{network.js → network/network.ts} +11 -8
- package/dist/store/reducers/network/types.ts +16 -0
- package/dist/store/reducers/node/node.ts +102 -0
- package/dist/store/reducers/node/selectors.ts +59 -0
- package/dist/store/reducers/node/types.ts +44 -0
- package/dist/store/reducers/overview/overview.ts +109 -0
- package/dist/store/reducers/overview/types.ts +24 -0
- package/dist/store/reducers/{schema.ts → schema/schema.ts} +24 -50
- package/dist/{types/store/schema.ts → store/reducers/schema/types.ts} +16 -15
- package/dist/store/reducers/{schemaAcl.js → schemaAcl/schemaAcl.ts} +20 -9
- package/dist/store/reducers/schemaAcl/types.ts +15 -0
- package/dist/store/reducers/settings/settings.ts +5 -3
- package/dist/types/api/acl.ts +1 -1
- package/dist/types/api/query.ts +78 -44
- package/dist/types/store/explainQuery.ts +2 -2
- package/dist/types/store/query.ts +4 -2
- package/dist/utils/constants.ts +3 -1
- package/dist/utils/nodes.ts +1 -1
- package/dist/utils/query.ts +3 -3
- package/package.json +1 -1
- package/dist/components/PoolUsage/PoolUsage.js +0 -54
- package/dist/store/reducers/node.js +0 -141
package/dist/types/api/query.ts
CHANGED
@@ -24,17 +24,17 @@ interface TKqpStatsCompile {}
|
|
24
24
|
interface TDqTableStats {
|
25
25
|
TablePath?: string;
|
26
26
|
/** uint64 */
|
27
|
-
ReadRows?: string;
|
27
|
+
ReadRows?: string | number;
|
28
28
|
/** uint64 */
|
29
|
-
ReadBytes?: string;
|
29
|
+
ReadBytes?: string | number;
|
30
30
|
/** uint64 */
|
31
|
-
WriteRows?: string;
|
31
|
+
WriteRows?: string | number;
|
32
32
|
/** uint64 */
|
33
|
-
WriteBytes?: string;
|
33
|
+
WriteBytes?: string | number;
|
34
34
|
/** uint64 */
|
35
|
-
EraseRows?: string;
|
35
|
+
EraseRows?: string | number;
|
36
36
|
/** uint64 */
|
37
|
-
EraseBytes?: string;
|
37
|
+
EraseBytes?: string | number;
|
38
38
|
AffectedPartitions?: number;
|
39
39
|
Extra?: unknown;
|
40
40
|
}
|
@@ -42,24 +42,24 @@ interface TDqTableStats {
|
|
42
42
|
/** source: https://github.com/ydb-platform/ydb/blob/main/ydb/library/yql/dq/actors/protos/dq_stats.proto */
|
43
43
|
interface TDqExecutionStats {
|
44
44
|
/** uint64 */
|
45
|
-
CpuTimeUs?: string;
|
45
|
+
CpuTimeUs?: string | number;
|
46
46
|
/** uint64 */
|
47
|
-
DurationUs?: string;
|
47
|
+
DurationUs?: string | number;
|
48
48
|
/** uint64 */
|
49
|
-
ResultRows?: string;
|
49
|
+
ResultRows?: string | number;
|
50
50
|
/** uint64 */
|
51
|
-
ResultBytes?: string;
|
51
|
+
ResultBytes?: string | number;
|
52
52
|
|
53
53
|
Tables?: TDqTableStats[];
|
54
54
|
|
55
55
|
/** uint64 */
|
56
|
-
ExecuterCpuTimeUs?: string;
|
56
|
+
ExecuterCpuTimeUs?: string | number;
|
57
57
|
/** uint64 */
|
58
|
-
StartTimeMs?: string;
|
58
|
+
StartTimeMs?: string | number;
|
59
59
|
/** uint64 */
|
60
|
-
FinishTimeMs?: string;
|
60
|
+
FinishTimeMs?: string | number;
|
61
61
|
/** uint64 */
|
62
|
-
FirstRowTimeMs?: string;
|
62
|
+
FirstRowTimeMs?: string | number;
|
63
63
|
|
64
64
|
Stages?: TDqStageStats[];
|
65
65
|
TxPlansWithStats?: string[];
|
@@ -70,17 +70,17 @@ interface TDqExecutionStats {
|
|
70
70
|
/** source: https://github.com/ydb-platform/ydb/blob/main/ydb/core/protos/kqp_stats.proto */
|
71
71
|
export interface TKqpStatsQuery {
|
72
72
|
/** uint64 */
|
73
|
-
DurationUs?: string;
|
73
|
+
DurationUs?: string | number;
|
74
74
|
Compilation?: TKqpStatsCompile;
|
75
75
|
|
76
76
|
/** uint64 */
|
77
|
-
WorkerCpuTimeUs?: string;
|
77
|
+
WorkerCpuTimeUs?: string | number;
|
78
78
|
/** uint64 */
|
79
|
-
ReadSetsCount?: string;
|
79
|
+
ReadSetsCount?: string | number;
|
80
80
|
/** uint64 */
|
81
|
-
MaxShardProgramSize?: string;
|
81
|
+
MaxShardProgramSize?: string | number;
|
82
82
|
/** uint64 */
|
83
|
-
MaxShardReplySize?: string;
|
83
|
+
MaxShardReplySize?: string | number;
|
84
84
|
|
85
85
|
Executions?: TDqExecutionStats[];
|
86
86
|
}
|
@@ -120,6 +120,10 @@ interface PlanNodeStats {
|
|
120
120
|
TotalOutputBytes?: number;
|
121
121
|
TotalDurationMs?: number;
|
122
122
|
TotalOutputRows?: number;
|
123
|
+
|
124
|
+
ComputeNodes?: unknown[];
|
125
|
+
NodesScanShards?: unknown[];
|
126
|
+
UseLlvm?: unknown;
|
123
127
|
}
|
124
128
|
|
125
129
|
interface PlanNodeOperator {
|
@@ -128,6 +132,7 @@ interface PlanNodeOperator {
|
|
128
132
|
ReadLimit?: string;
|
129
133
|
ReadColumns?: string[];
|
130
134
|
ReadRanges?: string[];
|
135
|
+
ReadRange?: string[];
|
131
136
|
Table?: string;
|
132
137
|
Iterator?: string;
|
133
138
|
}
|
@@ -153,7 +158,7 @@ export interface ScriptPlan {
|
|
153
158
|
meta: PlanMeta;
|
154
159
|
}
|
155
160
|
|
156
|
-
export interface
|
161
|
+
export interface QueryPlan {
|
157
162
|
Plan?: PlanNode;
|
158
163
|
tables?: PlanTable[];
|
159
164
|
meta: PlanMeta;
|
@@ -177,15 +182,22 @@ export interface ColumnType {
|
|
177
182
|
/** undefined = 'classic' */
|
178
183
|
export type Schemas = 'classic' | 'modern' | 'ydb' | undefined;
|
179
184
|
|
180
|
-
/**
|
181
|
-
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
-
|
186
|
-
|
187
|
-
|
188
|
-
|
185
|
+
/** undefined = 'execute' */
|
186
|
+
export type ExecuteActions =
|
187
|
+
| 'execute'
|
188
|
+
| 'execute-scan'
|
189
|
+
| 'execute-script'
|
190
|
+
| 'execute-data'
|
191
|
+
| 'execute-query'
|
192
|
+
| undefined;
|
193
|
+
|
194
|
+
export type ExplainActions =
|
195
|
+
| 'explain'
|
196
|
+
| 'explain-scan'
|
197
|
+
| 'explain-script'
|
198
|
+
| 'explain-data'
|
199
|
+
| 'explain-query'
|
200
|
+
| 'explain-ast';
|
189
201
|
|
190
202
|
export type Actions = ExecuteActions | ExplainActions;
|
191
203
|
|
@@ -197,19 +209,27 @@ export interface ErrorResponse {
|
|
197
209
|
}
|
198
210
|
|
199
211
|
// ==== Explain Responses ====
|
200
|
-
|
212
|
+
/**
|
213
|
+
* meta.type = 'script'
|
214
|
+
*
|
215
|
+
* explain-script
|
216
|
+
*/
|
201
217
|
export interface ExplainScriptResponse {
|
202
218
|
plan?: ScriptPlan;
|
203
219
|
}
|
204
|
-
|
205
|
-
|
220
|
+
/**
|
221
|
+
* meta.type = 'query'
|
222
|
+
*
|
223
|
+
* explain, explain-scan, explain-data, explain-query, explain-ast
|
224
|
+
*/
|
225
|
+
export interface ExplainQueryResponse {
|
206
226
|
ast?: string;
|
207
|
-
plan?:
|
227
|
+
plan?: QueryPlan;
|
208
228
|
}
|
209
229
|
|
210
230
|
export type ExplainResponse<Action extends ExplainActions> = Action extends 'explain-script'
|
211
231
|
? ExplainScriptResponse
|
212
|
-
:
|
232
|
+
: ExplainQueryResponse;
|
213
233
|
|
214
234
|
// ==== Execute Responses ====
|
215
235
|
|
@@ -222,22 +242,34 @@ type ResultFields<Schema extends Schemas> = Schema extends 'modern'
|
|
222
242
|
result?: KeyValueRow[];
|
223
243
|
};
|
224
244
|
|
225
|
-
|
226
|
-
|
245
|
+
/**
|
246
|
+
* meta.type = 'query'
|
247
|
+
*
|
248
|
+
* execute-scan, execute-data, execute-query
|
249
|
+
*/
|
250
|
+
export type ExecuteQueryResponse<Schema extends Schemas> = {
|
251
|
+
plan?: QueryPlan;
|
227
252
|
ast?: string;
|
228
253
|
stats?: TKqpStatsQuery;
|
229
254
|
} & ResultFields<Schema>;
|
230
255
|
|
256
|
+
/**
|
257
|
+
* meta.type = 'script'
|
258
|
+
*
|
259
|
+
* execute, execute-script
|
260
|
+
*/
|
231
261
|
export type ExecuteScriptResponse<Schema extends Schemas> = {
|
232
262
|
plan?: ScriptPlan;
|
233
263
|
ast?: string;
|
234
264
|
stats?: TKqpStatsQuery;
|
235
265
|
} & ResultFields<Schema>;
|
236
266
|
|
237
|
-
export type ExecuteResponse<
|
238
|
-
|
239
|
-
|
240
|
-
|
267
|
+
export type ExecuteResponse<Action extends ExecuteActions, Schema extends Schemas> = Action extends
|
268
|
+
| 'execute-scan'
|
269
|
+
| 'execute-data'
|
270
|
+
| 'execute-query'
|
271
|
+
? ExecuteQueryResponse<Schema>
|
272
|
+
: ExecuteScriptResponse<Schema>;
|
241
273
|
|
242
274
|
// ==== Combined API response ====
|
243
275
|
export type QueryAPIResponse<
|
@@ -250,13 +282,15 @@ export type QueryAPIResponse<
|
|
250
282
|
: unknown;
|
251
283
|
|
252
284
|
// ==== types to use in query result preparation ====
|
253
|
-
export type AnyExplainResponse =
|
285
|
+
export type AnyExplainResponse = ExplainQueryResponse | ExplainScriptResponse;
|
254
286
|
|
255
|
-
export type ExecuteModernResponse =
|
287
|
+
export type ExecuteModernResponse =
|
288
|
+
| ExecuteQueryResponse<'modern'>
|
289
|
+
| ExecuteScriptResponse<'modern'>;
|
256
290
|
export type ExecuteClassicResponse =
|
257
|
-
|
|
291
|
+
| ExecuteQueryResponse<'classic'>
|
258
292
|
| ExecuteScriptResponse<'classic'>;
|
259
|
-
export type ExecuteYdbResponse =
|
293
|
+
export type ExecuteYdbResponse = ExecuteQueryResponse<'ydb'> | ExecuteScriptResponse<'ydb'>;
|
260
294
|
|
261
295
|
export type AnyExecuteResponse =
|
262
296
|
| ExecuteModernResponse
|
@@ -2,7 +2,7 @@ import type {ExplainPlanNodeData, GraphNode, Link} from '@gravity-ui/paranoid';
|
|
2
2
|
|
3
3
|
import {GET_EXPLAIN_QUERY, GET_EXPLAIN_QUERY_AST} from '../../store/reducers/explainQuery';
|
4
4
|
import type {ApiRequestAction} from '../../store/utils';
|
5
|
-
import type {PlanTable, ErrorResponse,
|
5
|
+
import type {PlanTable, ErrorResponse, QueryPlan, ScriptPlan} from '../api/query';
|
6
6
|
import type {IQueryResult, QueryError} from './query';
|
7
7
|
|
8
8
|
export interface PreparedExplainResponse {
|
@@ -11,7 +11,7 @@ export interface PreparedExplainResponse {
|
|
11
11
|
nodes?: GraphNode<ExplainPlanNodeData>[];
|
12
12
|
tables?: PlanTable[];
|
13
13
|
version?: string;
|
14
|
-
pristine?:
|
14
|
+
pristine?: QueryPlan | ScriptPlan;
|
15
15
|
};
|
16
16
|
ast?: string;
|
17
17
|
}
|
@@ -4,7 +4,7 @@ import type {
|
|
4
4
|
ColumnType,
|
5
5
|
ErrorResponse,
|
6
6
|
ScriptPlan,
|
7
|
-
|
7
|
+
QueryPlan,
|
8
8
|
TKqpStatsQuery,
|
9
9
|
} from '../api/query';
|
10
10
|
|
@@ -12,7 +12,7 @@ export interface IQueryResult {
|
|
12
12
|
result?: KeyValueRow[];
|
13
13
|
columns?: ColumnType[];
|
14
14
|
stats?: TKqpStatsQuery;
|
15
|
-
plan?: ScriptPlan |
|
15
|
+
plan?: ScriptPlan | QueryPlan;
|
16
16
|
ast?: string;
|
17
17
|
}
|
18
18
|
|
@@ -26,4 +26,6 @@ export type QueryError = NetworkError | ErrorResponse;
|
|
26
26
|
export enum QueryModes {
|
27
27
|
scan = 'scan',
|
28
28
|
script = 'script',
|
29
|
+
data = 'data',
|
30
|
+
query = 'query',
|
29
31
|
}
|
package/dist/utils/constants.ts
CHANGED
@@ -78,7 +78,7 @@ export const COLORS_PRIORITY = {
|
|
78
78
|
export const THEME_KEY = 'theme';
|
79
79
|
export const INVERTED_DISKS_KEY = 'invertedDisks';
|
80
80
|
export const USE_NODES_ENDPOINT_IN_DIAGNOSTICS_KEY = 'useNodesEndpointInDiagnostics';
|
81
|
-
export const
|
81
|
+
export const ENABLE_ADDITIONAL_QUERY_MODES = 'enableAdditionalQueryModes';
|
82
82
|
export const SAVED_QUERIES_KEY = 'saved_queries';
|
83
83
|
export const ASIDE_HEADER_COMPACT_KEY = 'asideHeaderCompact';
|
84
84
|
export const QUERIES_HISTORY_KEY = 'queries_history';
|
@@ -106,3 +106,5 @@ export const TENANT_INITIAL_TAB_KEY = 'saved_tenant_initial_tab';
|
|
106
106
|
export const QUERY_INITIAL_MODE_KEY = 'query_initial_mode';
|
107
107
|
|
108
108
|
export const PARTITIONS_HIDDEN_COLUMNS_KEY = 'partitionsHiddenColumns';
|
109
|
+
|
110
|
+
export const CLUSTER_INFO_HIDDEN_KEY = 'clusterInfoHidden';
|
package/dist/utils/nodes.ts
CHANGED
@@ -20,7 +20,7 @@ export const isUnavailableNode = (node: INodesPreparedEntity | TSystemStateInfo)
|
|
20
20
|
export type NodeAddress = Pick<TSystemStateInfo, 'Host' | 'Endpoints'>;
|
21
21
|
|
22
22
|
export interface AdditionalNodesInfo extends Record<string, unknown> {
|
23
|
-
getNodeRef?: (node?: NodeAddress) => string;
|
23
|
+
getNodeRef?: (node?: NodeAddress) => string | null;
|
24
24
|
}
|
25
25
|
|
26
26
|
export const prepareNodesMap = (nodesList?: TNodeInfo[]) => {
|
package/dist/utils/query.ts
CHANGED
@@ -4,7 +4,7 @@ import type {
|
|
4
4
|
AnyExplainResponse,
|
5
5
|
ExecuteModernResponse,
|
6
6
|
KeyValueRow,
|
7
|
-
|
7
|
+
QueryPlan,
|
8
8
|
ScriptPlan,
|
9
9
|
} from '../types/api/query';
|
10
10
|
import type {IQueryResult} from '../types/store/query';
|
@@ -115,10 +115,10 @@ export const parseQueryAPIExplainResponse = (
|
|
115
115
|
return data;
|
116
116
|
};
|
117
117
|
|
118
|
-
const isExplainScriptPlan = (plan: ScriptPlan |
|
118
|
+
const isExplainScriptPlan = (plan: ScriptPlan | QueryPlan): plan is ScriptPlan =>
|
119
119
|
Boolean(plan && 'queries' in plan);
|
120
120
|
|
121
|
-
export const parseQueryExplainPlan = (plan: ScriptPlan |
|
121
|
+
export const parseQueryExplainPlan = (plan: ScriptPlan | QueryPlan): QueryPlan => {
|
122
122
|
if (isExplainScriptPlan(plan)) {
|
123
123
|
if (!plan.queries || !plan.queries.length) {
|
124
124
|
return {meta: plan.meta};
|
package/package.json
CHANGED
@@ -1,54 +0,0 @@
|
|
1
|
-
import React from 'react';
|
2
|
-
import cn from 'bem-cn-lite';
|
3
|
-
import './PoolUsage.scss';
|
4
|
-
import PropTypes from 'prop-types';
|
5
|
-
const b = cn('pool-usage');
|
6
|
-
|
7
|
-
const formatUsage = (usage) => (typeof usage === 'undefined' ? '' : Math.floor(usage * 100));
|
8
|
-
const getLineType = (fillWidth) => {
|
9
|
-
let fillColor = 'green';
|
10
|
-
if (fillWidth > 60 && fillWidth <= 80) {
|
11
|
-
fillColor = 'yellow';
|
12
|
-
} else if (fillWidth > 80) {
|
13
|
-
fillColor = 'red';
|
14
|
-
}
|
15
|
-
|
16
|
-
return fillColor;
|
17
|
-
};
|
18
|
-
export class PoolUsage extends React.Component {
|
19
|
-
static propTypes = {
|
20
|
-
data: PropTypes.object.isRequired,
|
21
|
-
};
|
22
|
-
|
23
|
-
render() {
|
24
|
-
const {data: pool = {}} = this.props;
|
25
|
-
|
26
|
-
const {Threads, Name = 'Unknown', Usage} = pool;
|
27
|
-
const dataExist = Usage && Threads;
|
28
|
-
|
29
|
-
const value = formatUsage(pool.Usage);
|
30
|
-
const fillWidth = value > 100 ? 100 : value;
|
31
|
-
|
32
|
-
return (
|
33
|
-
<div className={b()}>
|
34
|
-
<div className={b('info')}>
|
35
|
-
<div className={b('pool-name')}>{Name}</div>
|
36
|
-
{dataExist && (
|
37
|
-
<div className={b('value')}>
|
38
|
-
<div className={b('percents')}>{value < 1 ? '<1' : value}%</div>
|
39
|
-
<div className={b('threads')}>(×{Threads})</div>
|
40
|
-
</div>
|
41
|
-
)}
|
42
|
-
</div>
|
43
|
-
<div className={b('visual')}>
|
44
|
-
<div
|
45
|
-
className={b('usage-line', {type: getLineType(fillWidth)})}
|
46
|
-
style={{width: `${fillWidth}%`}}
|
47
|
-
/>
|
48
|
-
</div>
|
49
|
-
</div>
|
50
|
-
);
|
51
|
-
}
|
52
|
-
}
|
53
|
-
|
54
|
-
export default PoolUsage;
|
@@ -1,141 +0,0 @@
|
|
1
|
-
import {createRequestActionTypes, createApiRequest} from '../utils';
|
2
|
-
import '../../services/api';
|
3
|
-
import {stringifyVdiskId} from '../../utils';
|
4
|
-
import {createSelector} from 'reselect';
|
5
|
-
|
6
|
-
const FETCH_NODE = createRequestActionTypes('node', 'FETCH_NODE');
|
7
|
-
const FETCH_NODE_STRUCTURE = createRequestActionTypes('node', 'FETCH_NODE_STRUCTURE');
|
8
|
-
const RESET_NODE = 'node/RESET_NODE';
|
9
|
-
|
10
|
-
const node = (
|
11
|
-
state = {
|
12
|
-
data: {},
|
13
|
-
loading: true,
|
14
|
-
wasLoaded: false,
|
15
|
-
nodeStructure: {},
|
16
|
-
loadingStructure: true,
|
17
|
-
wasLoadedStructure: false,
|
18
|
-
},
|
19
|
-
action,
|
20
|
-
) => {
|
21
|
-
switch (action.type) {
|
22
|
-
case FETCH_NODE.REQUEST: {
|
23
|
-
return {
|
24
|
-
...state,
|
25
|
-
loading: true,
|
26
|
-
};
|
27
|
-
}
|
28
|
-
case FETCH_NODE.SUCCESS: {
|
29
|
-
return {
|
30
|
-
...state,
|
31
|
-
data: action.data,
|
32
|
-
loading: false,
|
33
|
-
wasLoaded: true,
|
34
|
-
error: undefined,
|
35
|
-
};
|
36
|
-
}
|
37
|
-
case FETCH_NODE.FAILURE: {
|
38
|
-
return {
|
39
|
-
...state,
|
40
|
-
error: action.error,
|
41
|
-
loading: false,
|
42
|
-
};
|
43
|
-
}
|
44
|
-
case FETCH_NODE_STRUCTURE.REQUEST: {
|
45
|
-
return {
|
46
|
-
...state,
|
47
|
-
loadingStructure: true,
|
48
|
-
};
|
49
|
-
}
|
50
|
-
case FETCH_NODE_STRUCTURE.SUCCESS: {
|
51
|
-
return {
|
52
|
-
...state,
|
53
|
-
nodeStructure: action.data,
|
54
|
-
loadingStructure: false,
|
55
|
-
wasLoadedStructure: true,
|
56
|
-
errorStructure: undefined,
|
57
|
-
};
|
58
|
-
}
|
59
|
-
case FETCH_NODE_STRUCTURE.FAILURE: {
|
60
|
-
return {
|
61
|
-
...state,
|
62
|
-
errorStructure: action.error,
|
63
|
-
loadingStructure: false,
|
64
|
-
};
|
65
|
-
}
|
66
|
-
case RESET_NODE: {
|
67
|
-
return {
|
68
|
-
...state,
|
69
|
-
data: {},
|
70
|
-
wasLoaded: false,
|
71
|
-
nodeStructure: {},
|
72
|
-
wasLoadedStructure: false,
|
73
|
-
};
|
74
|
-
}
|
75
|
-
default:
|
76
|
-
return state;
|
77
|
-
}
|
78
|
-
};
|
79
|
-
|
80
|
-
export const getNodeInfo = (id) => {
|
81
|
-
return createApiRequest({
|
82
|
-
request: window.api.getNodeInfo(id),
|
83
|
-
actions: FETCH_NODE,
|
84
|
-
});
|
85
|
-
};
|
86
|
-
|
87
|
-
export const getNodeStructure = (nodeId) => {
|
88
|
-
return createApiRequest({
|
89
|
-
request: window.api.getStorageInfo({nodeId}, {concurrentId: 'getNodeStructure'}),
|
90
|
-
actions: FETCH_NODE_STRUCTURE,
|
91
|
-
});
|
92
|
-
};
|
93
|
-
|
94
|
-
export function resetNode() {
|
95
|
-
return {
|
96
|
-
type: RESET_NODE,
|
97
|
-
};
|
98
|
-
}
|
99
|
-
|
100
|
-
const getNodeId = (state) => state.node?.data?.SystemStateInfo?.[0].NodeId;
|
101
|
-
|
102
|
-
const getRawNodeStructure = (state) => state.node?.nodeStructure;
|
103
|
-
|
104
|
-
export const selectNodeStructure = createSelector(
|
105
|
-
[getNodeId, getRawNodeStructure],
|
106
|
-
(nodeId, rawNodeStructure) => {
|
107
|
-
const pools = rawNodeStructure?.StoragePools;
|
108
|
-
const structure = {};
|
109
|
-
pools?.forEach((pool) => {
|
110
|
-
const groups = pool.Groups;
|
111
|
-
groups?.forEach((group) => {
|
112
|
-
const vDisks = group.VDisks?.filter((el) => el.NodeId === nodeId);
|
113
|
-
vDisks?.forEach((vd) => {
|
114
|
-
const vDiskId = stringifyVdiskId(vd.VDiskId);
|
115
|
-
const pDiskId = vd.PDisk?.PDiskId;
|
116
|
-
if (!structure[String(pDiskId)]) {
|
117
|
-
structure[String(pDiskId)] = {vDisks: {}, ...vd.PDisk};
|
118
|
-
}
|
119
|
-
structure[String(pDiskId)].vDisks[vDiskId] = {
|
120
|
-
...vd,
|
121
|
-
// VDisk doesn't have its own StoragePoolName when located inside StoragePool data
|
122
|
-
StoragePoolName: pool.Name,
|
123
|
-
};
|
124
|
-
});
|
125
|
-
});
|
126
|
-
});
|
127
|
-
|
128
|
-
const structureWithVdisksArray = Object.keys(structure).reduce((acc, el) => {
|
129
|
-
const vDisks = structure[el].vDisks;
|
130
|
-
const vDisksArray = Object.keys(vDisks).reduce((acc, key, index) => {
|
131
|
-
acc.push({...vDisks[key], id: key, order: index});
|
132
|
-
return acc;
|
133
|
-
}, []);
|
134
|
-
acc[el] = {...structure[el], vDisks: vDisksArray};
|
135
|
-
return acc;
|
136
|
-
}, {});
|
137
|
-
return structureWithVdisksArray;
|
138
|
-
},
|
139
|
-
);
|
140
|
-
|
141
|
-
export default node;
|