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

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 (16) hide show
  1. package/build/index.js +1 -1
  2. package/es/core/models/TopoApp.js +1 -1
  3. package/es/core/viewer/components/plugins/ResourceDetail/components/ResourceOverview/ResourceOverview.js +52 -6
  4. package/es/core/viewer/components/plugins/ResourceDetail/components/ResourceOverview/components/LinkTopo/LinkTopo.js +5 -2
  5. package/es/core/viewer/components/plugins/ResourceDetail/components/ResourceOverview/components/LinkTopo/LinkTopoCard.js +75 -2
  6. package/es/core/viewer/components/plugins/ResourceDetail/components/ResourceOverview/components/LinkTopo/hooks/useMetricPolling.js +68 -6
  7. package/es/core/viewer/components/plugins/ResourceDetail/components/ResourceOverview/components/LinkTopo/services/index.js +80 -0
  8. package/es/core/viewer/components/plugins/ResourceDetail/components/ResourceOverview/hooks/useMetricModels.js +65 -3
  9. package/lib/core/models/TopoApp.js +1 -1
  10. package/lib/core/viewer/components/plugins/ResourceDetail/components/ResourceOverview/ResourceOverview.js +52 -5
  11. package/lib/core/viewer/components/plugins/ResourceDetail/components/ResourceOverview/components/LinkTopo/LinkTopo.js +5 -2
  12. package/lib/core/viewer/components/plugins/ResourceDetail/components/ResourceOverview/components/LinkTopo/LinkTopoCard.js +82 -2
  13. package/lib/core/viewer/components/plugins/ResourceDetail/components/ResourceOverview/components/LinkTopo/hooks/useMetricPolling.js +67 -5
  14. package/lib/core/viewer/components/plugins/ResourceDetail/components/ResourceOverview/components/LinkTopo/services/index.js +86 -0
  15. package/lib/core/viewer/components/plugins/ResourceDetail/components/ResourceOverview/hooks/useMetricModels.js +66 -3
  16. package/package.json +2 -2
@@ -5,7 +5,11 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
5
5
  exports.__esModule = true;
6
6
  exports["default"] = LinkTopoCard;
7
7
 
8
- var _react = _interopRequireDefault(require("react"));
8
+ var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
9
+
10
+ var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
11
+
12
+ var _react = _interopRequireWildcard(require("react"));
9
13
 
10
14
  var _BlockBox = _interopRequireDefault(require("../../BlockBox"));
11
15
 
@@ -13,6 +17,12 @@ var _Configurator = _interopRequireDefault(require("../Configurator"));
13
17
 
14
18
  var _LinkTopo = _interopRequireDefault(require("./LinkTopo"));
15
19
 
