@riil-frontend/component-topology 12.1.2 → 13.0.0-dev.10

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 (35) hide show
  1. package/build/index.css +1 -1
  2. package/build/index.js +29 -29
  3. package/es/components/ColorPanel/index.js +68 -58
  4. package/es/core/editor/components/Toolbar/widgets/FontColorButton.js +10 -91
  5. package/es/core/editor/components/Toolbar/widgets/components/FontColorDropdown.js +120 -0
  6. package/es/core/editor/components/Toolbar/widgets/components/FontStyleSelect.js +21 -15
  7. package/es/core/hooks/useResourceConfig.js +1 -2
  8. package/es/core/hooks/useTopoEdit.js +2 -1
  9. package/es/core/models/TopoApp.js +1 -1
  10. package/es/core/models/topoData.js +3 -4
  11. package/es/core/models/utils/linkUtils.js +29 -24
  12. package/es/core/viewer/components/plugins/ResourceDetail/components/ResourceOverview/EventsCard.js +4 -2
  13. package/es/networkTopo/services/topo/basic.js +27 -17
  14. package/es/networkTopo/utils/__tests__/relateTopoData.js +205 -0
  15. package/es/networkTopo/utils/exitLinkUtil.js +2 -2
  16. package/es/networkTopo/utils/relateTopoDataUtil.js +149 -0
  17. package/es/utils/ResourceConfigUtil.js +1 -16
  18. package/lib/components/ColorPanel/index.js +71 -59
  19. package/lib/core/editor/components/Toolbar/widgets/FontColorButton.js +11 -95
  20. package/lib/core/editor/components/Toolbar/widgets/components/FontColorDropdown.js +136 -0
  21. package/lib/core/editor/components/Toolbar/widgets/components/FontStyleSelect.js +21 -15
  22. package/lib/core/hooks/useResourceConfig.js +1 -2
  23. package/lib/core/hooks/useTopoEdit.js +2 -1
  24. package/lib/core/models/TopoApp.js +1 -1
  25. package/lib/core/models/topoData.js +3 -4
  26. package/lib/core/models/utils/linkUtils.js +29 -24
  27. package/lib/core/viewer/components/plugins/ResourceDetail/components/ResourceOverview/EventsCard.js +6 -2
  28. package/lib/networkTopo/services/topo/basic.js +32 -18
  29. package/lib/networkTopo/utils/__tests__/relateTopoData.js +210 -0
  30. package/lib/networkTopo/utils/exitLinkUtil.js +2 -2
  31. package/lib/networkTopo/utils/relateTopoDataUtil.js +164 -0
  32. package/lib/utils/ResourceConfigUtil.js +1 -16
  33. package/package.json +2 -2
  34. /package/es/core/editor/components/Toolbar/widgets/{FontColorButton.module.scss → components/FontColorDropdown.module.scss} +0 -0
  35. /package/lib/core/editor/components/Toolbar/widgets/{FontColorButton.module.scss → components/FontColorDropdown.module.scss} +0 -0
@@ -72,38 +72,32 @@ function isAggLink(link) {
72
72
  return (link === null || link === void 0 ? void 0 : (_link$attributes2 = link.attributes) === null || _link$attributes2 === void 0 ? void 0 : _link$attributes2.destination_type) === "network.agg_interface" && (link === null || link === void 0 ? void 0 : (_link$attributes3 = link.attributes) === null || _link$attributes3 === void 0 ? void 0 : _link$attributes3.source_type) === "network.agg_interface";
73
73
  }
74
74
 
