@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
@@ -245,7 +245,7 @@ export function isOpenFlow(_x6) {
245
245
  return _isOpenFlow.apply(this, arguments);
246
246
  }
247
247
  /**
248
- * @name isOpenFlow 查指标值
248
+ * @name queryLastestValue 查指标值
249
249
  * @returns
250
250
  */
251
251
 
@@ -287,4 +287,60 @@ function _queryLastestValue() {
287
287
  }, _callee7);
288
288
  }));
289
289
  return _queryLastestValue.apply(this, arguments);
290
+ }
291
+
292
+ export function queryRetansRatioNetDelayRatio(_x8, _x9) {
293
+ return _queryRetansRatioNetDelayRatio.apply(this, arguments);
294
+ }
295
+
296
+ function _queryRetansRatioNetDelayRatio() {
297
+ _queryRetansRatioNetDelayRatio = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee8(params, retansRatioNetDelayRatioCodes) {
298
+ var result, linkOther;
299
+ return _regeneratorRuntime.wrap(function _callee8$(_context8) {
300
+ while (1) {
301
+ switch (_context8.prev = _context8.next) {
302
+ case 0:
303
+ if (retansRatioNetDelayRatioCodes.length) {
304
+ _context8.next = 2;
305
+ break;
306
+ }
307
+
308
+ return _context8.abrupt("return", []);
309
+
310
+ case 2:
311
+ _context8.next = 4;
312
+ return queryLastestValue(params);
313
+
314
+ case 4:
315
+ result = _context8.sent;
316
+ linkOther = [];
317
+
318
+ if (retansRatioNetDelayRatioCodes.includes('netDelayRatio')) {
319
+ linkOther.push({
320
+ 'code': 'netDelayRatio',
321
+ 'name': 'RTT时延',
322
+ 'ts': result.time,
323
+ 'value': (result.upNetDelayRatio * 1).toFixed(2) + ' ms' + '|' + (result.downNetDelayRatio * 1).toFixed(2) + ' ms'
324
+ });
325
+ }
326
+
327
+ if (retansRatioNetDelayRatioCodes.includes('retansRatio')) {
328
+ linkOther.push({
329
+ 'code': 'retansRatio',
330
+ 'name': '重传率',
331
+ 'ts': result.time,
332
+ 'value': result.upRetransRatio + ' %' + '|' + result.downRetansRatio + ' %'
333
+ });
334
+ }
335
+
336
+ return _context8.abrupt("return", linkOther);
337
+
338
+ case 9:
339
+ case "end":
340
+ return _context8.stop();
341
+ }
342
+ }
343
+ }, _callee8);
344
+ }));
345
+ return _queryRetansRatioNetDelayRatio.apply(this, arguments);
290
346
  }
@@ -3,7 +3,6 @@ import _regeneratorRuntime from "@babel/runtime/regenerator";
3
3
  import { useRequest } from 'ahooks';
4
4
  import { useEffect, useState } from 'react';
5
5
  import { queryCiMonitorMetricCodes } from "../../../getCiDisplayMetricModels";
