@riil-frontend/component-topology 9.0.0-a.22 → 9.0.0-a.24
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 +1 -1
- package/es/core/editor/components/Toolbar/widgets/FontSizeWidget.js +1 -1
- package/es/core/editor/components/Toolbar/widgets/components/textStyleSetting/ElementTextStyleSetting/elements/groupTitle.js +1 -1
- package/es/core/editor/components/settings/propertyViews/node/data/BindIpInput.js +2 -3
- package/es/core/editor/components/settings/propertyViews/node/data/Data.js +1 -2
- package/es/core/hooks/useResourceConfig.js +2 -1
- package/es/core/hooks/useTopoEdit.js +36 -64
- package/es/core/models/TopoApp.js +1 -1
- package/es/core/models/topoData.js +16 -9
- package/es/core/models/utils/linkUtils.js +35 -28
- package/es/core/store/models/topoConfig.js +10 -9
- package/es/networkTopo/getTopoData.js +2 -1
- package/es/networkTopo/services/topo/basic.js +8 -17
- package/es/networkTopo/utils/exitLinkUtil.js +84 -66
- package/es/utils/ResourceConfigUtil.js +5 -4
- package/es/utils/htElementDataUtil.js +1 -7
- package/lib/core/editor/components/Toolbar/widgets/FontSizeWidget.js +1 -1
- package/lib/core/editor/components/Toolbar/widgets/components/textStyleSetting/ElementTextStyleSetting/elements/groupTitle.js +1 -1
- package/lib/core/editor/components/settings/propertyViews/node/data/BindIpInput.js +2 -3
- package/lib/core/editor/components/settings/propertyViews/node/data/Data.js +1 -2
- package/lib/core/hooks/useResourceConfig.js +2 -1
- package/lib/core/hooks/useTopoEdit.js +36 -64
- package/lib/core/models/TopoApp.js +1 -1
- package/lib/core/models/topoData.js +16 -9
- package/lib/core/models/utils/linkUtils.js +33 -26
- package/lib/core/store/models/topoConfig.js +13 -8
- package/lib/networkTopo/getTopoData.js +2 -1
- package/lib/networkTopo/services/topo/basic.js +8 -19
- package/lib/networkTopo/utils/exitLinkUtil.js +84 -66
- package/lib/utils/ResourceConfigUtil.js +4 -4
- package/lib/utils/htElementDataUtil.js +0 -10
- package/package.json +2 -2
@@ -42,44 +42,51 @@ var _CiCache = _interopRequireDefault(require("../cache/CiCache"));
|
|
42
42
|
|
43
43
|
/**
|
44
44
|
* 是否关键链路
|
45
|
-
* @param {*} link
|
46
|
-
* @returns
|
45
|
+
* @param {*} link
|
46
|
+
* @returns
|
47
47
|
*/
|
48
48
|
function isCrucialLink(link) {
|
49
|
-
return !!link.attributes[
|
49
|
+
return !!link.attributes["network_link.is_crucial"];
|
50
50
|
}
|
51
51
|
/**
|
52
52
|
* 是否出口链路
|
53
|
-
* @param {*} link
|
54
|
-
* @returns
|
53
|
+
* @param {*} link
|
54
|
+
* @returns
|
55
55
|
*/
|
56
56
|
|
57
57
|
|
58
58
|
function isExitLink(link) {
|
59
|
-
return (link === null || link === void 0 ? void 0 : link.attributes) && !(link !== null && link !== void 0 && link.attributes[
|
59
|
+
return (link === null || link === void 0 ? void 0 : link.attributes) && !(link !== null && link !== void 0 && link.attributes["destination_id"]);
|
60
60
|
}
|
61
61
|
|
62
62
|
function mergeLinksData(links, linkCis, nodes, interfaceCiMap, interfaceDoc) {
|
63
|
-
var linkCiMap = (0, _keyBy["default"])(links,
|
63
|
+
var linkCiMap = (0, _keyBy["default"])(links, "id");
|
64
64
|
return links.map(function (link) {
|
65
65
|
var _interfaceCiMap$attri, _interfaceCiMap$attri2;
|
66
66
|
|
67
67
|
var linkCi = linkCiMap[link.id];
|
68
68
|
var attributes = (0, _extends2["default"])({}, linkCi === null || linkCi === void 0 ? void 0 : linkCi.attributes);
|
69
69
|
var sourceNode = nodes.find(function (node) {
|
70
|
-
return node.id === attributes[
|
70
|
+
return node.id === attributes["network_link.source_device_id"];
|
71
71
|
});
|
72
72
|
var targetNode = nodes.find(function (node) {
|
73
|
-
return node.id === attributes[
|
74
|
-
});
|
73
|
+
return node.id === attributes["network_link.destination_device_id"];
|
74
|
+
});
|
75
|
+
var target = link.target; // 目的端为ip节点
|
76
|
+
|
77
|
+
if (attributes["destination_type"] === "ip") {
|
78
|
+
target = "ip:" + attributes["network_link.destination_ipv4"];
|
79
|
+
} // 翻译
|
80
|
+
|
75
81
|
|
76
82
|
return (0, _extends2["default"])({}, link, {
|
83
|
+
target: target,
|
77
84
|
attributes: (0, _extends2["default"])({}, attributes, {
|
78
85
|
// 源/目的设备
|
79
|
-
|
86
|
+
"network_link.source_device_id_object": {
|
80
87
|
displayName: sourceNode === null || sourceNode === void 0 ? void 0 : sourceNode.name
|
81
88
|
},
|
82
|
-
|
89
|
+
"network_link.destination_device_id_object": {
|
83
90
|
displayName: targetNode === null || targetNode === void 0 ? void 0 : targetNode.name
|
84
91
|
},
|
85
92
|
// 源/目的接口类型
|
@@ -87,10 +94,10 @@ function mergeLinksData(links, linkCis, nodes, interfaceCiMap, interfaceDoc) {
|
|
87
94
|
destination_type_object: interfaceDoc[attributes.destination_type],
|
88
95
|
// 源/目的接口
|
89
96
|
source_id_object: {
|
90
|
-
displayName: (_interfaceCiMap$attri = interfaceCiMap[attributes.source_id]) === null || _interfaceCiMap$attri === void 0 ? void 0 : _interfaceCiMap$attri.attributes[
|
97
|
+
displayName: (_interfaceCiMap$attri = interfaceCiMap[attributes.source_id]) === null || _interfaceCiMap$attri === void 0 ? void 0 : _interfaceCiMap$attri.attributes["display_name"]
|
91
98
|
},
|
92
99
|
destination_id_object: {
|
93
|
-
displayName: (_interfaceCiMap$attri2 = interfaceCiMap[attributes.destination_id]) === null || _interfaceCiMap$attri2 === void 0 ? void 0 : _interfaceCiMap$attri2.attributes[
|
100
|
+
displayName: (_interfaceCiMap$attri2 = interfaceCiMap[attributes.destination_id]) === null || _interfaceCiMap$attri2 === void 0 ? void 0 : _interfaceCiMap$attri2.attributes["display_name"]
|
94
101
|
}
|
95
102
|
})
|
96
103
|
});
|
@@ -130,7 +137,7 @@ function _getLinksDetail() {
|
|
130
137
|
}), linkCis.map(function (item) {
|
131
138
|
return item.attributes.destination_type;
|
132
139
|
})))).filter(function (item) {
|
133
|
-
return item !==
|
140
|
+
return item !== "ip";
|
134
141
|
});
|
135
142
|
_context.next = 7;
|
136
143
|
return _CiCache["default"].load(interfaceIds);
|
@@ -174,10 +181,10 @@ var compatibleWith = function compatibleWith(value) {
|
|
174
181
|
exports.compatibleWith = compatibleWith;
|
175
182
|
var plurals = {
|
176
183
|
0: [],
|
177
|
-
1: [
|
178
|
-
2: [
|
179
|
-
3: [
|
180
|
-
4: [
|
184
|
+
1: ["phy"],
|
185
|
+
2: ["phy"],
|
186
|
+
3: ["agg"],
|
187
|
+
4: ["phy", "agg"]
|
181
188
|
};
|
182
189
|
exports.plurals = plurals;
|
183
190
|
|
@@ -194,25 +201,25 @@ var showLinkByConfig = function showLinkByConfig(props) {
|
|
194
201
|
var dm = gv.getDataModel();
|
195
202
|
var edges = (0, _htElementUtils.getEdges)(dm); // console.log("edges", edges);
|
196
203
|
|
197
|
-
var showPhy = types.indexOf(
|
198
|
-
var showAgg = types.indexOf(
|
204
|
+
var showPhy = types.indexOf("phy") >= 0;
|
205
|
+
var showAgg = types.indexOf("agg") >= 0; // console.log("edges----types",showType, types,showPhy, showAgg);
|
199
206
|
|
200
207
|
if (Array.isArray(edges) && edges.length > 0) {
|
201
208
|
edges.map(function (edge) {
|
202
209
|
if (showType === 1 || showType === true) {
|
203
210
|
// 单链路全部显示
|
204
211
|
// console.log("单链路全部显示", edge);
|
205
|
-
edge.s(
|
212
|
+
edge.s("2d.visible", true);
|
206
213
|
} else {
|
207
214
|
var _d$attributes, _d$attributes2;
|
208
215
|
|
209
216
|
var d = topo.dataModel.getDataById(edge.getTag()); // 判断是否聚合链路
|
210
217
|
|
211
|
-
if ((d === null || d === void 0 ? void 0 : (_d$attributes = d.attributes) === null || _d$attributes === void 0 ? void 0 : _d$attributes.destination_type) ===
|
212
|
-
edge.s(
|
218
|
+
if ((d === null || d === void 0 ? void 0 : (_d$attributes = d.attributes) === null || _d$attributes === void 0 ? void 0 : _d$attributes.destination_type) === "network.agg_interface" && (d === null || d === void 0 ? void 0 : (_d$attributes2 = d.attributes) === null || _d$attributes2 === void 0 ? void 0 : _d$attributes2.source_type) === "network.agg_interface") {
|
219
|
+
edge.s("2d.visible", showAgg);
|
213
220
|
} else {
|
214
221
|
// console.log("edge", edge, d, showAgg);
|
215
|
-
edge.s(
|
222
|
+
edge.s("2d.visible", showPhy);
|
216
223
|
}
|
217
224
|
}
|
218
225
|
});
|
@@ -229,7 +236,7 @@ var mergeExportLinkData = function mergeExportLinkData(props) {
|
|
229
236
|
var linkData = (0, _extends2["default"])({}, link, {
|
230
237
|
name: attrObj.name,
|
231
238
|
source: attrObj["network_link.source_device_id"],
|
232
|
-
target: attrObj.destination_type ===
|
239
|
+
target: attrObj.destination_type === "ip" ? target.getTag() : attrObj["network_link.destination_device_id"],
|
233
240
|
operation: attrObj.operation,
|
234
241
|
interfaceSource: attrObj["source_id"],
|
235
242
|
interfaceTarget: attrObj["destination_id"],
|
@@ -347,22 +347,27 @@ function _default(topoApp) {
|
|
347
347
|
layout: (0, _topoData2.getLayoutId)(group.layout),
|
348
348
|
resources: (0, _topoData2.resToConditions)(group.resources)
|
349
349
|
});
|
350
|
-
});
|
350
|
+
});
|
351
|
+
|
352
|
+
_rlog["default"].debug("getTopoByConditions--------", viewConditions, groupInfo);
|
351
353
|
|
352
|
-
_context4.next =
|
354
|
+
_context4.next = 6;
|
353
355
|
return topoApp.serverApi.getTopoDataByResource(topoId, viewConditions, groupInfo, exportLinkIdList, ipNodes);
|
354
356
|
|
355
|
-
case
|
357
|
+
case 6:
|
356
358
|
data = _context4.sent;
|
357
|
-
|
359
|
+
|
360
|
+
_rlog["default"].debug("getTopoByConditions--------data", data);
|
361
|
+
|
362
|
+
_context4.next = 10;
|
358
363
|
return (0, _getTopoData.buildData)(data);
|
359
364
|
|
360
|
-
case
|
365
|
+
case 10:
|
361
366
|
data = _context4.sent;
|
362
|
-
_context4.next =
|
367
|
+
_context4.next = 13;
|
363
368
|
return Promise.all([(0, _getTopoData.addLinkData)(data), topoApp.ciTyeCache.getCiTypeMap((0, _topoData.getCiTypes)(data)), dispatch.customIcon.loadCustomIcons()]);
|
364
369
|
|
365
|
-
case
|
370
|
+
case 13:
|
366
371
|
_yield$Promise$all = _context4.sent;
|
367
372
|
dataWithLinkDetail = _yield$Promise$all[0];
|
368
373
|
_combTopoData = (0, _topoData.combTopoData)({
|
@@ -389,7 +394,7 @@ function _default(topoApp) {
|
|
389
394
|
topoDataTrans: topoDataTrans
|
390
395
|
});
|
391
396
|
|
392
|
-
case
|
397
|
+
case 21:
|
393
398
|
case "end":
|
394
399
|
return _context4.stop();
|
395
400
|
}
|
@@ -92,6 +92,7 @@ function _addLinkData() {
|
|
92
92
|
|
93
93
|
case 4:
|
94
94
|
networkLinks = _context.sent;
|
95
|
+
console.log("如果是网络链路,补充详情信息", networkLinks);
|
95
96
|
otherLinks = links.filter(function (link) {
|
96
97
|
return link.ciType !== 'network_link';
|
97
98
|
});
|
@@ -100,7 +101,7 @@ function _addLinkData() {
|
|
100
101
|
linkGroups: []
|
101
102
|
}));
|
102
103
|
|
103
|
-
case
|
104
|
+
case 8:
|
104
105
|
case "end":
|
105
106
|
return _context.stop();
|
106
107
|
}
|
@@ -428,17 +428,17 @@ var _default = (0, _extends2["default"])({
|
|
428
428
|
*/
|
429
429
|
getTopoData: function getTopoData(id) {
|
430
430
|
return (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee12() {
|
431
|
-
var _result$nodes, _result$links
|
431
|
+
var _result$nodes, _result$links;
|
432
432
|
|
433
|
+
var result;
|
433
434
|
return _regenerator["default"].wrap(function _callee12$(_context12) {
|
434
435
|
while (1) {
|
435
436
|
switch (_context12.prev = _context12.next) {
|
436
437
|
case 0:
|
437
|
-
_context12.
|
438
|
-
_context12.next = 3;
|
438
|
+
_context12.next = 2;
|
439
439
|
return _componentTopologyUtils.request.get(API_ROOT + "/structure/both/" + id);
|
440
440
|
|
441
|
-
case
|
441
|
+
case 2:
|
442
442
|
result = _context12.sent;
|
443
443
|
return _context12.abrupt("return", (0, _exitLinkUtil.processExitLink)((0, _extends2["default"])({}, result, {
|
444
444
|
nodes: (_result$nodes = result.nodes) !== null && _result$nodes !== void 0 ? _result$nodes : [],
|
@@ -449,20 +449,12 @@ var _default = (0, _extends2["default"])({
|
|
449
449
|
})
|
450
450
|
})));
|
451
451
|
|
452
|
-
case
|
453
|
-
_context12.prev = 7;
|
454
|
-
_context12.t0 = _context12["catch"](0);
|
455
|
-
|
456
|
-
_rlog["default"].debug('getTopoData-error', _context12.t0);
|
457
|
-
|
458
|
-
return _context12.abrupt("return", null);
|
459
|
-
|
460
|
-
case 11:
|
452
|
+
case 4:
|
461
453
|
case "end":
|
462
454
|
return _context12.stop();
|
463
455
|
}
|
464
456
|
}
|
465
|
-
}, _callee12
|
457
|
+
}, _callee12);
|
466
458
|
}))();
|
467
459
|
},
|
468
460
|
|
@@ -505,7 +497,7 @@ var _default = (0, _extends2["default"])({
|
|
505
497
|
ciType: 'network_link'
|
506
498
|
});
|
507
499
|
})
|
508
|
-
})));
|
500
|
+
}), obj.groups));
|
509
501
|
|
510
502
|
case 7:
|
511
503
|
case "end":
|
@@ -544,10 +536,7 @@ var _default = (0, _extends2["default"])({
|
|
544
536
|
|
545
537
|
obj = prepareGroupParams(newGroups);
|
546
538
|
_context14.next = 6;
|
547
|
-
return _componentTopologyUtils.request.post(API_ROOT + "/resource/" + id, (0, _extends2["default"])({}, otherConfig, obj
|
548
|
-
exportLinkIdList: [] // 传空数组清空
|
549
|
-
|
550
|
-
}));
|
539
|
+
return _componentTopologyUtils.request.post(API_ROOT + "/resource/" + id, (0, _extends2["default"])({}, otherConfig, obj));
|
551
540
|
|
552
541
|
case 6:
|
553
542
|
return _context14.abrupt("return", _context14.sent);
|
@@ -75,57 +75,71 @@ function isUniqueIp(dataModel, ip, nodeElement) {
|
|
75
75
|
|
76
76
|
function processExitLink(topoData) {
|
77
77
|
var nodes = topoData.nodes,
|
78
|
-
links = topoData.links;
|
79
|
-
var serialize = (0, _extends2["default"])({}, getHtSerialize(topoData.serialize));
|
78
|
+
links = topoData.links; // 出口链路目的端设置为IP节点或者ping资源节点id
|
80
79
|
|
81
|
-
|
82
|
-
return topoData;
|
83
|
-
} // 历史数据升级
|
80
|
+
var newLinks = updateLinkTarget(links, nodes);
|
84
81
|
|
82
|
+
if (!topoData.serialize) {
|
83
|
+
return (0, _extends2["default"])({}, topoData, {
|
84
|
+
links: newLinks
|
85
|
+
});
|
86
|
+
}
|
87
|
+
|
88
|
+
var serialize = (0, _extends2["default"])({}, getHtSerialize(topoData.serialize)); // 历史数据升级
|
85
89
|
|
86
90
|
links.filter(isExitLink) // 升级V1.4前配置的出口链路目的端节点为IP节点
|
87
91
|
.forEach(function (link) {
|
88
|
-
return upgradeExitLinkTarget(link);
|
89
|
-
}); //
|
92
|
+
return upgradeExitLinkTarget(link, serialize);
|
93
|
+
}); // 历史数据适配:同IP节点关联多个不同IP的链路、分级拓扑。target匹配不到元素时,根据序列化匹配
|
90
94
|
|
91
|
-
|
92
|
-
if (!isExitLink(link) || link.target && nodes.find(function (node) {
|
93
|
-
return node.id === link.target;
|
94
|
-
})) {
|
95
|
-
return link;
|
96
|
-
}
|
95
|
+
newLinks = upgradeLinkTargetNotExisted(links); // IP节点构造为node。如果有相同ip的ping资源和图片节点,图片节点消失(不构造)
|
97
96
|
|
98
|
-
|
99
|
-
|
97
|
+
var ipNodes = getIpNodes(serialize, nodes);
|
98
|
+
return (0, _extends2["default"])({}, topoData, {
|
99
|
+
nodes: [].concat(nodes, ipNodes),
|
100
|
+
links: newLinks,
|
101
|
+
serialize: serialize
|
102
|
+
}); // 历史数据适配:同IP节点关联多个不同IP的链路、分级拓扑。target匹配不到元素时,根据序列化匹配
|
103
|
+
|
104
|
+
function upgradeLinkTargetNotExisted(links) {
|
105
|
+
newLinks = links.map(function (link) {
|
106
|
+
if (!isExitLink(link) || link.target && nodes.find(function (node) {
|
107
|
+
return node.id === link.target;
|
108
|
+
})) {
|
109
|
+
return link;
|
110
|
+
}
|
100
111
|
|
101
|
-
|
112
|
+
var destinationIp = link.attributes['network_link.destination_ipv4'];
|
113
|
+
var pingNode = findPingNode(nodes, destinationIp); // 出口链路目的端设置为IP节点或者ping资源节点id
|
102
114
|
|
103
|
-
|
115
|
+
var target = link.target; // 历史数据适配:同IP节点关联多个不同IP的链路、分级拓扑。target匹配不到元素时,根据序列化匹配
|
104
116
|
|
105
|
-
|
106
|
-
var linkSerialize = findElementSerializeById(serialize, link.id);
|
117
|
+
var targetSerialize = findElementSerializeById(serialize, target);
|
107
118
|
|
108
|
-
if (
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
119
|
+
if (!targetSerialize) {
|
120
|
+
var linkSerialize = findElementSerializeById(serialize, link.id);
|
121
|
+
|
122
|
+
if (linkSerialize) {
|
123
|
+
// 根据链路序列化数据找目的端节点
|
124
|
+
// eslint-disable-next-line no-underscore-dangle
|
125
|
+
var targetNodeSerialize = serialize.d.find(function (item) {
|
126
|
+
return item.i === linkSerialize.p.target.__i;
|
127
|
+
});
|
114
128
|
|
115
|
-
|
116
|
-
|
129
|
+
if (targetNodeSerialize) {
|
130
|
+
target = targetNodeSerialize.p.tag;
|
131
|
+
}
|
117
132
|
}
|
118
133
|
}
|
119
|
-
}
|
120
134
|
|
121
|
-
|
122
|
-
|
135
|
+
return (0, _extends2["default"])({}, link, {
|
136
|
+
target: target
|
137
|
+
});
|
123
138
|
});
|
124
|
-
|
125
|
-
|
126
|
-
var ipNodes = getIpNodes();
|
139
|
+
return newLinks;
|
140
|
+
}
|
127
141
|
|
128
|
-
function getIpNodes() {
|
142
|
+
function getIpNodes(serialize, nodes) {
|
129
143
|
// 从序列化获取关联的IP
|
130
144
|
var ips = serialize.d.filter(function (item) {
|
131
145
|
return item.a.bindType === 'ip';
|
@@ -133,10 +147,10 @@ function processExitLink(topoData) {
|
|
133
147
|
return item.a.bindIp;
|
134
148
|
}).filter(function (item) {
|
135
149
|
return !!item;
|
136
|
-
})
|
150
|
+
}) // 过滤ping资源对应的ip
|
151
|
+
.filter(function (ip) {
|
137
152
|
return !findPingNode(nodes, ip);
|
138
|
-
});
|
139
|
-
|
153
|
+
});
|
140
154
|
return ips.map(buildIpNode);
|
141
155
|
}
|
142
156
|
|
@@ -157,7 +171,7 @@ function processExitLink(topoData) {
|
|
157
171
|
*/
|
158
172
|
|
159
173
|
|
160
|
-
function upgradeExitLinkTarget(link) {
|
174
|
+
function upgradeExitLinkTarget(link, serialize) {
|
161
175
|
var destinationIp = link.attributes['network_link.destination_ipv4'];
|
162
176
|
var linkSerialize = findElementSerializeById(serialize, link.id);
|
163
177
|
|
@@ -176,12 +190,6 @@ function processExitLink(topoData) {
|
|
176
190
|
}
|
177
191
|
}
|
178
192
|
}
|
179
|
-
|
180
|
-
return (0, _extends2["default"])({}, topoData, {
|
181
|
-
nodes: [].concat(nodes, ipNodes),
|
182
|
-
links: newLinks,
|
183
|
-
serialize: serialize
|
184
|
-
});
|
185
193
|
} // 从拓扑数据查找
|
186
194
|
|
187
195
|
|
@@ -189,30 +197,10 @@ function findPingNode(nodes, ip) {
|
|
189
197
|
return nodes.find(function (node) {
|
190
198
|
return node.ciType === "ping" && (node.ipAddress || node.attributes.ipv4_address) === ip;
|
191
199
|
});
|
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
|
200
|
+
} // 出口链路目的端设置为IP节点或者ping资源节点id
|
214
201
|
|
215
202
|
|
203
|
+
function updateLinkTarget(links, nodes) {
|
216
204
|
var newLinks = links.map(function (link) {
|
217
205
|
if (!isExitLink(link) || link.target && nodes.find(function (node) {
|
218
206
|
return node.id === link.target;
|
@@ -228,8 +216,38 @@ function processByConditionResult(topoData) {
|
|
228
216
|
target: target
|
229
217
|
});
|
230
218
|
});
|
219
|
+
return newLinks;
|
220
|
+
}
|
221
|
+
/**
|
222
|
+
* 编辑模式按资源查询拓扑数据处理出口链路target
|
223
|
+
* 1. 出口链路目的端设置为IP节点或者ping资源节点id
|
224
|
+
* 2. IP构造为node节点
|
225
|
+
* FIXME 移到frontend 网络拓扑编辑
|
226
|
+
* @param {*} topoData
|
227
|
+
* @returns
|
228
|
+
*/
|
229
|
+
|
230
|
+
|
231
|
+
function processByConditionResult(topoData, groupConfigs) {
|
232
|
+
var nodes = topoData.nodes,
|
233
|
+
links = topoData.links;
|
234
|
+
var ipNodes = getIpNodes(groupConfigs, nodes); // 出口链路目的端设置为IP节点或者ping资源节点id
|
235
|
+
|
236
|
+
var newLinks = updateLinkTarget(links, nodes);
|
231
237
|
return (0, _extends2["default"])({}, topoData, {
|
232
238
|
nodes: [].concat(nodes, ipNodes),
|
233
239
|
links: newLinks
|
234
240
|
});
|
241
|
+
|
242
|
+
function getIpNodes(groupConfigs, nodes) {
|
243
|
+
var ips = groupConfigs.map(function (g) {
|
244
|
+
return g.condition.linkIps;
|
245
|
+
}).reduce(function (result, groupIps) {
|
246
|
+
return [].concat(result, groupIps);
|
247
|
+
}, []) // 过滤ping资源对应的ip节点
|
248
|
+
.filter(function (ip) {
|
249
|
+
return !findPingNode(nodes, ip);
|
250
|
+
});
|
251
|
+
return ips.map(buildIpNode);
|
252
|
+
}
|
235
253
|
}
|
@@ -13,8 +13,6 @@ var _linkUtils = require("../core/models/utils/linkUtils");
|
|
13
13
|
|
14
14
|
var _clusterUtil = require("./clusterUtil");
|
15
15
|
|
16
|
-
var _htElementDataUtil = require("./htElementDataUtil");
|
17
|
-
|
18
16
|
var _htElementUtils = require("./htElementUtils");
|
19
17
|
|
20
18
|
/**
|
@@ -118,7 +116,9 @@ function getLayerDatas(dataModel) {
|
|
118
116
|
name: layerElement.s('label'),
|
119
117
|
order: layerElement.a('order'),
|
120
118
|
resources: {
|
121
|
-
"static": (0,
|
119
|
+
"static": (0, _htElementUtils.getLayerChildren)(layerElement).filter(function (item) {
|
120
|
+
return !!item.getTag();
|
121
|
+
}).map(function (node) {
|
122
122
|
return node.getTag();
|
123
123
|
})
|
124
124
|
}
|
@@ -147,7 +147,7 @@ function getGroupConfigByElement(groupElement) {
|
|
147
147
|
name: groupElement.a('name'),
|
148
148
|
order: groupElement.a('order'),
|
149
149
|
resources: {
|
150
|
-
"static": (0,
|
150
|
+
"static": (0, _htElementUtils.getGroupChildren)(groupElement).filter(function (node) {
|
151
151
|
return !!node.getTag();
|
152
152
|
}).map(function (node) {
|
153
153
|
return node.getTag();
|
@@ -2,8 +2,6 @@
|
|
2
2
|
|
3
3
|
exports.__esModule = true;
|
4
4
|
exports.getAllEdgeResourceIds = void 0;
|
5
|
-
exports.getGroupChildrenResourceElements = getGroupChildrenResourceElements;
|
6
|
-
exports.getLayerChildrenResourceElements = getLayerChildrenResourceElements;
|
7
5
|
exports.isEdge = isEdge;
|
8
6
|
exports.isGroup = isGroup;
|
9
7
|
exports.isLayer = isLayer;
|
@@ -46,14 +44,6 @@ function isResourceNodeElement(element) {
|
|
46
44
|
return (htElementUtils.isGroup(element) || htElementUtils.isNode(element)) && isResourceElement(element);
|
47
45
|
}
|
48
46
|
|
49
|
-
function getGroupChildrenResourceElements(element) {
|
50
|
-
return (0, htElementUtils.getGroupChildren)(element).filter(isResourceElement);
|
51
|
-
}
|
52
|
-
|
53
|
-
function getLayerChildrenResourceElements(layerElement) {
|
54
|
-
return (0, htElementUtils.getLayerChildren)(layerElement).filter(isResourceElement);
|
55
|
-
}
|
56
|
-
|
57
47
|
var getAllEdgeResourceIds = function getAllEdgeResourceIds(dm) {
|
58
48
|
return (0, htElementUtils.getEdges)(dm).filter(function (node) {
|
59
49
|
return !!node.getTag();
|
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.24",
|
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.24/build/index.html",
|
120
120
|
"gitHead": "2da19ffccbb7ca60a8acf396e39f542c68bb33f5"
|
121
121
|
}
|