@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
package/lib/core/test/Test.js
CHANGED
@@ -39,7 +39,7 @@ var Test = /*#__PURE__*/function () {
|
|
39
39
|
|
40
40
|
var nodeElement = htTopo.getGraphView().sm().fd();
|
41
41
|
var ip = {
|
42
|
-
'id': '
|
42
|
+
'id': 'ip:1.1.1.1',
|
43
43
|
'name': '1.1.1.1',
|
44
44
|
customName: null,
|
45
45
|
// 'groupId': null,
|
@@ -51,12 +51,12 @@ var Test = /*#__PURE__*/function () {
|
|
51
51
|
|
52
52
|
};
|
53
53
|
nodeElement.a(ip);
|
54
|
-
nodeElement.setTag('
|
54
|
+
nodeElement.setTag('ip:1.1.1.1');
|
55
55
|
var link = {
|
56
56
|
'id': '0000000019b462d1',
|
57
57
|
'name': '172.17.160.116(Gi2/2/0/1) - 172.27.130.13(Gi 0/9)',
|
58
58
|
'source': '00000000029f9411',
|
59
|
-
'target': '
|
59
|
+
'target': 'ip:1.1.1.1',
|
60
60
|
'operation': 'delete',
|
61
61
|
'interfaceSource': '0000000018080aee',
|
62
62
|
'interfaceTarget': '000000000341b015',
|
@@ -25,7 +25,9 @@ var _cmdb = require("../cmdb");
|
|
25
25
|
|
26
26
|
var _model = require("../model");
|
27
27
|
|
28
|
-
var
|
28
|
+
var _exitLinkUtil = require("../../utils/exitLinkUtil");
|
29
|
+
|
30
|
+
var _excluded = ["groups", "resources", "exportLinkIdList"];
|
29
31
|
var API_ROOT = _constants.TOPO_API_ROOT;
|
30
32
|
/**
|
31
33
|
* 拓扑图(看做一个容器)的“父容器”ID
|
@@ -72,10 +74,16 @@ function prepareResourceParams(conditions, query) {
|
|
72
74
|
dynamicCondition.sort = query.sortBy + " " + query.sortOrder;
|
73
75
|
}
|
74
76
|
|
75
|
-
var fixedConditionIdList = staticRes || undefined;
|
76
77
|
return {
|
77
78
|
dynamicCondition: dynamicCondition,
|
78
|
-
fixedConditionIdList:
|
79
|
+
fixedConditionIdList: (staticRes || []).filter(function (ciId) {
|
80
|
+
return !ciId.startsWith('ip:');
|
81
|
+
}),
|
82
|
+
linkIps: (staticRes || []).filter(function (ciId) {
|
83
|
+
return ciId.startsWith('ip:');
|
84
|
+
}).map(function (ciId) {
|
85
|
+
return ciId.replace('ip:', '');
|
86
|
+
})
|
79
87
|
};
|
80
88
|
}
|
81
89
|
|
@@ -420,7 +428,7 @@ var _default = (0, _extends2["default"])({
|
|
420
428
|
*/
|
421
429
|
getTopoData: function getTopoData(id) {
|
422
430
|
return (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee12() {
|
423
|
-
var _result$links, result;
|
431
|
+
var _result$nodes, _result$links, result;
|
424
432
|
|
425
433
|
return _regenerator["default"].wrap(function _callee12$(_context12) {
|
426
434
|
while (1) {
|
@@ -432,13 +440,14 @@ var _default = (0, _extends2["default"])({
|
|
432
440
|
|
433
441
|
case 3:
|
434
442
|
result = _context12.sent;
|
435
|
-
return _context12.abrupt("return", (0, _extends2["default"])({}, result, {
|
443
|
+
return _context12.abrupt("return", (0, _exitLinkUtil.processExitLink)((0, _extends2["default"])({}, result, {
|
444
|
+
nodes: (_result$nodes = result.nodes) !== null && _result$nodes !== void 0 ? _result$nodes : [],
|
436
445
|
links: ((_result$links = result.links) !== null && _result$links !== void 0 ? _result$links : []).map(function (item) {
|
437
446
|
return (0, _extends2["default"])({}, item, {
|
438
447
|
ciType: 'network_link'
|
439
448
|
});
|
440
449
|
})
|
441
|
-
}));
|
450
|
+
})));
|
442
451
|
|
443
452
|
case 7:
|
444
453
|
_context12.prev = 7;
|
@@ -464,9 +473,9 @@ var _default = (0, _extends2["default"])({
|
|
464
473
|
* @param {Array} groups
|
465
474
|
* @returns
|
466
475
|
*/
|
467
|
-
getTopoDataByResource: function getTopoDataByResource(id, resources, groups
|
476
|
+
getTopoDataByResource: function getTopoDataByResource(id, resources, groups) {
|
468
477
|
return (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee13() {
|
469
|
-
var _result$links2;
|
478
|
+
var _result$nodes2, _result$links2;
|
470
479
|
|
471
480
|
var data, obj, result;
|
472
481
|
return _regenerator["default"].wrap(function _callee13$(_context13) {
|
@@ -485,19 +494,18 @@ var _default = (0, _extends2["default"])({
|
|
485
494
|
|
486
495
|
obj = prepareGroupParams(data);
|
487
496
|
_context13.next = 5;
|
488
|
-
return _componentTopologyUtils.request.post(API_ROOT + "/structure/byCondition/" + id, (0, _extends2["default"])({}, obj
|
489
|
-
exportLinkIdList: exportLinkIdList
|
490
|
-
}));
|
497
|
+
return _componentTopologyUtils.request.post(API_ROOT + "/structure/byCondition/" + id, (0, _extends2["default"])({}, obj));
|
491
498
|
|
492
499
|
case 5:
|
493
500
|
result = _context13.sent;
|
494
|
-
return _context13.abrupt("return", (0, _extends2["default"])({}, result, {
|
501
|
+
return _context13.abrupt("return", (0, _exitLinkUtil.processByConditionResult)((0, _extends2["default"])({}, result, {
|
502
|
+
nodes: (_result$nodes2 = result.nodes) !== null && _result$nodes2 !== void 0 ? _result$nodes2 : [],
|
495
503
|
links: ((_result$links2 = result.links) !== null && _result$links2 !== void 0 ? _result$links2 : []).map(function (item) {
|
496
504
|
return (0, _extends2["default"])({}, item, {
|
497
505
|
ciType: 'network_link'
|
498
506
|
});
|
499
507
|
})
|
500
|
-
}));
|
508
|
+
})));
|
501
509
|
|
502
510
|
case 7:
|
503
511
|
case "end":
|
@@ -517,12 +525,12 @@ var _default = (0, _extends2["default"])({
|
|
517
525
|
*/
|
518
526
|
bindResourceToTopo: function bindResourceToTopo(id, config) {
|
519
527
|
return (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee14() {
|
520
|
-
var groups, resources, otherConfig, newGroups, obj;
|
528
|
+
var groups, resources, exportLinkIdList, otherConfig, newGroups, obj;
|
521
529
|
return _regenerator["default"].wrap(function _callee14$(_context14) {
|
522
530
|
while (1) {
|
523
531
|
switch (_context14.prev = _context14.next) {
|
524
532
|
case 0:
|
525
|
-
groups = config.groups, resources = config.resources, otherConfig = (0, _objectWithoutPropertiesLoose2["default"])(config, _excluded);
|
533
|
+
groups = config.groups, resources = config.resources, exportLinkIdList = config.exportLinkIdList, otherConfig = (0, _objectWithoutPropertiesLoose2["default"])(config, _excluded);
|
526
534
|
newGroups = isAvailableArray(groups) ? groups : [];
|
527
535
|
|
528
536
|
if (resources) {
|
@@ -536,7 +544,10 @@ var _default = (0, _extends2["default"])({
|
|
536
544
|
|
537
545
|
obj = prepareGroupParams(newGroups);
|
538
546
|
_context14.next = 6;
|
539
|
-
return _componentTopologyUtils.request.post(API_ROOT + "/resource/" + id, (0, _extends2["default"])({}, otherConfig, obj
|
547
|
+
return _componentTopologyUtils.request.post(API_ROOT + "/resource/" + id, (0, _extends2["default"])({}, otherConfig, obj, {
|
548
|
+
exportLinkIdList: [] // 传空数组清空
|
549
|
+
|
550
|
+
}));
|
540
551
|
|
541
552
|
case 6:
|
542
553
|
return _context14.abrupt("return", _context14.sent);
|
@@ -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,6 +40,48 @@ 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
|
+
}))();
|
43
85
|
}
|
44
86
|
};
|
45
87
|
exports["default"] = _default;
|
@@ -0,0 +1,235 @@
|
|
1
|
+
"use strict";
|
2
|
+
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
4
|
+
|
5
|
+
exports.__esModule = true;
|
6
|
+
exports.isUniqueIp = isUniqueIp;
|
7
|
+
exports.processByConditionResult = processByConditionResult;
|
8
|
+
exports.processExitLink = processExitLink;
|
9
|
+
|
10
|
+
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
|
11
|
+
|
12
|
+
var _htElementUtils = require("../../utils/htElementUtils");
|
13
|
+
|
14
|
+
function findPingNodeFromHt(nodes, ip) {
|
15
|
+
return nodes.find(function (node) {
|
16
|
+
return node.a('ciType') === "ping" && node.a('ipAddress') === ip;
|
17
|
+
});
|
18
|
+
}
|
19
|
+
|
20
|
+
function isPingHtNode(node, ip) {
|
21
|
+
return node.a('ciType') === "ping" && node.a('ipAddress') === ip;
|
22
|
+
}
|
23
|
+
|
24
|
+
function isIpHtNode(node, ip) {
|
25
|
+
return node.a('bindType') === ip && node.a('ipAddress') === ip;
|
26
|
+
}
|
27
|
+
|
28
|
+
function buildIpNode(ip) {
|
29
|
+
return {
|
30
|
+
'id': "ip:" + ip,
|
31
|
+
'name': ip,
|
32
|
+
bindType: 'ip',
|
33
|
+
// 绑定资源类型。关联资源 值为空,关联IP ip
|
34
|
+
bindIp: ip,
|
35
|
+
// TODO 所属区域,从序列化拿
|
36
|
+
// 'groupId': null,
|
37
|
+
// 'groupTag': null,
|
38
|
+
ipAddress: ip,
|
39
|
+
// 'attributes': [],
|
40
|
+
// 'metrics': [],
|
41
|
+
type: "node",
|
42
|
+
// 'dtype': 'device'
|
43
|
+
operation: "delete"
|
44
|
+
};
|
45
|
+
}
|
46
|
+
|
47
|
+
function getHtSerialize(serialize) {
|
48
|
+
if (serialize) {
|
49
|
+
return JSON.parse(serialize);
|
50
|
+
}
|
51
|
+
|
52
|
+
return null;
|
53
|
+
}
|
54
|
+
|
55
|
+
function isExitLink(link) {
|
56
|
+
return link.attributes.destination_type === "ip";
|
57
|
+
} // 判断拓扑图上ip是否唯一
|
58
|
+
|
59
|
+
|
60
|
+
function isUniqueIp(dataModel, ip, nodeElement) {
|
61
|
+
var nodes = (0, _htElementUtils.getNodes)(dataModel);
|
62
|
+
var isUnique = !!nodes.filter(function (node) {
|
63
|
+
return node.getId() !== nodeElement.getId();
|
64
|
+
}).filter(function (node) {
|
65
|
+
return isPingHtNode(node, ip) || isIpHtNode(node, ip);
|
66
|
+
});
|
67
|
+
return isUnique;
|
68
|
+
}
|
69
|
+
/**
|
70
|
+
* 打开拓扑出口链路处理
|
71
|
+
* @param {*} topoData
|
72
|
+
* @returns
|
73
|
+
*/
|
74
|
+
|
75
|
+
|
76
|
+
function processExitLink(topoData) {
|
77
|
+
var nodes = topoData.nodes,
|
78
|
+
links = topoData.links;
|
79
|
+
var serialize = (0, _extends2["default"])({}, getHtSerialize(topoData.serialize));
|
80
|
+
|
81
|
+
if (!serialize) {
|
82
|
+
return topoData;
|
83
|
+
} // 历史数据升级
|
84
|
+
|
85
|
+
|
86
|
+
links.filter(isExitLink) // 升级V1.4前配置的出口链路目的端节点为IP节点
|
87
|
+
.forEach(function (link) {
|
88
|
+
return upgradeExitLinkTarget(link);
|
89
|
+
}); // 出口链路目的端设置为IP节点或者ping资源节点id
|
90
|
+
|
91
|
+
var newLinks = links.map(function (link) {
|
92
|
+
if (!isExitLink(link) || link.target && nodes.find(function (node) {
|
93
|
+
return node.id === link.target;
|
94
|
+
})) {
|
95
|
+
return link;
|
96
|
+
}
|
97
|
+
|
98
|
+
var destinationIp = link.attributes['network_link.destination_ipv4'];
|
99
|
+
var pingNode = findPingNode(nodes, destinationIp); // 出口链路目的端设置为IP节点或者ping资源节点id
|
100
|
+
|
101
|
+
var target = pingNode ? pingNode.id : "ip:" + destinationIp; // 历史数据适配:同IP节点关联多个不同IP的链路、分级拓扑。target匹配不到元素时,根据序列化匹配
|
102
|
+
|
103
|
+
var targetSerialize = findElementSerializeById(serialize, target);
|
104
|
+
|
105
|
+
if (!targetSerialize) {
|
106
|
+
var linkSerialize = findElementSerializeById(serialize, link.id);
|
107
|
+
|
108
|
+
if (linkSerialize) {
|
109
|
+
// 根据链路序列化数据找目的端节点
|
110
|
+
// eslint-disable-next-line no-underscore-dangle
|
111
|
+
var targetNodeSerialize = serialize.d.find(function (item) {
|
112
|
+
return item.i === linkSerialize.p.target.__i;
|
113
|
+
});
|
114
|
+
|
115
|
+
if (targetNodeSerialize) {
|
116
|
+
target = targetNodeSerialize.p.tag;
|
117
|
+
}
|
118
|
+
}
|
119
|
+
}
|
120
|
+
|
121
|
+
return (0, _extends2["default"])({}, link, {
|
122
|
+
target: target
|
123
|
+
});
|
124
|
+
}); // IP节点构造为node。如果有相同ip的ping资源和图片节点,图片节点消失(不构造)
|
125
|
+
|
126
|
+
var ipNodes = getIpNodes();
|
127
|
+
|
128
|
+
function getIpNodes() {
|
129
|
+
// 从序列化获取关联的IP
|
130
|
+
var ips = serialize.d.filter(function (item) {
|
131
|
+
return item.a.bindType === 'ip';
|
132
|
+
}).map(function (item) {
|
133
|
+
return item.a.bindIp;
|
134
|
+
}).filter(function (item) {
|
135
|
+
return !!item;
|
136
|
+
}).filter(function (ip) {
|
137
|
+
return !findPingNode(nodes, ip);
|
138
|
+
}); // TODO 过滤ping资源对应的ip
|
139
|
+
|
140
|
+
return ips.map(buildIpNode);
|
141
|
+
}
|
142
|
+
|
143
|
+
function findIpNodeSerialize(serialize, ip) {
|
144
|
+
return serialize.d.find(function (item) {
|
145
|
+
return item.p.tag === "ip:" + ip;
|
146
|
+
});
|
147
|
+
}
|
148
|
+
|
149
|
+
function findElementSerializeById(serialize, id) {
|
150
|
+
return serialize.d.find(function (item) {
|
151
|
+
return item.a.id === id;
|
152
|
+
});
|
153
|
+
}
|
154
|
+
/**
|
155
|
+
* 链路在序列化存在且目的端不是ping资源、IP节点时,升级链路目的端序列化数据为IP节点
|
156
|
+
* @param {*} link
|
157
|
+
*/
|
158
|
+
|
159
|
+
|
160
|
+
function upgradeExitLinkTarget(link) {
|
161
|
+
var destinationIp = link.attributes['network_link.destination_ipv4'];
|
162
|
+
var linkSerialize = findElementSerializeById(serialize, link.id);
|
163
|
+
|
164
|
+
if (linkSerialize) {
|
165
|
+
// 根据链路序列化数据找目的端节点
|
166
|
+
// eslint-disable-next-line no-underscore-dangle
|
167
|
+
var targetNodeSerialize = serialize.d.find(function (item) {
|
168
|
+
return item.i === linkSerialize.p.target.__i;
|
169
|
+
});
|
170
|
+
|
171
|
+
if (!targetNodeSerialize.p.tag) {
|
172
|
+
targetNodeSerialize.a = (0, _extends2["default"])({}, targetNodeSerialize.a, buildIpNode(destinationIp), {
|
173
|
+
isbinding: true
|
174
|
+
});
|
175
|
+
targetNodeSerialize.p.tag = "ip:" + destinationIp;
|
176
|
+
}
|
177
|
+
}
|
178
|
+
}
|
179
|
+
|
180
|
+
return (0, _extends2["default"])({}, topoData, {
|
181
|
+
nodes: [].concat(nodes, ipNodes),
|
182
|
+
links: newLinks,
|
183
|
+
serialize: serialize
|
184
|
+
});
|
185
|
+
} // 从拓扑数据查找
|
186
|
+
|
187
|
+
|
188
|
+
function findPingNode(nodes, ip) {
|
189
|
+
return nodes.find(function (node) {
|
190
|
+
return node.ciType === "ping" && (node.ipAddress || node.attributes.ipv4_address) === ip;
|
191
|
+
});
|
192
|
+
}
|
193
|
+
/**
|
194
|
+
* 编辑模式按资源查询拓扑数据处理出口链路target
|
195
|
+
* FIXME 移到frontend 网络拓扑编辑
|
196
|
+
* @param {*} topoData
|
197
|
+
* @returns
|
198
|
+
*/
|
199
|
+
|
200
|
+
|
201
|
+
function processByConditionResult(topoData) {
|
202
|
+
var nodes = topoData.nodes,
|
203
|
+
links = topoData.links;
|
204
|
+
var ipNodes = getIpNodes();
|
205
|
+
|
206
|
+
function getIpNodes() {
|
207
|
+
// 从序列化获取关联的IP
|
208
|
+
var ips = [].filter(function (ip) {
|
209
|
+
return !findPingNode(nodes, ip);
|
210
|
+
}); // TODO 过滤ping资源对应的ip
|
211
|
+
|
212
|
+
return ips.map(buildIpNode);
|
213
|
+
} // 出口链路目的端设置为IP节点或者ping资源节点id
|
214
|
+
|
215
|
+
|
216
|
+
var newLinks = links.map(function (link) {
|
217
|
+
if (!isExitLink(link) || link.target && nodes.find(function (node) {
|
218
|
+
return node.id === link.target;
|
219
|
+
})) {
|
220
|
+
return link;
|
221
|
+
}
|
222
|
+
|
223
|
+
var destinationIp = link.attributes['network_link.destination_ipv4'];
|
224
|
+
var pingNode = findPingNode(nodes, destinationIp); // 出口链路目的端设置为IP节点或者ping资源节点id
|
225
|
+
|
226
|
+
var target = pingNode ? pingNode.id : "ip:" + destinationIp;
|
227
|
+
return (0, _extends2["default"])({}, link, {
|
228
|
+
target: target
|
229
|
+
});
|
230
|
+
});
|
231
|
+
return (0, _extends2["default"])({}, topoData, {
|
232
|
+
nodes: [].concat(nodes, ipNodes),
|
233
|
+
links: newLinks
|
234
|
+
});
|
235
|
+
}
|
@@ -55,7 +55,7 @@ function getElementData(element) {
|
|
55
55
|
styleMap: element.getStyleMap()
|
56
56
|
};
|
57
57
|
|
58
|
-
if (className ===
|
58
|
+
if (className === "ht.Edge") {
|
59
59
|
return (0, _extends3["default"])({}, commonData);
|
60
60
|
}
|
61
61
|
|
@@ -67,7 +67,7 @@ function getElementData(element) {
|
|
67
67
|
function isNode(element) {
|
68
68
|
// HT为了支持区域内无节点可展开增加了站位节点,因此 节点的layer等于container_blank的过滤掉就可以了
|
69
69
|
// eslint-disable-next-line no-underscore-dangle
|
70
|
-
return element instanceof ht.Node && !isLayer(element) && element._layer !==
|
70
|
+
return element instanceof ht.Node && !isLayer(element) && element._layer !== "container_blank";
|
71
71
|
}
|
72
72
|
|
73
73
|
function isEdge(element) {
|
@@ -80,7 +80,7 @@ function isValidEdge(element) {
|
|
80
80
|
}
|
81
81
|
|
82
82
|
if (!element.getSource() || !element.getTarget()) {
|
83
|
-
_rlog["default"].error(
|
83
|
+
_rlog["default"].error("isValidEdge 连线异常:源或目的为空", element);
|
84
84
|
|
85
85
|
return false;
|
86
86
|
}
|
@@ -97,7 +97,7 @@ function isLayer(element) {
|
|
97
97
|
}
|
98
98
|
|
99
99
|
function isText(element) {
|
100
|
-
return element instanceof ht.Text && element.a(
|
100
|
+
return element instanceof ht.Text && element.a("isText");
|
101
101
|
}
|
102
102
|
|
103
103
|
function getElements(dataModel) {
|
@@ -123,7 +123,7 @@ function getGroupDatas(dataModel) {
|
|
123
123
|
|
124
124
|
function getGroupElementByTag(dataModel, tag) {
|
125
125
|
return dataModel.getDataByTag(tag) || dataModel.getDatas().toArray().filter(function (item) {
|
126
|
-
return item.a(
|
126
|
+
return item.a("tag") === tag;
|
127
127
|
})[0];
|
128
128
|
}
|
129
129
|
|
@@ -135,14 +135,14 @@ function getGroupData(element) {
|
|
135
135
|
var parent = element.getParent();
|
136
136
|
var groupInfo = parent ? {
|
137
137
|
groupId: parent.getTag(),
|
138
|
-
groupTag: parent.a(
|
138
|
+
groupTag: parent.a("tag") // 父容器
|
139
139
|
|
140
140
|
} : {};
|
141
141
|
return (0, _extends3["default"])({
|
142
142
|
name: element.getStyleMap().label
|
143
143
|
}, element.getAttrObject(), {
|
144
144
|
id: element.getTag(),
|
145
|
-
tag: element.a(
|
145
|
+
tag: element.a("tag"),
|
146
146
|
image: element.getImage()
|
147
147
|
}, groupInfo);
|
148
148
|
}
|
@@ -159,7 +159,7 @@ function getNodeData(element) {
|
|
159
159
|
var parent = element.getParent();
|
160
160
|
var groupInfo = parent ? {
|
161
161
|
groupId: parent.getTag(),
|
162
|
-
groupTag: parent.a(
|
162
|
+
groupTag: parent.a("tag") // 父容器
|
163
163
|
|
164
164
|
} : {};
|
165
165
|
return (0, _extends3["default"])({}, element.getAttrObject(), {
|
@@ -173,12 +173,12 @@ function getEdges(dataModel) {
|
|
173
173
|
}
|
174
174
|
|
175
175
|
function isEdgeGroupExpanded(edge) {
|
176
|
-
return isEdge(edge) && edge.getEdgeGroup() && !!edge.s(
|
176
|
+
return isEdge(edge) && edge.getEdgeGroup() && !!edge.s("edge.expanded");
|
177
177
|
}
|
178
178
|
/**
|
179
179
|
* 是否连线组代理
|
180
|
-
* @param {*} edge
|
181
|
-
* @returns
|
180
|
+
* @param {*} edge
|
181
|
+
* @returns
|
182
182
|
*/
|
183
183
|
|
184
184
|
|
@@ -187,9 +187,9 @@ function isEdgeGroupAgent(edge) {
|
|
187
187
|
}
|
188
188
|
/**
|
189
189
|
* 获得两个节点间的连线列表
|
190
|
-
* @param {*} node1
|
191
|
-
* @param {*} node2
|
192
|
-
* @returns
|
190
|
+
* @param {*} node1
|
191
|
+
* @param {*} node2
|
192
|
+
* @returns
|
193
193
|
*/
|
194
194
|
|
195
195
|
|
@@ -212,7 +212,7 @@ function getEdgesBetweenNodes(node1, node2) {
|
|
212
212
|
}
|
213
213
|
/**
|
214
214
|
* 获得节点间的连线组,连线<=1时返回null
|
215
|
-
* @returns
|
215
|
+
* @returns
|
216
216
|
*/
|
217
217
|
|
218
218
|
|
@@ -232,7 +232,7 @@ function getEdgeGroupByNodes(node1, node2) {
|
|
232
232
|
}
|
233
233
|
/**
|
234
234
|
* 获得节点间的连线组,连线<=1时返回null
|
235
|
-
* @returns
|
235
|
+
* @returns
|
236
236
|
*/
|
237
237
|
|
238
238
|
|
@@ -241,7 +241,7 @@ function getEdgeGroupByNodeTags(dataModel, nodeTag1, nodeTag2) {
|
|
241
241
|
var node2 = dataModel.getDataByTag(nodeTag2);
|
242
242
|
|
243
243
|
if (!node1 || !node2) {
|
244
|
-
console.warn(
|
244
|
+
console.warn("getEdgeGroupByNodes 未找到节点", {
|
245
245
|
node1: node1,
|
246
246
|
node2: node2,
|
247
247
|
nodeTag1: nodeTag1,
|
@@ -328,7 +328,7 @@ function getGroupChildren(group) {
|
|
328
328
|
|
329
329
|
|
330
330
|
return group.getChildren().getArray().filter(function (node) {
|
331
|
-
return node._layer !==
|
331
|
+
return node._layer !== "container_blank";
|
332
332
|
});
|
333
333
|
}
|
334
334
|
/**
|
@@ -361,7 +361,7 @@ function getGroupChildrenData(group) {
|
|
361
361
|
function setElementRuntimeStyle(element, name, value) {
|
362
362
|
var _extends2;
|
363
363
|
|
364
|
-
var prevRuntimeStyle = element.a(
|
364
|
+
var prevRuntimeStyle = element.a("runtimeStyles") || {};
|
365
365
|
var runtimeStyle = (0, _extends3["default"])({}, prevRuntimeStyle, (_extends2 = {}, _extends2[name] = value, _extends2)); // if (prevRuntimeStyle[name] === undefined && value === undefined) {
|
366
366
|
// return
|
367
367
|
// }
|
@@ -370,7 +370,7 @@ function setElementRuntimeStyle(element, name, value) {
|
|
370
370
|
runtimeStyle[name] = undefined; // delete runtimeStyle[name]
|
371
371
|
}
|
372
372
|
|
373
|
-
element.a(
|
373
|
+
element.a("runtimeStyles", runtimeStyle);
|
374
374
|
}
|
375
375
|
/**
|
376
376
|
* 判断拓扑图是否存在元素
|
@@ -384,7 +384,7 @@ function isExistedElement(htTopo, dataModel, data) {
|
|
384
384
|
|
385
385
|
|
386
386
|
var element = getElements(dataModel).find(function (item) {
|
387
|
-
return data.tag && item.a(
|
387
|
+
return data.tag && item.a("tag") === data.tag;
|
388
388
|
});
|
389
389
|
|
390
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.21",
|
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.21/build/index.html",
|
120
120
|
"gitHead": "2da19ffccbb7ca60a8acf396e39f542c68bb33f5"
|
121
121
|
}
|