ydb-embedded-ui 2.4.3 → 2.5.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 +33 -0
- package/dist/components/InfoViewer/formatters/schema.ts +2 -1
- package/dist/components/InfoViewer/schemaInfo/CDCStreamInfo.tsx +3 -16
- package/dist/components/InfoViewer/schemaInfo/PersQueueGroupInfo.tsx +8 -13
- package/dist/components/InfoViewer/schemaInfo/TableIndexInfo.tsx +2 -12
- package/dist/components/InfoViewer/schemaOverview/CDCStreamOverview.tsx +3 -16
- package/dist/components/InfoViewer/schemaOverview/PersQueueGroupOverview.tsx +8 -13
- package/dist/components/InfoViewer/utils.ts +6 -6
- package/dist/components/Loader/Loader.scss +6 -3
- package/dist/components/Loader/Loader.tsx +7 -5
- package/dist/components/Loader/index.ts +1 -0
- package/dist/components/UptimeFIlter/UptimeFilter.tsx +21 -0
- package/dist/components/UptimeFIlter/index.ts +1 -0
- package/dist/containers/Node/Node.scss +1 -0
- package/dist/containers/Node/Node.tsx +3 -8
- package/dist/containers/Node/NodeStructure/NodeStructure.scss +0 -6
- package/dist/containers/Node/NodeStructure/NodeStructure.tsx +1 -1
- package/dist/containers/Nodes/Nodes.js +22 -10
- package/dist/{components → containers}/NodesViewer/NodesViewer.js +49 -62
- package/dist/{components → containers}/NodesViewer/NodesViewer.scss +0 -0
- package/dist/containers/Storage/Pdisk/Pdisk.scss +1 -1
- package/dist/containers/Storage/Storage.js +35 -10
- package/dist/containers/Storage/StorageNodes/StorageNodes.scss +2 -2
- package/dist/containers/Storage/StorageNodes/StorageNodes.tsx +35 -17
- package/dist/containers/Storage/StorageNodes/i18n/en.json +6 -4
- package/dist/containers/Storage/StorageNodes/i18n/ru.json +6 -4
- package/dist/containers/Storage/UsageFilter/UsageFilter.scss +10 -5
- package/dist/containers/Tenant/Acl/Acl.js +1 -7
- package/dist/containers/Tenant/Diagnostics/Compute/Compute.js +1 -1
- package/dist/containers/Tenant/Diagnostics/Consumers/Consumers.tsx +34 -8
- package/dist/containers/Tenant/Diagnostics/Describe/Describe.scss +0 -8
- package/dist/containers/Tenant/Diagnostics/Describe/Describe.tsx +87 -0
- package/dist/containers/Tenant/Diagnostics/Diagnostics.scss +0 -7
- package/dist/containers/Tenant/Diagnostics/Diagnostics.tsx +5 -7
- package/dist/containers/Tenant/Diagnostics/TopShards/TopShards.js +21 -13
- package/dist/containers/Tenant/ObjectGeneral/ObjectGeneral.tsx +1 -5
- package/dist/containers/Tenant/QueryEditor/QueryExplain/QueryExplain.js +16 -30
- package/dist/containers/Tenant/QueryEditor/SaveQuery/SaveQuery.js +1 -4
- package/dist/containers/Tenant/Schema/SchemaInfoViewer/SchemaInfoViewer.js +23 -28
- package/dist/containers/Tenant/Schema/SchemaTree/SchemaTree.tsx +2 -7
- package/dist/containers/Tenant/Tenant.tsx +8 -5
- package/dist/containers/Tenant/TenantPages.tsx +1 -1
- package/dist/containers/Tenant/utils/schemaActions.ts +9 -20
- package/dist/services/api.js +14 -5
- package/dist/store/reducers/clusterNodes.js +29 -10
- package/dist/store/reducers/describe.ts +60 -30
- package/dist/store/reducers/nodes.js +24 -3
- package/dist/store/reducers/{schema.js → schema.ts} +22 -14
- package/dist/store/reducers/storage.js +46 -5
- package/dist/types/api/error.ts +4 -2
- package/dist/types/store/describe.ts +21 -1
- package/dist/types/store/schema.ts +46 -0
- package/dist/utils/index.js +6 -2
- package/dist/utils/nodes.ts +9 -0
- package/package.json +1 -1
- package/dist/containers/Tenant/Diagnostics/Describe/Describe.js +0 -130
@@ -2,24 +2,23 @@ import {createSelector, Selector} from 'reselect';
|
|
2
2
|
import {Reducer} from 'redux';
|
3
3
|
|
4
4
|
import '../../services/api';
|
5
|
-
import {TEvDescribeSchemeResult} from '../../types/api/schema';
|
6
5
|
import {IConsumer} from '../../types/api/consumers';
|
7
|
-
import {IDescribeRootStateSlice, IDescribeState} from '../../types/store/describe';
|
8
|
-
import {
|
9
|
-
import {createRequestActionTypes, createApiRequest, ApiRequestAction} from '../utils';
|
6
|
+
import {IDescribeRootStateSlice, IDescribeState, IDescribeAction} from '../../types/store/describe';
|
7
|
+
import {createRequestActionTypes, createApiRequest} from '../utils';
|
10
8
|
|
11
|
-
const FETCH_DESCRIBE = createRequestActionTypes('describe', 'FETCH_DESCRIBE');
|
9
|
+
export const FETCH_DESCRIBE = createRequestActionTypes('describe', 'FETCH_DESCRIBE');
|
10
|
+
const SET_CURRENT_DESCRIBE_PATH = 'describe/SET_CURRENT_DESCRIBE_PATH';
|
11
|
+
const SET_DATA_WAS_NOT_LOADED = 'describe/SET_DATA_WAS_NOT_LOADED';
|
12
12
|
|
13
13
|
const initialState = {
|
14
14
|
loading: false,
|
15
15
|
wasLoaded: false,
|
16
16
|
data: {},
|
17
|
+
currentDescribe: undefined,
|
18
|
+
currentDescribePath: undefined,
|
17
19
|
};
|
18
20
|
|
19
|
-
const describe: Reducer<
|
20
|
-
IDescribeState,
|
21
|
-
ApiRequestAction<typeof FETCH_DESCRIBE, TEvDescribeSchemeResult, IResponseError>
|
22
|
-
> = (state = initialState, action) => {
|
21
|
+
const describe: Reducer<IDescribeState, IDescribeAction> = (state = initialState, action) => {
|
23
22
|
switch (action.type) {
|
24
23
|
case FETCH_DESCRIBE.REQUEST: {
|
25
24
|
return {
|
@@ -28,52 +27,83 @@ const describe: Reducer<
|
|
28
27
|
};
|
29
28
|
}
|
30
29
|
case FETCH_DESCRIBE.SUCCESS: {
|
31
|
-
|
30
|
+
const data = action.data;
|
32
31
|
|
33
|
-
|
32
|
+
const isCurrentDescribePath = data.Path === state.currentDescribePath;
|
33
|
+
|
34
|
+
let newData = state.data;
|
35
|
+
|
36
|
+
if (data.Path) {
|
34
37
|
newData = JSON.parse(JSON.stringify(state.data));
|
35
|
-
newData[
|
36
|
-
}
|
37
|
-
|
38
|
+
newData[data.Path] = data;
|
39
|
+
}
|
40
|
+
|
41
|
+
if (!isCurrentDescribePath) {
|
42
|
+
return {
|
43
|
+
...state,
|
44
|
+
data: newData,
|
45
|
+
};
|
38
46
|
}
|
39
47
|
|
40
48
|
return {
|
41
49
|
...state,
|
42
50
|
data: newData,
|
43
|
-
currentDescribe:
|
51
|
+
currentDescribe: data,
|
44
52
|
loading: false,
|
45
53
|
wasLoaded: true,
|
46
54
|
error: undefined,
|
47
55
|
};
|
48
56
|
}
|
57
|
+
|
49
58
|
case FETCH_DESCRIBE.FAILURE: {
|
59
|
+
if (action.error?.isCancelled) {
|
60
|
+
return state;
|
61
|
+
}
|
62
|
+
|
50
63
|
return {
|
51
64
|
...state,
|
52
65
|
error: action.error,
|
53
66
|
loading: false,
|
54
67
|
};
|
55
68
|
}
|
69
|
+
case SET_CURRENT_DESCRIBE_PATH: {
|
70
|
+
return {
|
71
|
+
...state,
|
72
|
+
currentDescribePath: action.data,
|
73
|
+
};
|
74
|
+
}
|
75
|
+
case SET_DATA_WAS_NOT_LOADED: {
|
76
|
+
return {
|
77
|
+
...state,
|
78
|
+
wasLoaded: false,
|
79
|
+
};
|
80
|
+
}
|
56
81
|
default:
|
57
82
|
return state;
|
58
83
|
}
|
59
84
|
};
|
60
85
|
|
86
|
+
export const setCurrentDescribePath = (path: string) => {
|
87
|
+
return {
|
88
|
+
type: SET_CURRENT_DESCRIBE_PATH,
|
89
|
+
data: path,
|
90
|
+
} as const;
|
91
|
+
};
|
92
|
+
|
93
|
+
export const setDataWasNotLoaded = () => {
|
94
|
+
return {
|
95
|
+
type: SET_DATA_WAS_NOT_LOADED,
|
96
|
+
} as const;
|
97
|
+
};
|
98
|
+
|
61
99
|
// Consumers selectors
|
62
|
-
const selectConsumersNames:
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
export const selectConsumers: Selector<IDescribeRootStateSlice, IConsumer[]> =
|
68
|
-
selectConsumersNames,
|
69
|
-
(names = []) => {
|
70
|
-
const consumers = names.map((name) => {
|
71
|
-
return {name};
|
72
|
-
});
|
73
|
-
|
74
|
-
return consumers;
|
75
|
-
},
|
76
|
-
);
|
100
|
+
const selectConsumersNames = (state: IDescribeRootStateSlice, path: string | undefined) =>
|
101
|
+
path
|
102
|
+
? state.describe.data[path]?.PathDescription?.PersQueueGroup?.PQTabletConfig?.ReadRules
|
103
|
+
: undefined;
|
104
|
+
|
105
|
+
export const selectConsumers: Selector<IDescribeRootStateSlice, IConsumer[], [string | undefined]> =
|
106
|
+
createSelector(selectConsumersNames, (names = []) => names.map((name) => ({name})));
|
77
107
|
|
78
108
|
export function getDescribe({path}: {path: string}) {
|
79
109
|
return createApiRequest({
|
@@ -1,9 +1,19 @@
|
|
1
1
|
import {createRequestActionTypes, createApiRequest} from '../utils';
|
2
2
|
import '../../services/api';
|
3
|
+
import {NodesUptimeFilterValues} from '../../utils/nodes';
|
3
4
|
|
4
5
|
const FETCH_NODES = createRequestActionTypes('nodes', 'FETCH_NODES');
|
5
6
|
|
6
|
-
const
|
7
|
+
const CLEAR_NODES = 'nodes/CLEAR_NODES';
|
8
|
+
const SET_NODES_UPTIME_FILTER = 'nodes/SET_NODES_UPTIME_FILTER';
|
9
|
+
|
10
|
+
const initialState = {
|
11
|
+
loading: true,
|
12
|
+
wasLoaded: false,
|
13
|
+
nodesUptimeFilter: NodesUptimeFilterValues.All,
|
14
|
+
};
|
15
|
+
|
16
|
+
const nodes = (state = initialState, action) => {
|
7
17
|
switch (action.type) {
|
8
18
|
case FETCH_NODES.REQUEST: {
|
9
19
|
return {
|
@@ -28,7 +38,7 @@ const nodes = function z(state = {loading: true, wasLoaded: false}, action) {
|
|
28
38
|
loading: false,
|
29
39
|
};
|
30
40
|
}
|
31
|
-
case
|
41
|
+
case CLEAR_NODES: {
|
32
42
|
return {
|
33
43
|
...state,
|
34
44
|
loading: true,
|
@@ -38,6 +48,10 @@ const nodes = function z(state = {loading: true, wasLoaded: false}, action) {
|
|
38
48
|
error: undefined,
|
39
49
|
};
|
40
50
|
}
|
51
|
+
|
52
|
+
case SET_NODES_UPTIME_FILTER: {
|
53
|
+
return {...state, nodesUptimeFilter: action.data};
|
54
|
+
}
|
41
55
|
default:
|
42
56
|
return state;
|
43
57
|
}
|
@@ -50,6 +64,13 @@ export function getNodes(path) {
|
|
50
64
|
});
|
51
65
|
}
|
52
66
|
|
53
|
-
export const clearNodes = () => ({type:
|
67
|
+
export const clearNodes = () => ({type: CLEAR_NODES});
|
68
|
+
|
69
|
+
export const setNodesUptimeFilter = (value) => ({
|
70
|
+
type: SET_NODES_UPTIME_FILTER,
|
71
|
+
data: value,
|
72
|
+
});
|
73
|
+
|
74
|
+
export const getNodesUptimeFilter = (state) => state.nodes.nodesUptimeFilter;
|
54
75
|
|
55
76
|
export default nodes;
|
@@ -1,7 +1,11 @@
|
|
1
|
-
import {
|
1
|
+
import {Reducer} from 'redux';
|
2
|
+
|
3
|
+
import {ISchemaAction, ISchemaData, ISchemaState} from '../../types/store/schema';
|
2
4
|
import '../../services/api';
|
3
5
|
|
4
|
-
|
6
|
+
import {createRequestActionTypes, createApiRequest} from '../utils';
|
7
|
+
|
8
|
+
export const FETCH_SCHEMA = createRequestActionTypes('schema', 'FETCH_SCHEMA');
|
5
9
|
const PRELOAD_SCHEMAS = 'schema/PRELOAD_SCHEMAS';
|
6
10
|
const SET_SCHEMA = 'schema/SET_SCHEMA';
|
7
11
|
const SET_SHOW_PREVIEW = 'schema/SET_SHOW_PREVIEW';
|
@@ -18,7 +22,7 @@ export const initialState = {
|
|
18
22
|
showPreview: false,
|
19
23
|
};
|
20
24
|
|
21
|
-
const schema = (state = initialState, action) => {
|
25
|
+
const schema: Reducer<ISchemaState, ISchemaAction> = (state = initialState, action) => {
|
22
26
|
switch (action.type) {
|
23
27
|
case FETCH_SCHEMA.REQUEST: {
|
24
28
|
return {
|
@@ -28,7 +32,11 @@ const schema = (state = initialState, action) => {
|
|
28
32
|
}
|
29
33
|
case FETCH_SCHEMA.SUCCESS: {
|
30
34
|
const newData = JSON.parse(JSON.stringify(state.data));
|
31
|
-
|
35
|
+
|
36
|
+
if (action.data.Path) {
|
37
|
+
newData[action.data.Path] = action.data;
|
38
|
+
}
|
39
|
+
|
32
40
|
const currentSchema = state.currentSchemaPath
|
33
41
|
? newData[state.currentSchemaPath]
|
34
42
|
: action.data;
|
@@ -100,49 +108,49 @@ const schema = (state = initialState, action) => {
|
|
100
108
|
}
|
101
109
|
};
|
102
110
|
|
103
|
-
export function getSchema({path}) {
|
111
|
+
export function getSchema({path}: {path: string}) {
|
104
112
|
return createApiRequest({
|
105
113
|
request: window.api.getSchema({path}),
|
106
114
|
actions: FETCH_SCHEMA,
|
107
115
|
});
|
108
116
|
}
|
109
117
|
|
110
|
-
export function setCurrentSchemaPath(currentSchemaPath) {
|
118
|
+
export function setCurrentSchemaPath(currentSchemaPath: string) {
|
111
119
|
return {
|
112
120
|
type: SET_SCHEMA,
|
113
121
|
data: currentSchemaPath,
|
114
|
-
};
|
122
|
+
} as const;
|
115
123
|
}
|
116
124
|
export function enableAutorefresh() {
|
117
125
|
return {
|
118
126
|
type: ENABLE_AUTOREFRESH,
|
119
|
-
};
|
127
|
+
} as const;
|
120
128
|
}
|
121
129
|
export function disableAutorefresh() {
|
122
130
|
return {
|
123
131
|
type: DISABLE_AUTOREFRESH,
|
124
|
-
};
|
132
|
+
} as const;
|
125
133
|
}
|
126
|
-
export function setShowPreview(value) {
|
134
|
+
export function setShowPreview(value: boolean) {
|
127
135
|
return {
|
128
136
|
type: SET_SHOW_PREVIEW,
|
129
137
|
data: value,
|
130
|
-
};
|
138
|
+
} as const;
|
131
139
|
}
|
132
140
|
|
133
141
|
// only stores data for paths that are not in the store yet
|
134
142
|
// existing paths are ignored
|
135
|
-
export function preloadSchemas(data) {
|
143
|
+
export function preloadSchemas(data: ISchemaData) {
|
136
144
|
return {
|
137
145
|
type: PRELOAD_SCHEMAS,
|
138
146
|
data,
|
139
|
-
};
|
147
|
+
} as const;
|
140
148
|
}
|
141
149
|
|
142
150
|
export function resetLoadingState() {
|
143
151
|
return {
|
144
152
|
type: RESET_LOADING_STATE,
|
145
|
-
};
|
153
|
+
} as const;
|
146
154
|
}
|
147
155
|
|
148
156
|
export default schema;
|
@@ -1,10 +1,14 @@
|
|
1
|
-
import {createRequestActionTypes, createApiRequest} from '../utils';
|
2
|
-
import '../../services/api';
|
3
1
|
import _ from 'lodash';
|
4
2
|
import {createSelector} from 'reselect';
|
5
|
-
|
3
|
+
|
4
|
+
import {calcUptime, calcUptimeInSeconds} from '../../utils';
|
6
5
|
import {getUsage} from '../../utils/storage';
|
6
|
+
import {NodesUptimeFilterValues} from '../../utils/nodes';
|
7
7
|
import {getPDiskType} from '../../utils/pdisk';
|
8
|
+
import {HOUR_IN_SECONDS} from '../../utils/constants';
|
9
|
+
import '../../services/api';
|
10
|
+
|
11
|
+
import {createRequestActionTypes, createApiRequest} from '../utils';
|
8
12
|
|
9
13
|
export const VisibleEntities = {
|
10
14
|
All: 'All',
|
@@ -29,6 +33,7 @@ const SET_FILTER = 'storage/SET_FILTER';
|
|
29
33
|
const SET_USAGE_FILTER = 'storage/SET_USAGE_FILTER';
|
30
34
|
const SET_VISIBLE_GROUPS = 'storage/SET_VISIBLE_GROUPS';
|
31
35
|
const SET_STORAGE_TYPE = 'storage/SET_STORAGE_TYPE';
|
36
|
+
const SET_NODES_UPTIME_FILTER = 'storage/SET_NODES_UPTIME_FILTER';
|
32
37
|
|
33
38
|
const initialState = {
|
34
39
|
loading: true,
|
@@ -36,6 +41,7 @@ const initialState = {
|
|
36
41
|
filter: '',
|
37
42
|
usageFilter: [],
|
38
43
|
visible: VisibleEntities.Missing,
|
44
|
+
nodesUptimeFilter: NodesUptimeFilterValues.All,
|
39
45
|
type: StorageTypes.groups,
|
40
46
|
};
|
41
47
|
|
@@ -93,6 +99,13 @@ const storage = (state = initialState, action) => {
|
|
93
99
|
error: undefined,
|
94
100
|
};
|
95
101
|
}
|
102
|
+
|
103
|
+
case SET_NODES_UPTIME_FILTER: {
|
104
|
+
return {
|
105
|
+
...state,
|
106
|
+
nodesUptimeFilter: action.data,
|
107
|
+
};
|
108
|
+
}
|
96
109
|
case SET_STORAGE_TYPE: {
|
97
110
|
return {
|
98
111
|
...state,
|
@@ -149,6 +162,13 @@ export function setVisibleEntities(value) {
|
|
149
162
|
};
|
150
163
|
}
|
151
164
|
|
165
|
+
export function setNodesUptimeFilter(value) {
|
166
|
+
return {
|
167
|
+
type: SET_NODES_UPTIME_FILTER,
|
168
|
+
data: value,
|
169
|
+
};
|
170
|
+
}
|
171
|
+
|
152
172
|
export const getStoragePools = (state) => state.storage.data?.StoragePools;
|
153
173
|
export const getStoragePoolsGroupsCount = (state) => ({
|
154
174
|
total: state.storage.data?.TotalGroups || 0,
|
@@ -162,6 +182,7 @@ export const getStorageNodesCount = (state) => ({
|
|
162
182
|
export const getStorageFilter = (state) => state.storage.filter;
|
163
183
|
export const getUsageFilter = (state) => state.storage.usageFilter;
|
164
184
|
export const getVisibleEntities = (state) => state.storage.visible;
|
185
|
+
export const getNodesUptimeFilter = (state) => state.storage.nodesUptimeFilter;
|
165
186
|
export const getStorageType = (state) => state.storage.type;
|
166
187
|
export const getNodesObject = (state) =>
|
167
188
|
_.reduce(
|
@@ -337,12 +358,32 @@ const filterByUsage = (entities, usage) => {
|
|
337
358
|
});
|
338
359
|
};
|
339
360
|
|
361
|
+
export const filterByUptime = (nodes = [], nodesUptimeFilter) => {
|
362
|
+
if (nodesUptimeFilter === NodesUptimeFilterValues.All) {
|
363
|
+
return nodes;
|
364
|
+
}
|
365
|
+
return nodes.filter(({StartTime}) => {
|
366
|
+
return !StartTime || calcUptimeInSeconds(StartTime) < HOUR_IN_SECONDS;
|
367
|
+
});
|
368
|
+
};
|
369
|
+
|
340
370
|
export const getFilteredEntities = createSelector(
|
341
|
-
[
|
342
|
-
|
371
|
+
[
|
372
|
+
getStorageFilter,
|
373
|
+
getUsageFilter,
|
374
|
+
getStorageType,
|
375
|
+
getNodesUptimeFilter,
|
376
|
+
getVisibleEntitiesList,
|
377
|
+
],
|
378
|
+
(textFilter, usageFilter, type, nodesUptimeFilter, entities) => {
|
343
379
|
let result = entities;
|
344
380
|
result = filterByText(result, type, textFilter);
|
345
381
|
result = filterByUsage(result, usageFilter);
|
382
|
+
|
383
|
+
if (type === StorageTypes.nodes) {
|
384
|
+
result = filterByUptime(result, nodesUptimeFilter);
|
385
|
+
}
|
386
|
+
|
346
387
|
return result;
|
347
388
|
},
|
348
389
|
);
|
package/dist/types/api/error.ts
CHANGED
@@ -1,14 +1,34 @@
|
|
1
|
+
import {
|
2
|
+
FETCH_DESCRIBE,
|
3
|
+
setCurrentDescribePath,
|
4
|
+
setDataWasNotLoaded,
|
5
|
+
} from '../../store/reducers/describe';
|
6
|
+
import {ApiRequestAction} from '../../store/utils';
|
1
7
|
import {IResponseError} from '../api/error';
|
2
8
|
import {TEvDescribeSchemeResult} from '../api/schema';
|
3
9
|
|
10
|
+
export type IDescribeData = Record<string, TEvDescribeSchemeResult>;
|
11
|
+
|
4
12
|
export interface IDescribeState {
|
5
13
|
loading: boolean;
|
6
14
|
wasLoaded: boolean;
|
7
|
-
data:
|
15
|
+
data: IDescribeData;
|
8
16
|
currentDescribe?: TEvDescribeSchemeResult;
|
17
|
+
currentDescribePath?: string;
|
9
18
|
error?: IResponseError;
|
10
19
|
}
|
11
20
|
|
21
|
+
type IDescribeApiRequestAction = ApiRequestAction<
|
22
|
+
typeof FETCH_DESCRIBE,
|
23
|
+
TEvDescribeSchemeResult,
|
24
|
+
IResponseError
|
25
|
+
>;
|
26
|
+
|
27
|
+
export type IDescribeAction =
|
28
|
+
| IDescribeApiRequestAction
|
29
|
+
| ReturnType<typeof setCurrentDescribePath>
|
30
|
+
| ReturnType<typeof setDataWasNotLoaded>;
|
31
|
+
|
12
32
|
export interface IDescribeRootStateSlice {
|
13
33
|
describe: IDescribeState;
|
14
34
|
}
|
@@ -0,0 +1,46 @@
|
|
1
|
+
import {
|
2
|
+
disableAutorefresh,
|
3
|
+
enableAutorefresh,
|
4
|
+
FETCH_SCHEMA,
|
5
|
+
preloadSchemas,
|
6
|
+
resetLoadingState,
|
7
|
+
setCurrentSchemaPath,
|
8
|
+
setShowPreview,
|
9
|
+
} from '../../store/reducers/schema';
|
10
|
+
import {ApiRequestAction} from '../../store/utils';
|
11
|
+
import {IResponseError} from '../api/error';
|
12
|
+
import {TEvDescribeSchemeResult} from '../api/schema';
|
13
|
+
|
14
|
+
export type ISchemaData = Record<string, TEvDescribeSchemeResult>;
|
15
|
+
|
16
|
+
export interface ISchemaState {
|
17
|
+
loading: boolean;
|
18
|
+
wasLoaded: boolean;
|
19
|
+
data: ISchemaData;
|
20
|
+
currentSchema?: TEvDescribeSchemeResult;
|
21
|
+
currentSchemaPath?: string;
|
22
|
+
autorefresh: boolean;
|
23
|
+
showPreview: boolean;
|
24
|
+
error?: IResponseError;
|
25
|
+
}
|
26
|
+
|
27
|
+
type ISchemaApiRequestAction = ApiRequestAction<
|
28
|
+
typeof FETCH_SCHEMA,
|
29
|
+
TEvDescribeSchemeResult,
|
30
|
+
IResponseError
|
31
|
+
>;
|
32
|
+
|
33
|
+
export type ISchemaAction =
|
34
|
+
| ISchemaApiRequestAction
|
35
|
+
| (
|
36
|
+
| ReturnType<typeof setCurrentSchemaPath>
|
37
|
+
| ReturnType<typeof enableAutorefresh>
|
38
|
+
| ReturnType<typeof disableAutorefresh>
|
39
|
+
| ReturnType<typeof setShowPreview>
|
40
|
+
| ReturnType<typeof preloadSchemas>
|
41
|
+
| ReturnType<typeof resetLoadingState>
|
42
|
+
);
|
43
|
+
|
44
|
+
export interface ISchemaRootStateSlice {
|
45
|
+
schema: ISchemaState;
|
46
|
+
}
|
package/dist/utils/index.js
CHANGED
@@ -79,9 +79,13 @@ export const formatDateTime = (value) => {
|
|
79
79
|
return value > 0 ? new Date(Number(value)).toUTCString() : 'N/A';
|
80
80
|
};
|
81
81
|
|
82
|
-
export const
|
82
|
+
export const calcUptimeInSeconds = (milliseconds) => {
|
83
83
|
const currentDate = new Date();
|
84
|
-
return
|
84
|
+
return (currentDate - Number(milliseconds)) / 1000;
|
85
|
+
};
|
86
|
+
|
87
|
+
export const calcUptime = (milliseconds) => {
|
88
|
+
return formatUptime(calcUptimeInSeconds(milliseconds));
|
85
89
|
};
|
86
90
|
|
87
91
|
// determine how many nodes have status Connected "true"
|
package/package.json
CHANGED
@@ -1,130 +0,0 @@
|
|
1
|
-
import React from 'react';
|
2
|
-
import PropTypes from 'prop-types';
|
3
|
-
import cn from 'bem-cn-lite';
|
4
|
-
import {connect} from 'react-redux';
|
5
|
-
import {Loader} from '@gravity-ui/uikit';
|
6
|
-
import JSONTree from 'react-json-inspector';
|
7
|
-
|
8
|
-
import {getDescribe} from '../../../../store/reducers/describe';
|
9
|
-
|
10
|
-
import './Describe.scss';
|
11
|
-
import 'react-json-inspector/json-inspector.css';
|
12
|
-
import {AutoFetcher} from '../../../../utils/autofetcher';
|
13
|
-
|
14
|
-
const b = cn('kv-describe');
|
15
|
-
|
16
|
-
const expandMap = new Map();
|
17
|
-
|
18
|
-
class Describe extends React.Component {
|
19
|
-
static propTypes = {
|
20
|
-
error: PropTypes.string,
|
21
|
-
data: PropTypes.array,
|
22
|
-
loading: PropTypes.bool,
|
23
|
-
wasLoaded: PropTypes.bool,
|
24
|
-
autorefresh: PropTypes.bool,
|
25
|
-
tenant: PropTypes.string,
|
26
|
-
};
|
27
|
-
|
28
|
-
autofetcher;
|
29
|
-
|
30
|
-
componentDidMount() {
|
31
|
-
const {autorefresh} = this.props;
|
32
|
-
this.autofetcher = new AutoFetcher();
|
33
|
-
this.fetchData();
|
34
|
-
if (autorefresh) {
|
35
|
-
this.autofetcher.start();
|
36
|
-
this.autofetcher.fetch(() => this.fetchData);
|
37
|
-
}
|
38
|
-
}
|
39
|
-
|
40
|
-
componentDidUpdate(prevProps) {
|
41
|
-
const {autorefresh} = this.props;
|
42
|
-
|
43
|
-
if (autorefresh && !prevProps.autorefresh) {
|
44
|
-
this.fetchData();
|
45
|
-
this.autofetcher.stop();
|
46
|
-
this.autofetcher.start();
|
47
|
-
this.autofetcher.fetch(() => this.fetchData());
|
48
|
-
}
|
49
|
-
if (!autorefresh && prevProps.autorefresh) {
|
50
|
-
this.autofetcher.stop();
|
51
|
-
}
|
52
|
-
}
|
53
|
-
|
54
|
-
componentWillUnmount() {
|
55
|
-
this.autofetcher.stop();
|
56
|
-
}
|
57
|
-
|
58
|
-
fetchData() {
|
59
|
-
const {getDescribe, tenant, currentSchemaPath} = this.props;
|
60
|
-
const path = currentSchemaPath || tenant;
|
61
|
-
getDescribe({path});
|
62
|
-
}
|
63
|
-
|
64
|
-
renderDescribeJson = () => {
|
65
|
-
const {data} = this.props;
|
66
|
-
|
67
|
-
return (
|
68
|
-
<JSONTree
|
69
|
-
data={data}
|
70
|
-
className={b('tree')}
|
71
|
-
onClick={({path}) => {
|
72
|
-
const newValue = !(expandMap.get(path) || false);
|
73
|
-
expandMap.set(path, newValue);
|
74
|
-
}}
|
75
|
-
searchOptions={{
|
76
|
-
debounceTime: 300,
|
77
|
-
}}
|
78
|
-
isExpanded={(keypath) => {
|
79
|
-
return expandMap.get(keypath) || false;
|
80
|
-
}}
|
81
|
-
/>
|
82
|
-
);
|
83
|
-
};
|
84
|
-
|
85
|
-
render() {
|
86
|
-
const {error, loading, data, wasLoaded} = this.props;
|
87
|
-
|
88
|
-
if (loading && !wasLoaded) {
|
89
|
-
return (
|
90
|
-
<div className={b('loader-container')}>
|
91
|
-
<Loader size="m" />
|
92
|
-
</div>
|
93
|
-
);
|
94
|
-
}
|
95
|
-
|
96
|
-
if (error) {
|
97
|
-
return <div className={b('message-container')}>{error.data || error}</div>;
|
98
|
-
}
|
99
|
-
|
100
|
-
if (!loading && !data) {
|
101
|
-
return <div className={b('message-container')}>Empty</div>;
|
102
|
-
}
|
103
|
-
|
104
|
-
return (
|
105
|
-
<div className={b()}>
|
106
|
-
<div className={b('result')}>{this.renderDescribeJson()}</div>
|
107
|
-
</div>
|
108
|
-
);
|
109
|
-
}
|
110
|
-
}
|
111
|
-
|
112
|
-
const mapStateToProps = (state) => {
|
113
|
-
const {loading, error, currentDescribe, wasLoaded} = state.describe;
|
114
|
-
const {autorefresh, currentSchemaPath} = state.schema;
|
115
|
-
|
116
|
-
return {
|
117
|
-
data: currentDescribe,
|
118
|
-
loading,
|
119
|
-
error,
|
120
|
-
wasLoaded,
|
121
|
-
autorefresh,
|
122
|
-
currentSchemaPath,
|
123
|
-
};
|
124
|
-
};
|
125
|
-
|
126
|
-
const mapDispatchToProps = {
|
127
|
-
getDescribe,
|
128
|
-
};
|
129
|
-
|
130
|
-
export default connect(mapStateToProps, mapDispatchToProps)(Describe);
|