@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
@@ -1,7 +1,7 @@
|
|
1
1
|
import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/objectWithoutPropertiesLoose";
|
2
2
|
import _asyncToGenerator from "@babel/runtime/helpers/asyncToGenerator";
|
3
3
|
import _extends from "@babel/runtime/helpers/extends";
|
4
|
-
var _excluded = ["groups", "resources"];
|
4
|
+
var _excluded = ["groups", "resources", "exportLinkIdList"];
|
5
5
|
import _regeneratorRuntime from "@babel/runtime/regenerator";
|
6
6
|
import { request } from '@riil-frontend/component-topology-utils';
|
7
7
|
import rlog from '@riil-frontend/component-topology-utils/es/rlog';
|
@@ -9,6 +9,7 @@ import blackList from "./blacklist";
|
|
9
9
|
import { TOPO_API_ROOT } from "./constants";
|
10
10
|
import { commonQuery } from "../cmdb";
|
11
11
|
import { getBatchCi as _getBatchCi, getBatchCiMetric as _getBatchCiMetric } from "../model";
|
12
|
+
import { processByConditionResult, processExitLink } from "../../utils/exitLinkUtil";
|
12
13
|
var API_ROOT = TOPO_API_ROOT;
|
13
14
|
/**
|
14
15
|
* 拓扑图(看做一个容器)的“父容器”ID
|
@@ -53,10 +54,16 @@ function prepareResourceParams(conditions, query) {
|
|
53
54
|
dynamicCondition.sort = query.sortBy + " " + query.sortOrder;
|
54
55
|
}
|
55
56
|
|
56
|
-
var fixedConditionIdList = staticRes || undefined;
|
57
57
|
return {
|
58
58
|
dynamicCondition: dynamicCondition,
|
59
|
-
fixedConditionIdList:
|
59
|
+
fixedConditionIdList: (staticRes || []).filter(function (ciId) {
|
60
|
+
return !ciId.startsWith('ip:');
|
61
|
+
}),
|
62
|
+
linkIps: (staticRes || []).filter(function (ciId) {
|
63
|
+
return ciId.startsWith('ip:');
|
64
|
+
}).map(function (ciId) {
|
65
|
+
return ciId.replace('ip:', '');
|
66
|
+
})
|
60
67
|
};
|
61
68
|
}
|
62
69
|
|
@@ -401,7 +408,7 @@ export default _extends({
|
|
401
408
|
*/
|
402
409
|
getTopoData: function getTopoData(id) {
|
403
410
|
return _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee12() {
|
404
|
-
var _result$links, result;
|
411
|
+
var _result$nodes, _result$links, result;
|
405
412
|
|
406
413
|
return _regeneratorRuntime.wrap(function _callee12$(_context12) {
|
407
414
|
while (1) {
|
@@ -413,13 +420,14 @@ export default _extends({
|
|
413
420
|
|
414
421
|
case 3:
|
415
422
|
result = _context12.sent;
|
416
|
-
return _context12.abrupt("return", _extends({}, result, {
|
423
|
+
return _context12.abrupt("return", processExitLink(_extends({}, result, {
|
424
|
+
nodes: (_result$nodes = result.nodes) !== null && _result$nodes !== void 0 ? _result$nodes : [],
|
417
425
|
links: ((_result$links = result.links) !== null && _result$links !== void 0 ? _result$links : []).map(function (item) {
|
418
426
|
return _extends({}, item, {
|
419
427
|
ciType: 'network_link'
|
420
428
|
});
|
421
429
|
})
|
422
|
-
}));
|
430
|
+
})));
|
423
431
|
|
424
432
|
case 7:
|
425
433
|
_context12.prev = 7;
|
@@ -443,9 +451,9 @@ export default _extends({
|
|
443
451
|
* @param {Array} groups
|
444
452
|
* @returns
|
445
453
|
*/
|
446
|
-
getTopoDataByResource: function getTopoDataByResource(id, resources, groups
|
454
|
+
getTopoDataByResource: function getTopoDataByResource(id, resources, groups) {
|
447
455
|
return _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee13() {
|
448
|
-
var _result$links2;
|
456
|
+
var _result$nodes2, _result$links2;
|
449
457
|
|
450
458
|
var data, obj, result;
|
451
459
|
return _regeneratorRuntime.wrap(function _callee13$(_context13) {
|
@@ -464,19 +472,18 @@ export default _extends({
|
|
464
472
|
|
465
473
|
obj = prepareGroupParams(data);
|
466
474
|
_context13.next = 5;
|
467
|
-
return request.post(API_ROOT + "/structure/byCondition/" + id, _extends({}, obj
|
468
|
-
exportLinkIdList: exportLinkIdList
|
469
|
-
}));
|
475
|
+
return request.post(API_ROOT + "/structure/byCondition/" + id, _extends({}, obj));
|
470
476
|
|
471
477
|
case 5:
|
472
478
|
result = _context13.sent;
|
473
|
-
return _context13.abrupt("return", _extends({}, result, {
|
479
|
+
return _context13.abrupt("return", processByConditionResult(_extends({}, result, {
|
480
|
+
nodes: (_result$nodes2 = result.nodes) !== null && _result$nodes2 !== void 0 ? _result$nodes2 : [],
|
474
481
|
links: ((_result$links2 = result.links) !== null && _result$links2 !== void 0 ? _result$links2 : []).map(function (item) {
|
475
482
|
return _extends({}, item, {
|
476
483
|
ciType: 'network_link'
|
477
484
|
});
|
478
485
|
})
|
479
|
-
}));
|
486
|
+
})));
|
480
487
|
|
481
488
|
case 7:
|
482
489
|
case "end":
|
@@ -496,12 +503,12 @@ export default _extends({
|
|
496
503
|
*/
|
497
504
|
bindResourceToTopo: function bindResourceToTopo(id, config) {
|
498
505
|
return _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee14() {
|
499
|
-
var groups, resources, otherConfig, newGroups, obj;
|
506
|
+
var groups, resources, exportLinkIdList, otherConfig, newGroups, obj;
|
500
507
|
return _regeneratorRuntime.wrap(function _callee14$(_context14) {
|
501
508
|
while (1) {
|
502
509
|
switch (_context14.prev = _context14.next) {
|
503
510
|
case 0:
|
504
|
-
groups = config.groups, resources = config.resources, otherConfig = _objectWithoutPropertiesLoose(config, _excluded);
|
511
|
+
groups = config.groups, resources = config.resources, exportLinkIdList = config.exportLinkIdList, otherConfig = _objectWithoutPropertiesLoose(config, _excluded);
|
505
512
|
newGroups = isAvailableArray(groups) ? groups : [];
|
506
513
|
|
507
514
|
if (resources) {
|
@@ -515,7 +522,10 @@ export default _extends({
|
|
515
522
|
|
516
523
|
obj = prepareGroupParams(newGroups);
|
517
524
|
_context14.next = 6;
|
518
|
-
return request.post(API_ROOT + "/resource/" + id, _extends({}, otherConfig, obj
|
525
|
+
return request.post(API_ROOT + "/resource/" + id, _extends({}, otherConfig, obj, {
|
526
|
+
exportLinkIdList: [] // 传空数组清空
|
527
|
+
|
528
|
+
}));
|
519
529
|
|
520
530
|
case 6:
|
521
531
|
return _context14.abrupt("return", _context14.sent);
|
@@ -6,9 +6,9 @@ var API_ROOT = TOPO_API_ROOT;
|
|
6
6
|
export default {
|
7
7
|
/**
|
8
8
|
* 批量查询ci类型是否可创建链路
|
9
|
-
*
|
10
|
-
* @param {*} typeCodes
|
11
|
-
* @returns
|
9
|
+
*
|
10
|
+
* @param {*} typeCodes
|
11
|
+
* @returns
|
12
12
|
*/
|
13
13
|
getCiTypesConnectable: function getCiTypesConnectable(typeCodes) {
|
14
14
|
return _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee() {
|
@@ -29,5 +29,47 @@ export default {
|
|
29
29
|
}
|
30
30
|
}, _callee);
|
31
31
|
}))();
|
32
|
+
},
|
33
|
+
|
34
|
+
/**
|
35
|
+
* 通过ip查询关联链路
|
36
|
+
*
|
37
|
+
* @param {array} ciIds
|
38
|
+
*/
|
39
|
+
queryLinksByIp: function queryLinksByIp(ids, ip) {
|
40
|
+
return _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2() {
|
41
|
+
var stag, condition, parm, result;
|
42
|
+
return _regeneratorRuntime.wrap(function _callee2$(_context2) {
|
43
|
+
while (1) {
|
44
|
+
switch (_context2.prev = _context2.next) {
|
45
|
+
case 0:
|
46
|
+
stag = "'" + ids.join("','") + "'";
|
47
|
+
condition = "type('network_link') && network_link.destination_ipv4 = '" + ip + "' && network_link.source_device_id in [" + stag + "]";
|
48
|
+
parm = {
|
49
|
+
condition: condition,
|
50
|
+
sort: "name asc",
|
51
|
+
currentPage: 1,
|
52
|
+
pageSize: 999
|
53
|
+
};
|
54
|
+
_context2.prev = 3;
|
55
|
+
_context2.next = 6;
|
56
|
+
return request.post("/mdc/v1/api/cmdb/commonQueryCiData", parm);
|
57
|
+
|
58
|
+
case 6:
|
59
|
+
result = _context2.sent;
|
60
|
+
return _context2.abrupt("return", result);
|
61
|
+
|
62
|
+
case 10:
|
63
|
+
_context2.prev = 10;
|
64
|
+
_context2.t0 = _context2["catch"](3);
|
65
|
+
rlog.error("通过ip查询关联链路", _context2.t0);
|
66
|
+
|
67
|
+
case 13:
|
68
|
+
case "end":
|
69
|
+
return _context2.stop();
|
70
|
+
}
|
71
|
+
}
|
72
|
+
}, _callee2, null, [[3, 10]]);
|
73
|
+
}))();
|
32
74
|
}
|
33
75
|
};
|
@@ -0,0 +1,224 @@
|
|
1
|
+
import _extends from "@babel/runtime/helpers/extends";
|
2
|
+
import { getNodes } from "../../utils/htElementUtils";
|
3
|
+
|
4
|
+
function findPingNodeFromHt(nodes, ip) {
|
5
|
+
return nodes.find(function (node) {
|
6
|
+
return node.a('ciType') === "ping" && node.a('ipAddress') === ip;
|
7
|
+
});
|
8
|
+
}
|
9
|
+
|
10
|
+
function isPingHtNode(node, ip) {
|
11
|
+
return node.a('ciType') === "ping" && node.a('ipAddress') === ip;
|
12
|
+
}
|
13
|
+
|
14
|
+
function isIpHtNode(node, ip) {
|
15
|
+
return node.a('bindType') === ip && node.a('ipAddress') === ip;
|
16
|
+
}
|
17
|
+
|
18
|
+
function buildIpNode(ip) {
|
19
|
+
return {
|
20
|
+
'id': "ip:" + ip,
|
21
|
+
'name': ip,
|
22
|
+
bindType: 'ip',
|
23
|
+
// 绑定资源类型。关联资源 值为空,关联IP ip
|
24
|
+
bindIp: ip,
|
25
|
+
// TODO 所属区域,从序列化拿
|
26
|
+
// 'groupId': null,
|
27
|
+
// 'groupTag': null,
|
28
|
+
ipAddress: ip,
|
29
|
+
// 'attributes': [],
|
30
|
+
// 'metrics': [],
|
31
|
+
type: "node",
|
32
|
+
// 'dtype': 'device'
|
33
|
+
operation: "delete"
|
34
|
+
};
|
35
|
+
}
|
36
|
+
|
37
|
+
function getHtSerialize(serialize) {
|
38
|
+
if (serialize) {
|
39
|
+
return JSON.parse(serialize);
|
40
|
+
}
|
41
|
+
|
42
|
+
return null;
|
43
|
+
}
|
44
|
+
|
45
|
+
function isExitLink(link) {
|
46
|
+
return link.attributes.destination_type === "ip";
|
47
|
+
} // 判断拓扑图上ip是否唯一
|
48
|
+
|
49
|
+
|
50
|
+
export function isUniqueIp(dataModel, ip, nodeElement) {
|
51
|
+
var nodes = getNodes(dataModel);
|
52
|
+
var isUnique = !!nodes.filter(function (node) {
|
53
|
+
return node.getId() !== nodeElement.getId();
|
54
|
+
}).filter(function (node) {
|
55
|
+
return isPingHtNode(node, ip) || isIpHtNode(node, ip);
|
56
|
+
});
|
57
|
+
return isUnique;
|
58
|
+
}
|
59
|
+
/**
|
60
|
+
* 打开拓扑出口链路处理
|
61
|
+
* @param {*} topoData
|
62
|
+
* @returns
|
63
|
+
*/
|
64
|
+
|
65
|
+
export function processExitLink(topoData) {
|
66
|
+
var nodes = topoData.nodes,
|
67
|
+
links = topoData.links;
|
68
|
+
|
69
|
+
var serialize = _extends({}, getHtSerialize(topoData.serialize));
|
70
|
+
|
71
|
+
if (!serialize) {
|
72
|
+
return topoData;
|
73
|
+
} // 历史数据升级
|
74
|
+
|
75
|
+
|
76
|
+
links.filter(isExitLink) // 升级V1.4前配置的出口链路目的端节点为IP节点
|
77
|
+
.forEach(function (link) {
|
78
|
+
return upgradeExitLinkTarget(link);
|
79
|
+
}); // 出口链路目的端设置为IP节点或者ping资源节点id
|
80
|
+
|
81
|
+
var newLinks = links.map(function (link) {
|
82
|
+
if (!isExitLink(link) || link.target && nodes.find(function (node) {
|
83
|
+
return node.id === link.target;
|
84
|
+
})) {
|
85
|
+
return link;
|
86
|
+
}
|
87
|
+
|
88
|
+
var destinationIp = link.attributes['network_link.destination_ipv4'];
|
89
|
+
var pingNode = findPingNode(nodes, destinationIp); // 出口链路目的端设置为IP节点或者ping资源节点id
|
90
|
+
|
91
|
+
var target = pingNode ? pingNode.id : "ip:" + destinationIp; // 历史数据适配:同IP节点关联多个不同IP的链路、分级拓扑。target匹配不到元素时,根据序列化匹配
|
92
|
+
|
93
|
+
var targetSerialize = findElementSerializeById(serialize, target);
|
94
|
+
|
95
|
+
if (!targetSerialize) {
|
96
|
+
var linkSerialize = findElementSerializeById(serialize, link.id);
|
97
|
+
|
98
|
+
if (linkSerialize) {
|
99
|
+
// 根据链路序列化数据找目的端节点
|
100
|
+
// eslint-disable-next-line no-underscore-dangle
|
101
|
+
var targetNodeSerialize = serialize.d.find(function (item) {
|
102
|
+
return item.i === linkSerialize.p.target.__i;
|
103
|
+
});
|
104
|
+
|
105
|
+
if (targetNodeSerialize) {
|
106
|
+
target = targetNodeSerialize.p.tag;
|
107
|
+
}
|
108
|
+
}
|
109
|
+
}
|
110
|
+
|
111
|
+
return _extends({}, link, {
|
112
|
+
target: target
|
113
|
+
});
|
114
|
+
}); // IP节点构造为node。如果有相同ip的ping资源和图片节点,图片节点消失(不构造)
|
115
|
+
|
116
|
+
var ipNodes = getIpNodes();
|
117
|
+
|
118
|
+
function getIpNodes() {
|
119
|
+
// 从序列化获取关联的IP
|
120
|
+
var ips = serialize.d.filter(function (item) {
|
121
|
+
return item.a.bindType === 'ip';
|
122
|
+
}).map(function (item) {
|
123
|
+
return item.a.bindIp;
|
124
|
+
}).filter(function (item) {
|
125
|
+
return !!item;
|
126
|
+
}).filter(function (ip) {
|
127
|
+
return !findPingNode(nodes, ip);
|
128
|
+
}); // TODO 过滤ping资源对应的ip
|
129
|
+
|
130
|
+
return ips.map(buildIpNode);
|
131
|
+
}
|
132
|
+
|
133
|
+
function findIpNodeSerialize(serialize, ip) {
|
134
|
+
return serialize.d.find(function (item) {
|
135
|
+
return item.p.tag === "ip:" + ip;
|
136
|
+
});
|
137
|
+
}
|
138
|
+
|
139
|
+
function findElementSerializeById(serialize, id) {
|
140
|
+
return serialize.d.find(function (item) {
|
141
|
+
return item.a.id === id;
|
142
|
+
});
|
143
|
+
}
|
144
|
+
/**
|
145
|
+
* 链路在序列化存在且目的端不是ping资源、IP节点时,升级链路目的端序列化数据为IP节点
|
146
|
+
* @param {*} link
|
147
|
+
*/
|
148
|
+
|
149
|
+
|
150
|
+
function upgradeExitLinkTarget(link) {
|
151
|
+
var destinationIp = link.attributes['network_link.destination_ipv4'];
|
152
|
+
var linkSerialize = findElementSerializeById(serialize, link.id);
|
153
|
+
|
154
|
+
if (linkSerialize) {
|
155
|
+
// 根据链路序列化数据找目的端节点
|
156
|
+
// eslint-disable-next-line no-underscore-dangle
|
157
|
+
var targetNodeSerialize = serialize.d.find(function (item) {
|
158
|
+
return item.i === linkSerialize.p.target.__i;
|
159
|
+
});
|
160
|
+
|
161
|
+
if (!targetNodeSerialize.p.tag) {
|
162
|
+
targetNodeSerialize.a = _extends({}, targetNodeSerialize.a, buildIpNode(destinationIp), {
|
163
|
+
isbinding: true
|
164
|
+
});
|
165
|
+
targetNodeSerialize.p.tag = "ip:" + destinationIp;
|
166
|
+
}
|
167
|
+
}
|
168
|
+
}
|
169
|
+
|
170
|
+
return _extends({}, topoData, {
|
171
|
+
nodes: [].concat(nodes, ipNodes),
|
172
|
+
links: newLinks,
|
173
|
+
serialize: serialize
|
174
|
+
});
|
175
|
+
} // 从拓扑数据查找
|
176
|
+
|
177
|
+
function findPingNode(nodes, ip) {
|
178
|
+
return nodes.find(function (node) {
|
179
|
+
return node.ciType === "ping" && (node.ipAddress || node.attributes.ipv4_address) === ip;
|
180
|
+
});
|
181
|
+
}
|
182
|
+
/**
|
183
|
+
* 编辑模式按资源查询拓扑数据处理出口链路target
|
184
|
+
* FIXME 移到frontend 网络拓扑编辑
|
185
|
+
* @param {*} topoData
|
186
|
+
* @returns
|
187
|
+
*/
|
188
|
+
|
189
|
+
|
190
|
+
export function processByConditionResult(topoData) {
|
191
|
+
var nodes = topoData.nodes,
|
192
|
+
links = topoData.links;
|
193
|
+
var ipNodes = getIpNodes();
|
194
|
+
|
195
|
+
function getIpNodes() {
|
196
|
+
// 从序列化获取关联的IP
|
197
|
+
var ips = [].filter(function (ip) {
|
198
|
+
return !findPingNode(nodes, ip);
|
199
|
+
}); // TODO 过滤ping资源对应的ip
|
200
|
+
|
201
|
+
return ips.map(buildIpNode);
|
202
|
+
} // 出口链路目的端设置为IP节点或者ping资源节点id
|
203
|
+
|
204
|
+
|
205
|
+
var newLinks = links.map(function (link) {
|
206
|
+
if (!isExitLink(link) || link.target && nodes.find(function (node) {
|
207
|
+
return node.id === link.target;
|
208
|
+
})) {
|
209
|
+
return link;
|
210
|
+
}
|
211
|
+
|
212
|
+
var destinationIp = link.attributes['network_link.destination_ipv4'];
|
213
|
+
var pingNode = findPingNode(nodes, destinationIp); // 出口链路目的端设置为IP节点或者ping资源节点id
|
214
|
+
|
215
|
+
var target = pingNode ? pingNode.id : "ip:" + destinationIp;
|
216
|
+
return _extends({}, link, {
|
217
|
+
target: target
|
218
|
+
});
|
219
|
+
});
|
220
|
+
return _extends({}, topoData, {
|
221
|
+
nodes: [].concat(nodes, ipNodes),
|
222
|
+
links: newLinks
|
223
|
+
});
|
224
|
+
}
|
@@ -15,7 +15,7 @@ function getElementData(element) {
|
|
15
15
|
styleMap: element.getStyleMap()
|
16
16
|
};
|
17
17
|
|
18
|
-
if (className ===
|
18
|
+
if (className === "ht.Edge") {
|
19
19
|
return _extends({}, commonData);
|
20
20
|
}
|
21
21
|
|
@@ -27,7 +27,7 @@ function getElementData(element) {
|
|
27
27
|
export function isNode(element) {
|
28
28
|
// HT为了支持区域内无节点可展开增加了站位节点,因此 节点的layer等于container_blank的过滤掉就可以了
|
29
29
|
// eslint-disable-next-line no-underscore-dangle
|
30
|
-
return element instanceof ht.Node && !isLayer(element) && element._layer !==
|
30
|
+
return element instanceof ht.Node && !isLayer(element) && element._layer !== "container_blank";
|
31
31
|
}
|
32
32
|
export function isEdge(element) {
|
33
33
|
return element instanceof ht.Edge;
|
@@ -38,7 +38,7 @@ export function isValidEdge(element) {
|
|
38
38
|
}
|
39
39
|
|
40
40
|
if (!element.getSource() || !element.getTarget()) {
|
41
|
-
rlog.error(
|
41
|
+
rlog.error("isValidEdge 连线异常:源或目的为空", element);
|
42
42
|
return false;
|
43
43
|
}
|
44
44
|
|
@@ -51,7 +51,7 @@ export function isLayer(element) {
|
|
51
51
|
return element instanceof ht.Grid;
|
52
52
|
}
|
53
53
|
export function isText(element) {
|
54
|
-
return element instanceof ht.Text && element.a(
|
54
|
+
return element instanceof ht.Text && element.a("isText");
|
55
55
|
}
|
56
56
|
export function getElements(dataModel) {
|
57
57
|
// console.error(111, dataModel.getDatas().getArray())
|
@@ -72,7 +72,7 @@ export function getGroupDatas(dataModel) {
|
|
72
72
|
}
|
73
73
|
export function getGroupElementByTag(dataModel, tag) {
|
74
74
|
return dataModel.getDataByTag(tag) || dataModel.getDatas().toArray().filter(function (item) {
|
75
|
-
return item.a(
|
75
|
+
return item.a("tag") === tag;
|
76
76
|
})[0];
|
77
77
|
}
|
78
78
|
export function getGroupData(element) {
|
@@ -83,14 +83,14 @@ export function getGroupData(element) {
|
|
83
83
|
var parent = element.getParent();
|
84
84
|
var groupInfo = parent ? {
|
85
85
|
groupId: parent.getTag(),
|
86
|
-
groupTag: parent.a(
|
86
|
+
groupTag: parent.a("tag") // 父容器
|
87
87
|
|
88
88
|
} : {};
|
89
89
|
return _extends({
|
90
90
|
name: element.getStyleMap().label
|
91
91
|
}, element.getAttrObject(), {
|
92
92
|
id: element.getTag(),
|
93
|
-
tag: element.a(
|
93
|
+
tag: element.a("tag"),
|
94
94
|
image: element.getImage()
|
95
95
|
}, groupInfo);
|
96
96
|
}
|
@@ -104,7 +104,7 @@ export function getNodeData(element) {
|
|
104
104
|
var parent = element.getParent();
|
105
105
|
var groupInfo = parent ? {
|
106
106
|
groupId: parent.getTag(),
|
107
|
-
groupTag: parent.a(
|
107
|
+
groupTag: parent.a("tag") // 父容器
|
108
108
|
|
109
109
|
} : {};
|
110
110
|
return _extends({}, element.getAttrObject(), {
|
@@ -116,12 +116,12 @@ export function getEdges(dataModel) {
|
|
116
116
|
return getElements(dataModel).filter(isValidEdge);
|
117
117
|
}
|
118
118
|
export function isEdgeGroupExpanded(edge) {
|
119
|
-
return isEdge(edge) && edge.getEdgeGroup() && !!edge.s(
|
119
|
+
return isEdge(edge) && edge.getEdgeGroup() && !!edge.s("edge.expanded");
|
120
120
|
}
|
121
121
|
/**
|
122
122
|
* 是否连线组代理
|
123
|
-
* @param {*} edge
|
124
|
-
* @returns
|
123
|
+
* @param {*} edge
|
124
|
+
* @returns
|
125
125
|
*/
|
126
126
|
|
127
127
|
export function isEdgeGroupAgent(edge) {
|
@@ -129,9 +129,9 @@ export function isEdgeGroupAgent(edge) {
|
|
129
129
|
}
|
130
130
|
/**
|
131
131
|
* 获得两个节点间的连线列表
|
132
|
-
* @param {*} node1
|
133
|
-
* @param {*} node2
|
134
|
-
* @returns
|
132
|
+
* @param {*} node1
|
133
|
+
* @param {*} node2
|
134
|
+
* @returns
|
135
135
|
*/
|
136
136
|
|
137
137
|
export function getEdgesBetweenNodes(node1, node2) {
|
@@ -153,7 +153,7 @@ export function getEdgesBetweenNodes(node1, node2) {
|
|
153
153
|
}
|
154
154
|
/**
|
155
155
|
* 获得节点间的连线组,连线<=1时返回null
|
156
|
-
* @returns
|
156
|
+
* @returns
|
157
157
|
*/
|
158
158
|
|
159
159
|
export function getEdgeGroupByNodes(node1, node2) {
|
@@ -172,7 +172,7 @@ export function getEdgeGroupByNodes(node1, node2) {
|
|
172
172
|
}
|
173
173
|
/**
|
174
174
|
* 获得节点间的连线组,连线<=1时返回null
|
175
|
-
* @returns
|
175
|
+
* @returns
|
176
176
|
*/
|
177
177
|
|
178
178
|
export function getEdgeGroupByNodeTags(dataModel, nodeTag1, nodeTag2) {
|
@@ -180,7 +180,7 @@ export function getEdgeGroupByNodeTags(dataModel, nodeTag1, nodeTag2) {
|
|
180
180
|
var node2 = dataModel.getDataByTag(nodeTag2);
|
181
181
|
|
182
182
|
if (!node1 || !node2) {
|
183
|
-
console.warn(
|
183
|
+
console.warn("getEdgeGroupByNodes 未找到节点", {
|
184
184
|
node1: node1,
|
185
185
|
node2: node2,
|
186
186
|
nodeTag1: nodeTag1,
|
@@ -261,7 +261,7 @@ export function getGroupChildren(group) {
|
|
261
261
|
|
262
262
|
|
263
263
|
return group.getChildren().getArray().filter(function (node) {
|
264
|
-
return node._layer !==
|
264
|
+
return node._layer !== "container_blank";
|
265
265
|
});
|
266
266
|
}
|
267
267
|
/**
|
@@ -291,7 +291,7 @@ export function getGroupChildrenData(group) {
|
|
291
291
|
export function setElementRuntimeStyle(element, name, value) {
|
292
292
|
var _extends2;
|
293
293
|
|
294
|
-
var prevRuntimeStyle = element.a(
|
294
|
+
var prevRuntimeStyle = element.a("runtimeStyles") || {};
|
295
295
|
|
296
296
|
var runtimeStyle = _extends({}, prevRuntimeStyle, (_extends2 = {}, _extends2[name] = value, _extends2)); // if (prevRuntimeStyle[name] === undefined && value === undefined) {
|
297
297
|
// return
|
@@ -302,7 +302,7 @@ export function setElementRuntimeStyle(element, name, value) {
|
|
302
302
|
runtimeStyle[name] = undefined; // delete runtimeStyle[name]
|
303
303
|
}
|
304
304
|
|
305
|
-
element.a(
|
305
|
+
element.a("runtimeStyles", runtimeStyle);
|
306
306
|
}
|
307
307
|
/**
|
308
308
|
* 判断拓扑图是否存在元素
|
@@ -315,7 +315,7 @@ export function isExistedElement(htTopo, dataModel, data) {
|
|
315
315
|
|
316
316
|
|
317
317
|
var element = getElements(dataModel).find(function (item) {
|
318
|
-
return data.tag && item.a(
|
318
|
+
return data.tag && item.a("tag") === data.tag;
|
319
319
|
});
|
320
320
|
|
321
321
|
if (element) {
|
@@ -5,7 +5,12 @@ exports["default"] = updateElementProperty;
|
|
5
5
|
|
6
6
|
function updateElementProperty(topo, name, value) {
|
7
7
|
// const element = topo.getDataModel().getDataById(selection[0].id);
|
8
|
-
var element = topo.getSelectionModel().getFirstData();
|
8
|
+
var element = topo.getSelectionModel().getFirstData();
|
9
|
+
console.info("updateElementProperty", topo.getSelectionModel().getSelection(), {
|
10
|
+
element: element,
|
11
|
+
name: name,
|
12
|
+
value: value
|
13
|
+
});
|
9
14
|
|
10
15
|
if (name.startsWith('attrObject.')) {
|
11
16
|
element.setAttr(name.replace('attrObject.', ''), value);
|