@riil-frontend/component-topology 9.0.0-a.3 → 9.0.0-a.30

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.
Files changed (103) hide show
  1. package/build/1.js +1 -1
  2. package/build/index.css +1 -1
  3. package/build/index.js +12 -12
  4. package/es/components/VerticalIconTab/VerticalIconTab.module.scss +11 -5
  5. package/es/core/components/TopoView/GraphViewPanel.js +17 -4
  6. package/es/core/components/TopoView/TopoView.module.scss +17 -3
  7. package/es/core/editor/components/BackgroundView/index.module.scss +3 -0
  8. package/es/core/editor/components/Sidebar/Sidebar.module.scss +7 -7
  9. package/es/core/editor/components/Sidebar/views/CanvasPanel/CanvasPanel.js +1 -1
  10. package/es/core/editor/components/Sidebar/views/CanvasPanel/CanvasPanel.module.scss +1 -0
  11. package/es/core/editor/components/Sidebar/views/ComponentPanel.js +1 -1
  12. package/es/core/editor/components/Sidebar/views/ImagePanel/ImagePanel.js +2 -1
  13. package/es/core/editor/components/Sidebar/views/LinkPanel.js +1 -1
  14. package/es/core/editor/components/Toolbar/widgets/EdgeTypeButton/EdgeType.js +21 -5
  15. package/es/core/editor/components/Toolbar/widgets/EdgeTypeButton/EdgeType.module.scss +5 -1
  16. package/es/core/editor/components/Toolbar/widgets/EdgeTypeButton/LineType.js +31 -12
  17. package/es/core/editor/components/Toolbar/widgets/EdgeTypeButton/LineType.module.scss +12 -2
  18. package/es/core/editor/components/Toolbar/widgets/EdgeTypeButton/index.js +6 -0
  19. package/es/core/editor/components/Toolbar/widgets/FontSizeWidget.js +1 -1
  20. package/es/core/editor/components/Toolbar/widgets/components/textStyleSetting/ElementTextStyleSetting/elements/groupTitle.js +1 -1
  21. package/es/core/editor/components/settings/core/updateElementProperty.js +6 -1
  22. package/es/core/editor/components/settings/propertyViews/group/DataTab/hoooks/useGroupRelateResource.js +4 -3
  23. package/es/core/editor/components/settings/propertyViews/node/data/BindIpInput.js +95 -0
  24. package/es/core/editor/components/settings/propertyViews/node/data/Data.js +46 -14
  25. package/es/core/editor/config/themes.js +53 -2
  26. package/es/core/event/topoEventListener.js +22 -0
  27. package/es/core/hooks/useAlarm.js +18 -12
  28. package/es/core/hooks/useCanvasTheme.js +12 -4
  29. package/es/core/hooks/useResourceConfig.js +2 -1
  30. package/es/core/hooks/useTopoEdit.js +97 -19
  31. package/es/core/hooks/useTopoEventListener.js +4 -18
  32. package/es/core/hooks/useTopoFullscreen.js +32 -0
  33. package/es/core/models/Alarm.js +4 -13
  34. package/es/core/models/TopoApp.js +1 -1
  35. package/es/core/models/topoData.js +16 -9
  36. package/es/core/models/utils/linkUtils.js +52 -27
  37. package/es/core/store/models/topoConfig.js +51 -20
  38. package/es/core/test/Test.js +52 -0
  39. package/es/core/viewer/components/plugins/ResourceDetail/components/ResourceOverview/ResourceOverview.js +11 -35
  40. package/es/core/viewer/components/plugins/ResourceDetail/components/ResourceOverview/components/LinkTopo/LinkTopo.js +14 -0
  41. package/es/core/viewer/components/plugins/ResourceDetail/components/ResourceOverview/components/LinkTopo/LinkTopoCard.js +8 -6
  42. package/es/core/viewer/components/plugins/ResourceDetail/components/ResourceOverview/components/LinkTopo/hooks/useMetricPolling.js +28 -56
  43. package/es/core/viewer/components/plugins/ResourceDetail/components/ResourceOverview/components/LinkTopo/services/index.js +57 -1
  44. package/es/core/viewer/components/plugins/ResourceDetail/components/ResourceOverview/hooks/useMetricModels.js +13 -52
  45. package/es/networkTopo/getTopoData.js +2 -1
  46. package/es/networkTopo/models/LinkDynamicStyleExecutor.js +5 -5
  47. package/es/networkTopo/services/link.js +1 -1
  48. package/es/networkTopo/services/topo/basic.js +27 -26
  49. package/es/networkTopo/services/topo/networkLink.js +45 -3
  50. package/es/networkTopo/utils/exitLinkUtil.js +257 -0
  51. package/es/utils/ResourceConfigUtil.js +5 -4
  52. package/es/utils/htElementDataUtil.js +1 -7
  53. package/es/utils/htElementUtils.js +21 -21
  54. package/lib/components/VerticalIconTab/VerticalIconTab.module.scss +11 -5
  55. package/lib/core/components/TopoView/GraphViewPanel.js +18 -3
  56. package/lib/core/components/TopoView/TopoView.module.scss +17 -3
  57. package/lib/core/editor/components/BackgroundView/index.module.scss +3 -0
  58. package/lib/core/editor/components/Sidebar/Sidebar.module.scss +7 -7
  59. package/lib/core/editor/components/Sidebar/views/CanvasPanel/CanvasPanel.js +1 -1
  60. package/lib/core/editor/components/Sidebar/views/CanvasPanel/CanvasPanel.module.scss +1 -0
  61. package/lib/core/editor/components/Sidebar/views/ComponentPanel.js +1 -1
  62. package/lib/core/editor/components/Sidebar/views/ImagePanel/ImagePanel.js +2 -1
  63. package/lib/core/editor/components/Sidebar/views/LinkPanel.js +1 -1
  64. package/lib/core/editor/components/Toolbar/widgets/EdgeTypeButton/EdgeType.js +21 -4
  65. package/lib/core/editor/components/Toolbar/widgets/EdgeTypeButton/EdgeType.module.scss +5 -1
  66. package/lib/core/editor/components/Toolbar/widgets/EdgeTypeButton/LineType.js +31 -12
  67. package/lib/core/editor/components/Toolbar/widgets/EdgeTypeButton/LineType.module.scss +12 -2
  68. package/lib/core/editor/components/Toolbar/widgets/EdgeTypeButton/index.js +6 -0
  69. package/lib/core/editor/components/Toolbar/widgets/FontSizeWidget.js +1 -1
  70. package/lib/core/editor/components/Toolbar/widgets/components/textStyleSetting/ElementTextStyleSetting/elements/groupTitle.js +1 -1
  71. package/lib/core/editor/components/settings/core/updateElementProperty.js +6 -1
  72. package/lib/core/editor/components/settings/propertyViews/group/DataTab/hoooks/useGroupRelateResource.js +3 -3
  73. package/lib/core/editor/components/settings/propertyViews/node/data/BindIpInput.js +111 -0
  74. package/lib/core/editor/components/settings/propertyViews/node/data/Data.js +48 -14
  75. package/lib/core/editor/config/themes.js +53 -2
  76. package/lib/core/event/topoEventListener.js +27 -0
  77. package/lib/core/hooks/useAlarm.js +19 -12
  78. package/lib/core/hooks/useCanvasTheme.js +12 -4
  79. package/lib/core/hooks/useResourceConfig.js +2 -1
  80. package/lib/core/hooks/useTopoEdit.js +98 -18
  81. package/lib/core/hooks/useTopoEventListener.js +3 -17
  82. package/lib/core/hooks/useTopoFullscreen.js +42 -0
  83. package/lib/core/models/Alarm.js +5 -16
  84. package/lib/core/models/TopoApp.js +1 -1
  85. package/lib/core/models/topoData.js +16 -9
  86. package/lib/core/models/utils/linkUtils.js +53 -26
  87. package/lib/core/store/models/topoConfig.js +56 -19
  88. package/lib/core/test/Test.js +52 -0
  89. package/lib/core/viewer/components/plugins/ResourceDetail/components/ResourceOverview/ResourceOverview.js +10 -35
  90. package/lib/core/viewer/components/plugins/ResourceDetail/components/ResourceOverview/components/LinkTopo/LinkTopo.js +14 -0
  91. package/lib/core/viewer/components/plugins/ResourceDetail/components/ResourceOverview/components/LinkTopo/LinkTopoCard.js +8 -6
  92. package/lib/core/viewer/components/plugins/ResourceDetail/components/ResourceOverview/components/LinkTopo/hooks/useMetricPolling.js +28 -55
  93. package/lib/core/viewer/components/plugins/ResourceDetail/components/ResourceOverview/components/LinkTopo/services/index.js +58 -1
  94. package/lib/core/viewer/components/plugins/ResourceDetail/components/ResourceOverview/hooks/useMetricModels.js +13 -53
  95. package/lib/networkTopo/getTopoData.js +2 -1
  96. package/lib/networkTopo/models/LinkDynamicStyleExecutor.js +5 -5
  97. package/lib/networkTopo/services/topo/basic.js +28 -28
  98. package/lib/networkTopo/services/topo/networkLink.js +45 -3
  99. package/lib/networkTopo/utils/exitLinkUtil.js +269 -0
  100. package/lib/utils/ResourceConfigUtil.js +4 -4
  101. package/lib/utils/htElementDataUtil.js +0 -10
  102. package/lib/utils/htElementUtils.js +21 -21
  103. package/package.json +3 -3
