@riil-frontend/component-topology 9.0.0-a.2 → 9.0.0-a.20

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 (55) hide show
  1. package/build/index.css +1 -1
  2. package/build/index.js +2 -2
  3. package/es/components/VerticalIconTab/VerticalIconTab.module.scss +11 -5
  4. package/es/core/components/TopoView/GraphViewPanel.js +3 -2
  5. package/es/core/editor/components/BackgroundView/index.module.scss +3 -0
  6. package/es/core/editor/components/Sidebar/Sidebar.module.scss +7 -7
  7. package/es/core/editor/components/Sidebar/views/CanvasPanel/CanvasPanel.js +1 -1
  8. package/es/core/editor/components/Sidebar/views/CanvasPanel/CanvasPanel.module.scss +1 -0
  9. package/es/core/editor/components/Sidebar/views/ComponentPanel.js +1 -1
  10. package/es/core/editor/components/Sidebar/views/ImagePanel/ImagePanel.js +2 -1
  11. package/es/core/editor/components/Sidebar/views/LinkPanel.js +1 -1
  12. package/es/core/editor/config/themes.js +53 -2
  13. package/es/core/event/topoEventListener.js +22 -0
  14. package/es/core/hooks/useAlarm.js +18 -12
  15. package/es/core/hooks/useCanvasTheme.js +8 -1
  16. package/es/core/hooks/useTopoEventListener.js +4 -18
  17. package/es/core/models/Alarm.js +4 -13
  18. package/es/core/models/TopoApp.js +1 -1
  19. package/es/core/store/models/viewer/resourceDetail.js +7 -0
  20. package/es/core/test/Test.js +52 -0
  21. package/es/core/viewer/components/plugins/ResourceDetail/ResourceDetailDrawer.js +10 -9
  22. package/es/core/viewer/components/plugins/ResourceDetail/components/ResourceOverview/ResourceOverview.js +11 -35
  23. package/es/core/viewer/components/plugins/ResourceDetail/components/ResourceOverview/components/LinkTopo/LinkTopo.js +14 -0
  24. package/es/core/viewer/components/plugins/ResourceDetail/components/ResourceOverview/components/LinkTopo/LinkTopoCard.js +8 -6
  25. package/es/core/viewer/components/plugins/ResourceDetail/components/ResourceOverview/components/LinkTopo/hooks/useMetricPolling.js +28 -56
  26. package/es/core/viewer/components/plugins/ResourceDetail/components/ResourceOverview/components/LinkTopo/services/index.js +57 -1
  27. package/es/core/viewer/components/plugins/ResourceDetail/components/ResourceOverview/hooks/useMetricModels.js +13 -52
  28. package/es/networkTopo/models/LinkDynamicStyleExecutor.js +5 -5
  29. package/lib/components/VerticalIconTab/VerticalIconTab.module.scss +11 -5
  30. package/lib/core/components/TopoView/GraphViewPanel.js +3 -2
  31. package/lib/core/editor/components/BackgroundView/index.module.scss +3 -0
  32. package/lib/core/editor/components/Sidebar/Sidebar.module.scss +7 -7
  33. package/lib/core/editor/components/Sidebar/views/CanvasPanel/CanvasPanel.js +1 -1
  34. package/lib/core/editor/components/Sidebar/views/CanvasPanel/CanvasPanel.module.scss +1 -0
  35. package/lib/core/editor/components/Sidebar/views/ComponentPanel.js +1 -1
  36. package/lib/core/editor/components/Sidebar/views/ImagePanel/ImagePanel.js +2 -1
  37. package/lib/core/editor/components/Sidebar/views/LinkPanel.js +1 -1
  38. package/lib/core/editor/config/themes.js +53 -2
  39. package/lib/core/event/topoEventListener.js +27 -0
  40. package/lib/core/hooks/useAlarm.js +19 -12
  41. package/lib/core/hooks/useCanvasTheme.js +8 -1
  42. package/lib/core/hooks/useTopoEventListener.js +3 -17
  43. package/lib/core/models/Alarm.js +5 -16
  44. package/lib/core/models/TopoApp.js +1 -1
  45. package/lib/core/store/models/viewer/resourceDetail.js +7 -0
  46. package/lib/core/test/Test.js +52 -0
  47. package/lib/core/viewer/components/plugins/ResourceDetail/ResourceDetailDrawer.js +10 -9
  48. package/lib/core/viewer/components/plugins/ResourceDetail/components/ResourceOverview/ResourceOverview.js +10 -35
  49. package/lib/core/viewer/components/plugins/ResourceDetail/components/ResourceOverview/components/LinkTopo/LinkTopo.js +14 -0
  50. package/lib/core/viewer/components/plugins/ResourceDetail/components/ResourceOverview/components/LinkTopo/LinkTopoCard.js +8 -6
  51. package/lib/core/viewer/components/plugins/ResourceDetail/components/ResourceOverview/components/LinkTopo/hooks/useMetricPolling.js +28 -55
  52. package/lib/core/viewer/components/plugins/ResourceDetail/components/ResourceOverview/components/LinkTopo/services/index.js +58 -1
  53. package/lib/core/viewer/components/plugins/ResourceDetail/components/ResourceOverview/hooks/useMetricModels.js +13 -53
  54. package/lib/networkTopo/models/LinkDynamicStyleExecutor.js +5 -5
  55. package/package.json +3 -3
