@riil-frontend/component-topology 9.0.0-a.11 → 9.0.0-a.15

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.
@@ -24,7 +24,7 @@ import ElementTagTipConfig from "./tagstips/ElementTagTipConfig";
24
24
  import SelectionModel from "./SelectionModel";
25
25
  import CiCache from "./cache/CiCache"; // eslint-disable-next-line no-undef
26
26
 
27
- var version = typeof "9.0.0-a.11" === 'string' ? "9.0.0-a.11" : null;
27
+ var version = typeof "9.0.0-a.15" === 'string' ? "9.0.0-a.15" : null;
28
28
  console.info("\u62D3\u6251\u7248\u672C: " + version);
29
29
  /**
30
30
  * 拓扑显示和编辑
@@ -22,6 +22,58 @@ var Test = /*#__PURE__*/function () {
22
22
  _proto.onReady = function onReady() {// TODO 待移除测试代码
23
23
  // this.iconManage.openUpload()
24
24
  // this.topo.store.getModelDispatchers('linkDynamicStyleConfig').open({type: 'networkLink'});
25
+ }
26
+ /**
27
+ * 关联IP示例代码
28
+ */
29
+ ;
30
+
31
+ _proto.createExportLink = function createExportLink() {
32
+ var htTopo = this.topo.getHtTopo();
33
+ var dm = htTopo.getGraphView().dm(); // 设置节点关联IP
34
+
35
+ var nodeElement = htTopo.getGraphView().sm().fd();
36
+ var ip = {
37
+ 'id': 'ip_1.1.1.1',
38
+ 'name': '1.1.1.1',
39
+ customName: null,
40
+ // 'groupId': null,
41
+ // 'groupTag': null,
42
+ 'ipAddress': '1.1.1.1',
43
+ // 'attributes': [],
44
+ // 'metrics': [],
45
+ 'type': 'node' // 'dtype': 'device'
46
+
47
+ };
48
+ nodeElement.a(ip);
49
+ nodeElement.setTag('ip_1.1.1.1');
50
+ var link = {
51
+ 'id': '0000000019b462d1',
52
+ 'name': '172.17.160.116(Gi2/2/0/1) - 172.27.130.13(Gi 0/9)',
53
+ 'source': '00000000029f9411',
54
+ 'target': 'ip_1.1.1.1',
55
+ 'operation': 'delete',
56
+ 'interfaceSource': '0000000018080aee',
57
+ 'interfaceTarget': '000000000341b015',
58
+ 'ciType': 'network_link',
59
+ 'attributes': [],
60
+ 'manageStatus': 0,
61
+ 'permission': {
62
+ 'readable': true,
63
+ 'writeable': true,
64
+ 'deleteable': true
65
+ },
66
+ 'metrics': [],
67
+ 'type': 'link',
68
+ 'dtype': 'link'
69
+ };
70
+ var createElementsData = {
71
+ groups: [],
72
+ nodes: [],
73
+ links: [link],
74
+ linkGroups: []
75
+ };
76
+ htTopo.createElements(createElementsData);
25
77
  };
26
78
 
27
79
  return Test;
@@ -29,8 +29,7 @@ import useCiAttrAndMetricData from "./useCiAttrAndMetricData";
29
29
  import Configurator from "./components/Configurator";
30
30
  import { formatMetric } from "../../../../../../models/attributeFormatter";
31
31
  import LinkTopoCard from "./components/LinkTopo/LinkTopoCard";
32
- import EventsCard from "./EventsCard";
33
- import { checkMenu, isOpenFlow, queryLastestValue } from "./components/LinkTopo/services"; // url 处理,UICBB 的地址需截取前缀
32
+ import EventsCard from "./EventsCard"; // url 处理,UICBB 的地址需截取前缀
34
33
 
35
34
  function formatUrl(url) {
36
35
  var _window, _window$location;
@@ -692,7 +691,7 @@ export default function ResourceOverview(props) {
692
691
  _metricColChange = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee8(col) {
693
692
  var _col2, _col3;
694
693
 
695
- var codes, endTime, params, _ref5, times, metricList, newMetricList, metricLists;
694
+ var codes, endTime, params, _ref5, times, metricList, metricLists;
696
695
 
697
696
  return _regeneratorRuntime.wrap(function _callee8$(_context8) {
698
697
  while (1) {
@@ -740,16 +739,7 @@ export default function ResourceOverview(props) {
740
739
 
741
740
  case 11:
742
741
  metricList = _context8.sent;
743
- _context8.next = 14;
744
- return queryMetricList({
745
- 'name': data.attributes.display_name
746
- }, {
747
- 'id': data.attributes.name
748
- });
749
-
750
- case 14:
751
- newMetricList = _context8.sent;
752
- metricLists = metricList.concat(getNewMetricList(newMetricList));
742
+ metricLists = metricList.concat(getNewMetricList());
753
743
  rlog.debug('metricColChange', metricLists, monitorMetricModels);
754
744
  setMetric(col.map(function (item, key) {
755
745
  return {
@@ -775,7 +765,7 @@ export default function ResourceOverview(props) {
775
765
  }, 60000);
776
766
  }
777
767
 
778
- case 20:
768
+ case 17:
779
769
  case "end":
780
770
  return _context8.stop();
781
771
  }
@@ -785,73 +775,12 @@ export default function ResourceOverview(props) {
785
775
  return _metricColChange.apply(this, arguments);
786
776
  }
787
777
 
788
- function queryMetricList(_x9, _x10) {
789
- return _queryMetricList.apply(this, arguments);
790
- }
791
-
792
- function _queryMetricList() {
793
- _queryMetricList = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee9(data, param) {
794
- var checkMenus, isOpen, list;
795
- return _regeneratorRuntime.wrap(function _callee9$(_context9) {
796
- while (1) {
797
- switch (_context9.prev = _context9.next) {
798
- case 0:
799
- if (!(ciType !== 'network_link')) {
800
- _context9.next = 2;
801
- break;
802
- }
803
-
804
- return _context9.abrupt("return", []);
805
-
806
- case 2:
807
- _context9.next = 4;
808
- return checkMenu();
809
-
810
- case 4:
811
- checkMenus = _context9.sent;
812
-
813
- if (!(checkMenus[0].passed == 'PASS')) {
814
- _context9.next = 14;
815
- break;
816
- }
817
-
818
- _context9.next = 8;
819
- return isOpenFlow(data);
820
-
821
- case 8:
822
- isOpen = _context9.sent;
823
-
824
- if (!isOpen) {
825
- _context9.next = 14;
826
- break;
827
- }
828
-
829
- _context9.next = 12;
830
- return queryLastestValue(param);
831
-
832
- case 12:
833
- list = _context9.sent;
834
- return _context9.abrupt("return", list);
835
-
836
- case 14:
837
- return _context9.abrupt("return", []);
838
-
839
- case 15:
840
- case "end":
841
- return _context9.stop();
842
- }
843
- }
844
- }, _callee9);
845
- }));
846
- return _queryMetricList.apply(this, arguments);
847
- }
848
-
849
- var getNewMetricList = function getNewMetricList(data) {
778
+ var getNewMetricList = function getNewMetricList() {
850
779
  return [{
851
780
  errorMsg: null,
852
781
  mainCiId: "netDelayRatio",
853
782
  metricCode: "netDelayRatio",
854
- metricValue: data.upNetDelayRatio + ' ms' + '|' + data.downNetDelayRatio + ' ms',
783
+ metricValue: '0',
855
784
  subCiId: '',
856
785
  subCiType: null,
857
786
  mainCiType: null
@@ -859,7 +788,7 @@ export default function ResourceOverview(props) {
859
788
  errorMsg: null,
860
789
  mainCiId: "retansRatio",
861
790
  metricCode: "retansRatio",
862
- metricValue: data.upRetransRatio + ' %' + '|' + data.downRetansRatio + ' %',
791
+ metricValue: '0',
863
792
  subCiId: '',
864
793
  subCiType: null,
865
794
  mainCiType: null
@@ -1,7 +1,7 @@
1
1
  import _extends from "@babel/runtime/helpers/extends";
2
2
  import React, { useEffect, useState } from 'react';
3
3
  import { useRequest } from 'ahooks';
4
- import { queryLinkInterfacesLatestMetrics, queryLinkLatestMetrics, queryLastestValue } from "../services";
4
+ import { queryLinkInterfacesLatestMetrics, queryLinkLatestMetrics, queryRetansRatioNetDelayRatio } from "../services";
5
5
  import rlog from '@riil-frontend/component-topology-utils/es/rlog'; // 资源节点上方色块展示资源的发送速率发送带宽利用率、接收速率发送接收利用率、总错包数
6
6
 
7
7
  export default function useMetricPolling(_ref) {
@@ -9,10 +9,10 @@ export default function useMetricPolling(_ref) {
9
9
  linkMetricCodes = _ref.linkMetricCodes;
10
10
  var linkId = linkCi.id;
11
11
  var arr = ['netDelayRatio', 'retansRatio'];
12
- var oldCodes = [];
13
- var newCodes = [];
12
+ var codes = [];
13
+ var retansRatioNetDelayRatioCodes = [];
14
14
  linkMetricCodes.map(function (item) {
15
- arr.indexOf(item) > -1 ? newCodes.push(item) : oldCodes.push(item);
15
+ arr.indexOf(item) > -1 ? retansRatioNetDelayRatioCodes.push(item) : codes.push(item);
16
16
  });
17
17
 
18
18
  var _useState = useState({
@@ -26,35 +26,15 @@ export default function useMetricPolling(_ref) {
26
26
  data = _useState[0],
27
27
  setData = _useState[1];
28
28
 
29
- var queryLastestValues = useRequest(queryLastestValue, {
29
+ var queryLastestValues = useRequest(queryRetansRatioNetDelayRatio, {
30
30
  pollingInterval: 1000 * 15,
31
31
  pollingWhenHidden: false,
32
32
  debounceInterval: 200,
33
33
  manual: true,
34
34
  onSuccess: function onSuccess(result) {
35
- var datas = {
36
- linkOther: []
37
- };
38
-
39
- if (newCodes.includes('netDelayRatio')) {
40
- datas.linkOther.push({
41
- 'code': 'netDelayRatio',
42
- 'name': '下行RTT时延',
43
- 'ts': result.time,
44
- 'value': result.upNetDelayRatio + ' ms' + '|' + result.downNetDelayRatio + ' ms'
45
- });
46
- }
47
-
48
- if (newCodes.includes('retansRatio')) {
49
- datas.linkOther.push({
50
- 'code': 'retansRatio',
51
- 'name': '重传率',
52
- 'ts': result.time,
53
- 'value': result.upRetransRatio + ' %' + '|' + result.downRetansRatio + ' %'
54
- });
55
- }
56
-
57
- setData(_extends({}, data, datas));
35
+ setData(_extends({}, data, {
36
+ linkOther: result
37
+ }));
58
38
  }
59
39
  }); // 轮询hooks
60
40
 
@@ -78,26 +58,36 @@ export default function useMetricPolling(_ref) {
78
58
  rlog.info('链路拓扑指标轮询 queryInterfaceMetricsRequest 结果', result);
79
59
  }
80
60
  });
81
- var linkMetricCodesStr = oldCodes.map(function (item) {
61
+ var linkMetricCodesStr = codes.map(function (item) {
82
62
  return item;
83
63
  }).sort().join(',');
84
64
  useEffect(function () {
85
65
  if (linkId) {
86
66
  rlog.info('链路拓扑指标轮询 切换', {
87
67
  linkCi: linkCi,
88
- oldCodes: oldCodes
68
+ codes: codes
89
69
  });
90
- queryLinkMetricsRequest.run(linkCi, oldCodes);
91
-
92
- if (newCodes.length > 0) {
93
- queryLastestValues.run({
94
- 'id': linkCi.attributes.name
95
- });
96
- }
70
+ queryLinkMetricsRequest.run(linkCi, codes);
97
71
  }
98
72
 
99
73
  return function () {};
100
74
  }, [linkId, linkMetricCodesStr]);
75
+ var retansRatioNetDelayRatioCodesStr = retansRatioNetDelayRatioCodes.map(function (item) {
76
+ return item;
77
+ }).sort().join(',');
78
+ useEffect(function () {
79
+ if (linkId) {
80
+ rlog.info('链路拓扑指标勾选rtt|重传率 轮询', {
81
+ linkCi: linkCi,
82
+ retansRatioNetDelayRatioCodes: retansRatioNetDelayRatioCodes
83
+ });
84
+ queryLastestValues.run({
85
+ 'id': linkCi.attributes.name
86
+ }, retansRatioNetDelayRatioCodes);
87
+ }
88
+
89
+ return function () {};
90
+ }, [linkId, retansRatioNetDelayRatioCodesStr]);
101
91
  useEffect(function () {
102
92
  if (linkId) {
103
93
  rlog.info('链路拓扑指标轮询 queryInterfaceMetricsRequest 开始', {
@@ -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() + ' ms' + '|' + (result.downNetDelayRatio * 1).toFixed() + ' 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 * 1).toFixed() + ' %' + '|' + (result.downRetansRatio * 1).toFixed() + ' %'
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
  }
@@ -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.11" === 'string' ? "9.0.0-a.11" : null;
59
+ var version = typeof "9.0.0-a.15" === 'string' ? "9.0.0-a.15" : null;
60
60
  console.info("\u62D3\u6251\u7248\u672C: " + version);
61
61
  /**
62
62
  * 拓扑显示和编辑
@@ -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;
@@ -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,16 +772,7 @@ function ResourceOverview(props) {
774
772
 
775
773
  case 11:
776
774
  metricList = _context8.sent;
777
- _context8.next = 14;
778
- return queryMetricList({
779
- 'name': data.attributes.display_name
780
- }, {
781
- 'id': data.attributes.name
782
- });
783
-
784
- case 14:
785
- newMetricList = _context8.sent;
786
- metricLists = metricList.concat(getNewMetricList(newMetricList));
775
+ metricLists = metricList.concat(getNewMetricList());
787
776
 
788
777
  _rlog.rlog.debug('metricColChange', metricLists, monitorMetricModels);
789
778
 
@@ -811,7 +800,7 @@ function ResourceOverview(props) {
811
800
  }, 60000);
812
801
  }
813
802
 
814
- case 20:
803
+ case 17:
815
804
  case "end":
816
805
  return _context8.stop();
817
806
  }
@@ -821,73 +810,12 @@ function ResourceOverview(props) {
821
810
  return _metricColChange.apply(this, arguments);
822
811
  }
823
812
 
824
- function queryMetricList(_x9, _x10) {
825
- return _queryMetricList.apply(this, arguments);
826
- }
827
-
828
- function _queryMetricList() {
829
- _queryMetricList = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee9(data, param) {
830
- var checkMenus, isOpen, list;
831
- return _regenerator["default"].wrap(function _callee9$(_context9) {
832
- while (1) {
833
- switch (_context9.prev = _context9.next) {
834
- case 0:
835
- if (!(ciType !== 'network_link')) {
836
- _context9.next = 2;
837
- break;
838
- }
839
-
840
- return _context9.abrupt("return", []);
841
-
842
- case 2:
843
- _context9.next = 4;
844
- return (0, _services2.checkMenu)();
845
-
846
- case 4:
847
- checkMenus = _context9.sent;
848
-
849
- if (!(checkMenus[0].passed == 'PASS')) {
850
- _context9.next = 14;
851
- break;
852
- }
853
-
854
- _context9.next = 8;
855
- return (0, _services2.isOpenFlow)(data);
856
-
857
- case 8:
858
- isOpen = _context9.sent;
859
-
860
- if (!isOpen) {
861
- _context9.next = 14;
862
- break;
863
- }
864
-
865
- _context9.next = 12;
866
- return (0, _services2.queryLastestValue)(param);
867
-
868
- case 12:
869
- list = _context9.sent;
870
- return _context9.abrupt("return", list);
871
-
872
- case 14:
873
- return _context9.abrupt("return", []);
874
-
875
- case 15:
876
- case "end":
877
- return _context9.stop();
878
- }
879
- }
880
- }, _callee9);
881
- }));
882
- return _queryMetricList.apply(this, arguments);
883
- }
884
-
885
- var getNewMetricList = function getNewMetricList(data) {
813
+ var getNewMetricList = function getNewMetricList() {
886
814
  return [{
887
815
  errorMsg: null,
888
816
  mainCiId: "netDelayRatio",
889
817
  metricCode: "netDelayRatio",
890
- metricValue: data.upNetDelayRatio + ' ms' + '|' + data.downNetDelayRatio + ' ms',
818
+ metricValue: '0',
891
819
  subCiId: '',
892
820
  subCiType: null,
893
821
  mainCiType: null
@@ -895,7 +823,7 @@ function ResourceOverview(props) {
895
823
  errorMsg: null,
896
824
  mainCiId: "retansRatio",
897
825
  metricCode: "retansRatio",
898
- metricValue: data.upRetransRatio + ' %' + '|' + data.downRetansRatio + ' %',
826
+ metricValue: '0',
899
827
  subCiId: '',
900
828
  subCiType: null,
901
829
  mainCiType: null
@@ -25,10 +25,10 @@ function useMetricPolling(_ref) {
25
25
  linkMetricCodes = _ref.linkMetricCodes;
26
26
  var linkId = linkCi.id;
27
27
  var arr = ['netDelayRatio', 'retansRatio'];
28
- var oldCodes = [];
29
- var newCodes = [];
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,35 +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('netDelayRatio')) {
56
- datas.linkOther.push({
57
- 'code': 'netDelayRatio',
58
- 'name': '下行RTT时延',
59
- 'ts': result.time,
60
- 'value': result.upNetDelayRatio + ' ms' + '|' + result.downNetDelayRatio + ' ms'
61
- });
62
- }
63
-
64
- if (newCodes.includes('retansRatio')) {
65
- datas.linkOther.push({
66
- 'code': 'retansRatio',
67
- 'name': '重传率',
68
- 'ts': result.time,
69
- 'value': result.upRetransRatio + ' %' + '|' + result.downRetansRatio + ' %'
70
- });
71
- }
72
-
73
- setData((0, _extends2["default"])({}, data, datas));
51
+ setData((0, _extends2["default"])({}, data, {
52
+ linkOther: result
53
+ }));
74
54
  }
75
55
  }); // 轮询hooks
76
56
 
@@ -96,27 +76,38 @@ function useMetricPolling(_ref) {
96
76
  _rlog["default"].info('链路拓扑指标轮询 queryInterfaceMetricsRequest 结果', result);
97
77
  }
98
78
  });
99
- var linkMetricCodesStr = oldCodes.map(function (item) {
79
+ var linkMetricCodesStr = codes.map(function (item) {
100
80
  return item;
101
81
  }).sort().join(',');
102
82
  (0, _react.useEffect)(function () {
103
83
  if (linkId) {
104
84
  _rlog["default"].info('链路拓扑指标轮询 切换', {
105
85
  linkCi: linkCi,
106
- oldCodes: oldCodes
86
+ codes: codes
107
87
  });
108
88
 
109
- queryLinkMetricsRequest.run(linkCi, oldCodes);
110
-
111
- if (newCodes.length > 0) {
112
- queryLastestValues.run({
113
- 'id': linkCi.attributes.name
114
- });
115
- }
89
+ queryLinkMetricsRequest.run(linkCi, codes);
116
90
  }
117
91
 
118
92
  return function () {};
119
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]);
120
111
  (0, _react.useEffect)(function () {
121
112
  if (linkId) {
122
113
  _rlog["default"].info('链路拓扑指标轮询 queryInterfaceMetricsRequest 开始', {