@@ -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 7:
104
+ case 8:
104
105
  case "end":
105
106
  return _context.stop();
106
107
  }
@@ -16,15 +16,15 @@ var _linkUtil = require("../utils/linkUtil");
16
16
  // network_link.actual_bandwidth
17
17
  function calcEdgeWidth(actualBandwidth) {
18
18
  if (!actualBandwidth) {
19
- return 2;
19
+ return 3;
20
20
  } else if (actualBandwidth <= 100) {
21
- return 2;
22
- } else if (actualBandwidth <= 1000) {
23
21
  return 3;
24
- } else if (actualBandwidth <= 10000) {
22
+ } else if (actualBandwidth <= 1000) {
25
23
  return 4;
26
- } else if (actualBandwidth > 10000) {
24
+ } else if (actualBandwidth <= 10000) {
27
25
  return 5;
26
+ } else if (actualBandwidth > 10000) {
27
+ return 6;
28
28
  }
29
29
  }
30
30
 
@@ -25,7 +25,9 @@ var _cmdb = require("../cmdb");
25
25
 
26
26
  var _model = require("../model");
27
27
 
28
- var _excluded = ["groups", "resources"];
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: 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,40 +428,33 @@ 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;
424
432
 
433
+ var result;
425
434
  return _regenerator["default"].wrap(function _callee12$(_context12) {
426
435
  while (1) {
427
436
  switch (_context12.prev = _context12.next) {
428
437
  case 0:
429
- _context12.prev = 0;
430
- _context12.next = 3;
438
+ _context12.next = 2;
431
439
  return _componentTopologyUtils.request.get(API_ROOT + "/structure/both/" + id);
432
440
 
433
- case 3:
441
+ case 2:
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
- }));
442
-
443
- case 7:
444
- _context12.prev = 7;
445
- _context12.t0 = _context12["catch"](0);
446
-
447
- _rlog["default"].debug('getTopoData-error', _context12.t0);
450
+ })));
448
451
 