20
+ var _services = require("./services");
21
+
22
+ 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); }
23
+
24
+ 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; }
25
+
16
26
  function LinkTopoCard(props) {
17
27
  var _data$attributes;
18
28
 
@@ -26,6 +36,75 @@ function LinkTopoCard(props) {
26
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) || ''; // 该资源监控模板
27
37
 
28
38
  var isCrucial = data === null || data === void 0 ? void 0 : data.attributes['network_link.is_crucial'];
39
+
40
+ var _useState = (0, _react.useState)(-1),
41
+ openFlow = _useState[0],
42
+ setOpenFlow = _useState[1];
43
+
44
+ var analysisUrl = "../../default/trafficControl/linkConfigure?id=" + data.attributes.name + "&num=0";
45
+ var linkDetailsUrl = "/default/pagecenter/linkDetail/view/" + data.id + "?resId=" + data.id + "&domainCode=network&title=" + data.attributes.name + "&ciCode=network_link&tabByComType=uicbb-res-crucial-link-flow";
46
+
47
+ var isOpenFlows = /*#__PURE__*/function () {
48
+ var _ref = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee() {
49
+ var checkMenus, isOpen;
50
+ return _regenerator["default"].wrap(function _callee$(_context) {
51
+ while (1) {
52
+ switch (_context.prev = _context.next) {
53
+ case 0:
54
+ _context.next = 2;
55
+ return (0, _services.checkMenu)();
56
+
57
+ case 2:
58
+ checkMenus = _context.sent;
59
+
60
+ if (!(checkMenus[0].passed == 'PASS')) {
61
+ _context.next = 10;
62
+ break;
63
+ }
64
+
65
+ _context.next = 6;
66
+ return (0, _services.isOpenFlow)({
67
+ 'name': data.attributes.display_name
68
+ });
69
+
70
+ case 6:
71
+ isOpen = _context.sent;
72
+
73
+ //判断是不是有流量分析
74
+ if (isOpen) {
75
+ setOpenFlow({
76
+ name: '跳转关键链路详情',
77
+ url: linkDetailsUrl
78
+ });
79
+ } else {
80
+ setOpenFlow({
81
+ name: '跳转流量分析配置',
82
+ url: analysisUrl
83
+ });
84
+ }
85
+
86
+ _context.next = 11;
87
+ break;
88
+
89
+ case 10:
90
+ setOpenFlow(null);
91
+
92
+ case 11:
93
+ case "end":
94
+ return _context.stop();
95
+ }
96
+ }
97
+ }, _callee);
98
+ }));
99
+
100
+ return function isOpenFlows() {
101
+ return _ref.apply(this, arguments);
102
+ };
103
+ }();
104
+
105
+ (0, _react.useEffect)(function () {
106
+ isOpenFlows();
107
+ }, [data]);
29
108
  return /*#__PURE__*/_react["default"].createElement(_BlockBox["default"], {
30
109
  headerTitle: "\u8FD0\u884C\u60C5\u51B5",
31
110
  headerExtra: /*#__PURE__*/_react["default"].createElement(_Configurator["default"], {
@@ -40,6 +119,7 @@ function LinkTopoCard(props) {
40
119
  })
41
120
  }, /*#__PURE__*/_react["default"].createElement(_LinkTopo["default"], {
42
121
  data: data,
43
- linkMetricCodes: metricCodes
122
+ linkMetricCodes: metricCodes,
123
+ openFlow: openFlow
44
124
  }));
45
125
  }
@@ -24,17 +24,73 @@ 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 = [];
30
+ linkMetricCodes.map(function (item) {
31
+ arr.indexOf(item) > -1 ? newCodes.push(item) : oldCodes.push(item);
32
+ });
27
33
 
28
34
  var _useState = (0, _react.useState)({
29
35
  sourceMetrics: null,
30
36
  destinationMetrics: null,
31
37
  // 链路指标列表
32
38
  linkMetrics: [],
33
- linkMetricsTs: null
39
+ linkMetricsTs: null,
40
+ linkOther: []
34
41
  }),
35
42
  data = _useState[0],
36
- setData = _useState[1]; // 轮询hooks
43
+ setData = _useState[1];
37
44
 
45
+ var queryLastestValues = (0, _ahooks.useRequest)(_services.queryLastestValue, {
46
+ pollingInterval: 1000 * 15,
47
+ pollingWhenHidden: false,
48
+ debounceInterval: 200,
49
+ manual: true,
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));
92
+ }
93
+ }); // 轮询hooks
38
94
 
39
95
  var queryLinkMetricsRequest = (0, _ahooks.useRequest)(_services.queryLinkLatestMetrics, {
40
96
  pollingInterval: 60 * 1000,
@@ -58,17 +114,23 @@ function useMetricPolling(_ref) {
58
114
  _rlog["default"].info('链路拓扑指标轮询 queryInterfaceMetricsRequest 结果', result);
59
115
  }
60
116
  });