6
- import { checkMenu, isOpenFlow } from "../components/LinkTopo/services";
7
6
  /**
8
7
  * 概览指标定义
9
8
  * @param {*} props
@@ -35,7 +34,7 @@ var useMetricModels = function useMetricModels(props) {
35
34
 
36
35
  function _fetchData() {
37
36
  _fetchData = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee() {
38
- var monitorMetrics, ciMonitorMetricModels, checkMenus, isOpen, displayMetricModels, _metricCodes;
37
+ var monitorMetrics, ciMonitorMetricModels, displayMetricModels, _metricCodes;
39
38
 
40
39
  return _regeneratorRuntime.wrap(function _callee$(_context) {
41
40
  while (1) {
@@ -51,67 +50,29 @@ var useMetricModels = function useMetricModels(props) {
51
50
  return item === m.code;
52
51
  });
53
52
  });
54
- _context.next = 6;
55
- return checkMenu();
56
53
 
57
- case 6:
58
- checkMenus = _context.sent;
59
-
60
- if (!(checkMenus[0].passed == 'PASS' && resourceData.attributes.display_name && resourceData.attributes['network_link.is_crucial'])) {
61
- _context.next = 12;
62
- break;
63
- }
64
-
65
- _context.next = 10;
66
- return isOpenFlow({
67
- 'name': resourceData.attributes.display_name
68
- });
69
-
70
- case 10:
71
- isOpen = _context.sent;
72
-
73
- //
74
- if (isOpen) {
75
- ciMonitorMetricModels.push({
76
- changeValue: null,
77
- code: "downNetDelayRatio",
78
- id: "downNetDelayRatio",
79
- isGoldMetric: true,
80
- key: null,
81
- name: "下行RTT时延",
82
- unit: "ms"
83
- });
84
- ciMonitorMetricModels.push({
85
- changeValue: null,
86
- code: "downRetansRatio",
87
- id: "downRetansRatio",
88
- isGoldMetric: true,
89
- key: null,
90
- name: "下行重传率",
91
- unit: "%"
92
- });
93
- ciMonitorMetricModels.push({
54
+ if (resourceData.attributes['network_link.is_crucial']) {
55
+ ciMonitorMetricModels.unshift({
94
56
  changeValue: null,
95
- code: "upNetDelayRatio",
96
- id: "upNetDelayRatio",
57
+ code: "netDelayRatio",
58
+ id: "netDelayRatio",
97
59
  isGoldMetric: true,
98
60
  key: null,
99
- name: "上行RTT时延",
61
+ name: "RTT时延",
100
62
  unit: "ms"
101
63
  });
102
- ciMonitorMetricModels.push({
64
+ ciMonitorMetricModels.unshift({
103
65
  changeValue: null,
104
- code: "upRetransRatio",
105
- id: "upRetransRatio",
66
+ code: "retansRatio",
67
+ id: "retansRatio",
106
68
  isGoldMetric: true,
107
69
  key: null,
108
- name: "上行重传率",
70
+ name: "重传率",
109
71
  unit: "%"
110
72
  });
111
- }
73
+ } // 未监控不显示指标,临时在这里处理
74
+
112
75
 
113
- case 12:
114
- // 未监控不显示指标,临时在这里处理
115
76
  if (!isMonite) {
116
77
  ciMonitorMetricModels = [];
117
78
  }
@@ -143,7 +104,7 @@ var useMetricModels = function useMetricModels(props) {
143
104
 
144
105
  return _context.abrupt("return", displayMetricModels);
145
106
 
146
- case 17:
107
+ case 10:
147
108
  case "end":
148
109
  return _context.stop();
149
110
  }
@@ -77,6 +77,7 @@ function _addLinkData() {
77
77
 
78
78
  case 4:
79
79
  networkLinks = _context.sent;
80
+ console.log("如果是网络链路,补充详情信息", networkLinks);
80
81
  otherLinks = links.filter(function (link) {
81
82
  return link.ciType !== 'network_link';
82
83
  });
@@ -85,7 +86,7 @@ function _addLinkData() {
85
86
  linkGroups: []
86
87
  }));
87
88
 
88
- case 7:
89
+ case 8:
89
90
  case "end":
90
91
  return _context.stop();
91
92
  }
@@ -5,15 +5,15 @@ import { getLinksBetweenNodes } from "../utils/linkUtil"; // network_link.actual
5
5
 
6
6
  function calcEdgeWidth(actualBandwidth) {
7
7
  if (!actualBandwidth) {
8
- return 2;
8
+ return 3;
9
9
  } else if (actualBandwidth <= 100) {
10
- return 2;
11
- } else if (actualBandwidth <= 1000) {
12
10
  return 3;
13
- } else if (actualBandwidth <= 10000) {
11
+ } else if (actualBandwidth <= 1000) {
14
12
  return 4;
15
- } else if (actualBandwidth > 10000) {
13
+ } else if (actualBandwidth <= 10000) {
16
14
  return 5;
15
+ } else if (actualBandwidth > 10000) {
16
+ return 6;
17
17
  }
18
18
  }
19
19
 
@@ -1,6 +1,6 @@
1
1
  import _asyncToGenerator from "@babel/runtime/helpers/asyncToGenerator";
2
2
  import _regeneratorRuntime from "@babel/runtime/regenerator";
3
- import { request } from '@riil-frontend/component-topology-utils';
3
+ import { request } from "@riil-frontend/component-topology-utils";
4
4
  import rlog from "@riil-frontend/component-topology-utils/es/rlog";
5
5
  export default {
6
6
  /**
@@ -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: 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,38 +408,33 @@ 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;
405
412
 
413
+ var result;
406
414
  return _regeneratorRuntime.wrap(function _callee12$(_context12) {
407
415
  while (1) {
408
416
  switch (_context12.prev = _context12.next) {
409
417
  case 0:
410
- _context12.prev = 0;
411
- _context12.next = 3;
418
+ _context12.next = 2;
412
419
  return request.get(API_ROOT + "/structure/both/" + id);
413
420
 
414
- case 3:
421
+ case 2:
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
- case 7:
425
- _context12.prev = 7;
426
- _context12.t0 = _context12["catch"](0);
427
- rlog.debug('getTopoData-error', _context12.t0);
428
- return _context12.abrupt("return", null);
429
-
430
- case 11:
432
+ case 4:
431
433
  case "end":
432
434
  return _context12.stop();
433
435
  }
434
436
  }
435
- }, _callee12, null, [[0, 7]]);
437
+ }, _callee12);
436
438
  }))();
437
439
  },
438
440
 
@@ -443,9 +445,9 @@ export default _extends({
443
445
  * @param {Array} groups
444
446
  * @returns
445
447
  */