449
- return _context12.abrupt("return", null);
450
-
451
- case 11:
452
+ case 4:
452
453
  case "end":
453
454
  return _context12.stop();
454
455
  }
455
456
  }
456
- }, _callee12, null, [[0, 7]]);
457
+ }, _callee12);
457
458
  }))();
458
459
  },
459
460
 
@@ -464,9 +465,9 @@ var _default = (0, _extends2["default"])({
464
465
  * @param {Array} groups
465
466
  * @returns
466
467
  */
467
- getTopoDataByResource: function getTopoDataByResource(id, resources, groups, exportLinkIdList) {
468
+ getTopoDataByResource: function getTopoDataByResource(id, resources, groups) {
468
469
  return (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee13() {
469
- var _result$links2;
470
+ var _result$nodes2, _result$links2;
470
471
 
471
472
  var data, obj, result;
472
473
  return _regenerator["default"].wrap(function _callee13$(_context13) {
@@ -485,19 +486,18 @@ var _default = (0, _extends2["default"])({
485
486
 
486
487
  obj = prepareGroupParams(data);
487
488
  _context13.next = 5;
488
- return _componentTopologyUtils.request.post(API_ROOT + "/structure/byCondition/" + id, (0, _extends2["default"])({}, obj, {
489
- exportLinkIdList: exportLinkIdList
490
- }));
489
+ return _componentTopologyUtils.request.post(API_ROOT + "/structure/byCondition/" + id, (0, _extends2["default"])({}, obj));
491
490
 
492
491
  case 5:
493
492
  result = _context13.sent;
494
- return _context13.abrupt("return", (0, _extends2["default"])({}, result, {
493
+ return _context13.abrupt("return", (0, _exitLinkUtil.processByConditionResult)((0, _extends2["default"])({}, result, {
494
+ nodes: (_result$nodes2 = result.nodes) !== null && _result$nodes2 !== void 0 ? _result$nodes2 : [],
495
495
  links: ((_result$links2 = result.links) !== null && _result$links2 !== void 0 ? _result$links2 : []).map(function (item) {
496
496
  return (0, _extends2["default"])({}, item, {
497
497
  ciType: 'network_link'
498
498
  });
499
499
  })
500
- }));
500
+ }), obj.groups));
501
501
 
502
502
  case 7:
503
503
  case "end":
@@ -517,12 +517,12 @@ var _default = (0, _extends2["default"])({
517
517
  */
518
518
  bindResourceToTopo: function bindResourceToTopo(id, config) {
519
519
  return (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee14() {
520
- var groups, resources, otherConfig, newGroups, obj;
520
+ var groups, resources, exportLinkIdList, otherConfig, newGroups, obj;
521
521
  return _regenerator["default"].wrap(function _callee14$(_context14) {
522
522
  while (1) {
523
523
  switch (_context14.prev = _context14.next) {
524
524
  case 0:
525
- groups = config.groups, resources = config.resources, otherConfig = (0, _objectWithoutPropertiesLoose2["default"])(config, _excluded);
525
+ groups = config.groups, resources = config.resources, exportLinkIdList = config.exportLinkIdList, otherConfig = (0, _objectWithoutPropertiesLoose2["default"])(config, _excluded);
526
526
  newGroups = isAvailableArray(groups) ? groups : [];
527
527
 
528
528
  if (resources) {
@@ -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,269 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+
5
+ exports.__esModule = true;
6
+ exports.buildIpNode = buildIpNode;
7
+ exports.isUniqueIp = isUniqueIp;
8
+ exports.processByConditionResult = processByConditionResult;
9
+ exports.processExitLink = processExitLink;
10
+
11
+ var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
12
+
13
+ var _htElementUtils = require("../../utils/htElementUtils");
14
+
15
+ function findPingNodeFromHt(nodes, ip) {
16
+ return nodes.find(function (node) {
17
+ return node.a('ciType') === "ping" && node.a('ipAddress') === ip;
18
+ });
19
+ }
20
+
21
+ function isPingHtNode(node, ip) {
22
+ return node.a('ciType') === "ping" && node.a('ipAddress') === ip;
23
+ }
24
+
25
+ function isIpHtNode(node, ip) {
26
+ return node.a("bindType") === 'ip' && node.a("bindIp") === ip;
27
+ }
28
+
29
+ function buildIpNode(ip) {
30
+ return {
31
+ id: "ip:" + ip,
32
+ name: ip,
33
+ bindType: "ip",
34
+ // 绑定资源类型。关联资源 值为空,关联IP ip
35
+ bindIp: ip,
36
+ // TODO 所属区域,从序列化拿
37
+ // 'groupId': null,
38
+ // 'groupTag': null,
39
+ ipAddress: ip,
40
+ // 'attributes': [],
41
+ // 'metrics': [],
42
+ type: "node",
43
+ // 'dtype': 'device'
44
+ operation: "delete"
45
+ };
46
+ }
47
+
48
+ function getHtSerialize(serialize) {
49
+ if (serialize) {
50
+ return JSON.parse(serialize);
51
+ }
52
+
53
+ return null;
54
+ }
55
+
56
+ function isExitLink(link) {
57
+ return link.attributes.destination_type === "ip";
58
+ } // 判断拓扑图上ip是否唯一
59
+
60
+
61
+ function isUniqueIp(dataModel, ip, nodeElement) {
62
+ var nodes = (0, _htElementUtils.getNodes)(dataModel);
63
+ var isUnique = true;
64
+ console.log("nodes-nodeElement", nodes, nodeElement);
65
+
66
+ if (nodeElement) {
67
+ console.log("nodes-nodeElement---filter", nodes.filter(function (node) {
68
+ return node.getId() !== (nodeElement === null || nodeElement === void 0 ? void 0 : nodeElement.getId());
69
+ }));
70
+ var arr = nodes.filter(function (node) {
71
+ return node.getId() !== (nodeElement === null || nodeElement === void 0 ? void 0 : nodeElement.getId());
72
+ }).filter(function (node) {
73
+ return isPingHtNode(node, ip) || isIpHtNode(node, ip);
74
+ });
75
+ isUnique = arr.length === 0;
76
+ console.log("nodes-nodeElement---filter", arr, isUnique);
77
+ } else {
78
+ isUnique = nodes.filter(function (node) {
79
+ return node.a("ipAddress") === ip;
80
+ }).length === 0;
81
+ }
82
+
83
+ return isUnique;
84
+ }
85
+ /**
86
+ * 打开拓扑出口链路处理
87
+ * @param {*} topoData
88
+ * @returns
89
+ */
90
+
91
+
92
+ function processExitLink(topoData) {
93
+ var nodes = topoData.nodes,
94
+ links = topoData.links; // 出口链路目的端设置为IP节点或者ping资源节点id
95
+
96
+ var newLinks = updateLinkTarget(links, nodes);
97
+
98
+ if (!topoData.serialize) {
99
+ return (0, _extends2["default"])({}, topoData, {
100
+ links: newLinks
101
+ });
102
+ }
103
+
104
+ var serialize = (0, _extends2["default"])({}, getHtSerialize(topoData.serialize)); // 历史数据升级
105
+
106
+ links.filter(isExitLink) // 升级V1.4前配置的出口链路目的端节点为IP节点
107
+ .forEach(function (link) {
108
+ return upgradeExitLinkTarget(link, serialize);
109
+ }); // 历史数据适配:同IP节点关联多个不同IP的链路、分级拓扑。target匹配不到元素时,根据序列化匹配
110
+
111
+ newLinks = upgradeLinkTargetNotExisted(links); // IP节点构造为node。如果有相同ip的ping资源和图片节点,图片节点消失(不构造)
112
+
113
+ var ipNodes = getIpNodes(serialize, nodes);
114
+ return (0, _extends2["default"])({}, topoData, {
115
+ nodes: [].concat(nodes, ipNodes),
116
+ links: newLinks,
117
+ serialize: serialize
118
+ }); // 历史数据适配:同IP节点关联多个不同IP的链路、分级拓扑。target匹配不到元素时,根据序列化匹配
119
+
120
+ function upgradeLinkTargetNotExisted(links) {
121
+ newLinks = links.map(function (link) {
122
+ if (!isExitLink(link) || link.target && nodes.find(function (node) {
123
+ return node.id === link.target;
124
+ })) {
125
+ return link;
126
+ }
127
+
128
+ var destinationIp = link.attributes['network_link.destination_ipv4'];
129
+ var pingNode = findPingNode(nodes, destinationIp); // 出口链路目的端设置为IP节点或者ping资源节点id
130
+
131
+ var target = link.target; // 历史数据适配:同IP节点关联多个不同IP的链路、分级拓扑。target匹配不到元素时,根据序列化匹配
132
+
133
+ var targetSerialize = findElementSerializeById(serialize, target);
134
+
135
+ if (!targetSerialize) {
136
+ var linkSerialize = findElementSerializeById(serialize, link.id);
137
+
138
+ if (linkSerialize) {
139
+ // 根据链路序列化数据找目的端节点
140
+ // eslint-disable-next-line no-underscore-dangle
141
+ var targetNodeSerialize = serialize.d.find(function (item) {
142
+ return item.i === linkSerialize.p.target.__i;
143
+ });
144
+
145
+ if (targetNodeSerialize) {
146
+ target = targetNodeSerialize.p.tag;
147
+ }
148
+ }
149
+ }
150
+
151
+ return (0, _extends2["default"])({}, link, {
152
+ target: target
153
+ });
154
+ });
155
+ return newLinks;
156
+ }
157
+
158
+ function getIpNodes(serialize, nodes) {
159
+ // 从序列化获取关联的IP
160
+ var ips = serialize.d.filter(function (item) {
161
+ return item.a.bindType === 'ip';
162
+ }).map(function (item) {
163
+ return item.a.bindIp;
164
+ }).filter(function (item) {
165
+ return !!item;
166
+ }) // 过滤ping资源对应的ip
167
+ .filter(function (ip) {
168
+ return !findPingNode(nodes, ip);
169
+ });
170
+ return ips.map(buildIpNode);
171
+ }
172
+
173
+ function findIpNodeSerialize(serialize, ip) {
174
+ return serialize.d.find(function (item) {
175
+ return item.p.tag === "ip:" + ip;
176
+ });
177
+ }
178
+
179
+ function findElementSerializeById(serialize, id) {
180
+ return serialize.d.find(function (item) {
181
+ return item.a.id === id;
182
+ });
183
+ }
184
+ /**
185
+ * 链路在序列化存在且目的端不是ping资源、IP节点时,升级链路目的端序列化数据为IP节点
186
+ * @param {*} link
187
+ */
188
+
189
+
190
+ function upgradeExitLinkTarget(link, serialize) {
191
+ var destinationIp = link.attributes['network_link.destination_ipv4'];
192
+ var linkSerialize = findElementSerializeById(serialize, link.id);
193
+
194
+ if (linkSerialize) {
195
+ // 根据链路序列化数据找目的端节点
196
+ // eslint-disable-next-line no-underscore-dangle
197
+ var targetNodeSerialize = serialize.d.find(function (item) {
198
+ return item.i === linkSerialize.p.target.__i;
199
+ });
200
+
201
+ if (!targetNodeSerialize.p.tag) {
202
+ targetNodeSerialize.a = (0, _extends2["default"])({}, targetNodeSerialize.a, buildIpNode(destinationIp), {
203
+ isbinding: true
204
+ });
205
+ targetNodeSerialize.p.tag = "ip:" + destinationIp;
206
+ }
207
+ }
208
+ }
209
+ } // 从拓扑数据查找
210
+
211
+
212
+ function findPingNode(nodes, ip) {
213
+ return nodes.find(function (node) {
214
+ return node.ciType === "ping" && (node.ipAddress || node.attributes.ipv4_address) === ip;
215
+ });
216
+ } // 出口链路目的端设置为IP节点或者ping资源节点id
217
+
218
+
219
+ function updateLinkTarget(links, nodes) {
220
+ var newLinks = links.map(function (link) {
221
+ if (!isExitLink(link) || link.target && nodes.find(function (node) {
222
+ return node.id === link.target;
223
+ })) {
224
+ return link;
225
+ }
226
+
227
+ var destinationIp = link.attributes['network_link.destination_ipv4'];
228
+ var pingNode = findPingNode(nodes, destinationIp); // 出口链路目的端设置为IP节点或者ping资源节点id
229
+
230
+ var target = pingNode ? pingNode.id : "ip:" + destinationIp;
231
+ return (0, _extends2["default"])({}, link, {
232
+ target: target
233
+ });
234
+ });
235
+ return newLinks;
236
+ }
237
+ /**
238
+ * 编辑模式按资源查询拓扑数据处理出口链路target
239
+ * 1. 出口链路目的端设置为IP节点或者ping资源节点id
240
+ * 2. IP构造为node节点
241
+ * FIXME 移到frontend 网络拓扑编辑
242
+ * @param {*} topoData
243
+ * @returns
244
+ */
245
+
246
+
247
+ function processByConditionResult(topoData, groupConfigs) {
248
+ var nodes = topoData.nodes,
249
+ links = topoData.links;
250
+ var ipNodes = getIpNodes(groupConfigs, nodes); // 出口链路目的端设置为IP节点或者ping资源节点id
251
+
252
+ var newLinks = updateLinkTarget(links, nodes);
253
+ return (0, _extends2["default"])({}, topoData, {
254
+ nodes: [].concat(nodes, ipNodes),
255
+ links: newLinks
256
+ });
257
+
258
+ function getIpNodes(groupConfigs, nodes) {
259
+ var ips = groupConfigs.map(function (g) {
260
+ return g.condition.linkIps;
261
+ }).reduce(function (result, groupIps) {
262
+ return [].concat(result, groupIps);
263
+ }, []) // 过滤ping资源对应的ip节点
264
+ .filter(function (ip) {
265
+ return !findPingNode(nodes, ip);
266
+ });
267
+ return ips.map(buildIpNode);
268
+ }
269
+ }
@@ -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, _htElementDataUtil.getLayerChildrenResourceElements)(layerElement).map(function (node) {
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, _htElementDataUtil.getGroupChildrenResourceElements)(groupElement).filter(function (node) {
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();