61
- var linkMetricCodesStr = linkMetricCodes.map(function (item) {
117
+ var linkMetricCodesStr = oldCodes.map(function (item) {
62
118
  return item;
63
119
  }).sort().join(',');
64
120
  (0, _react.useEffect)(function () {
65
121
  if (linkId) {
66
122
  _rlog["default"].info('链路拓扑指标轮询 切换', {
67
123
  linkCi: linkCi,
68
- linkMetricCodes: linkMetricCodes
124
+ oldCodes: oldCodes
69
125
  });
70
126
 
71
- queryLinkMetricsRequest.run(linkCi, linkMetricCodes);
127
+ queryLinkMetricsRequest.run(linkCi, oldCodes);
128
+
129
+ if (newCodes.length > 0) {
130
+ queryLastestValues.run({
131
+ 'id': linkCi.attributes.name
132
+ });
133
+ }
72
134
  }
73
135
 
74
136
  return function () {};
@@ -3,7 +3,10 @@
3
3
  var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
4
 
5
5
  exports.__esModule = true;
6
+ exports.checkMenu = checkMenu;
7
+ exports.isOpenFlow = isOpenFlow;
6
8
  exports.queryAssetModel = queryAssetModel;
9
+ exports.queryLastestValue = queryLastestValue;
7
10
  exports.queryLatestMetrics = queryLatestMetrics;
8
11
  exports.queryLinkInterfacesLatestMetrics = queryLinkInterfacesLatestMetrics;
9
12
  exports.queryLinkLatestMetrics = queryLinkLatestMetrics;
@@ -152,6 +155,11 @@ function _queryLinkLatestMetrics() {
152
155
  function queryLinkInterfacesLatestMetrics(_x5) {
153
156
  return _queryLinkInterfacesLatestMetrics.apply(this, arguments);
154
157
  }
158
+ /**
159
+ * @name checkMenu 判断当前流量监控权限
160
+ * @returns
161
+ */
162
+
155
163
 
156
164
  function _queryLinkInterfacesLatestMetrics() {
157
165
  _queryLinkInterfacesLatestMetrics = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee4(linkCi) {
@@ -233,4 +241,82 @@ function _queryLinkInterfacesLatestMetrics() {
233
241
  }, _callee4);
234
242
  }));
235
243
  return _queryLinkInterfacesLatestMetrics.apply(this, arguments);
244
+ }
245
+
246
+ function checkMenu() {
247
+ return _checkMenu.apply(this, arguments);
248
+ }
249
+ /**
250
+ * @name isOpenFlow 是否配置流量分析
251
+ * @returns
252
+ */
253
+
254
+
255
+ function _checkMenu() {
256
+ _checkMenu = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee5() {
257
+ return _regenerator["default"].wrap(function _callee5$(_context5) {
258
+ while (1) {
259
+ switch (_context5.prev = _context5.next) {
260
+ case 0:
261
+ return _context5.abrupt("return", _componentTopologyUtils.request.post('/authorization/v1/api/authority/check/checkMenuAuthentication', [{
262
+ "url": "/default/trafficControl"
263
+ }]));
264
+
265
+ case 1:
266
+ case "end":
267
+ return _context5.stop();
268
+ }
269
+ }
270
+ }, _callee5);
271
+ }));
272
+ return _checkMenu.apply(this, arguments);
273
+ }
274
+
275
+ function isOpenFlow(_x6) {
276
+ return _isOpenFlow.apply(this, arguments);
277
+ }
278
+ /**
279
+ * @name isOpenFlow 查指标值
280
+ * @returns
281
+ */
282
+
283
+
284
+ function _isOpenFlow() {
285
+ _isOpenFlow = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee6(params) {
286
+ return _regenerator["default"].wrap(function _callee6$(_context6) {
287
+ while (1) {
288
+ switch (_context6.prev = _context6.next) {
289
+ case 0:
290
+ return _context6.abrupt("return", _componentTopologyUtils.request.post('/flow/v1/api/link/isOpenFlowMonitorByName', params));
291
+
292
+ case 1:
293
+ case "end":
294
+ return _context6.stop();
295
+ }
296
+ }
297
+ }, _callee6);
298
+ }));
299
+ return _isOpenFlow.apply(this, arguments);
300
+ }
301
+
302
+ function queryLastestValue(_x7) {
303
+ return _queryLastestValue.apply(this, arguments);
304
+ }
305
+
306
+ function _queryLastestValue() {
307
+ _queryLastestValue = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee7(params) {
308
+ return _regenerator["default"].wrap(function _callee7$(_context7) {
309
+ while (1) {
310
+ switch (_context7.prev = _context7.next) {
311
+ case 0:
312
+ return _context7.abrupt("return", _componentTopologyUtils.request.post('/flow/v1/api/LinkAnalyse/queryLastestValue', params));
313
+
314
+ case 1:
315
+ case "end":
316
+ return _context7.stop();
317
+ }
318
+ }
319
+ }, _callee7);
320
+ }));
321
+ return _queryLastestValue.apply(this, arguments);
236
322
  }
@@ -15,6 +15,8 @@ var _react = require("react");
15
15
 
16
16
  var _getCiDisplayMetricModels = require("../../../getCiDisplayMetricModels");
17
17
 