@@ -36,6 +36,11 @@ var themeMap = [{
36
36
  label: '深色',
37
37
  color: '#031425',
38
38
  toolsTheme: 'black'
39
+ }, {
40
+ name: 'poly',
41
+ label: 'Poly',
42
+ toolsTheme: 'black',
43
+ backgroundImage: '/img/topo/themes/poly.png'
39
44
  }].reduce(function (map, item) {
40
45
  var _extends2;
41
46
 
@@ -52,6 +57,7 @@ function useCanvasTheme(props) {
52
57
 
53
58
  var themeConfig = themeMap[themeName || 'white'];
54
59
  var canvasColor = hideBackgroundColor ? null : themeConfig.color;
60
+ var canvasbackgroundImage = hideBackgroundColor ? null : themeConfig.backgroundImage;
55
61
  (0, _react.useEffect)(function () {
56
62
  // 设置
57
63
  if (graphLoaded && themeConfig) {
@@ -74,6 +80,7 @@ function useCanvasTheme(props) {
74
80
  }
75
81
  }, [graphLoaded, canvasColor]);
76
82
  return {
77
- canvasColor: canvasColor
83
+ canvasColor: canvasColor,
84
+ canvasbackgroundImage: canvasbackgroundImage
78
85
  };
79
86
  }
@@ -5,29 +5,15 @@ exports["default"] = useTopoEventListener;
5
5
 
6
6
  var _react = require("react");
7
7
 
8
- var n = 0;
8
+ var _topoEventListener = require("../event/topoEventListener");
9
9
 
10
10
  function useTopoEventListener(props) {
11
11
  var type = props.type,
12
12
  onMessage = props.onMessage;
13
- var eventListenerName = (0, _react.useMemo)(function () {
14
- return "topo_" + n++;
15
- }, []);
16
13
  (0, _react.useEffect)(function () {
17
- var EE = window.EE;
18
-
19
- if (EE) {
20
- window.EE.on('topo', eventListenerName, function (data) {
21
- if (data.type === type) {
22
- onMessage(data.data);
23
- }
24
- });
25
- }
26
-
14
+ var listener = (0, _topoEventListener.createTopoEventListener)(type, onMessage);
27
15
  return function () {
28
- if (EE) {
29
- window.EE.removeListener('topo', eventListenerName);
30
- }
16
+ listener.close();
31
17
  };
32
18
  }, [type, onMessage]);
33
19
  }
@@ -19,8 +19,8 @@ var _componentRiilEventEmitter = require("@riil-frontend/component-riil-event-em
19
19
 
20
20
  var _utils = require("@riil-frontend/utils");
21
21
 
22
- // import moment from "moment";
23
- // import { alarmListDemo } from "./mocks";
22
+ var _topoEventListener = require("../event/topoEventListener");
23
+
24
24
  var Alarm = /*#__PURE__*/function () {
25
25
  function Alarm() {
26
26
  this.topo = void 0;
@@ -394,8 +394,6 @@ var Alarm = /*#__PURE__*/function () {
394
394
  /*#__PURE__*/
395
395
  function () {
396
396
  var _openTopoAlarm = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee6(id) {
397
- var _this2 = this;
398
-
399
397
  var _this$getState2, alarmOpening, topoAlarmIsOpen, alarmDispatchers;
400
398
 
401
399
  return _regenerator["default"].wrap(function _callee6$(_context6) {
@@ -427,20 +425,13 @@ var Alarm = /*#__PURE__*/function () {
427
425
 
428
426
  case 10:
429
427
  this.secretKey = _context6.sent;
430
-
431
428
  // rlog.debug("openTopoAlarm 获取初始化告警-------------------开始");
432
- _componentRiilEventEmitter.EE.on("topo", "topo", function (data, other) {
433
- _rlog["default"].debug("openTopoAlarm 获取初始化告警------收到信息", data);
434
-
435
- _this2.handleAlarmEvent(data);
436
- });
437
-
438
429
  this.updateState({
439
430
  alarmOpening: false,
440
431
  alarmIsOpened: true
441
432
  });
442
433
 
443
- case 13:
434
+ case 12:
444
435
  case "end":
445
436
  return _context6.stop();
446
437
  }
@@ -486,17 +477,15 @@ var Alarm = /*#__PURE__*/function () {
486
477
 
487
478
  _rlog["default"].debug("useAlarm.useEffect 告警WebSocket 结束");
488
479
 
489
- _componentRiilEventEmitter.EE.removeListener("topo", "topo");
490
-
491
480
  this.updateState({
492
481
  topoAlarmIsOpen: false,
493
482
  alarmOpening: false,
494
483
  alarmPanelIsOpen: false
495
484
  });
496
- _context7.next = 9;
485
+ _context7.next = 8;
497
486
  return this.topo.serverApi.closeTopoAlarm(id, this.secretKey);
498
487
 
499
- case 9:
488
+ case 8:
500
489
  case "end":
501
490
  return _context7.stop();
502
491
  }
@@ -56,7 +56,7 @@ var _SelectionModel = _interopRequireDefault(require("./SelectionModel"));
56
56
  var _CiCache = _interopRequireDefault(require("./cache/CiCache"));
57
57
 
58
58
  // eslint-disable-next-line no-undef
59
- var version = typeof "9.0.0-a.2" === 'string' ? "9.0.0-a.2" : null;
59
+ var version = typeof "9.0.0-a.20" === 'string' ? "9.0.0-a.20" : null;
60
60
  console.info("\u62D3\u6251\u7248\u672C: " + version);
61
61
  /**
62
62
  * 拓扑显示和编辑
@@ -29,6 +29,13 @@ var _default = {
29
29
  visible: false,
30
30
  id: null // 资源id
31
31
 
32
+ };
33
+ },
34
+ close: function close() {
35
+ return {
36
+ visible: false,
37
+ id: null // 资源id
38
+
32
39
  };
33
40
  }
34
41
  },
@@ -27,6 +27,58 @@ var Test = /*#__PURE__*/function () {
27
27
  _proto.onReady = function onReady() {// TODO 待移除测试代码
28
28
  // this.iconManage.openUpload()
29
29
  // this.topo.store.getModelDispatchers('linkDynamicStyleConfig').open({type: 'networkLink'});
30
+ }
31
+ /**
32
+ * 关联IP示例代码
33
+ */
34
+ ;
35
+
36
+ _proto.createExportLink = function createExportLink() {
37
+ var htTopo = this.topo.getHtTopo();
38
+ var dm = htTopo.getGraphView().dm(); // 设置节点关联IP
39
+
40
+ var nodeElement = htTopo.getGraphView().sm().fd();
41
+ var ip = {
42
+ 'id': 'ip_1.1.1.1',
43
+ 'name': '1.1.1.1',
44
+ customName: null,
45
+ // 'groupId': null,
46
+ // 'groupTag': null,
47
+ 'ipAddress': '1.1.1.1',
48
+ // 'attributes': [],
49
+ // 'metrics': [],
50
+ 'type': 'node' // 'dtype': 'device'
51
+
52
+ };
53
+ nodeElement.a(ip);
54
+ nodeElement.setTag('ip_1.1.1.1');
55
+ var link = {
56
+ 'id': '0000000019b462d1',
57
+ 'name': '172.17.160.116(Gi2/2/0/1) - 172.27.130.13(Gi 0/9)',
58
+ 'source': '00000000029f9411',
59
+ 'target': 'ip_1.1.1.1',
60
+ 'operation': 'delete',
61
+ 'interfaceSource': '0000000018080aee',
62
+ 'interfaceTarget': '000000000341b015',
63
+ 'ciType': 'network_link',
64
+ 'attributes': [],
65
+ 'manageStatus': 0,
66
+ 'permission': {
67
+ 'readable': true,
68
+ 'writeable': true,
69
+ 'deleteable': true
70
+ },
71
+ 'metrics': [],
72
+ 'type': 'link',
73
+ 'dtype': 'link'
74
+ };
75
+ var createElementsData = {
76
+ groups: [],
77
+ nodes: [],
78
+ links: [link],
79
+ linkGroups: []
80
+ };
81
+ htTopo.createElements(createElementsData);
30
82
  };
31
83
 
32
84
  return Test;
@@ -98,9 +98,7 @@ function ResourceDetailDrawer(props) {
98
98
  }, []); // 解决切换拓扑图隐藏概览
99
99
 
100
100
  (0, _react.useEffect)(function () {
101
- resourceDetailDispatchers.update({
102
- visible: false
103
- }); // TODO 其他数据重置
101
+ close(); // TODO 其他数据重置
104
102
  }, [topoId]);
105
103
 
106
104
  function getUser() {
@@ -176,6 +174,12 @@ function ResourceDetailDrawer(props) {
176
174
  }
177
175
  }
178
176
 
177
+ function close() {
178
+ resourceDetailDispatchers.update({
179
+ visible: false
180
+ });
181
+ }
182
+
179
183
  function init(data, targetType) {
180
184
  // console.log('初始化基本信息', data, targetType);
181
185
  var id = data.id,
@@ -236,7 +240,8 @@ function ResourceDetailDrawer(props) {
236
240
  topo: topo,
237
241
  userId: userId,
238
242
  activeData: activeData,
239
- resourceData: resourceData
243
+ resourceData: resourceData,
244
+ onClose: close
240
245
  }));
241
246
  };
242
247
 
@@ -250,11 +255,7 @@ function ResourceDetailDrawer(props) {
250
255
  })),
251
256
  width: 580,
252
257
  hasMask: false,
253
- onClose: function onClose() {
254
- return resourceDetailDispatchers.update({
255
- visible: false
256
- });
257
- }
258
+ onClose: close
258
259
  }, visible && resourceData && renderContent()));
259
260
  }
260
261
 
@@ -53,8 +53,6 @@ var _LinkTopoCard = _interopRequireDefault(require("./components/LinkTopo/LinkTo
53
53
 
54
54
  var _EventsCard = _interopRequireDefault(require("./EventsCard"));
55
55
 
56
- var _services2 = require("./components/LinkTopo/services");
57
-
58
56
  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); }
59
57
 
60
58
  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; }
@@ -726,7 +724,7 @@ function ResourceOverview(props) {
726
724
  _metricColChange = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee8(col) {
727
725
  var _col2, _col3;
728
726
 
729
- var codes, endTime, params, _ref5, times, metricList, newMetricList, metricLists;
727
+ var codes, endTime, params, _ref5, times, metricList, metricLists;
730
728
 
731
729
  return _regenerator["default"].wrap(function _callee8$(_context8) {
732
730
  while (1) {
@@ -774,14 +772,7 @@ function ResourceOverview(props) {
774
772
 
775
773
  case 11:
776
774
  metricList = _context8.sent;
777
- _context8.next = 14;
778
- return (0, _services2.queryLastestValue)({
779
- 'id': data.attributes.name
780
- });
781
-
782
- case 14:
783
- newMetricList = _context8.sent;
784
- metricLists = metricList.concat(getNewMetricList(newMetricList));
775
+ metricLists = metricList.concat(getNewMetricList());
785
776
 
786
777
  _rlog.rlog.debug('metricColChange', metricLists, monitorMetricModels);
787
778
 
@@ -809,7 +800,7 @@ function ResourceOverview(props) {
809
800
  }, 60000);
810
801
  }
811
802
 
812
- case 20:
803
+ case 17:
813
804
  case "end":
814
805
  return _context8.stop();
815
806
  }
@@ -819,36 +810,20 @@ function ResourceOverview(props) {
819
810
  return _metricColChange.apply(this, arguments);
820
811
  }
821
812
 
822
- var getNewMetricList = function getNewMetricList(data) {
813
+ var getNewMetricList = function getNewMetricList() {
823
814
  return [{
824
815
  errorMsg: null,
825
- mainCiId: "downNetDelayRatio",
826
- metricCode: "downNetDelayRatio",
827
- metricValue: data.downNetDelayRatio,
828
- subCiId: '',
829
- subCiType: null,
830
- mainCiType: null
831
- }, {
832
- errorMsg: null,
833
- mainCiId: "downRetansRatio",
834
- metricCode: "downRetansRatio",
835
- metricValue: data.downRetansRatio,
836
- subCiId: '',
837
- subCiType: null,
838
- mainCiType: null
839
- }, {
840
- errorMsg: null,
841
- mainCiId: "upNetDelayRatio",
842
- metricCode: "upNetDelayRatio",
843
- metricValue: data.upNetDelayRatio,
816
+ mainCiId: "netDelayRatio",
817
+ metricCode: "netDelayRatio",
818
+ metricValue: '0',
844
819
  subCiId: '',
845
820
  subCiType: null,
846
821
  mainCiType: null
847
822
  }, {
848
823
  errorMsg: null,
849
- mainCiId: "upRetransRatio",
850
- metricCode: "upRetransRatio",
851
- metricValue: data.upRetransRatio,
824
+ mainCiId: "retansRatio",
825
+ metricCode: "retansRatio",
826
+ metricValue: '0',
852
827
  subCiId: '',
853
828
  subCiType: null,
854
829
  mainCiType: null
@@ -25,6 +25,20 @@ function LinkTopo(props) {
25
25
  linkCi: data,
26
26
  linkMetricCodes: linkMetricCodes
27
27
  });
28
+ var linkMetrics = [].concat(metricData.linkMetrics, metricData.linkOther);
29
+ var linkMetricsList = [];
30
+
31
+ if (linkMetrics.length > 0) {
32
+ linkMetricCodes.forEach(function (e) {
33
+ var linkMetricsData = linkMetrics.filter(function (i) {
34
+ return e == i.code;
35
+ });
36
+ if (linkMetricsData.length > 0) linkMetricsList.push(linkMetricsData[0]);
37
+ });
38
+ metricData.linkMetrics = linkMetricsList;
39
+ metricData.linkOther = [];
40
+ }
41
+
28
42
  return /*#__PURE__*/_react["default"].createElement("div", {
29
43
  className: _LinkTopoModule["default"].container
30
44
  }, /*#__PURE__*/_react["default"].createElement(_componentCrucialLinkTopo["default"], (0, _extends2["default"])({
@@ -35,9 +35,9 @@ function LinkTopoCard(props) {
35
35
 
36
36
  var supportTemplates = (data === null || data === void 0 ? void 0 : (_data$attributes = data.attributes) === null || _data$attributes === void 0 ? void 0 : _data$attributes.support_templates) || ''; // 该资源监控模板
37
37
 
38
- var isCrucial = data === null || data === void 0 ? void 0 : data.attributes['network_link.is_crucial'];
38
+ var isCrucial = data === null || data === void 0 ? void 0 : data.attributes['network_link.is_crucial']; //是不是关键链路
39
39
 
40
- var _useState = (0, _react.useState)(-1),
40
+ var _useState = (0, _react.useState)(null),
41
41
  openFlow = _useState[0],
42
42
  setOpenFlow = _useState[1];
43
43
 
@@ -57,7 +57,7 @@ function LinkTopoCard(props) {
57
57
  case 2:
58
58
  checkMenus = _context.sent;
59
59
 
60
- if (!(checkMenus[0].passed == 'PASS')) {
60
+ if (!(checkMenus[0].passed == 'PASS' && isCrucial)) {
61
61
  _context.next = 10;
62
62
  break;
63
63
  }
@@ -73,12 +73,12 @@ function LinkTopoCard(props) {
73
73
  //判断是不是有流量分析
74
74
  if (isOpen) {
75
75
  setOpenFlow({
76
- name: '跳转关键链路详情',
76
+ name: '查看流量构成',
77
77
  url: linkDetailsUrl
78
78
  });
79
79
  } else {
80
80
  setOpenFlow({
81
- name: '跳转流量分析配置',
81
+ name: '配置流量分析',
82
82
  url: analysisUrl
83
83
  });
84
84
  }
@@ -119,7 +119,9 @@ function LinkTopoCard(props) {
119
119
  })
120
120
  }, /*#__PURE__*/_react["default"].createElement(_LinkTopo["default"], {
121
121
  data: data,
122
- linkMetricCodes: metricCodes,
122
+ linkMetricCodes: openFlow && openFlow.name == '查看流量构成' ? metricCodes : metricCodes.filter(function (i) {
123
+ return i != 'netDelayRatio' && i != 'retansRatio';
124
+ }),
123
125
  openFlow: openFlow
124
126
  }));
125
127
  }
@@ -24,11 +24,11 @@ function useMetricPolling(_ref) {
24
24
  var linkCi = _ref.linkCi,
25
25
  linkMetricCodes = _ref.linkMetricCodes;
26
26
  var linkId = linkCi.id;
27
- var arr = ['downNetDelayRatio', 'downRetansRatio', 'upNetDelayRatio', 'upRetransRatio'];
28
- var oldCodes = [];
29
- var newCodes = [];
27
+ var arr = ['netDelayRatio', 'retansRatio'];
28
+ var codes = [];
29
+ var retansRatioNetDelayRatioCodes = [];
30
30
  linkMetricCodes.map(function (item) {
31
- arr.indexOf(item) > -1 ? newCodes.push(item) : oldCodes.push(item);
31
+ arr.indexOf(item) > -1 ? retansRatioNetDelayRatioCodes.push(item) : codes.push(item);
32
32
  });
33
33
 
34
34
  var _useState = (0, _react.useState)({
@@ -42,53 +42,15 @@ function useMetricPolling(_ref) {
42
42
  data = _useState[0],
43
43
  setData = _useState[1];
44
44
 
45
- var queryLastestValues = (0, _ahooks.useRequest)(_services.queryLastestValue, {
45
+ var queryLastestValues = (0, _ahooks.useRequest)(_services.queryRetansRatioNetDelayRatio, {
46
46
  pollingInterval: 1000 * 15,
47
47
  pollingWhenHidden: false,
48
48
  debounceInterval: 200,
49
49
  manual: true,
50
50
  onSuccess: function onSuccess(result) {
51
- var datas = {
52
- linkOther: []
53
- };
54
-
55
- if (newCodes.includes('downNetDelayRatio')) {
56
- datas.linkOther.push({
57
- 'code': 'downNetDelayRatio',
58
- 'name': '下行RTT时延',
59
- 'ts': result.time,
60
- 'value': result.downNetDelayRatio + ' ms'
61
- });
62
- }
63
-
64
- if (newCodes.includes('downRetansRatio')) {
65
- datas.linkOther.push({
66
- 'code': 'downRetansRatio',
67
- 'name': '下行重传率',
68
- 'ts': result.time,
69
- 'value': result.downRetansRatio + ' %'
70
- });
71
- }
72
-
73
- if (newCodes.includes('upNetDelayRatio')) {
74
- datas.linkOther.push({
75
- 'code': 'upNetDelayRatio',
76
- 'name': '上行RTT时延',
77
- 'ts': result.time,
78
- 'value': result.upNetDelayRatio + ' ms'
79
- });
80
- }
81
-
82
- if (newCodes.includes('upRetransRatio')) {
83
- datas.linkOther.push({
84
- 'code': 'upRetransRatio',
85
- 'name': '上行重传率',
86
- 'ts': result.time,
87
- 'value': result.upRetransRatio + ' %'
88
- });
89
- }
90
-
91
- setData((0, _extends2["default"])({}, data, datas));
51
+ setData((0, _extends2["default"])({}, data, {
52
+ linkOther: result
53
+ }));
92
54
  }
93
55
  }); // 轮询hooks
94
56
 
@@ -114,27 +76,38 @@ function useMetricPolling(_ref) {
114
76
  _rlog["default"].info('链路拓扑指标轮询 queryInterfaceMetricsRequest 结果', result);
115
77
  }
116
78
  });
117
- var linkMetricCodesStr = oldCodes.map(function (item) {
79
+ var linkMetricCodesStr = codes.map(function (item) {
118
80
  return item;
119
81
  }).sort().join(',');
120
82
  (0, _react.useEffect)(function () {
121
83
  if (linkId) {
122
84
  _rlog["default"].info('链路拓扑指标轮询 切换', {
123
85
  linkCi: linkCi,
124
- oldCodes: oldCodes
86
+ codes: codes
125
87
  });
126
88
 
127
- queryLinkMetricsRequest.run(linkCi, oldCodes);
128
-
129
- if (newCodes.length > 0) {
130
- queryLastestValues.run({
131
- 'id': linkCi.attributes.name
132
- });
133
- }
89
+ queryLinkMetricsRequest.run(linkCi, codes);
134
90
  }
135
91
 
136
92
  return function () {};
137
93
  }, [linkId, linkMetricCodesStr]);
94
+ var retansRatioNetDelayRatioCodesStr = retansRatioNetDelayRatioCodes.map(function (item) {
95
+ return item;
96
+ }).sort().join(',');
97
+ (0, _react.useEffect)(function () {
98
+ if (linkId) {
99
+ _rlog["default"].info('链路拓扑指标勾选rtt|重传率 轮询', {
100
+ linkCi: linkCi,
101
+ retansRatioNetDelayRatioCodes: retansRatioNetDelayRatioCodes
102
+ });
103
+
104
+ queryLastestValues.run({
105
+ 'id': linkCi.attributes.name
106
+ }, retansRatioNetDelayRatioCodes);
107
+ }
108
+
109
+ return function () {};
110
+ }, [linkId, retansRatioNetDelayRatioCodesStr]);
138
111
  (0, _react.useEffect)(function () {
139
112
  if (linkId) {
140
113
  _rlog["default"].info('链路拓扑指标轮询 queryInterfaceMetricsRequest 开始', {
@@ -10,6 +10,7 @@ exports.queryLastestValue = queryLastestValue;
10
10
  exports.queryLatestMetrics = queryLatestMetrics;
11
11
  exports.queryLinkInterfacesLatestMetrics = queryLinkInterfacesLatestMetrics;
12
12
  exports.queryLinkLatestMetrics = queryLinkLatestMetrics;
13
+ exports.queryRetansRatioNetDelayRatio = queryRetansRatioNetDelayRatio;
13
14
 
14
15
  var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
15
16
 
@@ -276,7 +277,7 @@ function isOpenFlow(_x6) {
276
277
  return _isOpenFlow.apply(this, arguments);
277
278
  }
278
279
  /**
279
- * @name isOpenFlow 查指标值
280
+ * @name queryLastestValue 查指标值
280
281
  * @returns
281
282
  */
282
283
 
@@ -319,4 +320,60 @@ function _queryLastestValue() {
319
320
  }, _callee7);
320
321
  }));
321
322
  return _queryLastestValue.apply(this, arguments);
323
+ }
324
+
325
+ function queryRetansRatioNetDelayRatio(_x8, _x9) {
326
+ return _queryRetansRatioNetDelayRatio.apply(this, arguments);
327
+ }
328
+
329
+ function _queryRetansRatioNetDelayRatio() {
330
+ _queryRetansRatioNetDelayRatio = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee8(params, retansRatioNetDelayRatioCodes) {
331
+ var result, linkOther;
332
+ return _regenerator["default"].wrap(function _callee8$(_context8) {
333
+ while (1) {
334
+ switch (_context8.prev = _context8.next) {
335
+ case 0:
336
+ if (retansRatioNetDelayRatioCodes.length) {
337
+ _context8.next = 2;
338
+ break;
339
+ }
340
+
341
+ return _context8.abrupt("return", []);
342
+
343
+ case 2:
344
+ _context8.next = 4;
345
+ return queryLastestValue(params);
346
+
347
+ case 4:
348
+ result = _context8.sent;
349
+ linkOther = [];
350
+
351
+ if (retansRatioNetDelayRatioCodes.includes('netDelayRatio')) {
352
+ linkOther.push({
353
+ 'code': 'netDelayRatio',
354
+ 'name': 'RTT时延',
355
+ 'ts': result.time,
356
+ 'value': (result.upNetDelayRatio * 1).toFixed(2) + ' ms' + '|' + (result.downNetDelayRatio * 1).toFixed(2) + ' ms'
357
+ });
358
+ }
359
+
360
+ if (retansRatioNetDelayRatioCodes.includes('retansRatio')) {
361
+ linkOther.push({
362
+ 'code': 'retansRatio',
363
+ 'name': '重传率',
364
+ 'ts': result.time,
365
+ 'value': result.upRetransRatio + ' %' + '|' + result.downRetansRatio + ' %'
366
+ });
367
+ }
368
+
369
+ return _context8.abrupt("return", linkOther);
370
+
371
+ case 9:
372
+ case "end":
373
+ return _context8.stop();
374
+ }
375
+ }
376
+ }, _callee8);
377
+ }));
378
+ return _queryRetansRatioNetDelayRatio.apply(this, arguments);
322
379
  }