@riil-frontend/component-topology 9.0.0-a.20 → 9.0.0-a.21
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/index.js +9 -9
- package/es/core/editor/components/settings/core/updateElementProperty.js +6 -1
- package/es/core/editor/components/settings/propertyViews/node/data/BindIpInput.js +104 -0
- package/es/core/editor/components/settings/propertyViews/node/data/Data.js +47 -14
- package/es/core/hooks/useTopoEdit.js +144 -16
- package/es/core/models/TopoApp.js +1 -1
- package/es/core/models/utils/linkUtils.js +18 -0
- package/es/core/store/models/topoConfig.js +36 -7
- package/es/core/test/Test.js +3 -3
- package/es/networkTopo/services/link.js +1 -1
- package/es/networkTopo/services/topo/basic.js +26 -16
- package/es/networkTopo/services/topo/networkLink.js +45 -3
- package/es/networkTopo/utils/exitLinkUtil.js +224 -0
- package/es/utils/htElementUtils.js +21 -21
- package/lib/core/editor/components/settings/core/updateElementProperty.js +6 -1
- package/lib/core/editor/components/settings/propertyViews/node/data/BindIpInput.js +120 -0
- package/lib/core/editor/components/settings/propertyViews/node/data/Data.js +49 -14
- package/lib/core/hooks/useTopoEdit.js +146 -15
- package/lib/core/models/TopoApp.js +1 -1
- package/lib/core/models/utils/linkUtils.js +21 -1
- package/lib/core/store/models/topoConfig.js +37 -7
- package/lib/core/test/Test.js +3 -3
- package/lib/networkTopo/services/topo/basic.js +27 -16
- package/lib/networkTopo/services/topo/networkLink.js +45 -3
- package/lib/networkTopo/utils/exitLinkUtil.js +235 -0
- package/lib/utils/htElementUtils.js +21 -21
- package/package.json +2 -2
@@ -0,0 +1,120 @@
|
|
1
|
+
"use strict";
|
2
|
+
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
4
|
+
|
5
|
+
exports.__esModule = true;
|
6
|
+
exports["default"] = BindIpInput;
|
7
|
+
|
8
|
+
var _button = _interopRequireDefault(require("@alifd/next/lib/button"));
|
9
|
+
|
10
|
+
var _input = _interopRequireDefault(require("@alifd/next/lib/input"));
|
11
|
+
|
12
|
+
var _form = _interopRequireDefault(require("@alifd/next/lib/form"));
|
13
|
+
|
14
|
+
var _react = _interopRequireWildcard(require("react"));
|
15
|
+
|
16
|
+
var _exitLinkUtil = require("../../../../../../../networkTopo/utils/exitLinkUtil");
|
17
|
+
|
18
|
+
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
19
|
+
|
20
|
+
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { "default": obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj["default"] = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
21
|
+
|
22
|
+
var FormItem = _form["default"].Item;
|
23
|
+
/**
|
24
|
+
* @return {React.ReactNode | null}
|
25
|
+
*/
|
26
|
+
|
27
|
+
function BindIpInput(props) {
|
28
|
+
var _values$attrObjectBi;
|
29
|
+
|
30
|
+
var nodeElement = props.nodeElement,
|
31
|
+
topo = props.topo,
|
32
|
+
topoEditApi = props.topoEditApi,
|
33
|
+
values = props.values,
|
34
|
+
onChange = props.onChange,
|
35
|
+
fieldItem = props.fieldItem; // const currentResId = node.tag;
|
36
|
+
// console.log(
|
37
|
+
// "nodeElement, topo, topoEditApi, node",
|
38
|
+
// nodeElement,
|
39
|
+
// topo,
|
40
|
+
// topoEditApi,
|
41
|
+
// values
|
42
|
+
// );
|
43
|
+
|
44
|
+
var _useState = (0, _react.useState)(""),
|
45
|
+
error = _useState[0],
|
46
|
+
setError = _useState[1];
|
47
|
+
|
48
|
+
var _useState2 = (0, _react.useState)((_values$attrObjectBi = values["attrObject.bindIp"]) !== null && _values$attrObjectBi !== void 0 ? _values$attrObjectBi : ""),
|
49
|
+
txtValue = _useState2[0],
|
50
|
+
setTxtValue = _useState2[1];
|
51
|
+
|
52
|
+
var saveIp = function saveIp(v) {
|
53
|
+
fieldItem.validate(function (errors, vals) {
|
54
|
+
if (errors) {
|
55
|
+
console.error("saveIp-error", errors, vals);
|
56
|
+
} else {
|
57
|
+
console.log("saveIp", txtValue);
|
58
|
+
setError("");
|
59
|
+
onChange(txtValue);
|
60
|
+
topoEditApi.relateNodeIp(txtValue, nodeElement);
|
61
|
+
}
|
62
|
+
});
|
63
|
+
};
|
64
|
+
|
65
|
+
(0, _react.useEffect)(function () {
|
66
|
+
fieldItem.reset();
|
67
|
+
setTxtValue(values["attrObject.bindIp"]);
|
68
|
+
}, [values]);
|
69
|
+
|
70
|
+
var inputChange = function inputChange(v) {
|
71
|
+
setTxtValue(v); // onChange(v);
|
72
|
+
}; // 图片节点验证ip唯一性
|
73
|
+
|
74
|
+
|
75
|
+
var checkIp = function checkIp(rule, value, callback) {
|
76
|
+
var dm = topo.getDataModel();
|
77
|
+
var rex = /^((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)))$/;
|
78
|
+
var reg = value.match(rex);
|
79
|
+
|
80
|
+
if (reg === null) {
|
81
|
+
return callback();
|
82
|
+
}
|
83
|
+
|
84
|
+
var isUnique = (0, _exitLinkUtil.isUniqueIp)(dm, value, nodeElement);
|
85
|
+
console.log("checkIp", isUnique);
|
86
|
+
|
87
|
+
if (!isUnique) {
|
88
|
+
return callback("ip不能重复");
|
89
|
+
} else {
|
90
|
+
return callback();
|
91
|
+
}
|
92
|
+
};
|
93
|
+
|
94
|
+
return /*#__PURE__*/_react["default"].createElement("div", {
|
95
|
+
style: {
|
96
|
+
display: "flex"
|
97
|
+
}
|
98
|
+
}, /*#__PURE__*/_react["default"].createElement(FormItem, {
|
99
|
+
label: "\u5173\u8054IP",
|
100
|
+
pattern: /^((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)))$/,
|
101
|
+
patternTrigger: "onBlur",
|
102
|
+
patternMessage: "IP\u5730\u5740\u683C\u5F0F\u4E0D\u6B63\u786E",
|
103
|
+
validator: checkIp
|
104
|
+
}, /*#__PURE__*/_react["default"].createElement(_input["default"], {
|
105
|
+
placeholder: "\u8BF7\u8F93\u5165Ip\u5730\u5740",
|
106
|
+
name: "attrObject.bindIp",
|
107
|
+
state: error,
|
108
|
+
value: txtValue,
|
109
|
+
maxLength: 128,
|
110
|
+
onChange: inputChange
|
111
|
+
})), /*#__PURE__*/_react["default"].createElement(_button["default"], {
|
112
|
+
type: "primary",
|
113
|
+
text: true,
|
114
|
+
onClick: saveIp,
|
115
|
+
style: {
|
116
|
+
marginLeft: 10,
|
117
|
+
marginTop: 27
|
118
|
+
}
|
119
|
+
}, "\u4FDD\u5B58"));
|
120
|
+
}
|
@@ -27,6 +27,10 @@ var _NodeRelateResourceButton = _interopRequireDefault(require("./NodeRelateReso
|
|
27
27
|
|
28
28
|
var _PlatformDisplay = _interopRequireDefault(require("./PlatformDisplay"));
|
29
29
|
|
30
|
+
var _BindIpInput = _interopRequireDefault(require("./BindIpInput"));
|
31
|
+
|
32
|
+
var _exitLinkUtil = require("../../../../../../../networkTopo/utils/exitLinkUtil");
|
33
|
+
|
30
34
|
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
31
35
|
|
32
36
|
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { "default": obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj["default"] = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
@@ -37,20 +41,21 @@ var CollapsePanel = _collapse["default"].Panel;
|
|
37
41
|
function parseValues(values) {
|
38
42
|
return (0, _extends2["default"])({}, values, {
|
39
43
|
"attrObject.customName": values["attrObject.customName"] || values["attrObject.name"],
|
40
|
-
"attrObject.bindTopo": values["attrObject.bindTopo"] || ""
|
41
|
-
|
44
|
+
"attrObject.bindTopo": values["attrObject.bindTopo"] || "",
|
45
|
+
// 解决切换节点时关联拓扑选项未重置
|
46
|
+
"attrObject.bindIp": values["attrObject.bindIp"] || ""
|
42
47
|
});
|
43
48
|
}
|
44
49
|
|
45
50
|
function getBindType(values) {
|
46
|
-
if (values.tag) {
|
47
|
-
return "resource";
|
48
|
-
}
|
49
|
-
|
50
51
|
if (values.attrObject.bindType) {
|
51
52
|
return values.attrObject.bindType;
|
52
53
|
}
|
53
54
|
|
55
|
+
if (values.tag && !values.tag.startsWith("ip:")) {
|
56
|
+
return "resource";
|
57
|
+
}
|
58
|
+
|
54
59
|
return "none";
|
55
60
|
}
|
56
61
|
|
@@ -61,15 +66,21 @@ function Data(props) {
|
|
61
66
|
values = props.values,
|
62
67
|
_onChange = props.onChange,
|
63
68
|
editorProps = props.editorProps;
|
64
|
-
var bindType = getBindType(values);
|
69
|
+
var bindType = getBindType(values); // console.log("node, values", node, values);
|
65
70
|
|
66
71
|
var field = _field["default"].useField({
|
67
72
|
autoUnmount: false,
|
68
73
|
values: parseValues(values),
|
69
74
|
onChange: function onChange(name, value) {
|
70
|
-
|
75
|
+
field.validate(function (errors, vals) {
|
76
|
+
if (errors) {
|
77
|
+
console.error("field-Data", errors, vals);
|
78
|
+
} else {
|
79
|
+
var newValues = field.getValues();
|
71
80
|
|
72
|
-
|
81
|
+
_onChange(name, value, newValues);
|
82
|
+
}
|
83
|
+
});
|
73
84
|
}
|
74
85
|
});
|
75
86
|
|
@@ -129,7 +140,7 @@ function Data(props) {
|
|
129
140
|
}, /*#__PURE__*/_react["default"].createElement(_form["default"], {
|
130
141
|
field: field,
|
131
142
|
labelAlign: "top"
|
132
|
-
}, !values.tag && /*#__PURE__*/_react["default"].createElement(_form["default"].Item, {
|
143
|
+
}, (!values.tag || bindType === "ip") && /*#__PURE__*/_react["default"].createElement(_form["default"].Item, {
|
133
144
|
label: "\u5173\u8054\u7C7B\u578B"
|
134
145
|
}, /*#__PURE__*/_react["default"].createElement(_select["default"], {
|
135
146
|
name: "bindType",
|
@@ -143,7 +154,9 @@ function Data(props) {
|
|
143
154
|
value: "none"
|
144
155
|
}, "\u672A\u5173\u8054"), /*#__PURE__*/_react["default"].createElement(Option, {
|
145
156
|
value: "resource"
|
146
|
-
}, "\u5173\u8054\u8D44\u6E90"),
|
157
|
+
}, "\u5173\u8054\u8D44\u6E90"), /*#__PURE__*/_react["default"].createElement(Option, {
|
158
|
+
value: "ip"
|
159
|
+
}, "\u5173\u8054IP"), RelateTopoTree && /*#__PURE__*/_react["default"].createElement(Option, {
|
147
160
|
value: "topo"
|
148
161
|
}, "\u5173\u8054\u62D3\u6251"))), bindType === "resource" && /*#__PURE__*/_react["default"].createElement(_form["default"].Item, {
|
149
162
|
label: "\u5173\u8054\u8D44\u6E90"
|
@@ -157,7 +170,7 @@ function Data(props) {
|
|
157
170
|
flex: 1,
|
158
171
|
paddingRight: 16,
|
159
172
|
color: "#4D6277",
|
160
|
-
lineHeight:
|
173
|
+
lineHeight: "20px"
|
161
174
|
},
|
162
175
|
title: values.tag ? values.name : null
|
163
176
|
}, values.tag ? values.name : "—"), /*#__PURE__*/_react["default"].createElement(_NodeRelateResourceButton["default"], {
|
@@ -166,13 +179,35 @@ function Data(props) {
|
|
166
179
|
topo: topo,
|
167
180
|
topoEditApi: topoEditApi,
|
168
181
|
nodeBindResourceDrawerComponent: editorProps.nodeBindResourceDrawerComponent
|
169
|
-
}))), bindType === "
|
182
|
+
}))), bindType === "ip" &&
|
183
|
+
/*#__PURE__*/
|
184
|
+
// <Form.Item
|
185
|
+
// label="关联IP"
|
186
|
+
// // style={{ display: "flex" }}
|
187
|
+
// pattern={
|
188
|
+
// /^((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)))$/
|
189
|
+
// }
|
190
|
+
// patternTrigger="onBlur"
|
191
|
+
// patternMessage="IP地址格式不正确"
|
192
|
+
// >
|
193
|
+
_react["default"].createElement(_BindIpInput["default"], {
|
194
|
+
nodeElement: node,
|
195
|
+
values: values,
|
196
|
+
topo: topo,
|
197
|
+
fieldItem: field,
|
198
|
+
topoEditApi: topoEditApi,
|
199
|
+
placeholder: "\u8BF7\u8F93\u5165",
|
200
|
+
name: "attrObject.bindIp",
|
201
|
+
onChange: _onChange,
|
202
|
+
maxLength: 128
|
203
|
+
}) // </Form.Item>
|
204
|
+
, bindType === "topo" && RelateTopoTree && /*#__PURE__*/_react["default"].createElement(_form["default"].Item, {
|
170
205
|
label: "\u5173\u8054\u62D3\u6251"
|
171
206
|
}, /*#__PURE__*/_react["default"].createElement(RelateTopoTree, {
|
172
207
|
name: "attrObject.bindTopo",
|
173
208
|
topo: topo,
|
174
209
|
onChange: handleBindTopoChange
|
175
|
-
})), (editorProps === null || editorProps === void 0 ? void 0 : editorProps.topoType) ===
|
210
|
+
})), (editorProps === null || editorProps === void 0 ? void 0 : editorProps.topoType) === "cmpTopo" && node.getTag() && /*#__PURE__*/_react["default"].createElement(_form["default"].Item, {
|
176
211
|
label: "\u6240\u5C5E\u5E73\u53F0"
|
177
212
|
}, /*#__PURE__*/_react["default"].createElement(_PlatformDisplay["default"], props)))));
|
178
213
|
}
|
@@ -17,6 +17,8 @@ var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/
|
|
17
17
|
|
18
18
|
var _react = require("react");
|
19
19
|
|
20
|
+
var _lodash = _interopRequireDefault(require("lodash"));
|
21
|
+
|
20
22
|
var _rlog = _interopRequireDefault(require("@riil-frontend/component-topology-utils/es/rlog"));
|
21
23
|
|
22
24
|
var _componentTopologyGraph = require("@riil-frontend/component-topology-graph");
|
@@ -37,6 +39,10 @@ var _htElementDataUtil = require("../../utils/htElementDataUtil");
|
|
37
39
|
|
38
40
|
var _clusterUtil = require("../../utils/clusterUtil");
|
39
41
|
|
42
|
+
var _linkUtils = require("../models/utils/linkUtils");
|
43
|
+
|
44
|
+
var _exitLinkUtil = require("../../networkTopo/utils/exitLinkUtil");
|
45
|
+
|
40
46
|
var useTopoEdit = function useTopoEdit(params) {
|
41
47
|
var topo = params.topo,
|
42
48
|
topoId = params.topoId,
|
@@ -342,7 +348,7 @@ var useTopoEdit = function useTopoEdit(params) {
|
|
342
348
|
|
343
349
|
edges.map(function (edge) {
|
344
350
|
if (edge.a("dtype") === "link" && exportLinkIdList.indexOf(edge.getTag()) >= 0) {
|
345
|
-
// exLink.push(edge);
|
351
|
+
// exLink.push(edge);
|
346
352
|
topo.getGraphView().dm().remove(edge);
|
347
353
|
exportLinkIdList.splice(config.exportLinkIdList.indexOf(edge.getTag()), 1);
|
348
354
|
}
|
@@ -406,8 +412,8 @@ var useTopoEdit = function useTopoEdit(params) {
|
|
406
412
|
};
|
407
413
|
/**
|
408
414
|
* 获得未存在的连线元素
|
409
|
-
* @param {*} elements
|
410
|
-
* @returns
|
415
|
+
* @param {*} elements
|
416
|
+
* @returns
|
411
417
|
*/
|
412
418
|
|
413
419
|
|
@@ -420,8 +426,8 @@ var useTopoEdit = function useTopoEdit(params) {
|
|
420
426
|
}
|
421
427
|
/**
|
422
428
|
* 获得未存在的元素
|
423
|
-
* @param {Array} elements
|
424
|
-
* @returns
|
429
|
+
* @param {Array} elements
|
430
|
+
* @returns
|
425
431
|
*/
|
426
432
|
|
427
433
|
|
@@ -600,7 +606,7 @@ var useTopoEdit = function useTopoEdit(params) {
|
|
600
606
|
// 2022-11-10 修复 添加资源后分层重新布局问题,仅布局新增资源。替换api topo.updateElements(data)
|
601
607
|
newElements = findUNExistedElements(elements);
|
602
608
|
|
603
|
-
_rlog["default"].debug(
|
609
|
+
_rlog["default"].debug("添加分层资源", {
|
604
610
|
layer: group,
|
605
611
|
newElements: newElements
|
606
612
|
});
|
@@ -674,8 +680,8 @@ var useTopoEdit = function useTopoEdit(params) {
|
|
674
680
|
}
|
675
681
|
/**
|
676
682
|
* 未选中元素添加资源
|
677
|
-
*
|
678
|
-
* @param {*} data
|
683
|
+
*
|
684
|
+
* @param {*} data
|
679
685
|
*/
|
680
686
|
|
681
687
|
|
@@ -835,7 +841,7 @@ var useTopoEdit = function useTopoEdit(params) {
|
|
835
841
|
newLinkElements = findUNExistedLinkElements(elements);
|
836
842
|
createElementsData = null;
|
837
843
|
|
838
|
-
if (newData.type ===
|
844
|
+
if (newData.type === "group") {
|
839
845
|
groupChildren = (0, _topoData.findGroupChildren)(elements, newData);
|
840
846
|
newGroupChildren = [];
|
841
847
|
existedGroupChildren = [];
|
@@ -852,10 +858,10 @@ var useTopoEdit = function useTopoEdit(params) {
|
|
852
858
|
groups: [newData],
|
853
859
|
nodes: newGroupChildren,
|
854
860
|
links: newLinkElements.filter(function (item) {
|
855
|
-
return item.type ===
|
861
|
+
return item.type === "link";
|
856
862
|
}),
|
857
863
|
linkGroups: newLinkElements.filter(function (item) {
|
858
|
-
return item.type ===
|
864
|
+
return item.type === "linkGroup";
|
859
865
|
})
|
860
866
|
};
|
861
867
|
htTopo.createElements(createElementsData); // 切换前图上如果存在集群内的节点,切换节点为集群后,移到集群内
|
@@ -870,16 +876,16 @@ var useTopoEdit = function useTopoEdit(params) {
|
|
870
876
|
groups: [],
|
871
877
|
nodes: [newData],
|
872
878
|
links: newLinkElements.filter(function (item) {
|
873
|
-
return item.type ===
|
879
|
+
return item.type === "link";
|
874
880
|
}),
|
875
881
|
linkGroups: newLinkElements.filter(function (item) {
|
876
|
-
return item.type ===
|
882
|
+
return item.type === "linkGroup";
|
877
883
|
})
|
878
884
|
};
|
879
885
|
htTopo.createElements(createElementsData);
|
880
886
|
}
|
881
887
|
|
882
|
-
_rlog["default"].debug(
|
888
|
+
_rlog["default"].debug("批量创建元素", createElementsData); // 恢复图标、大小、位置
|
883
889
|
|
884
890
|
|
885
891
|
newElement = dm.getDataByTag(newData.id);
|
@@ -999,6 +1005,126 @@ var useTopoEdit = function useTopoEdit(params) {
|
|
999
1005
|
return _ref8.apply(this, arguments);
|
1000
1006
|
};
|
1001
1007
|
}();
|
1008
|
+
/**
|
1009
|
+
* 关联IP的图片节点
|
1010
|
+
*/
|
1011
|
+
|
1012
|
+
|
1013
|
+
function relateNodeIp(_x15, _x16) {
|
1014
|
+
return _relateNodeIp.apply(this, arguments);
|
1015
|
+
}
|
1016
|
+
|
1017
|
+
function _relateNodeIp() {
|
1018
|
+
_relateNodeIp = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee16(txtValue, nodeElement) {
|
1019
|
+
var _configObj$linkIps;
|
1020
|
+
|
1021
|
+
var dm, htTopo, elements, configObj, _yield$editDispatcher5, elementDatas, isUnique, ids, ip, re, config, linksData, createElementsData;
|
1022
|
+
|
1023
|
+
return _regenerator["default"].wrap(function _callee16$(_context16) {
|
1024
|
+
while (1) {
|
1025
|
+
switch (_context16.prev = _context16.next) {
|
1026
|
+
case 0:
|
1027
|
+
// console.log("bindIPtoNode", data);
|
1028
|
+
// 根据配置查询拓扑数据
|
1029
|
+
dm = topo.getDataModel();
|
1030
|
+
htTopo = topo.getHtTopo();
|
1031
|
+
elements = (0, _htElementUtils.getNodes)(dm); // 获取配置
|
1032
|
+
|
1033
|
+
configObj = topo.resourceConfig.getConfig();
|
1034
|
+
console.log("configObj", configObj);
|
1035
|
+
configObj.linkIps = [].concat((_configObj$linkIps = configObj.linkIps) !== null && _configObj$linkIps !== void 0 ? _configObj$linkIps : [], [txtValue]);
|
1036
|
+
console.log("configObj---over", configObj);
|
1037
|
+
_context16.next = 9;
|
1038
|
+
return resourceConfig.updateConfig(configObj);
|
1039
|
+
|
1040
|
+
case 9:
|
1041
|
+
_context16.next = 11;
|
1042
|
+
return editDispatchers.fetchDataByConfig();
|
1043
|
+
|
1044
|
+
case 11:
|
1045
|
+
_yield$editDispatcher5 = _context16.sent;
|
1046
|
+
elementDatas = _yield$editDispatcher5.elementDatas;
|
1047
|
+
console.log("bindIPtoNode", txtValue, nodeElement, elements);
|
1048
|
+
console.log("elementDatas", elementDatas); // 执行唯一性验证
|
1049
|
+
|
1050
|
+
isUnique = (0, _exitLinkUtil.isUniqueIp)(dm, txtValue, nodeElement);
|
1051
|
+
ids = [];
|
1052
|
+
elements.map(function (element) {
|
1053
|
+
if (element.getTag()) {
|
1054
|
+
ids.push(element.getTag());
|
1055
|
+
}
|
1056
|
+
});
|
1057
|
+
ip = {
|
1058
|
+
id: "ip:" + txtValue,
|
1059
|
+
name: txtValue,
|
1060
|
+
customName: null,
|
1061
|
+
// 'groupId': null,
|
1062
|
+
// 'groupTag': null,
|
1063
|
+
ipAddress: txtValue,
|
1064
|
+
// 'attributes': [],
|
1065
|
+
// 'metrics': [],
|
1066
|
+
type: "node",
|
1067
|
+
isbinding: true // 'dtype': 'device'
|
1068
|
+
|
1069
|
+
}; // 获取关联链路
|
1070
|
+
|
1071
|
+
if (!isUnique) {
|
1072
|
+
_context16.next = 30;
|
1073
|
+
break;
|
1074
|
+
}
|
1075
|
+
|
1076
|
+
nodeElement.a(ip);
|
1077
|
+
nodeElement.setName(txtValue); // nodeElement.a("name", txtValue);
|
1078
|
+
// nodeElement.a("customName", null);
|
1079
|
+
|
1080
|
+
nodeElement.setTag("ip:" + txtValue);
|
1081
|
+
_context16.next = 25;
|
1082
|
+
return editDispatchers.queryAllLinkByIp({
|
1083
|
+
ids: ids,
|
1084
|
+
ip: txtValue
|
1085
|
+
});
|
1086
|
+
|
1087
|
+
case 25:
|
1088
|
+
re = _context16.sent;
|
1089
|
+
console.log("queryAllLinkByIp", re);
|
1090
|
+
config = resourceConfig.getConfig();
|
1091
|
+
console.log("resourceConfig.getConfig", config);
|
1092
|
+
|
1093
|
+
if (re && re.length > 0) {
|
1094
|
+
linksData = [];
|
1095
|
+
re.map(function (link) {
|
1096
|
+
var sourceId = link.attributes["network_link.source_device_id"];
|
1097
|
+
var source = dm.getDataByTag(sourceId);
|
1098
|
+
var target = nodeElement; // console.log("source, nodeElement, link", source, target, link);
|
1099
|
+
|
1100
|
+
if (source && target) {
|
1101
|
+
var linkData = (0, _linkUtils.mergeExportLinkData)({
|
1102
|
+
source: source,
|
1103
|
+
target: target,
|
1104
|
+
link: link
|
1105
|
+
});
|
1106
|
+
console.log("linkData", linkData);
|
1107
|
+
linksData.push(linkData); // htTopo.createEdge(source, target, link);
|
1108
|
+
}
|
1109
|
+
});
|
1110
|
+
createElementsData = {
|
1111
|
+
groups: [],
|
1112
|
+
nodes: [],
|
1113
|
+
links: [].concat(linksData),
|
1114
|
+
linkGroups: []
|
1115
|
+
};
|
1116
|
+
htTopo.createElements(createElementsData); // htTopo.addElements({ lines: [...re] });
|
1117
|
+
}
|
1118
|
+
|
1119
|
+
case 30:
|
1120
|
+
case "end":
|
1121
|
+
return _context16.stop();
|
1122
|
+
}
|
1123
|
+
}
|
1124
|
+
}, _callee16);
|
1125
|
+
}));
|
1126
|
+
return _relateNodeIp.apply(this, arguments);
|
1127
|
+
}
|
1002
1128
|
|
1003
1129
|
var onEvent = function onEvent(e) {
|
1004
1130
|
var map = {};
|
@@ -1016,7 +1142,7 @@ var useTopoEdit = function useTopoEdit(params) {
|
|
1016
1142
|
*/
|
1017
1143
|
|
1018
1144
|
var setViewMouseMode = function setViewMouseMode(mode) {
|
1019
|
-
_rlog["default"].debug(
|
1145
|
+
_rlog["default"].debug("设置视图鼠标模式", mode);
|
1020
1146
|
|
1021
1147
|
topo.getHtTopo().setViewMouseMode(mode);
|
1022
1148
|
topoEditDispatchers.update({
|
@@ -1095,6 +1221,11 @@ var useTopoEdit = function useTopoEdit(params) {
|
|
1095
1221
|
*/
|
1096
1222
|
onDeleteElement: onDeleteElement,
|
1097
1223
|
|
1224
|
+
/**
|
1225
|
+
* 绑定图片ip
|
1226
|
+
*/
|
1227
|
+
relateNodeIp: relateNodeIp,
|
1228
|
+
|
1098
1229
|
/**
|
1099
1230
|
* 拓扑图保存回调
|
1100
1231
|
*/
|
@@ -56,7 +56,7 @@ var _SelectionModel = _interopRequireDefault(require("./SelectionModel"));
|
|
56
56
|
var _CiCache = _interopRequireDefault(require("./cache/CiCache"));
|
57
57
|
|
58
58
|
// eslint-disable-next-line no-undef
|
59
|
-
var version = typeof "9.0.0-a.
|
59
|
+
var version = typeof "9.0.0-a.21" === 'string' ? "9.0.0-a.21" : null;
|
60
60
|
console.info("\u62D3\u6251\u7248\u672C: " + version);
|
61
61
|
/**
|
62
62
|
* 拓扑显示和编辑
|
@@ -8,6 +8,7 @@ exports.compatibleWith = void 0;
|
|
8
8
|
exports.getLinksDetail = getLinksDetail;
|
9
9
|
exports.isCrucialLink = isCrucialLink;
|
10
10
|
exports.isExitLink = isExitLink;
|
11
|
+
exports.mergeExportLinkData = void 0;
|
11
12
|
exports.mergeLinksData = mergeLinksData;
|
12
13
|
exports.showLinkByConfig = exports.plurals = void 0;
|
13
14
|
|
@@ -218,4 +219,23 @@ var showLinkByConfig = function showLinkByConfig(props) {
|
|
218
219
|
}
|
219
220
|
};
|
220
221
|
|
221
|
-
exports.showLinkByConfig = showLinkByConfig;
|
222
|
+
exports.showLinkByConfig = showLinkByConfig;
|
223
|
+
|
224
|
+
var mergeExportLinkData = function mergeExportLinkData(props) {
|
225
|
+
var source = props.source,
|
226
|
+
target = props.target,
|
227
|
+
link = props.link;
|
228
|
+
var attrObj = link.attributes;
|
229
|
+
var linkData = (0, _extends2["default"])({}, link, {
|
230
|
+
name: attrObj.name,
|
231
|
+
source: attrObj["network_link.source_device_id"],
|
232
|
+
target: attrObj.destination_type === 'ip' ? target.getTag() : attrObj["network_link.destination_device_id"],
|
233
|
+
operation: attrObj.operation,
|
234
|
+
interfaceSource: attrObj["source_id"],
|
235
|
+
interfaceTarget: attrObj["destination_id"],
|
236
|
+
ciType: link.typeCode
|
237
|
+
});
|
238
|
+
return linkData;
|
239
|
+
};
|
240
|
+
|
241
|
+
exports.mergeExportLinkData = mergeExportLinkData;
|
@@ -27,6 +27,8 @@ var _topoData = require("../../../utils/topoData");
|
|
27
27
|
|
28
28
|
var _topoData2 = require("../../../core/models/topoData");
|
29
29
|
|
30
|
+
var _networkLink = _interopRequireDefault(require("../../../networkTopo/services/topo/networkLink"));
|
31
|
+
|
30
32
|
var _getTopoData = require("../../../networkTopo/getTopoData");
|
31
33
|
|
32
34
|
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
@@ -264,19 +266,20 @@ function _default(topoApp) {
|
|
264
266
|
var _this2 = this;
|
265
267
|
|
266
268
|
return (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee2() {
|
267
|
-
var editState, resources, _editState$groups, groups, _editState$exportLink, exportLinkIdList, query, data;
|
269
|
+
var editState, resources, _editState$groups, groups, _editState$exportLink, exportLinkIdList, _editState$ipNodes, ipNodes, query, data;
|
268
270
|
|
269
271
|
return _regenerator["default"].wrap(function _callee2$(_context2) {
|
270
272
|
while (1) {
|
271
273
|
switch (_context2.prev = _context2.next) {
|
272
274
|
case 0:
|
273
275
|
editState = rootState.topoConfig;
|
274
|
-
resources = editState.resources, _editState$groups = editState.groups, groups = _editState$groups === void 0 ? [] : _editState$groups, _editState$exportLink = editState.exportLinkIdList, exportLinkIdList = _editState$exportLink === void 0 ? [] : _editState$exportLink;
|
276
|
+
resources = editState.resources, _editState$groups = editState.groups, groups = _editState$groups === void 0 ? [] : _editState$groups, _editState$exportLink = editState.exportLinkIdList, exportLinkIdList = _editState$exportLink === void 0 ? [] : _editState$exportLink, _editState$ipNodes = editState.ipNodes, ipNodes = _editState$ipNodes === void 0 ? [] : _editState$ipNodes;
|
275
277
|
query = {
|
276
278
|
id: rootState.topoMod.topoId,
|
277
279
|
resources: resources,
|
278
280
|
groups: groups,
|
279
|
-
exportLinkIdList: exportLinkIdList
|
281
|
+
exportLinkIdList: exportLinkIdList,
|
282
|
+
ipNodes: ipNodes
|
280
283
|
};
|
281
284
|
_context2.next = 5;
|
282
285
|
return _this2.getTopoByConditions(query);
|
@@ -330,14 +333,14 @@ function _default(topoApp) {
|
|
330
333
|
var _this4 = this;
|
331
334
|
|
332
335
|
return (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee4() {
|
333
|
-
var topoId, resources, groups, exportLinkIdList, viewConditions, groupInfo, data, _yield$Promise$all, dataWithLinkDetail, _combTopoData, topoData, resAndMetrics, topoDataTrans;
|
336
|
+
var topoId, resources, groups, exportLinkIdList, ipNodes, viewConditions, groupInfo, data, _yield$Promise$all, dataWithLinkDetail, _combTopoData, topoData, resAndMetrics, topoDataTrans;
|
334
337
|
|
335
338
|
return _regenerator["default"].wrap(function _callee4$(_context4) {
|
336
339
|
while (1) {
|
337
340
|
switch (_context4.prev = _context4.next) {
|
338
341
|
case 0:
|
339
342
|
// rlog.debug("getTopoByConditions--------", params);
|
340
|
-
topoId = params.id, resources = params.resources, groups = params.groups, exportLinkIdList = params.exportLinkIdList;
|
343
|
+
topoId = params.id, resources = params.resources, groups = params.groups, exportLinkIdList = params.exportLinkIdList, ipNodes = params.ipNodes;
|
341
344
|
viewConditions = (0, _topoData2.resToConditions)(resources);
|
342
345
|
groupInfo = (0, _utils.isAvailableArray)(groups) && groups.map(function (group) {
|
343
346
|
return (0, _extends2["default"])({}, group, {
|
@@ -347,7 +350,7 @@ function _default(topoApp) {
|
|
347
350
|
}); // rlog.debug("getTopoByConditions--------", viewConditions, groupInfo);
|
348
351
|
|
349
352
|
_context4.next = 5;
|
350
|
-
return topoApp.serverApi.getTopoDataByResource(topoId, viewConditions, groupInfo, exportLinkIdList);
|
353
|
+
return topoApp.serverApi.getTopoDataByResource(topoId, viewConditions, groupInfo, exportLinkIdList, ipNodes);
|
351
354
|
|
352
355
|
case 5:
|
353
356
|
data = _context4.sent;
|
@@ -416,7 +419,7 @@ function _default(topoApp) {
|
|
416
419
|
}))
|
417
420
|
};
|
418
421
|
|
419
|
-
_rlog["default"].debug(
|
422
|
+
_rlog["default"].debug("saveGlobalConfig", config);
|
420
423
|
|
421
424
|
_context5.next = 5;
|
422
425
|
return topoApp.serverApi.saveTopoSettings(topoApp.id, config);
|
@@ -485,6 +488,33 @@ function _default(topoApp) {
|
|
485
488
|
switchToViewMode: function switchToViewMode() {
|
486
489
|
this.reset();
|
487
490
|
dispatch.topoMod.switchToViewMode();
|
491
|
+
},
|
492
|
+
queryAllLinkByIp: function queryAllLinkByIp(data) {
|
493
|
+
return (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee8() {
|
494
|
+
var _result$data;
|
495
|
+
|
496
|
+
var ids, ip, result;
|
497
|
+
return _regenerator["default"].wrap(function _callee8$(_context8) {
|
498
|
+
while (1) {
|
499
|
+
switch (_context8.prev = _context8.next) {
|
500
|
+
case 0:
|
501
|
+
ids = data.ids, ip = data.ip;
|
502
|
+
console.log("queryAllLinkByIp", ids, ip);
|
503
|
+
_context8.next = 4;
|
504
|
+
return _networkLink["default"].queryLinksByIp(ids, ip);
|
505
|
+
|
506
|
+
case 4:
|
507
|
+
result = _context8.sent;
|
508
|
+
console.log("queryAllLinkByIp-result", result);
|
509
|
+
return _context8.abrupt("return", (_result$data = result === null || result === void 0 ? void 0 : result.data) !== null && _result$data !== void 0 ? _result$data : []);
|
510
|
+
|
511
|
+
case 7:
|
512
|
+
case "end":
|
513
|
+
return _context8.stop();
|
514
|
+
}
|
515
|
+
}
|
516
|
+
}, _callee8);
|
517
|
+
}))();
|
488
518
|
}
|
489
519
|
};
|
490
520
|
}
|