75
- function mergeLinksData(links, linkCis, nodes, interfaceCiMap, interfaceDoc) {
75
+ function mergeLinksData(links, linkCis, nodes, ciMap, interfaceDoc) {
76
76
  var linkCiMap = (0, _keyBy["default"])(links, "id");
77
77
  return links.map(function (link) {
78
- var _interfaceCiMap$attri, _interfaceCiMap$attri2;
78
+ var _ciMap$attributes$net, _ciMap$attributes$net2, _ciMap$attributes$sou, _ciMap$attributes$des;
79
79
 
80
80
  var linkCi = linkCiMap[link.id];
81
- var attributes = (0, _extends2["default"])({}, linkCi === null || linkCi === void 0 ? void 0 : linkCi.attributes);
82
- var sourceNode = nodes.find(function (node) {
83
- return node.id === attributes["network_link.source_device_id"];
84
- });
85
- var targetNode = nodes.find(function (node) {
86
- return node.id === attributes["network_link.destination_device_id"];
87
- }); // 翻译
81
+ var attributes = (0, _extends2["default"])({}, linkCi === null || linkCi === void 0 ? void 0 : linkCi.attributes); // 翻译
88
82
 
89
83
  return (0, _extends2["default"])({}, link, {
90
84
  attributes: (0, _extends2["default"])({}, attributes, {
91
85
  // 源/目的设备
92
86
  "network_link.source_device_id_object": {
93
- displayName: sourceNode === null || sourceNode === void 0 ? void 0 : sourceNode.name
87
+ displayName: (_ciMap$attributes$net = ciMap[attributes["network_link.source_device_id"]]) === null || _ciMap$attributes$net === void 0 ? void 0 : _ciMap$attributes$net.attributes["display_name"]
94
88
  },
95
89
  "network_link.destination_device_id_object": {
96
- displayName: targetNode === null || targetNode === void 0 ? void 0 : targetNode.name
90
+ displayName: (_ciMap$attributes$net2 = ciMap[attributes["network_link.destination_device_id"]]) === null || _ciMap$attributes$net2 === void 0 ? void 0 : _ciMap$attributes$net2.attributes["display_name"]
97
91
  },
98
92
  // 源/目的接口类型
99
93
  source_type_object: interfaceDoc[attributes.source_type],
100
94
  destination_type_object: interfaceDoc[attributes.destination_type],
101
95
  // 源/目的接口
102
96
  source_id_object: {
103
- displayName: (_interfaceCiMap$attri = interfaceCiMap[attributes.source_id]) === null || _interfaceCiMap$attri === void 0 ? void 0 : _interfaceCiMap$attri.attributes["display_name"]
97
+ displayName: (_ciMap$attributes$sou = ciMap[attributes.source_id]) === null || _ciMap$attributes$sou === void 0 ? void 0 : _ciMap$attributes$sou.attributes["display_name"]
104
98
  },
105
99
  destination_id_object: {
106
- displayName: (_interfaceCiMap$attri2 = interfaceCiMap[attributes.destination_id]) === null || _interfaceCiMap$attri2 === void 0 ? void 0 : _interfaceCiMap$attri2.attributes["display_name"]
100
+ displayName: (_ciMap$attributes$des = ciMap[attributes.destination_id]) === null || _ciMap$attributes$des === void 0 ? void 0 : _ciMap$attributes$des.attributes["display_name"]
107
101
  }
108
102
  })
109
103
  });
@@ -116,7 +110,7 @@ function getLinksDetail(_x, _x2) {
116
110
 
117
111
  function _getLinksDetail() {
118
112
  _getLinksDetail = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee(links, nodes) {
119
- var linkCis, interfaceIds, interfaceTypes, interfaceCiMap, interfaceDoc;
113
+ var linkCis, ciMap, ciIds, interfaceTypes, loadCiMap, interfaceDoc;
120
114
  return _regenerator["default"].wrap(function _callee$(_context) {
121
115
  while (1) switch (_context.prev = _context.next) {
122
116
  case 0:
@@ -129,11 +123,20 @@ function _getLinksDetail() {
129
123
 
130
124
  case 2:
131
125
  linkCis = links;
132
- interfaceIds = [].concat(linkCis.map(function (item) {
126
+ ciMap = (0, _keyBy["default"])(nodes, "id");
127
+ ciIds = _lodash["default"].uniq([].concat(linkCis.map(function (item) {
128
+ return item.attributes['network_link.destination_device_id'];
129
+ }), linkCis.map(function (item) {
130
+ return item.attributes['network_link.source_device_id'];
131
+ }), linkCis.map(function (item) {
133
132
  return item.attributes.source_id;
134
133
  }), linkCis.map(function (item) {
135
134
  return item.attributes.destination_id;
136
- }));
135
+ }))).filter(function (item) {
136
+ return !!item;
137
+ }).filter(function (item) {
138
+ return !ciMap[item];
139
+ });
137
140
  interfaceTypes = _lodash["default"].compact(_lodash["default"].uniq([].concat(linkCis.map(function (item) {
138
141
  return item.attributes.source_type;
139
142
  }), linkCis.map(function (item) {
@@ -141,19 +144,21 @@ function _getLinksDetail() {
141
144
  })))).filter(function (item) {
142
145
  return item !== "ip";
143
146
  });
144
- _context.next = 7;
145
- return _CiCache["default"].load(interfaceIds);
147
+ _context.next = 8;
148
+ return _CiCache["default"].load(ciIds);
146
149
 
147
- case 7:
148
- interfaceCiMap = _context.sent;
149
- _context.next = 10;
150
+ case 8:
151
+ loadCiMap = _context.sent;
152
+ _context.next = 11;
150
153
  return _CiTypeCache["default"].load(interfaceTypes);
151
154
 
152
- case 10:
155
+ case 11:
153
156
  interfaceDoc = _context.sent;
154
- return _context.abrupt("return", mergeLinksData(links, linkCis, nodes, interfaceCiMap, interfaceDoc));
157
+ Object.assign(ciMap, loadCiMap); // console.log('getLinksDetail-mergeLinksData', { relations, interfaceIds, interfaceCis, })
158
+
159
+ return _context.abrupt("return", mergeLinksData(links, linkCis, nodes, ciMap, interfaceDoc));
155
160
 
156
- case 12:
161
+ case 14:
157
162
  case "end":
158
163
  return _context.stop();
159
164
  }
@@ -29,10 +29,11 @@ var _indexModule = _interopRequireDefault(require("./index.module.scss"));
29
29
 
30
30
  var _componentTopologyUtils = require("@riil-frontend/component-topology-utils");
31
31
 
32
+ var _loglevel = _interopRequireDefault(require("loglevel"));
33
+
32
34
  function formatUrl(url) {
33
35
  var _window, _window$location;
34
36
 
35
- console.log(url);
36
37
  var prefix = '/default/pagecenter';
37
38
 
38
39
  if (((_window = window) === null || _window === void 0 ? void 0 : (_window$location = _window.location) === null || _window$location === void 0 ? void 0 : _window$location.pathname.indexOf(prefix)) === 0 && (url === null || url === void 0 ? void 0 : url.indexOf(prefix)) === 0) {
@@ -47,11 +48,14 @@ function EventsCard(props) {
47
48
  closeDetailDrawer = props.closeDetailDrawer,
48
49
  onHandleAlarm = props.onHandleAlarm;
49
50
 
51
+ var log = _loglevel["default"].getLogger('topo');
52
+
50
53
  var jumpTo = function jumpTo(url) {
51
54
  closeDetailDrawer();
52
55
 
53
56
  if (topo.viewProps.jumpto) {
54
- topo.viewProps.jumpto(formatUrl(url));
57
+ log.debug('formatUrl(url)', url);
58
+ topo.viewProps.jumpto(url);
55
59
  } else {
56
60
  (0, _componentTopologyUtils.getHistory)().push(formatUrl(url));
57
61
  }
@@ -5,8 +5,6 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
5
5
  exports.__esModule = true;
6
6
  exports["default"] = exports.TOPO_PARENT_ID = exports.TOPO_GROUP_ID = void 0;
7
7
 
8
- var _objectWithoutPropertiesLoose2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutPropertiesLoose"));
9
-
10
8
  var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
11
9
 
12
10
  var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
@@ -23,7 +21,12 @@ var _model = require("../model");
23
21
 
24
22
  var _exitLinkUtil = require("../../utils/exitLinkUtil");
25
23
 
26
- var _excluded = ["groups", "resources"];
24
+ var relateTopoDataUtil = _interopRequireWildcard(require("../../utils/relateTopoDataUtil"));
25
+
26
+ function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
27
+
28
+ function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { "default": obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj["default"] = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
29
+
27
30
  var API_ROOT = _constants.TOPO_API_ROOT;
28
31
  /**
29
32
  * 拓扑图(看做一个容器)的“父容器”ID
@@ -66,7 +69,7 @@ function prepareResourceParams(conditions, query) {
66
69
  return {
67
70
  dynamicCondition: dynamicCondition,
68
71
  fixedConditionIdList: (staticRes || []).filter(function (ciId) {
69
- return !ciId.startsWith('ip:');
72
+ return !ciId.includes(':');
70
73
  }),
71
74
  linkIps: (staticRes || []).filter(function (ciId) {
72
75
  return ciId.startsWith('ip:');
@@ -115,7 +118,8 @@ function prepareGroupParams(modifiedGroups) {
115
118
  };
116
119
  }).filter(Boolean);
117
120
  return {
118
- groups: groups
121
+ groups: groups,
122
+ relateTopoIdList: relateTopoDataUtil.getRelateTopoIdListFromConfig(modifiedGroups)
119
123
  };
120
124
  }
121
125
 
@@ -406,16 +410,20 @@ var _default = (0, _extends2["default"])({
406
410
 
407
411
  case 2:
408
412
  result = _context12.sent;
409
- return _context12.abrupt("return", (0, _exitLinkUtil.processExitLink)((0, _extends2["default"])({}, result, {
413
+ result = (0, _extends2["default"])({}, result, {
410
414
  nodes: (_result$nodes = result.nodes) !== null && _result$nodes !== void 0 ? _result$nodes : [],
411
415
  links: ((_result$links = result.links) !== null && _result$links !== void 0 ? _result$links : []).map(function (item) {
412
416
  return (0, _extends2["default"])({}, item, {
413
417
  ciType: 'network_link'
414
418
  });
415
- })
416
- })));
419
+ }),
420
+ serialize: result.serialize ? JSON.parse(result.serialize) : undefined
421
+ });
422
+ result = relateTopoDataUtil.processBothTopoData(result);
423
+ result = (0, _exitLinkUtil.processExitLink)(result);
424
+ return _context12.abrupt("return", result);
417
425
 
418
- case 4:
426
+ case 7:
419
427
  case "end":
420
428
  return _context12.stop();
421
429
  }
@@ -434,7 +442,7 @@ var _default = (0, _extends2["default"])({
434
442
  return (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee13() {
435
443
  var _result$nodes2, _result$links2;
436
444
 
437
- var data, obj, result;
445
+ var data, params, result;
438
446
  return _regenerator["default"].wrap(function _callee13$(_context13) {
439
447
  while (1) switch (_context13.prev = _context13.next) {
440
448
  case 0:
@@ -448,22 +456,28 @@ var _default = (0, _extends2["default"])({
448
456
  });
449
457
  }
450
458
 
451
- obj = prepareGroupParams(data);
459
+ params = prepareGroupParams(data);
452
460
  _context13.next = 5;
453
- return _componentTopologyUtils.request.post(API_ROOT + "/structure/byCondition/" + id, (0, _extends2["default"])({}, obj));
461
+ return _componentTopologyUtils.request.post(API_ROOT + "/structure/byCondition/" + id, params);
454
462
 
455
463
  case 5:
456
464
  result = _context13.sent;
457
- return _context13.abrupt("return", (0, _exitLinkUtil.processByConditionResult)((0, _extends2["default"])({}, result, {
465
+ result = (0, _extends2["default"])({}, result, {
458
466
  nodes: (_result$nodes2 = result.nodes) !== null && _result$nodes2 !== void 0 ? _result$nodes2 : [],
459
467
  links: ((_result$links2 = result.links) !== null && _result$links2 !== void 0 ? _result$links2 : []).map(function (item) {
460
468
  return (0, _extends2["default"])({}, item, {
461
469
  ciType: 'network_link'
462
470
  });
463
471
  })
464
- }), obj.groups));
472
+ });
473
+ result = relateTopoDataUtil.processByConditionTopoData({
474
+ data: result,
475
+ config: data
476
+ });
477
+ result = (0, _exitLinkUtil.processByConditionResult)(result, params.groups);
478
+ return _context13.abrupt("return", result);
465
479
 
466
- case 7:
480
+ case 10:
467
481
  case "end":
468
482
  return _context13.stop();
469
483
  }
@@ -480,11 +494,11 @@ var _default = (0, _extends2["default"])({
480
494
  */
481
495
  bindResourceToTopo: function bindResourceToTopo(id, config) {
482
496
  return (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee14() {
483
- var groups, resources, otherConfig, newGroups, obj;
497
+ var groups, resources, newGroups, obj;
484
498
  return _regenerator["default"].wrap(function _callee14$(_context14) {
485
499
  while (1) switch (_context14.prev = _context14.next) {
486
500
  case 0:
487
- groups = config.groups, resources = config.resources, otherConfig = (0, _objectWithoutPropertiesLoose2["default"])(config, _excluded);
501
+ groups = config.groups, resources = config.resources;
488
502
  newGroups = Array.isArray(groups) ? groups : [];
489
503
 
490
504
  if (resources) {
@@ -498,7 +512,7 @@ var _default = (0, _extends2["default"])({
498
512
 
499
513
  obj = prepareGroupParams(newGroups);
500
514
  _context14.next = 6;
501
- return _componentTopologyUtils.request.post(API_ROOT + "/resource/" + id, (0, _extends2["default"])({}, otherConfig, obj));
515
+ return _componentTopologyUtils.request.post(API_ROOT + "/resource/" + id, obj);
502
516
 
503
517
  case 6:
504
518
  return _context14.abrupt("return", _context14.sent);
@@ -0,0 +1,210 @@
1
+ "use strict";
2
+
3
+ exports.__esModule = true;
4
+ exports.topoLinks = void 0;
5
+ // 二、子拓扑链路
6
+ // - 资源-子拓扑资源
7
+ // - 资源-子拓扑IP、Ping资源
8
+ // - 子拓扑资源-IP、Ping资源
9
+ // - 子拓扑资源-子拓扑资源
10
+ // - 子拓扑资源-子拓扑IP、Ping资源
11
+ var topoLinks = [// 资源-子拓扑资源
12
+ {
13
+ ciType: 'network_link',
14
+ "id": "00000000010decab",
15
+ "name": '资源、Ping资源-子拓扑资源',
16
+ "source": "00000000010de861",
17
+ 'targetType': 'topo',
18
+ "target": "6",
19
+ "operation": "delete",
20
+ "interfaceSource": "00000000010de8da",
21
+ "interfaceTarget": "00000000010de973",
22
+ "attributes": {
23
+ "network_link.to_if_connect": "r926054146526674944",
24
+ "network_link.source_device_ipv4": "172.17.166.18",
25
+ "network_link.destination_ipv4": "172.17.166.20",
26
+ "network_link.work_mode": "single",
27
+ "support_templates": "m.ethernet_link",
28
+ "destination_id": "00000000010de973",
29
+ "rated_bandwidth": 1000,
30
+ "network_link.actual_bandwidth": 1000,
31
+ "source_type": "network.interface",
32
+ "network_link.connect_type": "phy",
33
+ "display_name": "资源-子拓扑资源",
34
+ "asset_status": "2",
35
+ "destination_type": "network.interface",
36
+ "network_link.network_category": "CAN",
37
+ "network_link.source_ipv4": "172.17.166.18",
38
+ "name": "资源-子拓扑资源",
39
+ "distance_outlet": 2147483647,
40
+ "network_link.is_crucial": false,
41
+ "source_id": "00000000010de8da",
42
+ "network_link.source_device_id": "00000000010de861",
43
+ "network_link.destination_device_id": "00000000010de864",
44
+ "network_link.destination_device_ipv4": "172.17.166.20"
45
+ },
46
+ "sourceCode": null,
47
+ "level": null,
48
+ "customType": null,
49
+ "manageStatus": 3
50
+ }, // 资源-子拓扑IP、Ping资源
51
+ {
52
+ ciType: 'network_link',
53
+ "id": "00000000019990f1",
54
+ "name": "资源-子拓扑IP",
55
+ "source": "00000000010de861",
56
+ 'targetType': 'topo',
57
+ "target": "6",
58
+ "operation": "delete",
59
+ "interfaceSource": "00000000010de8b3",
60
+ "interfaceTarget": "",
61
+ "attributes": {
62
+ "network_link.source_device_ipv4": "172.17.166.18",
63
+ "network_link.destination_ipv4": "1.1.1.1",
64
+ "network_link.work_mode": "AandS",
65
+ "support_templates": "m.ethernet_link",
66
+ "rated_bandwidth": 100,
67
+ "network_link.actual_bandwidth": 100,
68
+ "source_type": "network.interface",
69
+ "network_link.connect_type": "phy",
70
+ "display_name": "资源-子拓扑IP",
71
+ "asset_status": "2",
72
+ "network_link_type": "2",
73
+ "destination_type": "ip",
74
+ "network_link.role": "master",
75
+ "network_link.network_category": "CAN",
76
+ "dcs": "331268969",
77
+ "network_link.source_ipv4": "172.17.166.18",
78
+ "name": "资源-子拓扑IP",
79
+ "distance_outlet": 2147483647,
80
+ "network_link.is_crucial": false,
81
+ "source_id": "00000000010de8b3",
82
+ "network_link.source_device_id": "00000000010de861",
83
+ "network_link.destination_device_ipv4": "1.1.1.1"
84
+ },
85
+ "sourceCode": null,
86
+ "level": null,
87
+ "customType": null,
88
+ "manageStatus": 3
89
+ }, // 子拓扑资源-IP、Ping资源
90
+ {
91
+ ciType: 'network_link',
92
+ "id": "0000000001999538",
93
+ "name": "IP-子拓扑资源",
94
+ 'sourceType': 'topo',
95
+ "source": "6",
96
+ "target": "",
97
+ "operation": "delete",
98
+ "interfaceSource": "00000000010de95e",
99
+ "interfaceTarget": "",
100
+ "attributes": {
101
+ "network_link.source_device_ipv4": "172.17.166.20",
102
+ "network_link.destination_ipv4": "1.5.5.5",
103
+ "network_link.work_mode": "AandS",
104
+ "support_templates": "m.ethernet_link",
105
+ "rated_bandwidth": 1000,
106
+ "network_link.actual_bandwidth": 1000,
107
+ "source_type": "network.interface",
108
+ "network_link.connect_type": "phy",
109
+ "display_name": "IP-子拓扑资源",
110
+ "asset_status": "2",
111
+ "network_link_type": "2",
112
+ "destination_type": "ip",
113
+ "network_link.role": "master",
114
+ "network_link.network_category": "CAN",
115
+ "dcs": "331268969",
116
+ "network_link.source_ipv4": "172.17.166.20",
117
+ "name": "172.17.166.20(Gi 0/1) - 1.5.5.5",
118
+ "distance_outlet": 2147483647,
119
+ "network_link.is_crucial": false,
120
+ "source_id": "00000000010de95e",
121
+ "network_link.source_device_id": "00000000010de864",
122
+ "network_link.destination_device_ipv4": "1.5.5.5"
123
+ },
124
+ "sourceCode": null,
125
+ "level": null,
126
+ "customType": null,
127
+ "manageStatus": 3
128
+ }, // 子拓扑资源-子拓扑资源
129
+ {
130
+ ciType: 'network_link',
131
+ "id": "0000000001899476",
132
+ "name": '子拓扑资源-子拓扑资源',
133
+ 'sourceType': 'topo',
134
+ "source": "3",
135
+ 'targetType': 'topo',
136
+ "target": "6",
137
+ "operation": "delete",
138
+ "interfaceSource": "00000000010de90e",
139
+ "interfaceTarget": "00000000010de973",
140
+ "attributes": {
141
+ "network_link.to_if_connect": "r933757920628178944",
142
+ "network_link.source_device_ipv4": "172.17.166.19",
143
+ "network_link.destination_ipv4": "172.17.166.20",
144
+ "network_link.work_mode": "single",
145
+ "support_templates": "m.ethernet_link",
146
+ "destination_id": "00000000010de973",
147
+ "rated_bandwidth": 1000,
148
+ "network_link.actual_bandwidth": 1000,
149
+ "source_type": "network.interface",
150
+ "network_link.connect_type": "phy",
151
+ "display_name": "子拓扑资源-子拓扑资源",
152
+ "asset_status": "2",
153
+ "network_link_type": "2",
154
+ "destination_type": "network.interface",
155
+ "network_link.network_category": "CAN",
156
+ "network_link.source_ipv4": "172.17.166.19",
157
+ "name": "172.17.166.19(Gi 0/50) - 172.17.166.20(Gi 0/22)",
158
+ "distance_outlet": 2147483647,
159
+ "network_link.is_crucial": false,
160
+ "source_id": "00000000010de90e",
161
+ "network_link.source_device_id": "00000000010de862",
162
+ "network_link.destination_device_id": "00000000010de864",
163
+ "network_link.destination_device_ipv4": "172.17.166.20"
164
+ },
165
+ "sourceCode": null,
166
+ "level": null,
167
+ "customType": null,
168
+ "manageStatus": 3
169
+ }, // 子拓扑资源-子拓扑IP、Ping资源
170
+ {
171
+ ciType: 'network_link',
172
+ "id": "0000000001999c86",
173
+ "name": "子拓扑资源-子拓扑IP",
174
+ 'sourceType': 'topo',
175
+ "source": "3",
176
+ 'targetType': 'topo',
177
+ "target": "6",
178
+ "operation": "delete",
179
+ "interfaceSource": "00000000010de95e",
180
+ "interfaceTarget": "",
181
+ "attributes": {
182
+ "network_link.source_device_ipv4": "172.17.166.20",
183
+ "network_link.destination_ipv4": "2.2.2.2",
184
+ "network_link.work_mode": "AandS",
185
+ "support_templates": "m.ethernet_link",
186
+ "rated_bandwidth": 1000,
187
+ "network_link.actual_bandwidth": 1000,
188
+ "source_type": "network.interface",
189
+ "network_link.connect_type": "phy",
190
+ "display_name": "子拓扑资源-子拓扑IP",
191
+ "asset_status": "2",
192
+ "network_link_type": "2",
193
+ "destination_type": "ip",
194
+ "network_link.role": "master",
195
+ "network_link.network_category": "CAN",
196
+ "dcs": "331268969",
197
+ "network_link.source_ipv4": "172.17.166.20",
198
+ "name": "172.17.166.20(Gi 0/1) - 2.2.2.2",
199
+ "distance_outlet": 2147483647,
200
+ "network_link.is_crucial": false,
201
+ "source_id": "00000000010de95e",
202
+ "network_link.source_device_id": "00000000010de864",
203
+ "network_link.destination_device_ipv4": "2.2.2.2"
204
+ },
205
+ "sourceCode": null,
206
+ "level": null,
207
+ "customType": null,
208
+ "manageStatus": 3
209
+ }];
210
+ exports.topoLinks = topoLinks;
@@ -47,11 +47,11 @@ function buildIpNode(ip) {
47
47
  }
48
48
 
49
49
  function getHtSerialize(serialize) {
50
- if (serialize) {
50
+ if (serialize && typeof serialize === 'string') {
51
51
  return JSON.parse(serialize);
52
52
  }
53
53
 
54
- return null;
54
+ return serialize;
55
55
  }
56
56
 
57
57
  function isExitLink(link) {
@@ -0,0 +1,164 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+
5
+ exports.__esModule = true;
6
+ exports.buildTopoNode = buildTopoNode;
7
+ exports.getRelateTopoIdListFromConfig = getRelateTopoIdListFromConfig;
8
+ exports.processBothTopoData = processBothTopoData;
9
+ exports.processByConditionTopoData = processByConditionTopoData;
10
+
11
+ var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
12
+
13
+ var _relateTopoData = require("./__tests__/relateTopoData");
14
+
15
+ // 关联拓扑数据
16
+
17
+ /**
18
+ * 升级历史数据:子拓扑节点序列化数据
19
+ * 构造子拓扑节点
20
+ * 构造子拓扑链路
21
+ * @param {*} ctx
22
+ */
23
+ function processBothTopoData(topoData) {
24
+ var nodes = topoData.nodes,
25
+ links = topoData.links;
26
+ var serialize = upgradeSerializeOldTopoNode(topoData.serialize);
27
+ return (0, _extends2["default"])({}, topoData, {
28
+ nodes: [].concat(nodes, buildTopoNodeDatasFromSerialize(serialize)),
29
+ links: buildTopoLinks(links),
30
+ serialize: serialize
31
+ });
32
+ }
33
+ /**
34
+ * 构造子拓扑节点
35
+ * 构造子拓扑链路
36
+ * @param {*} ctx
37
+ */
38
+
39
+
40
+ function processByConditionTopoData(ctx) {
41
+ var data = ctx.data,
42
+ config = ctx.config;
43
+ var nodes = data.nodes,
44
+ links = data.links;
45
+ return (0, _extends2["default"])({}, data, {
46
+ nodes: [].concat(nodes, buildTopoNodeDatas(config)),
47
+ links: buildTopoLinks(links)
48
+ });
49
+ }
50
+
51
+ function getRelateTopoIdListFromConfig(groups) {
52
+ var relateTopoIdList = [];
53
+ groups.forEach(function (g) {
54
+ g.resources["static"].filter(function (ciId) {
55
+ return ciId.startsWith('topo:');
56
+ }).map(function (ciId) {
57
+ return ciId.replace('topo:', '');
58
+ }).map(function (topoId) {
59
+ if (!relateTopoIdList.includes(topoId)) {
60
+ relateTopoIdList.push(topoId);
61
+ }
62
+ });
63
+ });
64
+ return relateTopoIdList;
65
+ }
66
+
67
+ function buildTopoNode(topoId) {
68
+ return {
69
+ id: "topo:" + topoId,
70
+ // name: ,
71
+ bindType: "topo",
72
+ // 绑定资源类型。关联资源 值为空,关联IP ip
73
+ bindIp: topoId,
74
+ // TODO 所属区域,从序列化拿
75
+ // 'groupId': null,
76
+ // 'groupTag': null,
77
+ // 'attributes': [],
78
+ // 'metrics': [],
79
+ type: "node",
80
+ isbinding: true,
81
+ // 'dtype': 'device'
82
+ operation: "delete"
83
+ };
84
+ }
85
+
86
+ function buildTopoLinks(links) {
87
+ if (process.env.NODE_ENV !== 'production') {
88
+ links.push.apply(links, _relateTopoData.topoLinks);
89
+ }
90
+
91
+ return links.map(function (link) {
92
+ return (0, _extends2["default"])({}, link, {
93
+ "source": link.sourceType ? link.sourceType + ':' + link.source : link.source,
94
+ "target": link.targetType ? link.targetType + ':' + link.target : link.target
95
+ });
96
+ });
97
+ }
98
+ /**
99
+ * 升级历史数据:子拓扑节点序列化数据
100
+ * @param {*} serialize
101
+ */
102
+
103
+
104
+ function upgradeSerializeOldTopoNode(serialize) {
105
+ if (serialize) {
106
+ var isOldTopoNode = function isOldTopoNode(ele) {
107
+ return isTopoNode(ele) && !ele.p.tag;
108
+ };
109
+
110
+ var oldTopoNodes = serialize.d.filter(isOldTopoNode);
111
+ oldTopoNodes.forEach(function (node) {
112
+ var _node$a;
113
+
114
+ var topoId = (_node$a = node.a) === null || _node$a === void 0 ? void 0 : _node$a.bindTopo;
115
+ node.a = (0, _extends2["default"])({}, node.a, buildTopoNode(topoId));
116
+ node.p.tag = "topo:" + topoId;
117
+ });
118
+ }
119
+
120
+ return serialize;
121
+ }
122
+
123
+ function isTopoNode(ele) {
124
+ var _ele$a;
125
+
126
+ return !!((_ele$a = ele.a) !== null && _ele$a !== void 0 && _ele$a.bindTopo);
127
+ }
128
+
129
+ function buildTopoNodeDatasFromSerialize(serialize) {
130
+ if (!serialize) {
131
+ return [];
132
+ }
133
+
134
+ var topoNodes = serialize.d.filter(isTopoNode);
135
+ var topoNodeDatas = topoNodes.map(function (node) {
136
+ var _node$a2;
137
+
138
+ var topoId = (_node$a2 = node.a) === null || _node$a2 === void 0 ? void 0 : _node$a2.bindTopo;
139
+ return buildTopoNode(topoId);
140
+ });
141
+ return topoNodeDatas;
142
+ }
143
+
144
+ function buildTopoNodeDatas(config) {
145
+ var topoNodeDatas = [];
146
+ config.forEach(function (g) {
147
+ g.resources["static"].filter(function (ciId) {
148
+ return ciId.startsWith('topo:');
149
+ }).map(function (ciId) {
150
+ return ciId.replace('topo:', '');
151
+ }).map(function (topoId) {
152
+ topoNodeDatas.push((0, _extends2["default"])({}, buildTopoNode(topoId), {
153
+ // 添加资源拓扑节点消失的问题
154
+ 'groupId': g.id,
155
+ 'groupTag': g.tag
156
+ }));
157
+ });
158
+ });
159
+ return topoNodeDatas;
160
+ }
161
+
162
+ function getRelateTopoIdsFromSerialize(serialize) {
163
+ return serialize;
164
+ }