d2aura 26.0.13 → 26.0.14
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/api/eda/edaManagerApi.d.ts +50 -15
- package/api/eda/edaManagerApi.js +80 -29
- package/api/eda/edaManagerApi.js.map +1 -1
- package/api/eda/generated/events.d.ts +109 -60
- package/api/eda/generated/events.js +182 -88
- package/api/eda/generated/events.js.map +1 -1
- package/api/eda/generated/structures.d.ts +78 -14
- package/api/eda/generated/structures.js.map +1 -1
- package/core/i18n/d2aura.sk.json +30 -2
- package/coreui/components/edaManager/components/detail/components/edaVectorMassChangeButton.d.ts +1 -1
- package/coreui/components/edaManager/components/detail/components/edaVectorMassChangeButton.js +2 -2
- package/coreui/components/edaManager/components/detail/components/edaVectorMassChangeButton.js.map +1 -1
- package/coreui/components/edaManagerComponent/components/edaChartViewer.d.ts +14 -0
- package/coreui/components/edaManagerComponent/components/edaChartViewer.js +370 -0
- package/coreui/components/edaManagerComponent/components/edaChartViewer.js.map +1 -0
- package/coreui/components/edaManagerComponent/components/edaDataBasePanel.d.ts +4 -8
- package/coreui/components/edaManagerComponent/components/edaDataBasePanel.js +18 -75
- package/coreui/components/edaManagerComponent/components/edaDataBasePanel.js.map +1 -1
- package/coreui/components/edaManagerComponent/components/edaDetailPanel.d.ts +5 -14
- package/coreui/components/edaManagerComponent/components/edaDetailPanel.js +80 -19
- package/coreui/components/edaManagerComponent/components/edaDetailPanel.js.map +1 -1
- package/coreui/components/edaManagerComponent/components/edaGraphPanel.d.ts +2 -7
- package/coreui/components/edaManagerComponent/components/edaGraphPanel.js +15 -380
- package/coreui/components/edaManagerComponent/components/edaGraphPanel.js.map +1 -1
- package/coreui/components/edaManagerComponent/components/edaGroupDetailPanel.d.ts +3 -14
- package/coreui/components/edaManagerComponent/components/edaGroupDetailPanel.js +54 -67
- package/coreui/components/edaManagerComponent/components/edaGroupDetailPanel.js.map +1 -1
- package/coreui/components/edaManagerComponent/components/edaLoadingOverlay.d.ts +7 -0
- package/coreui/components/edaManagerComponent/components/edaLoadingOverlay.js +35 -0
- package/coreui/components/edaManagerComponent/components/edaLoadingOverlay.js.map +1 -0
- package/coreui/components/edaManagerComponent/components/edaSampleRangePickerPanel.d.ts +2 -16
- package/coreui/components/edaManagerComponent/components/edaSampleRangePickerPanel.js +47 -50
- package/coreui/components/edaManagerComponent/components/edaSampleRangePickerPanel.js.map +1 -1
- package/coreui/components/edaManagerComponent/components/edaScenarioDetailPanel.d.ts +3 -14
- package/coreui/components/edaManagerComponent/components/edaScenarioDetailPanel.js +67 -81
- package/coreui/components/edaManagerComponent/components/edaScenarioDetailPanel.js.map +1 -1
- package/coreui/components/edaManagerComponent/components/edaTableEditorDialog.d.ts +12 -0
- package/coreui/components/edaManagerComponent/components/edaTableEditorDialog.js +268 -0
- package/coreui/components/edaManagerComponent/components/edaTableEditorDialog.js.map +1 -0
- package/coreui/components/edaManagerComponent/components/edaTablePanel.d.ts +2 -6
- package/coreui/components/edaManagerComponent/components/edaTablePanel.js +119 -62
- package/coreui/components/edaManagerComponent/components/edaTablePanel.js.map +1 -1
- package/coreui/components/edaManagerComponent/components/edaTimeWindowPickerPanel.d.ts +2 -13
- package/coreui/components/edaManagerComponent/components/edaTimeWindowPickerPanel.js +57 -88
- package/coreui/components/edaManagerComponent/components/edaTimeWindowPickerPanel.js.map +1 -1
- package/coreui/components/edaManagerComponent/components/edaTreeView.d.ts +4 -51
- package/coreui/components/edaManagerComponent/components/edaTreeView.js +299 -259
- package/coreui/components/edaManagerComponent/components/edaTreeView.js.map +1 -1
- package/coreui/components/edaManagerComponent/components/edaVectorDetailPanel.d.ts +3 -21
- package/coreui/components/edaManagerComponent/components/edaVectorDetailPanel.js +160 -179
- package/coreui/components/edaManagerComponent/components/edaVectorDetailPanel.js.map +1 -1
- package/coreui/components/edaManagerComponent/components/exportDialog.d.ts +18 -0
- package/coreui/components/edaManagerComponent/components/exportDialog.js +157 -0
- package/coreui/components/edaManagerComponent/components/exportDialog.js.map +1 -0
- package/coreui/components/edaManagerComponent/constants/edaTypes.d.ts +10 -11
- package/coreui/components/edaManagerComponent/constants/edaTypes.js.map +1 -1
- package/coreui/components/edaManagerComponent/context/edaConfigContext.d.ts +26 -0
- package/coreui/components/edaManagerComponent/context/edaConfigContext.js +20 -0
- package/coreui/components/edaManagerComponent/context/edaConfigContext.js.map +1 -0
- package/coreui/components/edaManagerComponent/context/edaVectorDataContext.d.ts +9 -16
- package/coreui/components/edaManagerComponent/context/edaVectorDataContext.js.map +1 -1
- package/coreui/components/edaManagerComponent/context/edaVectorDataProvider.d.ts +0 -1
- package/coreui/components/edaManagerComponent/context/edaVectorDataProvider.js +71 -66
- package/coreui/components/edaManagerComponent/context/edaVectorDataProvider.js.map +1 -1
- package/coreui/components/edaManagerComponent/context/loadingContext.d.ts +1 -1
- package/coreui/components/edaManagerComponent/context/loadingContext.js.map +1 -1
- package/coreui/components/edaManagerComponent/context/{sharedSampleRange.d.ts → sharedSampleRangeContext.d.ts} +6 -3
- package/coreui/components/edaManagerComponent/context/sharedSampleRangeContext.js +3 -0
- package/coreui/components/edaManagerComponent/context/sharedSampleRangeContext.js.map +1 -0
- package/coreui/components/edaManagerComponent/context/useEdaActions.d.ts +7 -0
- package/coreui/components/edaManagerComponent/context/useEdaActions.js +22 -0
- package/coreui/components/edaManagerComponent/context/useEdaActions.js.map +1 -0
- package/coreui/components/edaManagerComponent/edaDetail.d.ts +7 -26
- package/coreui/components/edaManagerComponent/edaDetail.js +124 -106
- package/coreui/components/edaManagerComponent/edaDetail.js.map +1 -1
- package/coreui/components/edaManagerComponent/edaManager.d.ts +4 -11
- package/coreui/components/edaManagerComponent/edaManager.js +29 -22
- package/coreui/components/edaManagerComponent/edaManager.js.map +1 -1
- package/coreui/components/edaManagerComponent/edaNavigator.d.ts +4 -12
- package/coreui/components/edaManagerComponent/edaNavigator.js +36 -41
- package/coreui/components/edaManagerComponent/edaNavigator.js.map +1 -1
- package/coreui/components/edaManagerComponent/edaSelect.d.ts +2 -3
- package/coreui/components/edaManagerComponent/edaSelect.js +22 -44
- package/coreui/components/edaManagerComponent/edaSelect.js.map +1 -1
- package/coreui/components/edaManagerComponent/utils/export.d.ts +9 -0
- package/coreui/components/edaManagerComponent/utils/export.js +573 -0
- package/coreui/components/edaManagerComponent/utils/export.js.map +1 -0
- package/coreui/components/edaManagerComponent/utils/utils.d.ts +6 -12
- package/coreui/components/edaManagerComponent/utils/utils.js +26 -15
- package/coreui/components/edaManagerComponent/utils/utils.js.map +1 -1
- package/d2configuration/edaManager/DB.EM_EDA_DescriptiveVector.xml +65 -0
- package/d2configuration/edaManager/DB.EM_EDA_FunctionPrescription.xml +65 -0
- package/d2configuration/edaManager/E.EM_DETAIL_IMPL.xml +67 -1
- package/d2configuration/edaManager/E.EM_DETAIL_SQL.xml +85 -0
- package/d2configuration/edaManager/E.EM_DETAIL_UNIT.xml +123 -2
- package/d2configuration/edaManager/E.EM_NAVIGATOR_IMPL.xml +1 -1
- package/d2configuration/edaManager/E.EM_NAVIGATOR_UNIT.xml +1 -1
- package/d2configuration/edaManager/E.EM_VECTOR_IMPL.xml +20 -6
- package/d2configuration/edaManager/E.EM_VECTOR_UNIT.xml +95 -17
- package/d2configuration/edaManager/SD.EM_EDA_DescriptiveVector.xml +179 -0
- package/d2configuration/edaManager/SD.EM_EDA_FunctionPrescription.xml +91 -0
- package/d2configuration/edaManager/SD.EM_EDA_InsertValuesToVector_V1.xml +227 -0
- package/d2configuration/edaManager/SD.EM_EDA_PairVector.xml +454 -0
- package/d2configuration/edaManager/SD.EM_EDA_ReadValuesFromVector_V1.xml +13 -3
- package/d2configuration/edaManager/SD.EM_EDA_VectorStats.xml +91 -0
- package/d2configuration/edaManager/SD.EM_Filter_Condition.xml +1 -1
- package/package.json +5 -3
- package/coreui/components/edaManagerComponent/components/edaBasePanel.d.ts +0 -16
- package/coreui/components/edaManagerComponent/components/edaBasePanel.js +0 -85
- package/coreui/components/edaManagerComponent/components/edaBasePanel.js.map +0 -1
- package/coreui/components/edaManagerComponent/context/sharedSampleRange.js +0 -13
- package/coreui/components/edaManagerComponent/context/sharedSampleRange.js.map +0 -1
- package/d2configuration/edaManager/EDA_CancelSession.xml +0 -54
- package/d2configuration/edaManager/EDA_GetSessionId.xml +0 -54
- package/d2configuration/edaManager/EDA_ReadValuesFromVektorRec.xml +0 -54
- package/d2configuration/edaManager/EDA_StatVectorRec.xml +0 -56
|
@@ -1,9 +1,8 @@
|
|
|
1
|
-
import React from "react";
|
|
2
|
-
import { Tree, Typography } from "antd";
|
|
3
|
-
import { DownOutlined, FolderOpenOutlined, FunctionOutlined, LoadingOutlined, QuestionOutlined } from "@ant-design/icons";
|
|
4
|
-
import WithCss from "d2coreui/components/style/withCss";
|
|
5
|
-
import { createStyles } from "antd-style";
|
|
1
|
+
import React, { useCallback, useEffect, useRef, useState } from "react";
|
|
6
2
|
import { EdaVectorType } from "../constants/edaTypes";
|
|
3
|
+
import { createStyles } from "antd-style";
|
|
4
|
+
import { Dropdown, Tree, Typography } from "antd";
|
|
5
|
+
import { DownOutlined, FolderOpenOutlined, FunctionOutlined, LoadingOutlined, QuestionOutlined } from "@ant-design/icons";
|
|
7
6
|
import { NumberFifteenFilled } from "../icons/numberFifteenFilled";
|
|
8
7
|
import { LetterHFilled } from "../icons/letterHFilled";
|
|
9
8
|
import { LetterDFilled } from "../icons/letterDFilled";
|
|
@@ -12,13 +11,14 @@ import { LetterIFilled } from "../icons/letterIFilled";
|
|
|
12
11
|
import { PairOutlined } from "../icons/pairOutlined";
|
|
13
12
|
import { PeriodicOutlined } from "../icons/periodicOutlined";
|
|
14
13
|
import i18n from "d2core/i18n/i18n";
|
|
14
|
+
import { useEdaActions } from "../context/useEdaActions";
|
|
15
15
|
const useStyles = createStyles(({ css }) => {
|
|
16
16
|
return {
|
|
17
17
|
baseLayout: css `
|
|
18
18
|
position: relative;
|
|
19
19
|
height: 100%;
|
|
20
20
|
width: 100%;
|
|
21
|
-
|
|
21
|
+
|
|
22
22
|
.ant-tree {
|
|
23
23
|
height: 100%;
|
|
24
24
|
background-color: transparent;
|
|
@@ -32,7 +32,7 @@ const useStyles = createStyles(({ css }) => {
|
|
|
32
32
|
white-space: nowrap;
|
|
33
33
|
text-overflow: ellipsis;
|
|
34
34
|
overflow: hidden;
|
|
35
|
-
|
|
35
|
+
|
|
36
36
|
.ant-tree-title {
|
|
37
37
|
white-space: nowrap;
|
|
38
38
|
}
|
|
@@ -41,10 +41,7 @@ const useStyles = createStyles(({ css }) => {
|
|
|
41
41
|
absoluteLayout: css `
|
|
42
42
|
overflow: auto;
|
|
43
43
|
position: absolute;
|
|
44
|
-
|
|
45
|
-
right: 0;
|
|
46
|
-
top: 0;
|
|
47
|
-
bottom: 0;
|
|
44
|
+
inset: 0;
|
|
48
45
|
`
|
|
49
46
|
};
|
|
50
47
|
});
|
|
@@ -53,98 +50,89 @@ export var TreeViewType;
|
|
|
53
50
|
TreeViewType["GROUP"] = "group";
|
|
54
51
|
TreeViewType["SCENARIO"] = "scenario";
|
|
55
52
|
})(TreeViewType || (TreeViewType = {}));
|
|
56
|
-
export
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
this.setState({ loading: "" });
|
|
121
|
-
try {
|
|
122
|
-
let treeData;
|
|
123
|
-
switch (type) {
|
|
124
|
-
case TreeViewType.GROUP:
|
|
125
|
-
const rootGroups = await this.props.api.getGroupChildren(undefined);
|
|
126
|
-
treeData = this.convertGroups(rootGroups.items, undefined);
|
|
127
|
-
break;
|
|
128
|
-
case TreeViewType.SCENARIO:
|
|
129
|
-
const rootScenarios = await this.props.api.getScenarioChildren(undefined);
|
|
130
|
-
treeData = this.convertScenarios(rootScenarios.items, undefined);
|
|
131
|
-
break;
|
|
132
|
-
}
|
|
133
|
-
this.setState({ treeData: treeData });
|
|
53
|
+
export const EdaTreeView = ({ api, type, onItemDoubleClick }) => {
|
|
54
|
+
const { styles } = useStyles();
|
|
55
|
+
const { triggerExport, renderActionDialogs } = useEdaActions(api);
|
|
56
|
+
const childParentMap = useRef(new Map());
|
|
57
|
+
const nodeMap = useRef(new Map());
|
|
58
|
+
const divRef = useRef(null);
|
|
59
|
+
const [treeData, setTreeData] = useState([]);
|
|
60
|
+
const [expandedKeys, setExpandedKeys] = useState([]);
|
|
61
|
+
const [selectedKeys, setSelectedKeys] = useState([]);
|
|
62
|
+
const [height, setHeight] = useState(0);
|
|
63
|
+
const [loadingKey, setLoadingKey] = useState();
|
|
64
|
+
const [rightClickedNode, setRightClickedNode] = useState();
|
|
65
|
+
const convertGroups = useCallback((groups, parentId) => {
|
|
66
|
+
return groups.map((group) => {
|
|
67
|
+
const node = {
|
|
68
|
+
key: group.ID,
|
|
69
|
+
title: group.DisplayName,
|
|
70
|
+
isLeaf: false,
|
|
71
|
+
icon: React.createElement(FolderOpenOutlined, null),
|
|
72
|
+
group: group,
|
|
73
|
+
};
|
|
74
|
+
childParentMap.current.set(group.ID, parentId);
|
|
75
|
+
nodeMap.current.set(group.ID, node);
|
|
76
|
+
return node;
|
|
77
|
+
});
|
|
78
|
+
}, []);
|
|
79
|
+
const convertScenarios = useCallback((scenarios, parentId) => {
|
|
80
|
+
return scenarios.map((scenario) => {
|
|
81
|
+
const node = {
|
|
82
|
+
key: scenario.ID,
|
|
83
|
+
title: scenario.DisplayName,
|
|
84
|
+
isLeaf: false,
|
|
85
|
+
icon: React.createElement(FolderOpenOutlined, null),
|
|
86
|
+
scenario: scenario,
|
|
87
|
+
};
|
|
88
|
+
childParentMap.current.set(scenario.ID, parentId);
|
|
89
|
+
nodeMap.current.set(scenario.ID, node);
|
|
90
|
+
return node;
|
|
91
|
+
});
|
|
92
|
+
}, []);
|
|
93
|
+
const convertVectors = useCallback((vectors, parentId) => {
|
|
94
|
+
return vectors.map((vector) => {
|
|
95
|
+
const id = `${parentId}_${vector.ID}`;
|
|
96
|
+
const node = {
|
|
97
|
+
key: id,
|
|
98
|
+
title: vector.DisplayName,
|
|
99
|
+
isLeaf: true,
|
|
100
|
+
icon: getVectorIcon(vector.Type),
|
|
101
|
+
vector: vector,
|
|
102
|
+
};
|
|
103
|
+
childParentMap.current.set(id, parentId);
|
|
104
|
+
nodeMap.current.set(id, node);
|
|
105
|
+
return node;
|
|
106
|
+
});
|
|
107
|
+
}, []);
|
|
108
|
+
const loadVectors = useCallback(async (data, id, nodes, vectors) => {
|
|
109
|
+
const amount = vectors.leftCount > api.pageSize ? api.pageSize : vectors.leftCount;
|
|
110
|
+
nodes.push(...convertVectors(vectors.items, id));
|
|
111
|
+
if (data.vectorOffset === undefined) {
|
|
112
|
+
data.vectorOffset = {
|
|
113
|
+
done: vectors.leftCount === 0,
|
|
114
|
+
offset: vectors.items.length,
|
|
115
|
+
total: vectors.items.length + vectors.leftCount,
|
|
116
|
+
};
|
|
134
117
|
}
|
|
135
|
-
|
|
136
|
-
|
|
118
|
+
else {
|
|
119
|
+
data.vectorOffset.done = vectors.leftCount === 0;
|
|
120
|
+
data.vectorOffset.offset += vectors.items.length;
|
|
137
121
|
}
|
|
138
|
-
|
|
139
|
-
|
|
122
|
+
if (!data.vectorOffset.done) {
|
|
123
|
+
const key = `${id}_show_more`;
|
|
124
|
+
nodes.push({
|
|
125
|
+
key: key,
|
|
126
|
+
title: renderShowMoreTitle(key, data, amount, data.vectorOffset.total),
|
|
127
|
+
isLeaf: true,
|
|
128
|
+
});
|
|
140
129
|
}
|
|
141
|
-
}
|
|
142
|
-
|
|
143
|
-
const { api } = this.props;
|
|
130
|
+
}, [convertVectors]);
|
|
131
|
+
const loadGroups = useCallback(async (data, id, nodes) => {
|
|
144
132
|
if (!data.groupOffset?.done) {
|
|
145
133
|
const groups = await api.getGroupChildren(id, data.groupOffset?.offset);
|
|
146
134
|
const amount = groups.leftCount > api.pageSize ? api.pageSize : groups.leftCount;
|
|
147
|
-
nodes.push(...
|
|
135
|
+
nodes.push(...convertGroups(groups.items, id));
|
|
148
136
|
if (data.groupOffset === undefined) {
|
|
149
137
|
data.groupOffset = {
|
|
150
138
|
done: groups.leftCount === 0,
|
|
@@ -160,240 +148,292 @@ export class EdaTreeView extends React.Component {
|
|
|
160
148
|
const key = `${id}_show_more`;
|
|
161
149
|
nodes.push({
|
|
162
150
|
key: key,
|
|
163
|
-
title:
|
|
151
|
+
title: renderShowMoreTitle(key, data, amount, data.groupOffset.total),
|
|
164
152
|
isLeaf: true,
|
|
165
153
|
});
|
|
166
154
|
}
|
|
167
155
|
}
|
|
168
156
|
if (data.groupOffset.done && !data.vectorOffset?.done) {
|
|
169
157
|
const vectors = await api.getGroupVectors(id, data.vectorOffset?.offset);
|
|
170
|
-
|
|
158
|
+
await loadVectors(data, id, nodes, vectors);
|
|
171
159
|
}
|
|
172
|
-
}
|
|
173
|
-
|
|
174
|
-
const { api } = this.props;
|
|
160
|
+
}, [convertGroups, loadVectors]);
|
|
161
|
+
const loadScenarios = useCallback(async (data, id, nodes) => {
|
|
175
162
|
if (!data.scenarioOffset?.done) {
|
|
176
|
-
const
|
|
177
|
-
const amount =
|
|
178
|
-
nodes.push(...
|
|
163
|
+
const scenarios = await api.getScenarioChildren(id, data.scenarioOffset?.offset);
|
|
164
|
+
const amount = scenarios.leftCount > api.pageSize ? api.pageSize : scenarios.leftCount;
|
|
165
|
+
nodes.push(...convertScenarios(scenarios.items, id));
|
|
179
166
|
if (data.scenarioOffset === undefined) {
|
|
180
167
|
data.scenarioOffset = {
|
|
181
|
-
done:
|
|
182
|
-
offset:
|
|
183
|
-
total:
|
|
168
|
+
done: scenarios.leftCount === 0,
|
|
169
|
+
offset: scenarios.items.length,
|
|
170
|
+
total: scenarios.items.length + scenarios.leftCount,
|
|
184
171
|
};
|
|
185
172
|
}
|
|
186
173
|
else {
|
|
187
|
-
data.scenarioOffset.done =
|
|
188
|
-
data.scenarioOffset.offset +=
|
|
174
|
+
data.scenarioOffset.done = scenarios.leftCount === 0;
|
|
175
|
+
data.scenarioOffset.offset += scenarios.items.length;
|
|
189
176
|
}
|
|
190
177
|
if (!data.scenarioOffset.done) {
|
|
191
178
|
const key = `${id}_show_more`;
|
|
192
179
|
nodes.push({
|
|
193
180
|
key: key,
|
|
194
|
-
title:
|
|
181
|
+
title: renderShowMoreTitle(key, data, amount, data.scenarioOffset.total),
|
|
195
182
|
isLeaf: true,
|
|
196
183
|
});
|
|
197
184
|
}
|
|
198
185
|
}
|
|
199
186
|
if (data.scenarioOffset.done && !data.vectorOffset?.done) {
|
|
200
187
|
const vectors = await api.getScenarioVectors(id, data.vectorOffset?.offset, undefined, true);
|
|
201
|
-
|
|
188
|
+
await loadVectors(data, id, nodes, vectors);
|
|
202
189
|
}
|
|
203
|
-
}
|
|
204
|
-
|
|
205
|
-
const
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
done: vectors.leftCount === 0,
|
|
211
|
-
offset: vectors.items.length,
|
|
212
|
-
total: vectors.items.length + vectors.leftCount,
|
|
213
|
-
};
|
|
190
|
+
}, [convertScenarios, loadVectors]);
|
|
191
|
+
const updateTreeState = useCallback((data, nodes, treeData, dataId, resolve, reject) => {
|
|
192
|
+
const index = treeData.findIndex((t) => (type === TreeViewType.GROUP ? t.group?.ID : t.scenario?.ID) === dataId);
|
|
193
|
+
if (index < 0) {
|
|
194
|
+
console.warn("Failed to find index");
|
|
195
|
+
reject();
|
|
196
|
+
return;
|
|
214
197
|
}
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
198
|
+
treeData[index] = { ...data, children: treeData[index].children };
|
|
199
|
+
if (treeData[index].children) {
|
|
200
|
+
treeData[index].children.pop();
|
|
201
|
+
treeData[index].children.push(...nodes);
|
|
218
202
|
}
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
nodes.push({
|
|
222
|
-
key: key,
|
|
223
|
-
title: this.renderTitle(key, data, amount, data.vectorOffset.total),
|
|
224
|
-
isLeaf: true,
|
|
225
|
-
});
|
|
203
|
+
else {
|
|
204
|
+
treeData[index].children = nodes;
|
|
226
205
|
}
|
|
227
|
-
|
|
228
|
-
|
|
206
|
+
nodeMap.current.set(dataId, treeData[index]);
|
|
207
|
+
resolve();
|
|
208
|
+
}, [type]);
|
|
209
|
+
const onLoadData = useCallback(async (data, id) => {
|
|
229
210
|
if (data.children) {
|
|
230
211
|
return Promise.resolve();
|
|
231
212
|
}
|
|
232
|
-
|
|
213
|
+
setLoadingKey(id);
|
|
233
214
|
try {
|
|
234
|
-
const { type } = this.props;
|
|
235
215
|
let id;
|
|
236
216
|
const nodes = [];
|
|
237
217
|
switch (type) {
|
|
238
218
|
case TreeViewType.GROUP:
|
|
239
219
|
if (!data.group) {
|
|
240
220
|
console.warn("No group!");
|
|
241
|
-
|
|
221
|
+
setLoadingKey(undefined);
|
|
242
222
|
return;
|
|
243
223
|
}
|
|
244
224
|
id = data.group.ID;
|
|
245
|
-
await
|
|
225
|
+
await loadGroups(data, id, nodes);
|
|
246
226
|
break;
|
|
247
227
|
case TreeViewType.SCENARIO:
|
|
248
228
|
if (!data.scenario) {
|
|
249
229
|
console.warn("No scenario!");
|
|
250
|
-
|
|
230
|
+
setLoadingKey(undefined);
|
|
251
231
|
return;
|
|
252
232
|
}
|
|
253
233
|
id = data.scenario.ID;
|
|
254
|
-
await
|
|
234
|
+
await loadScenarios(data, id, nodes);
|
|
255
235
|
break;
|
|
256
236
|
default:
|
|
257
|
-
|
|
237
|
+
setLoadingKey(undefined);
|
|
258
238
|
return;
|
|
259
239
|
}
|
|
260
|
-
const parentId = this.childParentMap.get(id);
|
|
261
240
|
await new Promise((resolve, reject) => {
|
|
262
|
-
|
|
263
|
-
const
|
|
264
|
-
if (
|
|
265
|
-
|
|
241
|
+
setTreeData((treeData) => {
|
|
242
|
+
const parentId = childParentMap.current.get(id);
|
|
243
|
+
if (parentId !== undefined) {
|
|
244
|
+
const parentNode = nodeMap.current.get(parentId);
|
|
245
|
+
if (parentNode?.children) {
|
|
246
|
+
updateTreeState(data, nodes, parentNode.children, id, resolve, reject);
|
|
247
|
+
}
|
|
248
|
+
else {
|
|
249
|
+
console.warn("No parent for node", id);
|
|
250
|
+
reject();
|
|
251
|
+
}
|
|
266
252
|
}
|
|
267
253
|
else {
|
|
268
|
-
|
|
269
|
-
reject();
|
|
254
|
+
updateTreeState(data, nodes, treeData, id, resolve, reject);
|
|
270
255
|
}
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
this.updateTree(data, nodes, this.state.treeData, id, resolve, reject);
|
|
274
|
-
}
|
|
256
|
+
return [...treeData];
|
|
257
|
+
});
|
|
275
258
|
});
|
|
276
259
|
}
|
|
277
260
|
catch (e) {
|
|
278
261
|
console.warn("Failed to load tree data", e);
|
|
279
262
|
}
|
|
280
263
|
finally {
|
|
281
|
-
|
|
264
|
+
setLoadingKey(undefined);
|
|
282
265
|
}
|
|
283
|
-
}
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
266
|
+
}, [api, type, convertGroups, convertScenarios, updateTreeState, loadGroups, loadScenarios]);
|
|
267
|
+
const renderShowMoreTitle = (key, data, amount, total) => (React.createElement(Typography.Link, { onClick: async (e) => {
|
|
268
|
+
e.stopPropagation();
|
|
269
|
+
e.preventDefault();
|
|
270
|
+
await onLoadData(data, key);
|
|
271
|
+
} }, i18n("Show %{n} more (of %{o})", { n: String(amount), o: String(total) })));
|
|
272
|
+
useEffect(() => {
|
|
273
|
+
const initLoad = async () => {
|
|
274
|
+
setLoadingKey("");
|
|
275
|
+
try {
|
|
276
|
+
let initialData;
|
|
277
|
+
if (type === TreeViewType.GROUP) {
|
|
278
|
+
const res = await api.getGroupChildren(undefined);
|
|
279
|
+
initialData = convertGroups(res.items, undefined);
|
|
280
|
+
}
|
|
281
|
+
else {
|
|
282
|
+
const res = await api.getScenarioChildren(undefined);
|
|
283
|
+
initialData = convertScenarios(res.items, undefined);
|
|
284
|
+
}
|
|
285
|
+
setTreeData(initialData);
|
|
286
|
+
}
|
|
287
|
+
catch (e) {
|
|
288
|
+
console.warn("Failed to load tree data", e);
|
|
289
|
+
}
|
|
290
|
+
finally {
|
|
291
|
+
setLoadingKey(undefined);
|
|
292
|
+
}
|
|
293
|
+
};
|
|
294
|
+
initLoad();
|
|
295
|
+
}, [api, type, convertGroups, convertScenarios]);
|
|
296
|
+
useEffect(() => {
|
|
297
|
+
if (!divRef.current) {
|
|
298
|
+
return;
|
|
287
299
|
}
|
|
288
|
-
|
|
289
|
-
|
|
300
|
+
const observer = new ResizeObserver((entries) => {
|
|
301
|
+
const entry = entries[0];
|
|
302
|
+
if (entry) {
|
|
303
|
+
setHeight(entry.contentRect.height);
|
|
304
|
+
}
|
|
305
|
+
});
|
|
306
|
+
observer.observe(divRef.current);
|
|
307
|
+
return () => observer.disconnect();
|
|
308
|
+
}, []);
|
|
309
|
+
const titleRenderer = useCallback((node) => {
|
|
310
|
+
if (node.key === loadingKey) {
|
|
311
|
+
return React.createElement(Typography.Link, null,
|
|
312
|
+
React.createElement(LoadingOutlined, null),
|
|
313
|
+
i18n("Loading"),
|
|
314
|
+
"...");
|
|
290
315
|
}
|
|
291
|
-
|
|
292
|
-
|
|
316
|
+
return node.title;
|
|
317
|
+
}, [loadingKey]);
|
|
318
|
+
const onDoubleClick = useCallback((_e, node) => {
|
|
319
|
+
if (node.vector) {
|
|
320
|
+
onItemDoubleClick?.({ id: node.vector.ID, type: 0 }, node.vector);
|
|
293
321
|
}
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
updateTree(data, nodes, treeData, dataId, resolve, reject) {
|
|
297
|
-
const { type } = this.props;
|
|
298
|
-
const index = treeData.findIndex((t) => (type === TreeViewType.GROUP ? t.group?.ID : t.scenario?.ID) === dataId);
|
|
299
|
-
if (index < 0) {
|
|
300
|
-
console.warn("Failed to find index");
|
|
301
|
-
reject();
|
|
302
|
-
return;
|
|
322
|
+
else if (node.group) {
|
|
323
|
+
onItemDoubleClick?.({ id: node.group.ID, type: 1 }, node.group);
|
|
303
324
|
}
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
treeData[index].children.pop();
|
|
307
|
-
treeData[index].children.push(...nodes);
|
|
325
|
+
else if (node.scenario) {
|
|
326
|
+
onItemDoubleClick?.({ id: node.scenario.ID, type: 2 }, node.scenario);
|
|
308
327
|
}
|
|
309
|
-
|
|
310
|
-
|
|
328
|
+
setSelectedKeys([node.key]);
|
|
329
|
+
}, [onItemDoubleClick]);
|
|
330
|
+
const getMenuItems = useCallback((node) => {
|
|
331
|
+
const result = [
|
|
332
|
+
{ key: 'export', label: i18n("Export to XML") },
|
|
333
|
+
];
|
|
334
|
+
if (node.vector) {
|
|
335
|
+
result.push(...[]);
|
|
311
336
|
}
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
}
|
|
315
|
-
convertGroups(groups, parentId) {
|
|
316
|
-
const data = [];
|
|
317
|
-
for (let group of groups) {
|
|
318
|
-
const node = {
|
|
319
|
-
key: group.ID,
|
|
320
|
-
title: group.DisplayName,
|
|
321
|
-
isLeaf: false,
|
|
322
|
-
icon: React.createElement(FolderOpenOutlined, null),
|
|
323
|
-
group: group,
|
|
324
|
-
};
|
|
325
|
-
data.push(node);
|
|
326
|
-
this.childParentMap.set(group.ID, parentId);
|
|
327
|
-
this.nodeMap.set(group.ID, node);
|
|
337
|
+
if (node.group) {
|
|
338
|
+
result.push(...[]);
|
|
328
339
|
}
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
convertScenarios(scenarios, parentId) {
|
|
332
|
-
const data = [];
|
|
333
|
-
for (let scenario of scenarios) {
|
|
334
|
-
const node = {
|
|
335
|
-
key: scenario.ID,
|
|
336
|
-
title: scenario.DisplayName,
|
|
337
|
-
isLeaf: false,
|
|
338
|
-
icon: React.createElement(FolderOpenOutlined, null),
|
|
339
|
-
scenario: scenario,
|
|
340
|
-
};
|
|
341
|
-
data.push(node);
|
|
342
|
-
this.childParentMap.set(scenario.ID, parentId);
|
|
343
|
-
this.nodeMap.set(scenario.ID, node);
|
|
340
|
+
if (node.scenario) {
|
|
341
|
+
result.push(...[]);
|
|
344
342
|
}
|
|
345
|
-
return
|
|
346
|
-
}
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
isLeaf: true,
|
|
355
|
-
icon: this.getVectorIcon(vector.Type),
|
|
356
|
-
vector: vector,
|
|
357
|
-
};
|
|
358
|
-
data.push(node);
|
|
359
|
-
this.childParentMap.set(id, parentId);
|
|
360
|
-
this.nodeMap.set(id, node);
|
|
343
|
+
return result;
|
|
344
|
+
}, []);
|
|
345
|
+
const onRightClick = useCallback(({ node }) => {
|
|
346
|
+
setRightClickedNode(node);
|
|
347
|
+
}, []);
|
|
348
|
+
const handleContextMenuItemClicked = useCallback(async ({ key }) => {
|
|
349
|
+
let type = undefined;
|
|
350
|
+
if (rightClickedNode?.vector) {
|
|
351
|
+
type = 0;
|
|
361
352
|
}
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
case
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
353
|
+
if (rightClickedNode?.group) {
|
|
354
|
+
type = 1;
|
|
355
|
+
}
|
|
356
|
+
if (rightClickedNode?.scenario) {
|
|
357
|
+
type = 2;
|
|
358
|
+
}
|
|
359
|
+
if (type === undefined) {
|
|
360
|
+
return;
|
|
361
|
+
}
|
|
362
|
+
switch (key) {
|
|
363
|
+
case "export": {
|
|
364
|
+
let data = undefined;
|
|
365
|
+
switch (type) {
|
|
366
|
+
case 0: {
|
|
367
|
+
const result = await api.loadVectorData(rightClickedNode?.vector?.ID);
|
|
368
|
+
if (!result) {
|
|
369
|
+
return;
|
|
370
|
+
}
|
|
371
|
+
data = { type: 0, data: result };
|
|
372
|
+
break;
|
|
373
|
+
}
|
|
374
|
+
case 1: {
|
|
375
|
+
const result = await api.loadGroupData(rightClickedNode?.group?.ID);
|
|
376
|
+
if (!result) {
|
|
377
|
+
return;
|
|
378
|
+
}
|
|
379
|
+
data = { type: 1, data: result };
|
|
380
|
+
break;
|
|
381
|
+
}
|
|
382
|
+
case 2: {
|
|
383
|
+
const result = await api.loadScenarioData(rightClickedNode?.scenario?.ID);
|
|
384
|
+
if (!result) {
|
|
385
|
+
return;
|
|
386
|
+
}
|
|
387
|
+
data = { type: 2, data: result };
|
|
388
|
+
break;
|
|
389
|
+
}
|
|
390
|
+
}
|
|
391
|
+
triggerExport(data);
|
|
392
|
+
return;
|
|
393
|
+
}
|
|
396
394
|
}
|
|
395
|
+
}, [rightClickedNode]);
|
|
396
|
+
return (React.createElement(Dropdown, { menu: {
|
|
397
|
+
items: rightClickedNode ? getMenuItems(rightClickedNode) : [],
|
|
398
|
+
onClick: handleContextMenuItemClicked,
|
|
399
|
+
}, trigger: ['contextMenu'] },
|
|
400
|
+
React.createElement("div", { ref: divRef, className: styles.baseLayout },
|
|
401
|
+
React.createElement("div", { className: styles.absoluteLayout },
|
|
402
|
+
React.createElement(Tree, { blockNode: true, showLine: true, showIcon: true, switcherIcon: React.createElement(DownOutlined, null), height: height, loadData: onLoadData, onRightClick: onRightClick, onExpand: setExpandedKeys, onDoubleClick: onDoubleClick, expandedKeys: expandedKeys, selectedKeys: selectedKeys, titleRender: titleRenderer, treeData: treeData }),
|
|
403
|
+
renderActionDialogs()))));
|
|
404
|
+
};
|
|
405
|
+
const getVectorIcon = (type) => {
|
|
406
|
+
switch (type) {
|
|
407
|
+
case EdaVectorType.FifteenMinutes:
|
|
408
|
+
return React.createElement(NumberFifteenFilled, null);
|
|
409
|
+
case EdaVectorType.Hour:
|
|
410
|
+
return React.createElement(LetterHFilled, null);
|
|
411
|
+
case EdaVectorType.Day:
|
|
412
|
+
return React.createElement(LetterDFilled, null);
|
|
413
|
+
case EdaVectorType.Descriptive:
|
|
414
|
+
return React.createElement(LetterCFilled, null);
|
|
415
|
+
case EdaVectorType.Interval:
|
|
416
|
+
return React.createElement(LetterIFilled, null);
|
|
417
|
+
case EdaVectorType.FifteenMinutesCalc:
|
|
418
|
+
return React.createElement(NumberFifteenFilled, { style: { color: "orange" } });
|
|
419
|
+
case EdaVectorType.HourCalc:
|
|
420
|
+
return React.createElement(LetterHFilled, { style: { color: "orange" } });
|
|
421
|
+
case EdaVectorType.DayCalc:
|
|
422
|
+
return React.createElement(LetterDFilled, { style: { color: "orange" } });
|
|
423
|
+
case EdaVectorType.Change:
|
|
424
|
+
return React.createElement(LetterCFilled, null);
|
|
425
|
+
case EdaVectorType.ChangeCalc:
|
|
426
|
+
return React.createElement(LetterCFilled, { style: { color: "orange" } });
|
|
427
|
+
case EdaVectorType.Pair:
|
|
428
|
+
return React.createElement(PairOutlined, null);
|
|
429
|
+
case EdaVectorType.Periodic:
|
|
430
|
+
return React.createElement(PeriodicOutlined, null);
|
|
431
|
+
case EdaVectorType.PeriodicCalc:
|
|
432
|
+
return React.createElement(PeriodicOutlined, { style: { color: "orange" } });
|
|
433
|
+
case EdaVectorType.Functional:
|
|
434
|
+
return React.createElement(FunctionOutlined, null);
|
|
435
|
+
default:
|
|
436
|
+
return React.createElement(QuestionOutlined, null);
|
|
397
437
|
}
|
|
398
|
-
}
|
|
438
|
+
};
|
|
399
439
|
//# sourceMappingURL=edaTreeView.js.map
|