@riil-frontend/component-topology 9.0.0-a.3 → 9.0.0-a.31
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.
- package/build/1.js +1 -1
- package/build/index.css +1 -1
- package/build/index.js +12 -12
- package/es/components/VerticalIconTab/VerticalIconTab.module.scss +11 -5
- package/es/core/components/TopoView/GraphViewPanel.js +17 -4
- package/es/core/components/TopoView/TopoView.module.scss +17 -3
- package/es/core/editor/components/BackgroundView/index.module.scss +3 -0
- package/es/core/editor/components/Sidebar/Sidebar.module.scss +7 -7
- package/es/core/editor/components/Sidebar/views/CanvasPanel/CanvasPanel.js +1 -1
- package/es/core/editor/components/Sidebar/views/CanvasPanel/CanvasPanel.module.scss +1 -0
- package/es/core/editor/components/Sidebar/views/ComponentPanel.js +1 -1
- package/es/core/editor/components/Sidebar/views/ImagePanel/ImagePanel.js +2 -1
- package/es/core/editor/components/Sidebar/views/LinkPanel.js +1 -1
- package/es/core/editor/components/Toolbar/widgets/EdgeTypeButton/EdgeType.js +21 -5
- package/es/core/editor/components/Toolbar/widgets/EdgeTypeButton/EdgeType.module.scss +5 -1
- package/es/core/editor/components/Toolbar/widgets/EdgeTypeButton/LineType.js +31 -12
- package/es/core/editor/components/Toolbar/widgets/EdgeTypeButton/LineType.module.scss +12 -2
- package/es/core/editor/components/Toolbar/widgets/EdgeTypeButton/index.js +6 -0
- package/es/core/editor/components/Toolbar/widgets/FontSizeWidget.js +1 -1
- package/es/core/editor/components/Toolbar/widgets/components/textStyleSetting/ElementTextStyleSetting/elements/groupTitle.js +1 -1
- package/es/core/editor/components/settings/core/updateElementProperty.js +6 -1
- package/es/core/editor/components/settings/propertyViews/group/DataTab/hoooks/useGroupRelateResource.js +4 -3
- package/es/core/editor/components/settings/propertyViews/node/data/BindIpInput.js +95 -0
- package/es/core/editor/components/settings/propertyViews/node/data/Data.js +46 -14
- package/es/core/editor/config/themes.js +53 -2
- package/es/core/event/topoEventListener.js +22 -0
- package/es/core/hooks/useAlarm.js +18 -12
- package/es/core/hooks/useCanvasTheme.js +12 -4
- package/es/core/hooks/useResourceConfig.js +2 -1
- package/es/core/hooks/useTopoEdit.js +113 -19
- package/es/core/hooks/useTopoEventListener.js +4 -18
- package/es/core/hooks/useTopoFullscreen.js +32 -0
- package/es/core/models/Alarm.js +4 -13
- package/es/core/models/TopoApp.js +1 -1
- package/es/core/models/topoData.js +16 -9
- package/es/core/models/utils/linkUtils.js +52 -27
- package/es/core/store/models/topoConfig.js +51 -20
- package/es/core/test/Test.js +52 -0
- package/es/core/viewer/components/plugins/ResourceDetail/components/ResourceOverview/ResourceOverview.js +11 -35
- package/es/core/viewer/components/plugins/ResourceDetail/components/ResourceOverview/components/LinkTopo/LinkTopo.js +14 -0
- package/es/core/viewer/components/plugins/ResourceDetail/components/ResourceOverview/components/LinkTopo/LinkTopoCard.js +8 -6
- package/es/core/viewer/components/plugins/ResourceDetail/components/ResourceOverview/components/LinkTopo/hooks/useMetricPolling.js +28 -56
- package/es/core/viewer/components/plugins/ResourceDetail/components/ResourceOverview/components/LinkTopo/services/index.js +57 -1
- package/es/core/viewer/components/plugins/ResourceDetail/components/ResourceOverview/hooks/useMetricModels.js +13 -52
- package/es/networkTopo/getTopoData.js +2 -1
- package/es/networkTopo/models/LinkDynamicStyleExecutor.js +5 -5
- package/es/networkTopo/services/link.js +1 -1
- package/es/networkTopo/services/topo/basic.js +27 -26
- package/es/networkTopo/services/topo/networkLink.js +45 -3
- package/es/networkTopo/utils/exitLinkUtil.js +262 -0
- package/es/utils/ResourceConfigUtil.js +5 -4
- package/es/utils/htElementDataUtil.js +1 -7
- package/es/utils/htElementUtils.js +21 -21
- package/lib/components/VerticalIconTab/VerticalIconTab.module.scss +11 -5
- package/lib/core/components/TopoView/GraphViewPanel.js +18 -3
- package/lib/core/components/TopoView/TopoView.module.scss +17 -3
- package/lib/core/editor/components/BackgroundView/index.module.scss +3 -0
- package/lib/core/editor/components/Sidebar/Sidebar.module.scss +7 -7
- package/lib/core/editor/components/Sidebar/views/CanvasPanel/CanvasPanel.js +1 -1
- package/lib/core/editor/components/Sidebar/views/CanvasPanel/CanvasPanel.module.scss +1 -0
- package/lib/core/editor/components/Sidebar/views/ComponentPanel.js +1 -1
- package/lib/core/editor/components/Sidebar/views/ImagePanel/ImagePanel.js +2 -1
- package/lib/core/editor/components/Sidebar/views/LinkPanel.js +1 -1
- package/lib/core/editor/components/Toolbar/widgets/EdgeTypeButton/EdgeType.js +21 -4
- package/lib/core/editor/components/Toolbar/widgets/EdgeTypeButton/EdgeType.module.scss +5 -1
- package/lib/core/editor/components/Toolbar/widgets/EdgeTypeButton/LineType.js +31 -12
- package/lib/core/editor/components/Toolbar/widgets/EdgeTypeButton/LineType.module.scss +12 -2
- package/lib/core/editor/components/Toolbar/widgets/EdgeTypeButton/index.js +6 -0
- package/lib/core/editor/components/Toolbar/widgets/FontSizeWidget.js +1 -1
- package/lib/core/editor/components/Toolbar/widgets/components/textStyleSetting/ElementTextStyleSetting/elements/groupTitle.js +1 -1
- package/lib/core/editor/components/settings/core/updateElementProperty.js +6 -1
- package/lib/core/editor/components/settings/propertyViews/group/DataTab/hoooks/useGroupRelateResource.js +3 -3
- package/lib/core/editor/components/settings/propertyViews/node/data/BindIpInput.js +111 -0
- package/lib/core/editor/components/settings/propertyViews/node/data/Data.js +48 -14
- package/lib/core/editor/config/themes.js +53 -2
- package/lib/core/event/topoEventListener.js +27 -0
- package/lib/core/hooks/useAlarm.js +19 -12
- package/lib/core/hooks/useCanvasTheme.js +12 -4
- package/lib/core/hooks/useResourceConfig.js +2 -1
- package/lib/core/hooks/useTopoEdit.js +114 -18
- package/lib/core/hooks/useTopoEventListener.js +3 -17
- package/lib/core/hooks/useTopoFullscreen.js +42 -0
- package/lib/core/models/Alarm.js +5 -16
- package/lib/core/models/TopoApp.js +1 -1
- package/lib/core/models/topoData.js +16 -9
- package/lib/core/models/utils/linkUtils.js +53 -26
- package/lib/core/store/models/topoConfig.js +56 -19
- package/lib/core/test/Test.js +52 -0
- package/lib/core/viewer/components/plugins/ResourceDetail/components/ResourceOverview/ResourceOverview.js +10 -35
- package/lib/core/viewer/components/plugins/ResourceDetail/components/ResourceOverview/components/LinkTopo/LinkTopo.js +14 -0
- package/lib/core/viewer/components/plugins/ResourceDetail/components/ResourceOverview/components/LinkTopo/LinkTopoCard.js +8 -6
- package/lib/core/viewer/components/plugins/ResourceDetail/components/ResourceOverview/components/LinkTopo/hooks/useMetricPolling.js +28 -55
- package/lib/core/viewer/components/plugins/ResourceDetail/components/ResourceOverview/components/LinkTopo/services/index.js +58 -1
- package/lib/core/viewer/components/plugins/ResourceDetail/components/ResourceOverview/hooks/useMetricModels.js +13 -53
- package/lib/networkTopo/getTopoData.js +2 -1
- package/lib/networkTopo/models/LinkDynamicStyleExecutor.js +5 -5
- package/lib/networkTopo/services/topo/basic.js +28 -28
- package/lib/networkTopo/services/topo/networkLink.js +45 -3
- package/lib/networkTopo/utils/exitLinkUtil.js +274 -0
- package/lib/utils/ResourceConfigUtil.js +4 -4
- package/lib/utils/htElementDataUtil.js +0 -10
- package/lib/utils/htElementUtils.js +21 -21
- 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
|
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,
|
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
|
-
|
58
|
-
|
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: "
|
96
|
-
id: "
|
57
|
+
code: "netDelayRatio",
|
58
|
+
id: "netDelayRatio",
|
97
59
|
isGoldMetric: true,
|
98
60
|
key: null,
|
99
|
-
name: "
|
61
|
+
name: "RTT时延",
|
100
62
|
unit: "ms"
|
101
63
|
});
|
102
|
-
ciMonitorMetricModels.
|
64
|
+
ciMonitorMetricModels.unshift({
|
103
65
|
changeValue: null,
|
104
|
-
code: "
|
105
|
-
id: "
|
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
|
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
|
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
|
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 <=
|
11
|
+
} else if (actualBandwidth <= 1000) {
|
14
12
|
return 4;
|
15
|
-
} else if (actualBandwidth
|
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
|
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:
|
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$
|
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.
|
411
|
-
_context12.next = 3;
|
418
|
+
_context12.next = 2;
|
412
419
|
return request.get(API_ROOT + "/structure/both/" + id);
|
413
420
|
|
414
|
-
case
|
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
|
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
|
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
|
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,262 @@
|
|
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
|
+
isbinding: true,
|
33
|
+
// 'dtype': 'device'
|
34
|
+
operation: "delete"
|
35
|
+
};
|
36
|
+
}
|
37
|
+
|
38
|
+
function getHtSerialize(serialize) {
|
39
|
+
if (serialize) {
|
40
|
+
return JSON.parse(serialize);
|
41
|
+
}
|
42
|
+
|
43
|
+
return null;
|
44
|
+
}
|
45
|
+
|
46
|
+
function isExitLink(link) {
|
47
|
+
return link.attributes.destination_type === "ip";
|
48
|
+
} // 判断拓扑图上ip是否唯一
|
49
|
+
|
50
|
+
|
51
|
+
export function isUniqueIp(dataModel, ip, nodeElement) {
|
52
|
+
var nodes = getNodes(dataModel);
|
53
|
+
var isUnique = true;
|
54
|
+
console.log("nodes-nodeElement", nodes, nodeElement);
|
55
|
+
|
56
|
+
if (nodeElement) {
|
57
|
+
console.log("nodes-nodeElement---filter", nodes.filter(function (node) {
|
58
|
+
return node.getId() !== (nodeElement === null || nodeElement === void 0 ? void 0 : nodeElement.getId());
|
59
|
+
}));
|
60
|
+
var arr = nodes.filter(function (node) {
|
61
|
+
return node.getId() !== (nodeElement === null || nodeElement === void 0 ? void 0 : nodeElement.getId());
|
62
|
+
}).filter(function (node) {
|
63
|
+
return isPingHtNode(node, ip) || isIpHtNode(node, ip);
|
64
|
+
});
|
65
|
+
isUnique = arr.length === 0;
|
66
|
+
console.log("nodes-nodeElement---filter", arr, isUnique);
|
67
|
+
} else {
|
68
|
+
isUnique = nodes.filter(function (node) {
|
69
|
+
return node.a("ipAddress") === ip;
|
70
|
+
}).length === 0;
|
71
|
+
}
|
72
|
+
|
73
|
+
return isUnique;
|
74
|
+
}
|
75
|
+
/**
|
76
|
+
* 打开拓扑出口链路处理
|
77
|
+
* @param {*} topoData
|
78
|
+
* @returns
|
79
|
+
*/
|
80
|
+
|
81
|
+
export function processExitLink(topoData) {
|
82
|
+
var nodes = topoData.nodes,
|
83
|
+
links = topoData.links; // 出口链路目的端设置为IP节点或者ping资源节点id
|
84
|
+
|
85
|
+
var newLinks = updateLinkTarget(links, nodes);
|
86
|
+
|
87
|
+
if (!topoData.serialize) {
|
88
|
+
return _extends({}, topoData, {
|
89
|
+
links: newLinks
|
90
|
+
});
|
91
|
+
}
|
92
|
+
|
93
|
+
var serialize = _extends({}, getHtSerialize(topoData.serialize)); // 历史数据升级
|
94
|
+
|
95
|
+
|
96
|
+
links.filter(isExitLink) // 升级V1.4前配置的出口链路目的端节点为IP节点
|
97
|
+
.forEach(function (link) {
|
98
|
+
return upgradeExitLinkTarget(link, serialize);
|
99
|
+
}); // 历史数据适配:同IP节点关联多个不同IP的链路、分级拓扑。target匹配不到元素时,根据序列化匹配
|
100
|
+
|
101
|
+
newLinks = upgradeLinkTargetNotExisted(links); // IP节点构造为node。如果有相同ip的ping资源和图片节点,图片节点消失(不构造)
|
102
|
+
|
103
|
+
var ipNodes = getIpNodes(serialize, nodes);
|
104
|
+
return _extends({}, topoData, {
|
105
|
+
nodes: [].concat(nodes, ipNodes),
|
106
|
+
links: newLinks,
|
107
|
+
serialize: serialize
|
108
|
+
}); // 历史数据适配:同IP节点关联多个不同IP的链路、分级拓扑。target匹配不到元素时,根据序列化匹配
|
109
|
+
|
110
|
+
function upgradeLinkTargetNotExisted(links) {
|
111
|
+
newLinks = links.map(function (link) {
|
112
|
+
if (!isExitLink(link) || link.target && nodes.find(function (node) {
|
113
|
+
return node.id === link.target;
|
114
|
+
})) {
|
115
|
+
return link;
|
116
|
+
}
|
117
|
+
|
118
|
+
var destinationIp = link.attributes['network_link.destination_ipv4'];
|
119
|
+
var pingNode = findPingNode(nodes, destinationIp); // 出口链路目的端设置为IP节点或者ping资源节点id
|
120
|
+
|
121
|
+
var target = link.target; // 历史数据适配:同IP节点关联多个不同IP的链路、分级拓扑。target匹配不到元素时,根据序列化匹配
|
122
|
+
|
123
|
+
var targetSerialize = findElementSerializeById(serialize, target);
|
124
|
+
|
125
|
+
if (!targetSerialize) {
|
126
|
+
var linkSerialize = findElementSerializeById(serialize, link.id);
|
127
|
+
|
128
|
+
if (linkSerialize) {
|
129
|
+
// 根据链路序列化数据找目的端节点
|
130
|
+
// eslint-disable-next-line no-underscore-dangle
|
131
|
+
var targetNodeSerialize = serialize.d.find(function (item) {
|
132
|
+
var _linkSerialize$p$targ;
|
133
|
+
|
134
|
+
return item.i === (linkSerialize === null || linkSerialize === void 0 ? void 0 : (_linkSerialize$p$targ = linkSerialize.p.target) === null || _linkSerialize$p$targ === void 0 ? void 0 : _linkSerialize$p$targ.__i);
|
135
|
+
});
|
136
|
+
|
137
|
+
if (targetNodeSerialize) {
|
138
|
+
target = targetNodeSerialize.p.tag;
|
139
|
+
}
|
140
|
+
}
|
141
|
+
}
|
142
|
+
|
143
|
+
return _extends({}, link, {
|
144
|
+
target: target
|
145
|
+
});
|
146
|
+
});
|
147
|
+
return newLinks;
|
148
|
+
}
|
149
|
+
|
150
|
+
function getIpNodes(serialize, nodes) {
|
151
|
+
// 从序列化获取关联的IP
|
152
|
+
var ips = serialize.d.filter(function (item) {
|
153
|
+
return item.a.bindType === 'ip';
|
154
|
+
}).map(function (item) {
|
155
|
+
return item.a.bindIp;
|
156
|
+
}).filter(function (item) {
|
157
|
+
return !!item;
|
158
|
+
}) // 过滤ping资源对应的ip
|
159
|
+
.filter(function (ip) {
|
160
|
+
return !findPingNode(nodes, ip);
|
161
|
+
});
|
162
|
+
return ips.map(buildIpNode);
|
163
|
+
}
|
164
|
+
|
165
|
+
function findIpNodeSerialize(serialize, ip) {
|
166
|
+
return serialize.d.find(function (item) {
|
167
|
+
return item.p.tag === "ip:" + ip;
|
168
|
+
});
|
169
|
+
}
|
170
|
+
|
171
|
+
function findElementSerializeById(serialize, id) {
|
172
|
+
return serialize.d.find(function (item) {
|
173
|
+
return item.a.id === id;
|
174
|
+
});
|
175
|
+
}
|
176
|
+
/**
|
177
|
+
* 链路在序列化存在且目的端不是ping资源、IP节点时,升级链路目的端序列化数据为IP节点
|
178
|
+
* @param {*} link
|
179
|
+
*/
|
180
|
+
|
181
|
+
|
182
|
+
function upgradeExitLinkTarget(link, serialize) {
|
183
|
+
var destinationIp = link.attributes['network_link.destination_ipv4'];
|
184
|
+
var linkSerialize = findElementSerializeById(serialize, link.id);
|
185
|
+
|
186
|
+
if (linkSerialize) {
|
187
|
+
// 根据链路序列化数据找目的端节点
|
188
|
+
// eslint-disable-next-line no-underscore-dangle
|
189
|
+
var targetNodeSerialize = serialize.d.find(function (item) {
|
190
|
+
var _linkSerialize$p$targ2;
|
191
|
+
|
192
|
+
return item.i === (linkSerialize === null || linkSerialize === void 0 ? void 0 : (_linkSerialize$p$targ2 = linkSerialize.p.target) === null || _linkSerialize$p$targ2 === void 0 ? void 0 : _linkSerialize$p$targ2.__i);
|
193
|
+
});
|
194
|
+
|
195
|
+
if (targetNodeSerialize && !targetNodeSerialize.p.tag) {
|
196
|
+
targetNodeSerialize.a = _extends({}, targetNodeSerialize.a, buildIpNode(destinationIp), {
|
197
|
+
isbinding: true
|
198
|
+
});
|
199
|
+
targetNodeSerialize.p.tag = "ip:" + destinationIp;
|
200
|
+
}
|
201
|
+
}
|
202
|
+
}
|
203
|
+
} // 从拓扑数据查找
|
204
|
+
|
205
|
+
function findPingNode(nodes, ip) {
|
206
|
+
return nodes.find(function (node) {
|
207
|
+
return node.ciType === "ping" && (node.ipAddress || node.attributes.ipv4_address) === ip;
|
208
|
+
});
|
209
|
+
} // 出口链路目的端设置为IP节点或者ping资源节点id
|
210
|
+
|
211
|
+
|
212
|
+
function updateLinkTarget(links, nodes) {
|
213
|
+
var newLinks = links.map(function (link) {
|
214
|
+
if (!isExitLink(link) || link.target && nodes.find(function (node) {
|
215
|
+
return node.id === link.target;
|
216
|
+
})) {
|
217
|
+
return link;
|
218
|
+
}
|
219
|
+
|
220
|
+
var destinationIp = link.attributes['network_link.destination_ipv4'];
|
221
|
+
var pingNode = findPingNode(nodes, destinationIp); // 出口链路目的端设置为IP节点或者ping资源节点id
|
222
|
+
|
223
|
+
var target = pingNode ? pingNode.id : "ip:" + destinationIp;
|
224
|
+
return _extends({}, link, {
|
225
|
+
target: target
|
226
|
+
});
|
227
|
+
});
|
228
|
+
return newLinks;
|
229
|
+
}
|
230
|
+
/**
|
231
|
+
* 编辑模式按资源查询拓扑数据处理出口链路target
|
232
|
+
* 1. 出口链路目的端设置为IP节点或者ping资源节点id
|
233
|
+
* 2. IP构造为node节点
|
234
|
+
* FIXME 移到frontend 网络拓扑编辑
|
235
|
+
* @param {*} topoData
|
236
|
+
* @returns
|
237
|
+
*/
|
238
|
+
|
239
|
+
|
240
|
+
export function processByConditionResult(topoData, groupConfigs) {
|
241
|
+
var nodes = topoData.nodes,
|
242
|
+
links = topoData.links;
|
243
|
+
var ipNodes = getIpNodes(groupConfigs, nodes); // 出口链路目的端设置为IP节点或者ping资源节点id
|
244
|
+
|
245
|
+
var newLinks = updateLinkTarget(links, nodes);
|
246
|
+
return _extends({}, topoData, {
|
247
|
+
nodes: [].concat(nodes, ipNodes),
|
248
|
+
links: newLinks
|
249
|
+
});
|
250
|
+
|
251
|
+
function getIpNodes(groupConfigs, nodes) {
|
252
|
+
var ips = groupConfigs.map(function (g) {
|
253
|
+
return g.condition.linkIps;
|
254
|
+
}).reduce(function (result, groupIps) {
|
255
|
+
return [].concat(result, groupIps);
|
256
|
+
}, []) // 过滤ping资源对应的ip节点
|
257
|
+
.filter(function (ip) {
|
258
|
+
return !findPingNode(nodes, ip);
|
259
|
+
});
|
260
|
+
return ips.map(buildIpNode);
|
261
|
+
}
|
262
|
+
}
|