@riil-frontend/component-topology 9.0.0-a.12 → 9.0.0-a.16
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 +1 -6
- package/es/core/editor/components/settings/propertyViews/node/data/Data.js +8 -27
- package/es/core/hooks/useTopoEdit.js +16 -133
- package/es/core/models/TopoApp.js +1 -1
- package/es/core/models/utils/linkUtils.js +0 -18
- package/es/core/store/models/topoConfig.js +7 -36
- package/es/core/viewer/components/plugins/ResourceDetail/components/ResourceOverview/components/LinkTopo/services/index.js +2 -2
- package/es/networkTopo/services/link.js +1 -1
- package/es/networkTopo/services/topo/basic.js +3 -4
- package/es/networkTopo/services/topo/networkLink.js +3 -45
- package/es/utils/htElementUtils.js +21 -43
- package/lib/core/editor/components/settings/core/updateElementProperty.js +1 -6
- package/lib/core/editor/components/settings/propertyViews/node/data/Data.js +8 -28
- package/lib/core/hooks/useTopoEdit.js +15 -133
- package/lib/core/models/TopoApp.js +1 -1
- package/lib/core/models/utils/linkUtils.js +1 -21
- package/lib/core/store/models/topoConfig.js +7 -37
- package/lib/core/viewer/components/plugins/ResourceDetail/components/ResourceOverview/components/LinkTopo/services/index.js +2 -2
- package/lib/networkTopo/services/topo/basic.js +3 -5
- package/lib/networkTopo/services/topo/networkLink.js +3 -45
- package/lib/utils/htElementUtils.js +21 -45
- package/package.json +2 -2
- package/es/core/editor/components/settings/propertyViews/node/data/BindIpInput.js +0 -61
- package/es/networkTopo/utils/exitLinkUtil.js +0 -110
- package/lib/core/editor/components/settings/propertyViews/node/data/BindIpInput.js +0 -74
- package/lib/networkTopo/utils/exitLinkUtil.js +0 -115
@@ -353,7 +353,7 @@ function _queryRetansRatioNetDelayRatio() {
|
|
353
353
|
'code': 'netDelayRatio',
|
354
354
|
'name': '下行RTT时延',
|
355
355
|
'ts': result.time,
|
356
|
-
'value': (result.upNetDelayRatio * 1).toFixed() + ' ms' + '|' + (result.downNetDelayRatio * 1).toFixed() + ' ms'
|
356
|
+
'value': (result.upNetDelayRatio * 1).toFixed(2) + ' ms' + '|' + (result.downNetDelayRatio * 1).toFixed(2) + ' ms'
|
357
357
|
});
|
358
358
|
}
|
359
359
|
|
@@ -362,7 +362,7 @@ function _queryRetansRatioNetDelayRatio() {
|
|
362
362
|
'code': 'retansRatio',
|
363
363
|
'name': '重传率',
|
364
364
|
'ts': result.time,
|
365
|
-
'value':
|
365
|
+
'value': result.upRetransRatio + ' %' + '|' + result.downRetansRatio + ' %'
|
366
366
|
});
|
367
367
|
}
|
368
368
|
|
@@ -25,8 +25,6 @@ var _cmdb = require("../cmdb");
|
|
25
25
|
|
26
26
|
var _model = require("../model");
|
27
27
|
|
28
|
-
var _exitLinkUtil = require("../../utils/exitLinkUtil");
|
29
|
-
|
30
28
|
var _excluded = ["groups", "resources"];
|
31
29
|
var API_ROOT = _constants.TOPO_API_ROOT;
|
32
30
|
/**
|
@@ -434,13 +432,13 @@ var _default = (0, _extends2["default"])({
|
|
434
432
|
|
435
433
|
case 3:
|
436
434
|
result = _context12.sent;
|
437
|
-
return _context12.abrupt("return", (0,
|
435
|
+
return _context12.abrupt("return", (0, _extends2["default"])({}, result, {
|
438
436
|
links: ((_result$links = result.links) !== null && _result$links !== void 0 ? _result$links : []).map(function (item) {
|
439
437
|
return (0, _extends2["default"])({}, item, {
|
440
438
|
ciType: 'network_link'
|
441
439
|
});
|
442
440
|
})
|
443
|
-
}))
|
441
|
+
}));
|
444
442
|
|
445
443
|
case 7:
|
446
444
|
_context12.prev = 7;
|
@@ -466,7 +464,7 @@ var _default = (0, _extends2["default"])({
|
|
466
464
|
* @param {Array} groups
|
467
465
|
* @returns
|
468
466
|
*/
|
469
|
-
getTopoDataByResource: function getTopoDataByResource(id, resources, groups, exportLinkIdList
|
467
|
+
getTopoDataByResource: function getTopoDataByResource(id, resources, groups, exportLinkIdList) {
|
470
468
|
return (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee13() {
|
471
469
|
var _result$links2;
|
472
470
|
|
@@ -17,9 +17,9 @@ var API_ROOT = _constants.TOPO_API_ROOT;
|
|
17
17
|
var _default = {
|
18
18
|
/**
|
19
19
|
* 批量查询ci类型是否可创建链路
|
20
|
-
*
|
21
|
-
* @param {*} typeCodes
|
22
|
-
* @returns
|
20
|
+
*
|
21
|
+
* @param {*} typeCodes
|
22
|
+
* @returns
|
23
23
|
*/
|
24
24
|
getCiTypesConnectable: function getCiTypesConnectable(typeCodes) {
|
25
25
|
return (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee() {
|
@@ -40,48 +40,6 @@ var _default = {
|
|
40
40
|
}
|
41
41
|
}, _callee);
|
42
42
|
}))();
|
43
|
-
},
|
44
|
-
|
45
|
-
/**
|
46
|
-
* 通过ip查询关联链路
|
47
|
-
*
|
48
|
-
* @param {array} ciIds
|
49
|
-
*/
|
50
|
-
queryLinksByIp: function queryLinksByIp(ids, ip) {
|
51
|
-
return (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee2() {
|
52
|
-
var stag, condition, parm, result;
|
53
|
-
return _regenerator["default"].wrap(function _callee2$(_context2) {
|
54
|
-
while (1) {
|
55
|
-
switch (_context2.prev = _context2.next) {
|
56
|
-
case 0:
|
57
|
-
stag = "'" + ids.join("','") + "'";
|
58
|
-
condition = "type('network_link') && network_link.destination_ipv4 = '" + ip + "' && network_link.source_device_id in [" + stag + "]";
|
59
|
-
parm = {
|
60
|
-
condition: condition,
|
61
|
-
sort: "name asc",
|
62
|
-
currentPage: 1,
|
63
|
-
pageSize: 999
|
64
|
-
};
|
65
|
-
_context2.prev = 3;
|
66
|
-
_context2.next = 6;
|
67
|
-
return _componentTopologyUtils.request.post("/mdc/v1/api/cmdb/commonQueryCiData", parm);
|
68
|
-
|
69
|
-
case 6:
|
70
|
-
result = _context2.sent;
|
71
|
-
return _context2.abrupt("return", result);
|
72
|
-
|
73
|
-
case 10:
|
74
|
-
_context2.prev = 10;
|
75
|
-
_context2.t0 = _context2["catch"](3);
|
76
|
-
rlog.error("通过ip查询关联链路", _context2.t0);
|
77
|
-
|
78
|
-
case 13:
|
79
|
-
case "end":
|
80
|
-
return _context2.stop();
|
81
|
-
}
|
82
|
-
}
|
83
|
-
}, _callee2, null, [[3, 10]]);
|
84
|
-
}))();
|
85
43
|
}
|
86
44
|
};
|
87
45
|
exports["default"] = _default;
|
@@ -32,7 +32,6 @@ exports.isGroup = isGroup;
|
|
32
32
|
exports.isLayer = isLayer;
|
33
33
|
exports.isNode = isNode;
|
34
34
|
exports.isText = isText;
|
35
|
-
exports.isUniqueIp = isUniqueIp;
|
36
35
|
exports.isValidEdge = isValidEdge;
|
37
36
|
exports.setElementRuntimeStyle = setElementRuntimeStyle;
|
38
37
|
|
@@ -56,7 +55,7 @@ function getElementData(element) {
|
|
56
55
|
styleMap: element.getStyleMap()
|
57
56
|
};
|
58
57
|
|
59
|
-
if (className ===
|
58
|
+
if (className === 'ht.Edge') {
|
60
59
|
return (0, _extends3["default"])({}, commonData);
|
61
60
|
}
|
62
61
|
|
@@ -68,7 +67,7 @@ function getElementData(element) {
|
|
68
67
|
function isNode(element) {
|
69
68
|
// HT为了支持区域内无节点可展开增加了站位节点,因此 节点的layer等于container_blank的过滤掉就可以了
|
70
69
|
// eslint-disable-next-line no-underscore-dangle
|
71
|
-
return element instanceof ht.Node && !isLayer(element) && element._layer !==
|
70
|
+
return element instanceof ht.Node && !isLayer(element) && element._layer !== 'container_blank';
|
72
71
|
}
|
73
72
|
|
74
73
|
function isEdge(element) {
|
@@ -81,7 +80,7 @@ function isValidEdge(element) {
|
|
81
80
|
}
|
82
81
|
|
83
82
|
if (!element.getSource() || !element.getTarget()) {
|
84
|
-
_rlog["default"].error(
|
83
|
+
_rlog["default"].error('isValidEdge 连线异常:源或目的为空', element);
|
85
84
|
|
86
85
|
return false;
|
87
86
|
}
|
@@ -98,30 +97,7 @@ function isLayer(element) {
|
|
98
97
|
}
|
99
98
|
|
100
99
|
function isText(element) {
|
101
|
-
return element instanceof ht.Text && element.a(
|
102
|
-
}
|
103
|
-
|
104
|
-
function isUniqueIp(dataModel, ip) {
|
105
|
-
console.log("isUniqueIp", ip);
|
106
|
-
var nodes = getNodes(dataModel);
|
107
|
-
var isUnique = true;
|
108
|
-
|
109
|
-
for (var i = 0; i < nodes.length; i++) {
|
110
|
-
var element = nodes[i];
|
111
|
-
var tagTxt = element.getTag();
|
112
|
-
console.log("isUniqueIp-element", tagTxt, ip);
|
113
|
-
|
114
|
-
if (tagTxt !== null && tagTxt !== void 0 && tagTxt.startsWith("ip_")) {
|
115
|
-
var ipTxt = tagTxt.replace("ip_", '');
|
116
|
-
|
117
|
-
if (ipTxt === ip) {
|
118
|
-
isUnique = false;
|
119
|
-
break;
|
120
|
-
}
|
121
|
-
}
|
122
|
-
}
|
123
|
-
|
124
|
-
return isUnique;
|
100
|
+
return element instanceof ht.Text && element.a('isText');
|
125
101
|
}
|
126
102
|
|
127
103
|
function getElements(dataModel) {
|
@@ -147,7 +123,7 @@ function getGroupDatas(dataModel) {
|
|
147
123
|
|
148
124
|
function getGroupElementByTag(dataModel, tag) {
|
149
125
|
return dataModel.getDataByTag(tag) || dataModel.getDatas().toArray().filter(function (item) {
|
150
|
-
return item.a(
|
126
|
+
return item.a('tag') === tag;
|
151
127
|
})[0];
|
152
128
|
}
|
153
129
|
|
@@ -159,14 +135,14 @@ function getGroupData(element) {
|
|
159
135
|
var parent = element.getParent();
|
160
136
|
var groupInfo = parent ? {
|
161
137
|
groupId: parent.getTag(),
|
162
|
-
groupTag: parent.a(
|
138
|
+
groupTag: parent.a('tag') // 父容器
|
163
139
|
|
164
140
|
} : {};
|
165
141
|
return (0, _extends3["default"])({
|
166
142
|
name: element.getStyleMap().label
|
167
143
|
}, element.getAttrObject(), {
|
168
144
|
id: element.getTag(),
|
169
|
-
tag: element.a(
|
145
|
+
tag: element.a('tag'),
|
170
146
|
image: element.getImage()
|
171
147
|
}, groupInfo);
|
172
148
|
}
|
@@ -183,7 +159,7 @@ function getNodeData(element) {
|
|
183
159
|
var parent = element.getParent();
|
184
160
|
var groupInfo = parent ? {
|
185
161
|
groupId: parent.getTag(),
|
186
|
-
groupTag: parent.a(
|
162
|
+
groupTag: parent.a('tag') // 父容器
|
187
163
|
|
188
164
|
} : {};
|
189
165
|
return (0, _extends3["default"])({}, element.getAttrObject(), {
|
@@ -197,12 +173,12 @@ function getEdges(dataModel) {
|
|
197
173
|
}
|
198
174
|
|
199
175
|
function isEdgeGroupExpanded(edge) {
|
200
|
-
return isEdge(edge) && edge.getEdgeGroup() && !!edge.s(
|
176
|
+
return isEdge(edge) && edge.getEdgeGroup() && !!edge.s('edge.expanded');
|
201
177
|
}
|
202
178
|
/**
|
203
179
|
* 是否连线组代理
|
204
|
-
* @param {*} edge
|
205
|
-
* @returns
|
180
|
+
* @param {*} edge
|
181
|
+
* @returns
|
206
182
|
*/
|
207
183
|
|
208
184
|
|
@@ -211,9 +187,9 @@ function isEdgeGroupAgent(edge) {
|
|
211
187
|
}
|
212
188
|
/**
|
213
189
|
* 获得两个节点间的连线列表
|
214
|
-
* @param {*} node1
|
215
|
-
* @param {*} node2
|
216
|
-
* @returns
|
190
|
+
* @param {*} node1
|
191
|
+
* @param {*} node2
|
192
|
+
* @returns
|
217
193
|
*/
|
218
194
|
|
219
195
|
|
@@ -236,7 +212,7 @@ function getEdgesBetweenNodes(node1, node2) {
|
|
236
212
|
}
|
237
213
|
/**
|
238
214
|
* 获得节点间的连线组,连线<=1时返回null
|
239
|
-
* @returns
|
215
|
+
* @returns
|
240
216
|
*/
|
241
217
|
|
242
218
|
|
@@ -256,7 +232,7 @@ function getEdgeGroupByNodes(node1, node2) {
|
|
256
232
|
}
|
257
233
|
/**
|
258
234
|
* 获得节点间的连线组,连线<=1时返回null
|
259
|
-
* @returns
|
235
|
+
* @returns
|
260
236
|
*/
|
261
237
|
|
262
238
|
|
@@ -265,7 +241,7 @@ function getEdgeGroupByNodeTags(dataModel, nodeTag1, nodeTag2) {
|
|
265
241
|
var node2 = dataModel.getDataByTag(nodeTag2);
|
266
242
|
|
267
243
|
if (!node1 || !node2) {
|
268
|
-
console.warn(
|
244
|
+
console.warn('getEdgeGroupByNodes 未找到节点', {
|
269
245
|
node1: node1,
|
270
246
|
node2: node2,
|
271
247
|
nodeTag1: nodeTag1,
|
@@ -352,7 +328,7 @@ function getGroupChildren(group) {
|
|
352
328
|
|
353
329
|
|
354
330
|
return group.getChildren().getArray().filter(function (node) {
|
355
|
-
return node._layer !==
|
331
|
+
return node._layer !== 'container_blank';
|
356
332
|
});
|
357
333
|
}
|
358
334
|
/**
|
@@ -385,7 +361,7 @@ function getGroupChildrenData(group) {
|
|
385
361
|
function setElementRuntimeStyle(element, name, value) {
|
386
362
|
var _extends2;
|
387
363
|
|
388
|
-
var prevRuntimeStyle = element.a(
|
364
|
+
var prevRuntimeStyle = element.a('runtimeStyles') || {};
|
389
365
|
var runtimeStyle = (0, _extends3["default"])({}, prevRuntimeStyle, (_extends2 = {}, _extends2[name] = value, _extends2)); // if (prevRuntimeStyle[name] === undefined && value === undefined) {
|
390
366
|
// return
|
391
367
|
// }
|
@@ -394,7 +370,7 @@ function setElementRuntimeStyle(element, name, value) {
|
|
394
370
|
runtimeStyle[name] = undefined; // delete runtimeStyle[name]
|
395
371
|
}
|
396
372
|
|
397
|
-
element.a(
|
373
|
+
element.a('runtimeStyles', runtimeStyle);
|
398
374
|
}
|
399
375
|
/**
|
400
376
|
* 判断拓扑图是否存在元素
|
@@ -408,7 +384,7 @@ function isExistedElement(htTopo, dataModel, data) {
|
|
408
384
|
|
409
385
|
|
410
386
|
var element = getElements(dataModel).find(function (item) {
|
411
|
-
return data.tag && item.a(
|
387
|
+
return data.tag && item.a('tag') === data.tag;
|
412
388
|
});
|
413
389
|
|
414
390
|
if (element) {
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@riil-frontend/component-topology",
|
3
|
-
"version": "9.0.0-a.
|
3
|
+
"version": "9.0.0-a.16",
|
4
4
|
"description": "拓扑",
|
5
5
|
"scripts": {
|
6
6
|
"start": "build-scripts start",
|
@@ -116,6 +116,6 @@
|
|
116
116
|
"access": "public"
|
117
117
|
},
|
118
118
|
"license": "MIT",
|
119
|
-
"homepage": "https://unpkg.com/@riil-frontend/component-topology@9.0.0-a.
|
119
|
+
"homepage": "https://unpkg.com/@riil-frontend/component-topology@9.0.0-a.16/build/index.html",
|
120
120
|
"gitHead": "2da19ffccbb7ca60a8acf396e39f542c68bb33f5"
|
121
121
|
}
|
@@ -1,61 +0,0 @@
|
|
1
|
-
import _Button from "@alifd/next/es/button";
|
2
|
-
import _Input from "@alifd/next/es/input";
|
3
|
-
import React, { useState } from "react";
|
4
|
-
|
5
|
-
/**
|
6
|
-
* @return {React.ReactNode | null}
|
7
|
-
*/
|
8
|
-
export default function BindIpInput(props) {
|
9
|
-
var _node$attrObjectIpv;
|
10
|
-
|
11
|
-
var nodeElement = props.nodeElement,
|
12
|
-
topo = props.topo,
|
13
|
-
topoEditApi = props.topoEditApi,
|
14
|
-
node = props.node,
|
15
|
-
onChange = props.onChange,
|
16
|
-
value = props.value; // const currentResId = node.tag;
|
17
|
-
|
18
|
-
console.log("nodeElement, topo, topoEditApi, node", nodeElement, topo, topoEditApi, node, value);
|
19
|
-
|
20
|
-
var _useState = useState(''),
|
21
|
-
error = _useState[0],
|
22
|
-
setError = _useState[1];
|
23
|
-
|
24
|
-
var _useState2 = useState((_node$attrObjectIpv = node["attrObject.ipv4"]) !== null && _node$attrObjectIpv !== void 0 ? _node$attrObjectIpv : ""),
|
25
|
-
txtValue = _useState2[0],
|
26
|
-
setTxtValue = _useState2[1];
|
27
|
-
|
28
|
-
var saveIp = function saveIp(v) {
|
29
|
-
console.log("saveIp", txtValue);
|
30
|
-
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)))$/;
|
31
|
-
var reg = txtValue.match(rex);
|
32
|
-
|
33
|
-
if (reg === null) {
|
34
|
-
setError('error');
|
35
|
-
} else {
|
36
|
-
setError('');
|
37
|
-
onChange(txtValue);
|
38
|
-
topoEditApi.relateNodeIp(txtValue, nodeElement);
|
39
|
-
}
|
40
|
-
};
|
41
|
-
|
42
|
-
return /*#__PURE__*/React.createElement("div", {
|
43
|
-
style: {
|
44
|
-
display: "flex"
|
45
|
-
}
|
46
|
-
}, /*#__PURE__*/React.createElement(_Input, {
|
47
|
-
placeholder: "\u8BF7\u8F93\u5165Ip\u5730\u5740",
|
48
|
-
name: "attrObject.ipv4",
|
49
|
-
state: error,
|
50
|
-
value: txtValue,
|
51
|
-
maxLength: 128,
|
52
|
-
onChange: setTxtValue
|
53
|
-
}), /*#__PURE__*/React.createElement(_Button, {
|
54
|
-
type: "primary",
|
55
|
-
text: true,
|
56
|
-
onClick: saveIp,
|
57
|
-
style: {
|
58
|
-
marginLeft: 10
|
59
|
-
}
|
60
|
-
}, "\u4FDD\u5B58"));
|
61
|
-
}
|
@@ -1,110 +0,0 @@
|
|
1
|
-
import _extends from "@babel/runtime/helpers/extends";
|
2
|
-
|
3
|
-
function findPingNode(nodes, ip) {
|
4
|
-
return nodes.find(function (node) {
|
5
|
-
return node.ciType === 'ping' && node.ipAddress === ip;
|
6
|
-
});
|
7
|
-
}
|
8
|
-
|
9
|
-
function buildIpNode(ip) {
|
10
|
-
return {
|
11
|
-
'id': "ip_" + ip,
|
12
|
-
'name': ip,
|
13
|
-
bindType: 'ip',
|
14
|
-
// 绑定资源类型。关联资源 值为空,关联IP ip
|
15
|
-
// TODO 所属区域,从序列化拿
|
16
|
-
// 'groupId': null,
|
17
|
-
// 'groupTag': null,
|
18
|
-
'ipAddress': '1.1.1.1',
|
19
|
-
// 'attributes': [],
|
20
|
-
// 'metrics': [],
|
21
|
-
'type': 'node',
|
22
|
-
// 'dtype': 'device'
|
23
|
-
'operation': 'delete'
|
24
|
-
};
|
25
|
-
}
|
26
|
-
|
27
|
-
function getHtSerialize(serialize) {
|
28
|
-
if (serialize) {
|
29
|
-
return JSON.parse(serialize);
|
30
|
-
}
|
31
|
-
|
32
|
-
return null;
|
33
|
-
}
|
34
|
-
|
35
|
-
function isExitLink(link) {
|
36
|
-
return link.attributes.destination_type === 'ip';
|
37
|
-
}
|
38
|
-
|
39
|
-
export function processExitLink(topoData) {
|
40
|
-
var nodes = topoData.nodes,
|
41
|
-
links = topoData.links;
|
42
|
-
|
43
|
-
var serialize = _extends({}, getHtSerialize(topoData.serialize)); // 出口链路目的端为IP节点时(非ping资源),IP构造为node节点
|
44
|
-
|
45
|
-
|
46
|
-
var ipNodes = [];
|
47
|
-
var newLinks = links.map(function (link) {
|
48
|
-
// 非出口链路不处理
|
49
|
-
if (!isExitLink(link)) {
|
50
|
-
return link;
|
51
|
-
} // 如果链路目的端在资源节点列表存在,则不处理
|
52
|
-
|
53
|
-
|
54
|
-
if (link.target && nodes.find(function (node) {
|
55
|
-
return node.id === link.target;
|
56
|
-
})) {
|
57
|
-
return link;
|
58
|
-
} // IP节点构造为node,链路作为标准链路处理
|
59
|
-
|
60
|
-
|
61
|
-
var destinationIp = link.attributes['network_link.destination_ipv4'];
|
62
|
-
var pingNode = findPingNode(nodes, destinationIp); // 目的端为非ping资源的IP节点时,构造为node
|
63
|
-
|
64
|
-
if (!pingNode && !ipNodes.find(function (item) {
|
65
|
-
return item.id === "ip_" + destinationIp;
|
66
|
-
})) {
|
67
|
-
var targetIpNode = buildIpNode(destinationIp);
|
68
|
-
ipNodes.push(targetIpNode);
|
69
|
-
} // 出口链路目的端为 ping资源 时,设置target为ping资源id
|
70
|
-
// 出口链路目的端为 IP节点 时,设置target为ip
|
71
|
-
|
72
|
-
|
73
|
-
var target = pingNode ? pingNode.id : "ip_" + destinationIp; // 序列化升级
|
74
|
-
|
75
|
-
if (!pingNode && serialize) {
|
76
|
-
// 1. 链路在序列化存在且目的端不是IP节点时,序列化升级
|
77
|
-
// 判断目的端节点是否是IP节点
|
78
|
-
var isIpNode = serialize.d.find(function (item) {
|
79
|
-
return item.p.tag === "ip_" + destinationIp;
|
80
|
-
}); // 序列化数据升级图片节点。
|
81
|
-
|
82
|
-
var linkSerialize = serialize.d.find(function (item) {
|
83
|
-
return item.a.id === link.id;
|
84
|
-
});
|
85
|
-
|
86
|
-
if (!isIpNode && linkSerialize) {
|
87
|
-
// 根据链路序列化数据找目的端节点
|
88
|
-
// eslint-disable-next-line no-underscore-dangle
|
89
|
-
var nodeSerialize = serialize.d.find(function (item) {
|
90
|
-
return item.i === linkSerialize.p.target.__i;
|
91
|
-
});
|
92
|
-
nodeSerialize.a = _extends({}, nodeSerialize.a, buildIpNode(destinationIp), {
|
93
|
-
isbinding: true
|
94
|
-
});
|
95
|
-
nodeSerialize.p.tag = "ip_" + destinationIp;
|
96
|
-
} // 如果有相同ip的ping资源和图片节点,图片节点消失(从序列化数据删除IP节点)
|
97
|
-
// TODO
|
98
|
-
|
99
|
-
}
|
100
|
-
|
101
|
-
return _extends({}, link, {
|
102
|
-
target: target
|
103
|
-
});
|
104
|
-
});
|
105
|
-
return _extends({}, topoData, {
|
106
|
-
nodes: [].concat(nodes, ipNodes),
|
107
|
-
links: newLinks,
|
108
|
-
serialize: serialize
|
109
|
-
});
|
110
|
-
}
|
@@ -1,74 +0,0 @@
|
|
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 _react = _interopRequireWildcard(require("react"));
|
13
|
-
|
14
|
-
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); }
|
15
|
-
|
16
|
-
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; }
|
17
|
-
|
18
|
-
/**
|
19
|
-
* @return {React.ReactNode | null}
|
20
|
-
*/
|
21
|
-
function BindIpInput(props) {
|
22
|
-
var _node$attrObjectIpv;
|
23
|
-
|
24
|
-
var nodeElement = props.nodeElement,
|
25
|
-
topo = props.topo,
|
26
|
-
topoEditApi = props.topoEditApi,
|
27
|
-
node = props.node,
|
28
|
-
onChange = props.onChange,
|
29
|
-
value = props.value; // const currentResId = node.tag;
|
30
|
-
|
31
|
-
console.log("nodeElement, topo, topoEditApi, node", nodeElement, topo, topoEditApi, node, value);
|
32
|
-
|
33
|
-
var _useState = (0, _react.useState)(''),
|
34
|
-
error = _useState[0],
|
35
|
-
setError = _useState[1];
|
36
|
-
|
37
|
-
var _useState2 = (0, _react.useState)((_node$attrObjectIpv = node["attrObject.ipv4"]) !== null && _node$attrObjectIpv !== void 0 ? _node$attrObjectIpv : ""),
|
38
|
-
txtValue = _useState2[0],
|
39
|
-
setTxtValue = _useState2[1];
|
40
|
-
|
41
|
-
var saveIp = function saveIp(v) {
|
42
|
-
console.log("saveIp", txtValue);
|
43
|
-
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)))$/;
|
44
|
-
var reg = txtValue.match(rex);
|
45
|
-
|
46
|
-
if (reg === null) {
|
47
|
-
setError('error');
|
48
|
-
} else {
|
49
|
-
setError('');
|
50
|
-
onChange(txtValue);
|
51
|
-
topoEditApi.relateNodeIp(txtValue, nodeElement);
|
52
|
-
}
|
53
|
-
};
|
54
|
-
|
55
|
-
return /*#__PURE__*/_react["default"].createElement("div", {
|
56
|
-
style: {
|
57
|
-
display: "flex"
|
58
|
-
}
|
59
|
-
}, /*#__PURE__*/_react["default"].createElement(_input["default"], {
|
60
|
-
placeholder: "\u8BF7\u8F93\u5165Ip\u5730\u5740",
|
61
|
-
name: "attrObject.ipv4",
|
62
|
-
state: error,
|
63
|
-
value: txtValue,
|
64
|
-
maxLength: 128,
|
65
|
-
onChange: setTxtValue
|
66
|
-
}), /*#__PURE__*/_react["default"].createElement(_button["default"], {
|
67
|
-
type: "primary",
|
68
|
-
text: true,
|
69
|
-
onClick: saveIp,
|
70
|
-
style: {
|
71
|
-
marginLeft: 10
|
72
|
-
}
|
73
|
-
}, "\u4FDD\u5B58"));
|
74
|
-
}
|
@@ -1,115 +0,0 @@
|
|
1
|
-
"use strict";
|
2
|
-
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
4
|
-
|
5
|
-
exports.__esModule = true;
|
6
|
-
exports.processExitLink = processExitLink;
|
7
|
-
|
8
|
-
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
|
9
|
-
|
10
|
-
function findPingNode(nodes, ip) {
|
11
|
-
return nodes.find(function (node) {
|
12
|
-
return node.ciType === 'ping' && node.ipAddress === ip;
|
13
|
-
});
|
14
|
-
}
|
15
|
-
|
16
|
-
function buildIpNode(ip) {
|
17
|
-
return {
|
18
|
-
'id': "ip_" + ip,
|
19
|
-
'name': ip,
|
20
|
-
bindType: 'ip',
|
21
|
-
// 绑定资源类型。关联资源 值为空,关联IP ip
|
22
|
-
// TODO 所属区域,从序列化拿
|
23
|
-
// 'groupId': null,
|
24
|
-
// 'groupTag': null,
|
25
|
-
'ipAddress': '1.1.1.1',
|
26
|
-
// 'attributes': [],
|
27
|
-
// 'metrics': [],
|
28
|
-
'type': 'node',
|
29
|
-
// 'dtype': 'device'
|
30
|
-
'operation': 'delete'
|
31
|
-
};
|
32
|
-
}
|
33
|
-
|
34
|
-
function getHtSerialize(serialize) {
|
35
|
-
if (serialize) {
|
36
|
-
return JSON.parse(serialize);
|
37
|
-
}
|
38
|
-
|
39
|
-
return null;
|
40
|
-
}
|
41
|
-
|
42
|
-
function isExitLink(link) {
|
43
|
-
return link.attributes.destination_type === 'ip';
|
44
|
-
}
|
45
|
-
|
46
|
-
function processExitLink(topoData) {
|
47
|
-
var nodes = topoData.nodes,
|
48
|
-
links = topoData.links;
|
49
|
-
var serialize = (0, _extends2["default"])({}, getHtSerialize(topoData.serialize)); // 出口链路目的端为IP节点时(非ping资源),IP构造为node节点
|
50
|
-
|
51
|
-
var ipNodes = [];
|
52
|
-
var newLinks = links.map(function (link) {
|
53
|
-
// 非出口链路不处理
|
54
|
-
if (!isExitLink(link)) {
|
55
|
-
return link;
|
56
|
-
} // 如果链路目的端在资源节点列表存在,则不处理
|
57
|
-
|
58
|
-
|
59
|
-
if (link.target && nodes.find(function (node) {
|
60
|
-
return node.id === link.target;
|
61
|
-
})) {
|
62
|
-
return link;
|
63
|
-
} // IP节点构造为node,链路作为标准链路处理
|
64
|
-
|
65
|
-
|
66
|
-
var destinationIp = link.attributes['network_link.destination_ipv4'];
|
67
|
-
var pingNode = findPingNode(nodes, destinationIp); // 目的端为非ping资源的IP节点时,构造为node
|
68
|
-
|
69
|
-
if (!pingNode && !ipNodes.find(function (item) {
|
70
|
-
return item.id === "ip_" + destinationIp;
|
71
|
-
})) {
|
72
|
-
var targetIpNode = buildIpNode(destinationIp);
|
73
|
-
ipNodes.push(targetIpNode);
|
74
|
-
} // 出口链路目的端为 ping资源 时,设置target为ping资源id
|
75
|
-
// 出口链路目的端为 IP节点 时,设置target为ip
|
76
|
-
|
77
|
-
|
78
|
-
var target = pingNode ? pingNode.id : "ip_" + destinationIp; // 序列化升级
|
79
|
-
|
80
|
-
if (!pingNode && serialize) {
|
81
|
-
// 1. 链路在序列化存在且目的端不是IP节点时,序列化升级
|
82
|
-
// 判断目的端节点是否是IP节点
|
83
|
-
var isIpNode = serialize.d.find(function (item) {
|
84
|
-
return item.p.tag === "ip_" + destinationIp;
|
85
|
-
}); // 序列化数据升级图片节点。
|
86
|
-
|
87
|
-
var linkSerialize = serialize.d.find(function (item) {
|
88
|
-
return item.a.id === link.id;
|
89
|
-
});
|
90
|
-
|
91
|
-
if (!isIpNode && linkSerialize) {
|
92
|
-
// 根据链路序列化数据找目的端节点
|
93
|
-
// eslint-disable-next-line no-underscore-dangle
|
94
|
-
var nodeSerialize = serialize.d.find(function (item) {
|
95
|
-
return item.i === linkSerialize.p.target.__i;
|
96
|
-
});
|
97
|
-
nodeSerialize.a = (0, _extends2["default"])({}, nodeSerialize.a, buildIpNode(destinationIp), {
|
98
|
-
isbinding: true
|
99
|
-
});
|
100
|
-
nodeSerialize.p.tag = "ip_" + destinationIp;
|
101
|
-
} // 如果有相同ip的ping资源和图片节点,图片节点消失(从序列化数据删除IP节点)
|
102
|
-
// TODO
|
103
|
-
|
104
|
-
}
|
105
|
-
|
106
|
-
return (0, _extends2["default"])({}, link, {
|
107
|
-
target: target
|
108
|
-
});
|
109
|
-
});
|
110
|
-
return (0, _extends2["default"])({}, topoData, {
|
111
|
-
nodes: [].concat(nodes, ipNodes),
|
112
|
-
links: newLinks,
|
113
|
-
serialize: serialize
|
114
|
-
});
|
115
|
-
}
|