18
+ var _services = require("../components/LinkTopo/services");
19
+
18
20
  /**
19
21
  * 概览指标定义
20
22
  * @param {*} props
@@ -26,6 +28,7 @@ var useMetricModels = function useMetricModels(props) {
26
28
  ciType = _props$data.ciType,
27
29
  isMonite = props.isMonite,
28
30
  ciTypeMeta = props.ciTypeMeta,
31
+ resourceData = props.resourceData,
29
32
  topo = props.topo,
30
33
  resourceOverviewProps = props.resourceOverviewProps;
31
34
 
@@ -44,7 +47,7 @@ var useMetricModels = function useMetricModels(props) {
44
47
 
45
48
  function _fetchData() {
46
49
  _fetchData = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee() {
47
- var monitorMetrics, ciMonitorMetricModels, displayMetricModels, _metricCodes;
50
+ var monitorMetrics, ciMonitorMetricModels, checkMenus, isOpen, displayMetricModels, _metricCodes;
48
51
 
49
52
  return _regenerator["default"].wrap(function _callee$(_context) {
50
53
  while (1) {
@@ -59,8 +62,68 @@ var useMetricModels = function useMetricModels(props) {
59
62
  return !!monitorMetrics.find(function (item) {
60
63
  return item === m.code;
61
64
  });
62
- }); // 未监控不显示指标,临时在这里处理
65
+ });
66
+ _context.next = 6;
67
+ return (0, _services.checkMenu)();
68
+
69
+ case 6:
70
+ checkMenus = _context.sent;
71
+
72
+ if (!(checkMenus[0].passed == 'PASS' && resourceData.attributes.display_name && resourceData.attributes['network_link.is_crucial'])) {
73
+ _context.next = 12;
74
+ break;
75
+ }
76
+
77
+ _context.next = 10;
78
+ return (0, _services.isOpenFlow)({
79
+ 'name': resourceData.attributes.display_name
80
+ });
81
+
82
+ case 10:
83
+ isOpen = _context.sent;
84
+
85
+ //
86
+ if (isOpen) {
87
+ ciMonitorMetricModels.push({
88
+ changeValue: null,
89
+ code: "downNetDelayRatio",
90
+ id: "downNetDelayRatio",
91
+ isGoldMetric: true,
92
+ key: null,
93
+ name: "下行RTT时延",
94
+ unit: "ms"
95
+ });
96
+ ciMonitorMetricModels.push({
97
+ changeValue: null,
98
+ code: "downRetansRatio",
99
+ id: "downRetansRatio",
100
+ isGoldMetric: true,
101
+ key: null,
102
+ name: "下行重传率",
103
+ unit: "%"
104
+ });
105
+ ciMonitorMetricModels.push({
106
+ changeValue: null,
107
+ code: "upNetDelayRatio",
108
+ id: "upNetDelayRatio",
109
+ isGoldMetric: true,
110
+ key: null,
111
+ name: "上行RTT时延",
112
+ unit: "ms"
113
+ });
114
+ ciMonitorMetricModels.push({
115
+ changeValue: null,
116
+ code: "upRetransRatio",
117
+ id: "upRetransRatio",
118
+ isGoldMetric: true,
119
+ key: null,
120
+ name: "上行重传率",
121
+ unit: "%"
122
+ });
123
+ }
63
124
 
125
+ case 12:
126
+ // 未监控不显示指标,临时在这里处理
64
127
  if (!isMonite) {
65
128
  ciMonitorMetricModels = [];
66
129
  }
@@ -92,7 +155,7 @@ var useMetricModels = function useMetricModels(props) {
92
155
 
93
156
  return _context.abrupt("return", displayMetricModels);
94
157
 
95
- case 9:
158
+ case 17:
96
159
  case "end":
97
160
  return _context.stop();
98
161
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@riil-frontend/component-topology",
3
- "version": "8.0.10",
3
+ "version": "9.0.0-a.2",
4
4
  "description": "拓扑",
5
5
  "scripts": {
6
6
  "start": "build-scripts start",
@@ -116,6 +116,6 @@
116
116
  "access": "public"
117
117
  },
118
118
  "license": "MIT",
119
- "homepage": "https://unpkg.com/@riil-frontend/component-topology@8.0.10/build/index.html",
119
+ "homepage": "https://unpkg.com/@riil-frontend/component-topology@9.0.0-a.2/build/index.html",
120
120
  "gitHead": "2da19ffccbb7ca60a8acf396e39f542c68bb33f5"
121
121
  }