@riil-frontend/component-topology 9.0.0-a.8 → 9.0.1
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/build/1.js +1 -1
- package/build/index.css +1 -1
- package/build/index.js +15 -15
- package/es/components/VerticalIconTab/VerticalIconTab.module.scss +11 -5
- package/es/core/components/TopoView/GraphViewPanel.js +17 -4
- package/es/core/components/TopoView/TopoView.module.scss +17 -3
- package/es/core/editor/components/BackgroundView/index.module.scss +3 -0
- package/es/core/editor/components/EditorPlugin.js +4 -1
- package/es/core/editor/components/Sidebar/Sidebar.module.scss +7 -7
- package/es/core/editor/components/Sidebar/views/CanvasPanel/CanvasPanel.js +1 -1
- package/es/core/editor/components/Sidebar/views/CanvasPanel/CanvasPanel.module.scss +1 -0
- package/es/core/editor/components/Sidebar/views/ComponentPanel.js +1 -1
- package/es/core/editor/components/Sidebar/views/ImagePanel/ImagePanel.js +2 -1
- package/es/core/editor/components/Sidebar/views/LinkPanel.js +1 -1
- package/es/core/editor/components/Toolbar/widgets/EdgeTypeButton/EdgeType.js +20 -5
- package/es/core/editor/components/Toolbar/widgets/EdgeTypeButton/EdgeType.module.scss +5 -1
- package/es/core/editor/components/Toolbar/widgets/EdgeTypeButton/LineType.js +31 -12
- package/es/core/editor/components/Toolbar/widgets/EdgeTypeButton/LineType.module.scss +12 -2
- package/es/core/editor/components/Toolbar/widgets/EdgeTypeButton/index.js +6 -0
- package/es/core/editor/components/Toolbar/widgets/FontSizeWidget.js +1 -1
- package/es/core/editor/components/Toolbar/widgets/components/textStyleSetting/ElementTextStyleSetting/elements/groupTitle.js +1 -1
- package/es/core/editor/components/settings/core/getPropertyViewType.js +3 -0
- package/es/core/editor/components/settings/core/updateElementProperty.js +6 -1
- package/es/core/editor/components/settings/propertyViews/group/DataTab/hoooks/useGroupRelateResource.js +4 -3
- package/es/core/editor/components/settings/propertyViews/layer/DataTab/NodeList.js +3 -2
- package/es/core/editor/components/settings/propertyViews/node/data/BindIpInput.js +95 -0
- package/es/core/editor/components/settings/propertyViews/node/data/Data.js +46 -14
- package/es/core/editor/config/themes.js +53 -2
- package/es/core/editor/utils/edgeTypeStyleUtil.js +38 -0
- package/es/core/hooks/useCanvasTheme.js +12 -4
- package/es/core/hooks/useResourceConfig.js +2 -1
- package/es/core/hooks/useTopoEdit.js +120 -19
- package/es/core/hooks/useTopoFullscreen.js +32 -0
- package/es/core/models/AttributeMetricDisplay.js +89 -74
- package/es/core/models/TopoApp.js +1 -1
- package/es/core/models/attributeFormatter/index.js +16 -16
- package/es/core/models/topoData.js +16 -9
- package/es/core/models/utils/linkUtils.js +52 -27
- package/es/core/store/models/topoConfig.js +51 -20
- package/es/core/test/Test.js +52 -0
- package/es/core/utils/graphLinkUtil.js +11 -6
- package/es/core/viewer/components/plugins/ResourceDetail/components/ResourceOverview/BaseInfo.js +16 -2
- package/es/core/viewer/components/plugins/ResourceDetail/components/ResourceOverview/ResourceOverview.js +8 -78
- package/es/core/viewer/components/plugins/ResourceDetail/components/ResourceOverview/components/LinkTopo/LinkTopo.js +14 -0
- package/es/core/viewer/components/plugins/ResourceDetail/components/ResourceOverview/components/LinkTopo/hooks/useMetricPolling.js +27 -37
- package/es/core/viewer/components/plugins/ResourceDetail/components/ResourceOverview/components/LinkTopo/services/index.js +57 -1
- package/es/core/viewer/components/plugins/ResourceDetail/components/ResourceOverview/index.module.scss +6 -0
- package/es/networkTopo/getTopoData.js +2 -1
- package/es/networkTopo/models/IpNodeTagsTipsBuilder.js +113 -0
- package/es/networkTopo/models/LinkDynamicStyleExecutor.js +8 -8
- package/es/networkTopo/models/TopoCenter.js +4 -3
- package/es/networkTopo/services/link.js +1 -1
- package/es/networkTopo/services/topo/basic.js +27 -26
- package/es/networkTopo/services/topo/networkLink.js +45 -3
- package/es/networkTopo/utils/exitLinkUtil.js +257 -0
- package/es/style.js +1 -0
- package/es/utils/ResourceConfigUtil.js +5 -4
- package/es/utils/htElementDataUtil.js +1 -7
- package/es/utils/htElementUtils.js +21 -21
- package/lib/components/VerticalIconTab/VerticalIconTab.module.scss +11 -5
- package/lib/core/components/TopoView/GraphViewPanel.js +18 -3
- package/lib/core/components/TopoView/TopoView.module.scss +17 -3
- package/lib/core/editor/components/BackgroundView/index.module.scss +3 -0
- package/lib/core/editor/components/EditorPlugin.js +7 -1
- package/lib/core/editor/components/Sidebar/Sidebar.module.scss +7 -7
- package/lib/core/editor/components/Sidebar/views/CanvasPanel/CanvasPanel.js +1 -1
- package/lib/core/editor/components/Sidebar/views/CanvasPanel/CanvasPanel.module.scss +1 -0
- package/lib/core/editor/components/Sidebar/views/ComponentPanel.js +1 -1
- package/lib/core/editor/components/Sidebar/views/ImagePanel/ImagePanel.js +2 -1
- package/lib/core/editor/components/Sidebar/views/LinkPanel.js +1 -1
- package/lib/core/editor/components/Toolbar/widgets/EdgeTypeButton/EdgeType.js +19 -3
- package/lib/core/editor/components/Toolbar/widgets/EdgeTypeButton/EdgeType.module.scss +5 -1
- package/lib/core/editor/components/Toolbar/widgets/EdgeTypeButton/LineType.js +31 -12
- package/lib/core/editor/components/Toolbar/widgets/EdgeTypeButton/LineType.module.scss +12 -2
- package/lib/core/editor/components/Toolbar/widgets/EdgeTypeButton/index.js +6 -0
- package/lib/core/editor/components/Toolbar/widgets/FontSizeWidget.js +1 -1
- package/lib/core/editor/components/Toolbar/widgets/components/textStyleSetting/ElementTextStyleSetting/elements/groupTitle.js +1 -1
- package/lib/core/editor/components/settings/core/getPropertyViewType.js +3 -0
- package/lib/core/editor/components/settings/core/updateElementProperty.js +6 -1
- package/lib/core/editor/components/settings/propertyViews/group/DataTab/hoooks/useGroupRelateResource.js +3 -3
- package/lib/core/editor/components/settings/propertyViews/layer/DataTab/NodeList.js +3 -1
- package/lib/core/editor/components/settings/propertyViews/node/data/BindIpInput.js +111 -0
- package/lib/core/editor/components/settings/propertyViews/node/data/Data.js +48 -14
- package/lib/core/editor/config/themes.js +53 -2
- package/lib/core/editor/utils/edgeTypeStyleUtil.js +39 -0
- package/lib/core/hooks/useCanvasTheme.js +12 -4
- package/lib/core/hooks/useResourceConfig.js +2 -1
- package/lib/core/hooks/useTopoEdit.js +121 -18
- package/lib/core/hooks/useTopoFullscreen.js +42 -0
- package/lib/core/models/AttributeMetricDisplay.js +85 -74
- package/lib/core/models/TopoApp.js +1 -1
- package/lib/core/models/attributeFormatter/index.js +14 -14
- package/lib/core/models/topoData.js +16 -9
- package/lib/core/models/utils/linkUtils.js +53 -26
- package/lib/core/store/models/topoConfig.js +56 -19
- package/lib/core/test/Test.js +52 -0
- package/lib/core/utils/graphLinkUtil.js +10 -5
- package/lib/core/viewer/components/plugins/ResourceDetail/components/ResourceOverview/BaseInfo.js +15 -1
- package/lib/core/viewer/components/plugins/ResourceDetail/components/ResourceOverview/ResourceOverview.js +7 -78
- package/lib/core/viewer/components/plugins/ResourceDetail/components/ResourceOverview/components/LinkTopo/LinkTopo.js +14 -0
- package/lib/core/viewer/components/plugins/ResourceDetail/components/ResourceOverview/components/LinkTopo/hooks/useMetricPolling.js +27 -36
- package/lib/core/viewer/components/plugins/ResourceDetail/components/ResourceOverview/components/LinkTopo/services/index.js +58 -1
- package/lib/core/viewer/components/plugins/ResourceDetail/components/ResourceOverview/index.module.scss +6 -0
- package/lib/networkTopo/getTopoData.js +2 -1
- package/lib/networkTopo/models/IpNodeTagsTipsBuilder.js +123 -0
- package/lib/networkTopo/models/LinkDynamicStyleExecutor.js +8 -8
- package/lib/networkTopo/models/TopoCenter.js +4 -3
- package/lib/networkTopo/services/topo/basic.js +28 -28
- package/lib/networkTopo/services/topo/networkLink.js +45 -3
- package/lib/networkTopo/utils/exitLinkUtil.js +269 -0
- package/lib/style.js +1 -0
- package/lib/utils/ResourceConfigUtil.js +4 -4
- package/lib/utils/htElementDataUtil.js +0 -10
- package/lib/utils/htElementUtils.js +21 -21
- package/package.json +2 -2
@@ -9,26 +9,29 @@ import React, { useEffect } from "react";
|
|
9
9
|
import textStyles from "../../../../../../common/text.module.scss";
|
10
10
|
import NodeRelateResourceButton from "./NodeRelateResourceButton";
|
11
11
|
import PlatformDisplay from "./PlatformDisplay";
|
12
|
+
import BindIpInput from "./BindIpInput";
|
13
|
+
import { isUniqueIp } from "../../../../../../../networkTopo/utils/exitLinkUtil";
|
12
14
|
var Option = _Select.Option;
|
13
15
|
var CollapsePanel = _Collapse.Panel;
|
14
16
|
|
15
17
|
function parseValues(values) {
|
16
18
|
return _extends({}, values, {
|
17
19
|
"attrObject.customName": values["attrObject.customName"] || values["attrObject.name"],
|
18
|
-
"attrObject.bindTopo": values["attrObject.bindTopo"] || ""
|
19
|
-
|
20
|
+
"attrObject.bindTopo": values["attrObject.bindTopo"] || "",
|
21
|
+
// 解决切换节点时关联拓扑选项未重置
|
22
|
+
"attrObject.bindIp": values["attrObject.bindIp"] || ""
|
20
23
|
});
|
21
24
|
}
|
22
25
|
|
23
26
|
function getBindType(values) {
|
24
|
-
if (values.tag) {
|
25
|
-
return "resource";
|
26
|
-
}
|
27
|
-
|
28
27
|
if (values.attrObject.bindType) {
|
29
28
|
return values.attrObject.bindType;
|
30
29
|
}
|
31
30
|
|
31
|
+
if (values.tag && !values.tag.startsWith("ip:")) {
|
32
|
+
return "resource";
|
33
|
+
}
|
34
|
+
|
32
35
|
return "none";
|
33
36
|
}
|
34
37
|
|
@@ -39,15 +42,20 @@ export default function Data(props) {
|
|
39
42
|
values = props.values,
|
40
43
|
_onChange = props.onChange,
|
41
44
|
editorProps = props.editorProps;
|
42
|
-
var bindType = getBindType(values);
|
45
|
+
var bindType = getBindType(values); // console.log("node, values", node, values);
|
43
46
|
|
44
47
|
var field = _Field.useField({
|
45
48
|
autoUnmount: false,
|
46
49
|
values: parseValues(values),
|
47
50
|
onChange: function onChange(name, value) {
|
48
|
-
|
51
|
+
field.validate(function (errors, vals) {
|
52
|
+
if (errors) {// console.error("field-Data", errors, vals);
|
53
|
+
} else {
|
54
|
+
var newValues = field.getValues();
|
49
55
|
|
50
|
-
|
56
|
+
_onChange(name, value, newValues);
|
57
|
+
}
|
58
|
+
});
|
51
59
|
}
|
52
60
|
});
|
53
61
|
|
@@ -107,7 +115,7 @@ export default function Data(props) {
|
|
107
115
|
}, /*#__PURE__*/React.createElement(_Form, {
|
108
116
|
field: field,
|
109
117
|
labelAlign: "top"
|
110
|
-
}, !values.tag && /*#__PURE__*/React.createElement(_Form.Item, {
|
118
|
+
}, (!values.tag || bindType === "ip") && /*#__PURE__*/React.createElement(_Form.Item, {
|
111
119
|
label: "\u5173\u8054\u7C7B\u578B"
|
112
120
|
}, /*#__PURE__*/React.createElement(_Select, {
|
113
121
|
name: "bindType",
|
@@ -121,7 +129,9 @@ export default function Data(props) {
|
|
121
129
|
value: "none"
|
122
130
|
}, "\u672A\u5173\u8054"), /*#__PURE__*/React.createElement(Option, {
|
123
131
|
value: "resource"
|
124
|
-
}, "\u5173\u8054\u8D44\u6E90"),
|
132
|
+
}, "\u5173\u8054\u8D44\u6E90"), /*#__PURE__*/React.createElement(Option, {
|
133
|
+
value: "ip"
|
134
|
+
}, "\u5173\u8054IP"), RelateTopoTree && /*#__PURE__*/React.createElement(Option, {
|
125
135
|
value: "topo"
|
126
136
|
}, "\u5173\u8054\u62D3\u6251"))), bindType === "resource" && /*#__PURE__*/React.createElement(_Form.Item, {
|
127
137
|
label: "\u5173\u8054\u8D44\u6E90"
|
@@ -135,7 +145,7 @@ export default function Data(props) {
|
|
135
145
|
flex: 1,
|
136
146
|
paddingRight: 16,
|
137
147
|
color: "#4D6277",
|
138
|
-
lineHeight:
|
148
|
+
lineHeight: "20px"
|
139
149
|
},
|
140
150
|
title: values.tag ? values.name : null
|
141
151
|
}, values.tag ? values.name : "—"), /*#__PURE__*/React.createElement(NodeRelateResourceButton, {
|
@@ -144,13 +154,35 @@ export default function Data(props) {
|
|
144
154
|
topo: topo,
|
145
155
|
topoEditApi: topoEditApi,
|
146
156
|
nodeBindResourceDrawerComponent: editorProps.nodeBindResourceDrawerComponent
|
147
|
-
}))), bindType === "
|
157
|
+
}))), bindType === "ip" &&
|
158
|
+
/*#__PURE__*/
|
159
|
+
// <Form.Item
|
160
|
+
// label="关联IP"
|
161
|
+
// // style={{ display: "flex" }}
|
162
|
+
// pattern={
|
163
|
+
// /^((25[0-5]|2[0-4]\d|((1\d{2})|([1-9]?\d)))\.){3}(25[0-5]|2[0-4]\d|((1\d{2})|([1-9]?\d)))$/
|
164
|
+
// }
|
165
|
+
// patternTrigger="onBlur"
|
166
|
+
// patternMessage="IP地址格式不正确"
|
167
|
+
// >
|
168
|
+
React.createElement(BindIpInput, {
|
169
|
+
nodeElement: node,
|
170
|
+
values: values,
|
171
|
+
topo: topo,
|
172
|
+
fieldItem: field,
|
173
|
+
topoEditApi: topoEditApi,
|
174
|
+
placeholder: "\u8BF7\u8F93\u5165",
|
175
|
+
name: "attrObject.bindIp",
|
176
|
+
onChange: _onChange,
|
177
|
+
maxLength: 128
|
178
|
+
}) // </Form.Item>
|
179
|
+
, bindType === "topo" && RelateTopoTree && /*#__PURE__*/React.createElement(_Form.Item, {
|
148
180
|
label: "\u5173\u8054\u62D3\u6251"
|
149
181
|
}, /*#__PURE__*/React.createElement(RelateTopoTree, {
|
150
182
|
name: "attrObject.bindTopo",
|
151
183
|
topo: topo,
|
152
184
|
onChange: handleBindTopoChange
|
153
|
-
})), (editorProps === null || editorProps === void 0 ? void 0 : editorProps.topoType) ===
|
185
|
+
})), (editorProps === null || editorProps === void 0 ? void 0 : editorProps.topoType) === "cmpTopo" && node.getTag() && /*#__PURE__*/React.createElement(_Form.Item, {
|
154
186
|
label: "\u6240\u5C5E\u5E73\u53F0"
|
155
187
|
}, /*#__PURE__*/React.createElement(PlatformDisplay, props)))));
|
156
188
|
}
|
@@ -22,7 +22,9 @@ var baseLightTheme = {
|
|
22
22
|
'group.title.color': '#4D6277',
|
23
23
|
// 标题文字颜色
|
24
24
|
'group.background': 'rgba(255, 255, 255, 0.9)',
|
25
|
-
'group.border.color': '#E4E9EE'
|
25
|
+
'group.border.color': '#E4E9EE',
|
26
|
+
// 边框颜色
|
27
|
+
'group.splitLine': false // 标题底部边框
|
26
28
|
|
27
29
|
}
|
28
30
|
},
|
@@ -84,7 +86,56 @@ var THEMES = [_extends({}, baseLightTheme, {
|
|
84
86
|
'group.title.color': '#FFFFFF',
|
85
87
|
// 标题文字颜色
|
86
88
|
'group.background': 'rgba(29,55,113,0.6)',
|
87
|
-
'group.border.color': 'rgba(8,165,244,0.8)'
|
89
|
+
'group.border.color': 'rgba(8,165,244,0.8)',
|
90
|
+
// 边框颜色
|
91
|
+
'group.splitLine': false // 标题底部边框
|
92
|
+
|
93
|
+
}
|
94
|
+
},
|
95
|
+
cluster: {
|
96
|
+
style: {
|
97
|
+
'group.title.color': '#FFFFFF',
|
98
|
+
// 标题文字颜色
|
99
|
+
'group.title.background': 'rgba(14,44,69,1)',
|
100
|
+
// 标题背景颜色 #0E2C45
|
101
|
+
'group.background': 'rgba(14,44,69,1)',
|
102
|
+
// #0E2C45
|
103
|
+
'group.border.color': '#08A5F4',
|
104
|
+
// 边框颜色
|
105
|
+
'group.border.radius': 3
|
106
|
+
}
|
107
|
+
}
|
108
|
+
}, {
|
109
|
+
name: 'poly',
|
110
|
+
label: 'Poly',
|
111
|
+
toolsTheme: 'black',
|
112
|
+
backgroundImage: '/img/topo/themes/poly.png',
|
113
|
+
backgroundImageThumbnail: '/img/topo/themes/poly_thumbnail.png',
|
114
|
+
globalNodeLabelStyle: {
|
115
|
+
color: '#ffffff'
|
116
|
+
},
|
117
|
+
globalEdgeTagStyle: {
|
118
|
+
color: '#E4E9EE',
|
119
|
+
background: 'rgba(6, 54, 88, 1)',
|
120
|
+
// 背景色,不传使用默认内置 @V1.2 index.js:1 #063658
|
121
|
+
borderColor: '#08A5F4' // 边框颜色,不传使用默认内置。用于主题切换 @V1.2
|
122
|
+
|
123
|
+
},
|
124
|
+
text: {
|
125
|
+
color: '#ffffff'
|
126
|
+
},
|
127
|
+
group: {
|
128
|
+
style: {
|
129
|
+
'group.title.background': 'rgba(0,0,0,0.01)',
|
130
|
+
// 标题背景颜色 #08A5F4
|
131
|
+
'group.title.color': '#8FECFF',
|
132
|
+
// 标题文字颜色
|
133
|
+
'group.title.border.color': '#ffffff',
|
134
|
+
// 边框颜色
|
135
|
+
'group.background': 'rgba(0,0,0,0.01)',
|
136
|
+
'group.border.color': '#ffffff',
|
137
|
+
// 边框颜色
|
138
|
+
'group.splitLine': true // 标题底部边框
|
88
139
|
|
89
140
|
}
|
90
141
|
},
|
@@ -1,4 +1,5 @@
|
|
1
1
|
import { getEdges } from "../../../utils/htElementUtils";
|
2
|
+
import { getEdgesBetweenNodes } from "../../../utils/htElementUtils";
|
2
3
|
var ht = window.ht;
|
3
4
|
export function getEdgesBySelection(topo) {
|
4
5
|
var getChildrenNodeIds = function getChildrenNodeIds(nodes) {
|
@@ -42,6 +43,43 @@ export function getEdgesBySelection(topo) {
|
|
42
43
|
|
43
44
|
return getSelectedEdges(topo.getGraphView());
|
44
45
|
}
|
46
|
+
/**
|
47
|
+
* 根据选中的线查找对应节点下所有的线是否都选中
|
48
|
+
* @param {*} topo
|
49
|
+
* @param {*} edges
|
50
|
+
* @param {*} operateEdgeFn
|
51
|
+
*/
|
52
|
+
|
53
|
+
export function isNodeAllEdges(topo) {
|
54
|
+
var selection = topo.getSelectionModel().getSelection().toArray(); // 选中的连线
|
55
|
+
|
56
|
+
var edges = selection.filter(function (element) {
|
57
|
+
return element instanceof ht.Edge;
|
58
|
+
});
|
59
|
+
var inEdges = false;
|
60
|
+
edges.forEach(function (edge) {
|
61
|
+
//根据两边节点查询到所有节点有关的线,过滤出相同的线(两个节点间的线)
|
62
|
+
var sourceNode = edge.getSource();
|
63
|
+
var targetNode = edge.getTarget();
|
64
|
+
var nodeLineList = getEdgesBetweenNodes(sourceNode, targetNode);
|
65
|
+
|
66
|
+
var _loop = function _loop(i) {
|
67
|
+
if (edges.filter(function (edge) {
|
68
|
+
return nodeLineList[i]._id == edge._id;
|
69
|
+
}).length == 0) {
|
70
|
+
inEdges = true;
|
71
|
+
return "break";
|
72
|
+
}
|
73
|
+
};
|
74
|
+
|
75
|
+
for (var i = 0; i < nodeLineList.length; i++) {
|
76
|
+
var _ret = _loop(i);
|
77
|
+
|
78
|
+
if (_ret === "break") break;
|
79
|
+
}
|
80
|
+
});
|
81
|
+
return inEdges;
|
82
|
+
}
|
45
83
|
/**
|
46
84
|
* 遍历连线及子连线
|
47
85
|
* @param {*} topo
|
@@ -4,7 +4,7 @@ var themeMap = [{
|
|
4
4
|
name: 'white',
|
5
5
|
label: '白色',
|
6
6
|
color: null,
|
7
|
-
toolsTheme: '
|
7
|
+
toolsTheme: 'white'
|
8
8
|
}, {
|
9
9
|
name: 'lightblue',
|
10
10
|
label: '蓝色',
|
@@ -22,7 +22,12 @@ var themeMap = [{
|
|
22
22
|
name: 'dark',
|
23
23
|
label: '深色',
|
24
24
|
color: '#031425',
|
25
|
-
toolsTheme: '
|
25
|
+
toolsTheme: 'dark'
|
26
|
+
}, {
|
27
|
+
name: 'poly',
|
28
|
+
label: 'Poly',
|
29
|
+
toolsTheme: 'dark',
|
30
|
+
backgroundImage: '/img/topo/themes/poly.png'
|
26
31
|
}].reduce(function (map, item) {
|
27
32
|
var _extends2;
|
28
33
|
|
@@ -38,12 +43,13 @@ export default function useCanvasTheme(props) {
|
|
38
43
|
|
39
44
|
var themeConfig = themeMap[themeName || 'white'];
|
40
45
|
var canvasColor = hideBackgroundColor ? null : themeConfig.color;
|
46
|
+
var canvasbackgroundImage = hideBackgroundColor ? null : themeConfig.backgroundImage;
|
41
47
|
useEffect(function () {
|
42
48
|
// 设置
|
43
49
|
if (graphLoaded && themeConfig) {
|
44
50
|
try {
|
45
51
|
topo.getHtTopo().setTheme(themeName);
|
46
|
-
topo.getHtTopo().setToolsTheme(
|
52
|
+
topo.getHtTopo().setToolsTheme(themeConfig.toolsTheme);
|
47
53
|
} catch (error) {
|
48
54
|
console.error('切换主题失败', error);
|
49
55
|
}
|
@@ -54,12 +60,14 @@ export default function useCanvasTheme(props) {
|
|
54
60
|
if (graphLoaded) {
|
55
61
|
try {
|
56
62
|
topo.getHtTopo().getGraphView().dm().setBackground(canvasColor);
|
63
|
+
topo.getHtTopo().getGraphView().dm().setBackground(canvasbackgroundImage);
|
57
64
|
} catch (error) {
|
58
65
|
console.error('切换主题失败', error);
|
59
66
|
}
|
60
67
|
}
|
61
68
|
}, [graphLoaded, canvasColor]);
|
62
69
|
return {
|
63
|
-
canvasColor: canvasColor
|
70
|
+
canvasColor: canvasColor,
|
71
|
+
canvasbackgroundImage: canvasbackgroundImage
|
64
72
|
};
|
65
73
|
}
|
@@ -45,7 +45,8 @@ export default function (props) {
|
|
45
45
|
resources: config.resources,
|
46
46
|
groups: config.groups,
|
47
47
|
exportLinkIdList: config.exportLinkIdList,
|
48
|
-
relateTopoIdList: config.relateTopoIdList
|
48
|
+
relateTopoIdList: config.relateTopoIdList //linkIps: config.linkIps,
|
49
|
+
|
49
50
|
};
|
50
51
|
};
|
51
52
|
|
@@ -4,16 +4,18 @@ import _Dialog from "@alifd/next/es/dialog";
|
|
4
4
|
import _asyncToGenerator from "@babel/runtime/helpers/asyncToGenerator";
|
5
5
|
import _regeneratorRuntime from "@babel/runtime/regenerator";
|
6
6
|
import { useCallback, useEffect, useMemo, useState } from "react";
|
7
|
+
import _ from "lodash";
|
7
8
|
import rlog from "@riil-frontend/component-topology-utils/es/rlog";
|
8
9
|
import { TopoEvent } from "@riil-frontend/component-topology-graph";
|
9
10
|
import { TPL_BLANK, TPL_TREE } from "../../utils/template";
|
10
|
-
import
|
11
|
-
import { getElements, getGroupElementByTag, isEdge, isExistedElement, isGroup, isLayer, isNode } from "../../utils/htElementUtils";
|
11
|
+
import { getGroupElementByTag, isEdge, isExistedElement, isGroup, isLayer, isNode, getNodes, getGroupChildren } from "../../utils/htElementUtils";
|
12
12
|
import useResourceConfig from "./useResourceConfig";
|
13
13
|
import useGroupAddResource from "./useGroupAddResource";
|
14
14
|
import { findGroupChildren } from "../../utils/topoData";
|
15
|
-
import {
|
15
|
+
import { isResourceElement } from "../../utils/htElementDataUtil";
|
16
16
|
import { isClusterHtElement, isClusterMemberHtElement } from "../../utils/clusterUtil";
|
17
|
+
import { mergeExportLinkData } from "../models/utils/linkUtils";
|
18
|
+
import { isUniqueIp, buildIpNode } from "../../networkTopo/utils/exitLinkUtil";
|
17
19
|
|
18
20
|
var useTopoEdit = function useTopoEdit(params) {
|
19
21
|
var topo = params.topo,
|
@@ -220,7 +222,7 @@ var useTopoEdit = function useTopoEdit(params) {
|
|
220
222
|
return;
|
221
223
|
}
|
222
224
|
|
223
|
-
if (!
|
225
|
+
if (!getGroupChildren(group).filter(isResourceElement).length || isClusterHtElement(group)) {
|
224
226
|
doDelete();
|
225
227
|
return;
|
226
228
|
} // 有子节点时需要确认
|
@@ -315,7 +317,7 @@ var useTopoEdit = function useTopoEdit(params) {
|
|
315
317
|
|
316
318
|
edges.map(function (edge) {
|
317
319
|
if (edge.a("dtype") === "link" && exportLinkIdList.indexOf(edge.getTag()) >= 0) {
|
318
|
-
// exLink.push(edge);
|
320
|
+
// exLink.push(edge);
|
319
321
|
topo.getGraphView().dm().remove(edge);
|
320
322
|
exportLinkIdList.splice(config.exportLinkIdList.indexOf(edge.getTag()), 1);
|
321
323
|
}
|
@@ -378,8 +380,8 @@ var useTopoEdit = function useTopoEdit(params) {
|
|
378
380
|
};
|
379
381
|
/**
|
380
382
|
* 获得未存在的连线元素
|
381
|
-
* @param {*} elements
|
382
|
-
* @returns
|
383
|
+
* @param {*} elements
|
384
|
+
* @returns
|
383
385
|
*/
|
384
386
|
|
385
387
|
|
@@ -392,8 +394,8 @@ var useTopoEdit = function useTopoEdit(params) {
|
|
392
394
|
}
|
393
395
|
/**
|
394
396
|
* 获得未存在的元素
|
395
|
-
* @param {Array} elements
|
396
|
-
* @returns
|
397
|
+
* @param {Array} elements
|
398
|
+
* @returns
|
397
399
|
*/
|
398
400
|
|
399
401
|
|
@@ -569,7 +571,7 @@ var useTopoEdit = function useTopoEdit(params) {
|
|
569
571
|
elements = _yield$editDispatcher4.elements;
|
570
572
|
// 2022-11-10 修复 添加资源后分层重新布局问题,仅布局新增资源。替换api topo.updateElements(data)
|
571
573
|
newElements = findUNExistedElements(elements);
|
572
|
-
rlog.debug(
|
574
|
+
rlog.debug("添加分层资源", {
|
573
575
|
layer: group,
|
574
576
|
newElements: newElements
|
575
577
|
});
|
@@ -642,8 +644,8 @@ var useTopoEdit = function useTopoEdit(params) {
|
|
642
644
|
}
|
643
645
|
/**
|
644
646
|
* 未选中元素添加资源
|
645
|
-
*
|
646
|
-
* @param {*} data
|
647
|
+
*
|
648
|
+
* @param {*} data
|
647
649
|
*/
|
648
650
|
|
649
651
|
|
@@ -800,7 +802,7 @@ var useTopoEdit = function useTopoEdit(params) {
|
|
800
802
|
newLinkElements = findUNExistedLinkElements(elements);
|
801
803
|
createElementsData = null;
|
802
804
|
|
803
|
-
if (newData.type ===
|
805
|
+
if (newData.type === "group") {
|
804
806
|
groupChildren = findGroupChildren(elements, newData);
|
805
807
|
newGroupChildren = [];
|
806
808
|
existedGroupChildren = [];
|
@@ -817,10 +819,10 @@ var useTopoEdit = function useTopoEdit(params) {
|
|
817
819
|
groups: [newData],
|
818
820
|
nodes: newGroupChildren,
|
819
821
|
links: newLinkElements.filter(function (item) {
|
820
|
-
return item.type ===
|
822
|
+
return item.type === "link";
|
821
823
|
}),
|
822
824
|
linkGroups: newLinkElements.filter(function (item) {
|
823
|
-
return item.type ===
|
825
|
+
return item.type === "linkGroup";
|
824
826
|
})
|
825
827
|
};
|
826
828
|
htTopo.createElements(createElementsData); // 切换前图上如果存在集群内的节点,切换节点为集群后,移到集群内
|
@@ -835,16 +837,16 @@ var useTopoEdit = function useTopoEdit(params) {
|
|
835
837
|
groups: [],
|
836
838
|
nodes: [newData],
|
837
839
|
links: newLinkElements.filter(function (item) {
|
838
|
-
return item.type ===
|
840
|
+
return item.type === "link";
|
839
841
|
}),
|
840
842
|
linkGroups: newLinkElements.filter(function (item) {
|
841
|
-
return item.type ===
|
843
|
+
return item.type === "linkGroup";
|
842
844
|
})
|
843
845
|
};
|
844
846
|
htTopo.createElements(createElementsData);
|
845
847
|
}
|
846
848
|
|
847
|
-
rlog.debug(
|
849
|
+
rlog.debug("批量创建元素", createElementsData); // 恢复图标、大小、位置
|
848
850
|
|
849
851
|
newElement = dm.getDataByTag(newData.id);
|
850
852
|
|
@@ -960,6 +962,100 @@ var useTopoEdit = function useTopoEdit(params) {
|
|
960
962
|
return _ref8.apply(this, arguments);
|
961
963
|
};
|
962
964
|
}();
|
965
|
+
/**
|
966
|
+
* 关联IP的图片节点
|
967
|
+
*/
|
968
|
+
|
969
|
+
|
970
|
+
function relateNodeIp(_x15, _x16) {
|
971
|
+
return _relateNodeIp.apply(this, arguments);
|
972
|
+
}
|
973
|
+
|
974
|
+
function _relateNodeIp() {
|
975
|
+
_relateNodeIp = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee16(txtValue, nodeElement) {
|
976
|
+
var dm, isUnique, ip, configObj, configData, _elements, newLinkElements, newLink, newLinkGroup, createElementsData, _htTopo;
|
977
|
+
|
978
|
+
return _regeneratorRuntime.wrap(function _callee16$(_context16) {
|
979
|
+
while (1) {
|
980
|
+
switch (_context16.prev = _context16.next) {
|
981
|
+
case 0:
|
982
|
+
console.log("bindIPtoNode", txtValue, nodeElement);
|
983
|
+
|
984
|
+
if (txtValue) {
|
985
|
+
_context16.next = 3;
|
986
|
+
break;
|
987
|
+
}
|
988
|
+
|
989
|
+
return _context16.abrupt("return");
|
990
|
+
|
991
|
+
case 3:
|
992
|
+
// if (txtValue === nodeElement.a('bindIp')) {
|
993
|
+
// return;
|
994
|
+
// }
|
995
|
+
// 根据配置查询拓扑数据
|
996
|
+
dm = topo.getDataModel(); // 执行唯一性验证
|
997
|
+
|
998
|
+
isUnique = isUniqueIp(dm, txtValue, nodeElement); // 获取关联链路
|
999
|
+
|
1000
|
+
if (!isUnique) {
|
1001
|
+
_context16.next = 25;
|
1002
|
+
break;
|
1003
|
+
}
|
1004
|
+
|
1005
|
+
ip = buildIpNode(txtValue);
|
1006
|
+
_context16.next = 9;
|
1007
|
+
return deleteExLink(nodeElement);
|
1008
|
+
|
1009
|
+
case 9:
|
1010
|
+
nodeElement.a(ip);
|
1011
|
+
nodeElement.setName(txtValue);
|
1012
|
+
nodeElement.setTag("ip:" + txtValue); // 获取配置
|
1013
|
+
|
1014
|
+
configObj = topo.resourceConfig.getConfig();
|
1015
|
+
_context16.next = 15;
|
1016
|
+
return resourceConfig.updateConfig(configObj);
|
1017
|
+
|
1018
|
+
case 15:
|
1019
|
+
_context16.next = 17;
|
1020
|
+
return editDispatchers.fetchDataByConfig();
|
1021
|
+
|
1022
|
+
case 17:
|
1023
|
+
configData = _context16.sent;
|
1024
|
+
// console.log("configData",configObj, configData);
|
1025
|
+
_elements = configData.elements;
|
1026
|
+
newLinkElements = findUNExistedLinkElements(_elements); // console.log("configData", configData, newLinkElements);
|
1027
|
+
|
1028
|
+
newLink = newLinkElements.filter(function (item) {
|
1029
|
+
return item.type === "link";
|
1030
|
+
});
|
1031
|
+
newLinkGroup = newLinkElements.filter(function (item) {
|
1032
|
+
return item.type === "linkGroup";
|
1033
|
+
}); // const newData = elements.find((item) => item.id === `ip:${txtValue}`);
|
1034
|
+
// console.log("newData",newLinkElements, newLink);
|
1035
|
+
|
1036
|
+
createElementsData = {
|
1037
|
+
groups: [],
|
1038
|
+
nodes: [],
|
1039
|
+
links: newLink,
|
1040
|
+
linkGroups: newLinkGroup
|
1041
|
+
};
|
1042
|
+
console.log("createElementsData", createElementsData);
|
1043
|
+
|
1044
|
+
if ([].concat(newLink, newLinkGroup).length > 0) {
|
1045
|
+
_htTopo = topo.getHtTopo();
|
1046
|
+
|
1047
|
+
_htTopo.createElements(createElementsData);
|
1048
|
+
}
|
1049
|
+
|
1050
|
+
case 25:
|
1051
|
+
case "end":
|
1052
|
+
return _context16.stop();
|
1053
|
+
}
|
1054
|
+
}
|
1055
|
+
}, _callee16);
|
1056
|
+
}));
|
1057
|
+
return _relateNodeIp.apply(this, arguments);
|
1058
|
+
}
|
963
1059
|
|
964
1060
|
var onEvent = function onEvent(e) {
|
965
1061
|
var map = {};
|
@@ -977,7 +1073,7 @@ var useTopoEdit = function useTopoEdit(params) {
|
|
977
1073
|
*/
|
978
1074
|
|
979
1075
|
var setViewMouseMode = function setViewMouseMode(mode) {
|
980
|
-
rlog.debug(
|
1076
|
+
rlog.debug("设置视图鼠标模式", mode);
|
981
1077
|
topo.getHtTopo().setViewMouseMode(mode);
|
982
1078
|
topoEditDispatchers.update({
|
983
1079
|
viewMouseMode: mode
|
@@ -1055,6 +1151,11 @@ var useTopoEdit = function useTopoEdit(params) {
|
|
1055
1151
|
*/
|
1056
1152
|
onDeleteElement: onDeleteElement,
|
1057
1153
|
|
1154
|
+
/**
|
1155
|
+
* 绑定图片ip
|
1156
|
+
*/
|
1157
|
+
relateNodeIp: relateNodeIp,
|
1158
|
+
|
1058
1159
|
/**
|
1059
1160
|
* 拓扑图保存回调
|
1060
1161
|
*/
|
@@ -0,0 +1,32 @@
|
|
1
|
+
import React, { useEffect } from 'react';
|
2
|
+
export default function useTopoFullscreen(props) {
|
3
|
+
var topo = props.topo,
|
4
|
+
panelRef = props.panelRef;
|
5
|
+
var topoModState = topo.store.useModelState('topoMod');
|
6
|
+
var graphLoaded = topoModState.graphLoaded,
|
7
|
+
graphLoaded2 = topoModState.graphLoaded2,
|
8
|
+
topoData = topoModState.data;
|
9
|
+
useEffect(function () {
|
10
|
+
var htTopo = topo.getHtTopo();
|
11
|
+
|
12
|
+
if ((graphLoaded || graphLoaded2) && topoData && htTopo.setFullScreenFunc) {
|
13
|
+
htTopo.setFullScreenFunc(function () {
|
14
|
+
panelRef.current.requestFullscreen();
|
15
|
+
});
|
16
|
+
}
|
17
|
+
}, [topoData, graphLoaded, graphLoaded2]); // 监听退出全屏
|
18
|
+
|
19
|
+
var panelDom = panelRef.current;
|
20
|
+
useEffect(function () {
|
21
|
+
panelDom === null || panelDom === void 0 ? void 0 : panelDom.addEventListener('fullscreenchange', handleFullscreenChange); // 监听退出全屏
|
22
|
+
|
23
|
+
function handleFullscreenChange() {
|
24
|
+
var htTopo = topo.getHtTopo();
|
25
|
+
htTopo.setToolsVisible(!document.fullscreenElement);
|
26
|
+
}
|
27
|
+
|
28
|
+
return function () {
|
29
|
+
panelDom === null || panelDom === void 0 ? void 0 : panelDom.removeEventListener('fullscreenchange', handleFullscreenChange);
|
30
|
+
};
|
31
|
+
}, [panelDom]);
|
32
|
+
}
|