446
- getTopoDataByResource: function getTopoDataByResource(id, resources, groups, exportLinkIdList) {
448
+ getTopoDataByResource: function getTopoDataByResource(id, resources, groups) {
447
449
  return _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee13() {
448
- var _result$links2;
450
+ var _result$nodes2, _result$links2;
449
451
 
450
452
  var data, obj, result;
451
453
  return _regeneratorRuntime.wrap(function _callee13$(_context13) {
@@ -464,19 +466,18 @@ export default _extends({
464
466
 
465
467
  obj = prepareGroupParams(data);
466
468
  _context13.next = 5;
467
- return request.post(API_ROOT + "/structure/byCondition/" + id, _extends({}, obj, {
468
- exportLinkIdList: exportLinkIdList
469
- }));
469
+ return request.post(API_ROOT + "/structure/byCondition/" + id, _extends({}, obj));
470
470
 
471
471
  case 5:
472
472
  result = _context13.sent;
473
- return _context13.abrupt("return", _extends({}, result, {
473
+ return _context13.abrupt("return", processByConditionResult(_extends({}, result, {
474
+ nodes: (_result$nodes2 = result.nodes) !== null && _result$nodes2 !== void 0 ? _result$nodes2 : [],
474
475
  links: ((_result$links2 = result.links) !== null && _result$links2 !== void 0 ? _result$links2 : []).map(function (item) {
475
476
  return _extends({}, item, {
476
477
  ciType: 'network_link'
477
478
  });
478
479
  })
479
- }));
480
+ }), obj.groups));
480
481
 
481
482
  case 7:
482
483
  case "end":
@@ -496,12 +497,12 @@ export default _extends({
496
497
  */
497
498
  bindResourceToTopo: function bindResourceToTopo(id, config) {
498
499
  return _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee14() {
499
- var groups, resources, otherConfig, newGroups, obj;
500
+ var groups, resources, exportLinkIdList, otherConfig, newGroups, obj;
500
501
  return _regeneratorRuntime.wrap(function _callee14$(_context14) {
501
502
  while (1) {
502
503
  switch (_context14.prev = _context14.next) {
503
504
  case 0:
504
- groups = config.groups, resources = config.resources, otherConfig = _objectWithoutPropertiesLoose(config, _excluded);
505
+ groups = config.groups, resources = config.resources, exportLinkIdList = config.exportLinkIdList, otherConfig = _objectWithoutPropertiesLoose(config, _excluded);
505
506
  newGroups = isAvailableArray(groups) ? groups : [];
506
507
 
507
508
  if (resources) {
@@ -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,257 @@
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("bindIp") === ip;
16
+ }
17
+
18
+ export 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 = true;
53
+ console.log("nodes-nodeElement", nodes, nodeElement);
54
+
55
+ if (nodeElement) {
56
+ console.log("nodes-nodeElement---filter", nodes.filter(function (node) {
57
+ return node.getId() !== (nodeElement === null || nodeElement === void 0 ? void 0 : nodeElement.getId());
58
+ }));
59
+ var arr = nodes.filter(function (node) {
60
+ return node.getId() !== (nodeElement === null || nodeElement === void 0 ? void 0 : nodeElement.getId());
61
+ }).filter(function (node) {
62
+ return isPingHtNode(node, ip) || isIpHtNode(node, ip);
63
+ });
64
+ isUnique = arr.length === 0;
65
+ console.log("nodes-nodeElement---filter", arr, isUnique);
66
+ } else {
67
+ isUnique = nodes.filter(function (node) {
68
+ return node.a("ipAddress") === ip;
69
+ }).length === 0;
70
+ }
71
+
72
+ return isUnique;
73
+ }
74
+ /**
75
+ * 打开拓扑出口链路处理
76
+ * @param {*} topoData
77
+ * @returns
78
+ */
79
+
80
+ export function processExitLink(topoData) {
81
+ var nodes = topoData.nodes,
82
+ links = topoData.links; // 出口链路目的端设置为IP节点或者ping资源节点id
83
+
84
+ var newLinks = updateLinkTarget(links, nodes);
85
+
86
+ if (!topoData.serialize) {
87
+ return _extends({}, topoData, {
88
+ links: newLinks
89
+ });
90
+ }
91
+
92
+ var serialize = _extends({}, getHtSerialize(topoData.serialize)); // 历史数据升级
93
+
94
+
95
+ links.filter(isExitLink) // 升级V1.4前配置的出口链路目的端节点为IP节点
96
+ .forEach(function (link) {
97
+ return upgradeExitLinkTarget(link, serialize);
98
+ }); // 历史数据适配:同IP节点关联多个不同IP的链路、分级拓扑。target匹配不到元素时,根据序列化匹配
99
+
100
+ newLinks = upgradeLinkTargetNotExisted(links); // IP节点构造为node。如果有相同ip的ping资源和图片节点,图片节点消失(不构造)
101
+
102
+ var ipNodes = getIpNodes(serialize, nodes);
103
+ return _extends({}, topoData, {
104
+ nodes: [].concat(nodes, ipNodes),
105
+ links: newLinks,
106
+ serialize: serialize
107
+ }); // 历史数据适配:同IP节点关联多个不同IP的链路、分级拓扑。target匹配不到元素时,根据序列化匹配
108
+
109
+ function upgradeLinkTargetNotExisted(links) {
110
+ newLinks = links.map(function (link) {
111
+ if (!isExitLink(link) || link.target && nodes.find(function (node) {
112
+ return node.id === link.target;
113
+ })) {
114
+ return link;
115
+ }
116
+
117
+ var destinationIp = link.attributes['network_link.destination_ipv4'];
118
+ var pingNode = findPingNode(nodes, destinationIp); // 出口链路目的端设置为IP节点或者ping资源节点id
119
+
120
+ var target = link.target; // 历史数据适配:同IP节点关联多个不同IP的链路、分级拓扑。target匹配不到元素时,根据序列化匹配
121
+
122
+ var targetSerialize = findElementSerializeById(serialize, target);
123
+
124
+ if (!targetSerialize) {
125
+ var linkSerialize = findElementSerializeById(serialize, link.id);
126
+
127
+ if (linkSerialize) {
128
+ // 根据链路序列化数据找目的端节点
129
+ // eslint-disable-next-line no-underscore-dangle
130
+ var targetNodeSerialize = serialize.d.find(function (item) {
131
+ return item.i === linkSerialize.p.target.__i;
132
+ });
133
+
134
+ if (targetNodeSerialize) {
135
+ target = targetNodeSerialize.p.tag;
136
+ }
137
+ }
138
+ }
139
+
140
+ return _extends({}, link, {
141
+ target: target
142
+ });
143
+ });
144
+ return newLinks;
145
+ }
146
+
147
+ function getIpNodes(serialize, nodes) {
148
+ // 从序列化获取关联的IP
149
+ var ips = serialize.d.filter(function (item) {
150
+ return item.a.bindType === 'ip';
151
+ }).map(function (item) {
152
+ return item.a.bindIp;
153
+ }).filter(function (item) {
154
+ return !!item;
155
+ }) // 过滤ping资源对应的ip
156
+ .filter(function (ip) {
157
+ return !findPingNode(nodes, ip);
158
+ });
159
+ return ips.map(buildIpNode);
160
+ }
161
+
162
+ function findIpNodeSerialize(serialize, ip) {
163
+ return serialize.d.find(function (item) {
164
+ return item.p.tag === "ip:" + ip;
165
+ });
166
+ }
167
+
168
+ function findElementSerializeById(serialize, id) {
169
+ return serialize.d.find(function (item) {
170
+ return item.a.id === id;
171
+ });
172
+ }
173
+ /**
174
+ * 链路在序列化存在且目的端不是ping资源、IP节点时,升级链路目的端序列化数据为IP节点
175
+ * @param {*} link
176
+ */
177
+
178
+
179
+ function upgradeExitLinkTarget(link, serialize) {
180
+ var destinationIp = link.attributes['network_link.destination_ipv4'];
181
+ var linkSerialize = findElementSerializeById(serialize, link.id);
182
+
183
+ if (linkSerialize) {
184
+ // 根据链路序列化数据找目的端节点
185
+ // eslint-disable-next-line no-underscore-dangle
186
+ var targetNodeSerialize = serialize.d.find(function (item) {
187
+ return item.i === linkSerialize.p.target.__i;
188
+ });
189
+
190
+ if (!targetNodeSerialize.p.tag) {
191
+ targetNodeSerialize.a = _extends({}, targetNodeSerialize.a, buildIpNode(destinationIp), {
192
+ isbinding: true
193
+ });
194
+ targetNodeSerialize.p.tag = "ip:" + destinationIp;
195
+ }
196
+ }
197
+ }
198
+ } // 从拓扑数据查找
199
+
200
+ function findPingNode(nodes, ip) {
201
+ return nodes.find(function (node) {
202
+ return node.ciType === "ping" && (node.ipAddress || node.attributes.ipv4_address) === ip;
203
+ });
204
+ } // 出口链路目的端设置为IP节点或者ping资源节点id
205
+
206
+
207
+ function updateLinkTarget(links, nodes) {
208
+ var newLinks = links.map(function (link) {
209
+ if (!isExitLink(link) || link.target && nodes.find(function (node) {
210
+ return node.id === link.target;
211
+ })) {
212
+ return link;
213
+ }
214
+
215
+ var destinationIp = link.attributes['network_link.destination_ipv4'];
216
+ var pingNode = findPingNode(nodes, destinationIp); // 出口链路目的端设置为IP节点或者ping资源节点id
217
+
218
+ var target = pingNode ? pingNode.id : "ip:" + destinationIp;
219
+ return _extends({}, link, {
220
+ target: target
221
+ });
222
+ });
223
+ return newLinks;
224
+ }
225
+ /**
226
+ * 编辑模式按资源查询拓扑数据处理出口链路target
227
+ * 1. 出口链路目的端设置为IP节点或者ping资源节点id
228
+ * 2. IP构造为node节点
229
+ * FIXME 移到frontend 网络拓扑编辑
230
+ * @param {*} topoData
231
+ * @returns
232
+ */
233
+
234
+
235
+ export function processByConditionResult(topoData, groupConfigs) {
236
+ var nodes = topoData.nodes,
237
+ links = topoData.links;
238
+ var ipNodes = getIpNodes(groupConfigs, nodes); // 出口链路目的端设置为IP节点或者ping资源节点id
239
+
240
+ var newLinks = updateLinkTarget(links, nodes);
241
+ return _extends({}, topoData, {
242
+ nodes: [].concat(nodes, ipNodes),
243
+ links: newLinks
244
+ });
245
+
246
+ function getIpNodes(groupConfigs, nodes) {
247
+ var ips = groupConfigs.map(function (g) {
248
+ return g.condition.linkIps;
249
+ }).reduce(function (result, groupIps) {
250
+ return [].concat(result, groupIps);
251
+ }, []) // 过滤ping资源对应的ip节点
252
+ .filter(function (ip) {
253
+ return !findPingNode(nodes, ip);
254
+ });
255
+ return ips.map(buildIpNode);
256
+ }
257
+ }