@riil-frontend/component-topology 12.1.1 → 12.1.3
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/index.css +1 -1
- package/build/index.js +29 -29
- package/es/components/ColorPanel/index.js +68 -58
- package/es/core/components/AlarmListPanel/components/AlarmListItem.js +10 -1
- package/es/core/editor/components/Toolbar/widgets/FontColorButton.js +10 -91
- package/es/core/editor/components/Toolbar/widgets/components/FontColorDropdown.js +120 -0
- package/es/core/editor/components/Toolbar/widgets/components/FontColorDropdown.module.scss +45 -0
- package/es/core/editor/components/Toolbar/widgets/components/FontStyleSelect.js +21 -15
- package/es/core/hooks/useResourceConfig.js +1 -2
- package/es/core/hooks/useTopoEdit.js +2 -1
- package/es/core/models/TopoApp.js +1 -1
- package/es/core/models/topoData.js +3 -4
- package/es/core/models/utils/linkUtils.js +29 -24
- package/es/core/store/models/topoMod.js +3 -6
- package/es/core/viewer/components/plugins/ResourceDetail/components/ResourceOverview/EventsCard.js +4 -2
- package/es/core/viewer/components/plugins/ResourceDetail/components/ResourceOverview/ResourceOverview.js +2 -1
- package/es/core/viewer/components/plugins/ResourceDetail/components/ResourceOverview/components/LinkTopo/LinkTopo.js +3 -2
- package/es/core/viewer/components/plugins/ResourceDetail/components/ResourceOverview/components/LinkTopo/LinkTopoCard.js +4 -2
- package/es/networkTopo/services/topo/basic.js +27 -17
- package/es/networkTopo/utils/exitLinkUtil.js +2 -2
- package/es/networkTopo/utils/relateTopoDataUtil.js +144 -0
- package/es/utils/ResourceConfigUtil.js +1 -16
- package/es/utils/htElementUtils.js +3 -1
- package/lib/components/ColorPanel/index.js +71 -59
- package/lib/core/components/AlarmListPanel/components/AlarmListItem.js +10 -1
- package/lib/core/editor/components/Toolbar/widgets/FontColorButton.js +11 -95
- package/lib/core/editor/components/Toolbar/widgets/components/FontColorDropdown.js +136 -0
- package/lib/core/editor/components/Toolbar/widgets/components/FontColorDropdown.module.scss +45 -0
- package/lib/core/editor/components/Toolbar/widgets/components/FontStyleSelect.js +21 -15
- package/lib/core/hooks/useResourceConfig.js +1 -2
- package/lib/core/hooks/useTopoEdit.js +2 -1
- package/lib/core/models/TopoApp.js +1 -1
- package/lib/core/models/topoData.js +3 -4
- package/lib/core/models/utils/linkUtils.js +29 -24
- package/lib/core/store/models/topoMod.js +3 -6
- package/lib/core/viewer/components/plugins/ResourceDetail/components/ResourceOverview/EventsCard.js +6 -2
- package/lib/core/viewer/components/plugins/ResourceDetail/components/ResourceOverview/ResourceOverview.js +2 -1
- package/lib/core/viewer/components/plugins/ResourceDetail/components/ResourceOverview/components/LinkTopo/LinkTopo.js +3 -2
- package/lib/core/viewer/components/plugins/ResourceDetail/components/ResourceOverview/components/LinkTopo/LinkTopoCard.js +4 -2
- package/lib/networkTopo/services/topo/basic.js +32 -18
- package/lib/networkTopo/utils/exitLinkUtil.js +2 -2
- package/lib/networkTopo/utils/relateTopoDataUtil.js +158 -0
- package/lib/utils/ResourceConfigUtil.js +1 -16
- package/lib/utils/htElementUtils.js +3 -1
- package/package.json +2 -2
@@ -72,38 +72,32 @@ function isAggLink(link) {
|
|
72
72
|
return (link === null || link === void 0 ? void 0 : (_link$attributes2 = link.attributes) === null || _link$attributes2 === void 0 ? void 0 : _link$attributes2.destination_type) === "network.agg_interface" && (link === null || link === void 0 ? void 0 : (_link$attributes3 = link.attributes) === null || _link$attributes3 === void 0 ? void 0 : _link$attributes3.source_type) === "network.agg_interface";
|
73
73
|
}
|
74
74
|
|
75
|
-
function mergeLinksData(links, linkCis, nodes,
|
75
|
+
function mergeLinksData(links, linkCis, nodes, ciMap, interfaceDoc) {
|
76
76
|
var linkCiMap = (0, _keyBy["default"])(links, "id");
|
77
77
|
return links.map(function (link) {
|
78
|
-
var
|
78
|
+
var _ciMap$attributes$net, _ciMap$attributes$net2, _ciMap$attributes$sou, _ciMap$attributes$des;
|
79
79
|
|
80
80
|
var linkCi = linkCiMap[link.id];
|
81
|
-
var attributes = (0, _extends2["default"])({}, linkCi === null || linkCi === void 0 ? void 0 : linkCi.attributes);
|
82
|
-
var sourceNode = nodes.find(function (node) {
|
83
|
-
return node.id === attributes["network_link.source_device_id"];
|
84
|
-
});
|
85
|
-
var targetNode = nodes.find(function (node) {
|
86
|
-
return node.id === attributes["network_link.destination_device_id"];
|
87
|
-
}); // 翻译
|
81
|
+
var attributes = (0, _extends2["default"])({}, linkCi === null || linkCi === void 0 ? void 0 : linkCi.attributes); // 翻译
|
88
82
|
|
89
83
|
return (0, _extends2["default"])({}, link, {
|
90
84
|
attributes: (0, _extends2["default"])({}, attributes, {
|
91
85
|
// 源/目的设备
|
92
86
|
"network_link.source_device_id_object": {
|
93
|
-
displayName:
|
87
|
+
displayName: (_ciMap$attributes$net = ciMap[attributes["network_link.source_device_id"]]) === null || _ciMap$attributes$net === void 0 ? void 0 : _ciMap$attributes$net.attributes["display_name"]
|
94
88
|
},
|
95
89
|
"network_link.destination_device_id_object": {
|
96
|
-
displayName:
|
90
|
+
displayName: (_ciMap$attributes$net2 = ciMap[attributes["network_link.destination_device_id"]]) === null || _ciMap$attributes$net2 === void 0 ? void 0 : _ciMap$attributes$net2.attributes["display_name"]
|
97
91
|
},
|
98
92
|
// 源/目的接口类型
|
99
93
|
source_type_object: interfaceDoc[attributes.source_type],
|
100
94
|
destination_type_object: interfaceDoc[attributes.destination_type],
|
101
95
|
// 源/目的接口
|
102
96
|
source_id_object: {
|
103
|
-
displayName: (
|
97
|
+
displayName: (_ciMap$attributes$sou = ciMap[attributes.source_id]) === null || _ciMap$attributes$sou === void 0 ? void 0 : _ciMap$attributes$sou.attributes["display_name"]
|
104
98
|
},
|
105
99
|
destination_id_object: {
|
106
|
-
displayName: (
|
100
|
+
displayName: (_ciMap$attributes$des = ciMap[attributes.destination_id]) === null || _ciMap$attributes$des === void 0 ? void 0 : _ciMap$attributes$des.attributes["display_name"]
|
107
101
|
}
|
108
102
|
})
|
109
103
|
});
|
@@ -116,7 +110,7 @@ function getLinksDetail(_x, _x2) {
|
|
116
110
|
|
117
111
|
function _getLinksDetail() {
|
118
112
|
_getLinksDetail = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee(links, nodes) {
|
119
|
-
var linkCis,
|
113
|
+
var linkCis, ciMap, ciIds, interfaceTypes, loadCiMap, interfaceDoc;
|
120
114
|
return _regenerator["default"].wrap(function _callee$(_context) {
|
121
115
|
while (1) switch (_context.prev = _context.next) {
|
122
116
|
case 0:
|
@@ -129,11 +123,20 @@ function _getLinksDetail() {
|
|
129
123
|
|
130
124
|
case 2:
|
131
125
|
linkCis = links;
|
132
|
-
|
126
|
+
ciMap = (0, _keyBy["default"])(nodes, "id");
|
127
|
+
ciIds = _lodash["default"].uniq([].concat(linkCis.map(function (item) {
|
128
|
+
return item.attributes['network_link.destination_device_id'];
|
129
|
+
}), linkCis.map(function (item) {
|
130
|
+
return item.attributes['network_link.source_device_id'];
|
131
|
+
}), linkCis.map(function (item) {
|
133
132
|
return item.attributes.source_id;
|
134
133
|
}), linkCis.map(function (item) {
|
135
134
|
return item.attributes.destination_id;
|
136
|
-
}))
|
135
|
+
}))).filter(function (item) {
|
136
|
+
return !!item;
|
137
|
+
}).filter(function (item) {
|
138
|
+
return !ciMap[item];
|
139
|
+
});
|
137
140
|
interfaceTypes = _lodash["default"].compact(_lodash["default"].uniq([].concat(linkCis.map(function (item) {
|
138
141
|
return item.attributes.source_type;
|
139
142
|
}), linkCis.map(function (item) {
|
@@ -141,19 +144,21 @@ function _getLinksDetail() {
|
|
141
144
|
})))).filter(function (item) {
|
142
145
|
return item !== "ip";
|
143
146
|
});
|
144
|
-
_context.next =
|
145
|
-
return _CiCache["default"].load(
|
147
|
+
_context.next = 8;
|
148
|
+
return _CiCache["default"].load(ciIds);
|
146
149
|
|
147
|
-
case
|
148
|
-
|
149
|
-
_context.next =
|
150
|
+
case 8:
|
151
|
+
loadCiMap = _context.sent;
|
152
|
+
_context.next = 11;
|
150
153
|
return _CiTypeCache["default"].load(interfaceTypes);
|
151
154
|
|
152
|
-
case
|
155
|
+
case 11:
|
153
156
|
interfaceDoc = _context.sent;
|
154
|
-
|
157
|
+
Object.assign(ciMap, loadCiMap); // console.log('getLinksDetail-mergeLinksData', { relations, interfaceIds, interfaceCis, })
|
158
|
+
|
159
|
+
return _context.abrupt("return", mergeLinksData(links, linkCis, nodes, ciMap, interfaceDoc));
|
155
160
|
|
156
|
-
case
|
161
|
+
case 14:
|
157
162
|
case "end":
|
158
163
|
return _context.stop();
|
159
164
|
}
|
@@ -415,7 +415,8 @@ function _default(topoApp) {
|
|
415
415
|
globalConfig: extraConfig,
|
416
416
|
type: (_result$config = result.config) === null || _result$config === void 0 ? void 0 : _result$config.showType,
|
417
417
|
topoData: topoData,
|
418
|
-
resAndMetrics: resAndMetrics
|
418
|
+
resAndMetrics: resAndMetrics,
|
419
|
+
loading: false
|
419
420
|
});
|
420
421
|
|
421
422
|
case 47:
|
@@ -447,11 +448,7 @@ function _default(topoApp) {
|
|
447
448
|
|
448
449
|
topoApp.options.onLoad();
|
449
450
|
|
450
|
-
|
451
|
-
loading: false
|
452
|
-
});
|
453
|
-
|
454
|
-
case 62:
|
451
|
+
case 61:
|
455
452
|
case "end":
|
456
453
|
return _context4.stop();
|
457
454
|
}
|
package/lib/core/viewer/components/plugins/ResourceDetail/components/ResourceOverview/EventsCard.js
CHANGED
@@ -29,10 +29,11 @@ var _indexModule = _interopRequireDefault(require("./index.module.scss"));
|
|
29
29
|
|
30
30
|
var _componentTopologyUtils = require("@riil-frontend/component-topology-utils");
|
31
31
|
|
32
|
+
var _loglevel = _interopRequireDefault(require("loglevel"));
|
33
|
+
|
32
34
|
function formatUrl(url) {
|
33
35
|
var _window, _window$location;
|
34
36
|
|
35
|
-
console.log(url);
|
36
37
|
var prefix = '/default/pagecenter';
|
37
38
|
|
38
39
|
if (((_window = window) === null || _window === void 0 ? void 0 : (_window$location = _window.location) === null || _window$location === void 0 ? void 0 : _window$location.pathname.indexOf(prefix)) === 0 && (url === null || url === void 0 ? void 0 : url.indexOf(prefix)) === 0) {
|
@@ -47,11 +48,14 @@ function EventsCard(props) {
|
|
47
48
|
closeDetailDrawer = props.closeDetailDrawer,
|
48
49
|
onHandleAlarm = props.onHandleAlarm;
|
49
50
|
|
51
|
+
var log = _loglevel["default"].getLogger('topo');
|
52
|
+
|
50
53
|
var jumpTo = function jumpTo(url) {
|
51
54
|
closeDetailDrawer();
|
52
55
|
|
53
56
|
if (topo.viewProps.jumpto) {
|
54
|
-
|
57
|
+
log.debug('formatUrl(url)', url);
|
58
|
+
topo.viewProps.jumpto(url);
|
55
59
|
} else {
|
56
60
|
(0, _componentTopologyUtils.getHistory)().push(formatUrl(url));
|
57
61
|
}
|
@@ -920,7 +920,8 @@ function ResourceOverview(props) {
|
|
920
920
|
return item.code;
|
921
921
|
}),
|
922
922
|
getOverviewConfig: resourceOverviewProps.getOverviewConfig,
|
923
|
-
saveOverviewConfig: resourceOverviewProps.saveOverviewConfig
|
923
|
+
saveOverviewConfig: resourceOverviewProps.saveOverviewConfig,
|
924
|
+
jumpto: topo.viewProps.jumpto
|
924
925
|
}) : /*#__PURE__*/_react["default"].createElement(_BlockBox["default"], {
|
925
926
|
headerTitle: "\u5173\u952E\u6307\u6807",
|
926
927
|
headerExtra: /*#__PURE__*/_react["default"].createElement(_Configurator["default"], {
|
@@ -20,7 +20,8 @@ var _LinkTopoModule = _interopRequireDefault(require("./LinkTopo.module.scss"));
|
|
20
20
|
function LinkTopo(props) {
|
21
21
|
var data = props.data,
|
22
22
|
linkMetricCodes = props.linkMetricCodes,
|
23
|
-
openFlow = props.openFlow
|
23
|
+
openFlow = props.openFlow,
|
24
|
+
jumpto = props.jumpto;
|
24
25
|
var metricData = (0, _useMetricPolling["default"])({
|
25
26
|
linkCi: data,
|
26
27
|
linkMetricCodes: linkMetricCodes
|
@@ -46,7 +47,7 @@ function LinkTopo(props) {
|
|
46
47
|
data: data // 链路ci数据
|
47
48
|
,
|
48
49
|
isNarrow: true,
|
49
|
-
jumpto: (0, _componentTopologyUtils.getHistory)().push
|
50
|
+
jumpto: jumpto || (0, _componentTopologyUtils.getHistory)().push
|
50
51
|
}, metricData, {
|
51
52
|
openFlow: openFlow
|
52
53
|
})));
|
@@ -31,7 +31,8 @@ function LinkTopoCard(props) {
|
|
31
31
|
defaultCols = props.defaultCols,
|
32
32
|
metricCol = props.metricCol,
|
33
33
|
metricColChange = props.metricColChange,
|
34
|
-
metricCodes = props.metricCodes
|
34
|
+
metricCodes = props.metricCodes,
|
35
|
+
jumpto = props.jumpto; // eslint-disable-next-line camelcase
|
35
36
|
|
36
37
|
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
38
|
|
@@ -122,6 +123,7 @@ function LinkTopoCard(props) {
|
|
122
123
|
linkMetricCodes: openFlow && openFlow.name == '查看流量构成' ? metricCodes : metricCodes.filter(function (i) {
|
123
124
|
return i != 'netDelayRatio' && i != 'retansRatio';
|
124
125
|
}),
|
125
|
-
openFlow: openFlow
|
126
|
+
openFlow: openFlow,
|
127
|
+
jumpto: jumpto
|
126
128
|
}));
|
127
129
|
}
|
@@ -5,8 +5,6 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
|
|
5
5
|
exports.__esModule = true;
|
6
6
|
exports["default"] = exports.TOPO_PARENT_ID = exports.TOPO_GROUP_ID = void 0;
|
7
7
|
|
8
|
-
var _objectWithoutPropertiesLoose2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutPropertiesLoose"));
|
9
|
-
|
10
8
|
var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
|
11
9
|
|
12
10
|
var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
|
@@ -23,7 +21,12 @@ var _model = require("../model");
|
|
23
21
|
|
24
22
|
var _exitLinkUtil = require("../../utils/exitLinkUtil");
|
25
23
|
|
26
|
-
var
|
24
|
+
var relateTopoDataUtil = _interopRequireWildcard(require("../../utils/relateTopoDataUtil"));
|
25
|
+
|
26
|
+
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); }
|
27
|
+
|
28
|
+
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; }
|
29
|
+
|
27
30
|
var API_ROOT = _constants.TOPO_API_ROOT;
|
28
31
|
/**
|
29
32
|
* 拓扑图(看做一个容器)的“父容器”ID
|
@@ -66,7 +69,7 @@ function prepareResourceParams(conditions, query) {
|
|
66
69
|
return {
|
67
70
|
dynamicCondition: dynamicCondition,
|
68
71
|
fixedConditionIdList: (staticRes || []).filter(function (ciId) {
|
69
|
-
return !ciId.
|
72
|
+
return !ciId.includes(':');
|
70
73
|
}),
|
71
74
|
linkIps: (staticRes || []).filter(function (ciId) {
|
72
75
|
return ciId.startsWith('ip:');
|
@@ -115,7 +118,8 @@ function prepareGroupParams(modifiedGroups) {
|
|
115
118
|
};
|
116
119
|
}).filter(Boolean);
|
117
120
|
return {
|
118
|
-
groups: groups
|
121
|
+
groups: groups,
|
122
|
+
relateTopoIdList: relateTopoDataUtil.getRelateTopoIdListFromConfig(modifiedGroups)
|
119
123
|
};
|
120
124
|
}
|
121
125
|
|
@@ -406,16 +410,20 @@ var _default = (0, _extends2["default"])({
|
|
406
410
|
|
407
411
|
case 2:
|
408
412
|
result = _context12.sent;
|
409
|
-
|
413
|
+
result = (0, _extends2["default"])({}, result, {
|
410
414
|
nodes: (_result$nodes = result.nodes) !== null && _result$nodes !== void 0 ? _result$nodes : [],
|
411
415
|
links: ((_result$links = result.links) !== null && _result$links !== void 0 ? _result$links : []).map(function (item) {
|
412
416
|
return (0, _extends2["default"])({}, item, {
|
413
417
|
ciType: 'network_link'
|
414
418
|
});
|
415
|
-
})
|
416
|
-
|
419
|
+
}),
|
420
|
+
serialize: result.serialize ? JSON.parse(result.serialize) : undefined
|
421
|
+
});
|
422
|
+
result = relateTopoDataUtil.processBothTopoData(result);
|
423
|
+
result = (0, _exitLinkUtil.processExitLink)(result);
|
424
|
+
return _context12.abrupt("return", result);
|
417
425
|
|
418
|
-
case
|
426
|
+
case 7:
|
419
427
|
case "end":
|
420
428
|
return _context12.stop();
|
421
429
|
}
|
@@ -434,7 +442,7 @@ var _default = (0, _extends2["default"])({
|
|
434
442
|
return (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee13() {
|
435
443
|
var _result$nodes2, _result$links2;
|
436
444
|
|
437
|
-
var data,
|
445
|
+
var data, params, result;
|
438
446
|
return _regenerator["default"].wrap(function _callee13$(_context13) {
|
439
447
|
while (1) switch (_context13.prev = _context13.next) {
|
440
448
|
case 0:
|
@@ -448,22 +456,28 @@ var _default = (0, _extends2["default"])({
|
|
448
456
|
});
|
449
457
|
}
|
450
458
|
|
451
|
-
|
459
|
+
params = prepareGroupParams(data);
|
452
460
|
_context13.next = 5;
|
453
|
-
return _componentTopologyUtils.request.post(API_ROOT + "/structure/byCondition/" + id,
|
461
|
+
return _componentTopologyUtils.request.post(API_ROOT + "/structure/byCondition/" + id, params);
|
454
462
|
|
455
463
|
case 5:
|
456
464
|
result = _context13.sent;
|
457
|
-
|
465
|
+
result = (0, _extends2["default"])({}, result, {
|
458
466
|
nodes: (_result$nodes2 = result.nodes) !== null && _result$nodes2 !== void 0 ? _result$nodes2 : [],
|
459
467
|
links: ((_result$links2 = result.links) !== null && _result$links2 !== void 0 ? _result$links2 : []).map(function (item) {
|
460
468
|
return (0, _extends2["default"])({}, item, {
|
461
469
|
ciType: 'network_link'
|
462
470
|
});
|
463
471
|
})
|
464
|
-
})
|
472
|
+
});
|
473
|
+
result = relateTopoDataUtil.processByConditionTopoData({
|
474
|
+
data: result,
|
475
|
+
config: data
|
476
|
+
});
|
477
|
+
result = (0, _exitLinkUtil.processByConditionResult)(result, params.groups);
|
478
|
+
return _context13.abrupt("return", result);
|
465
479
|
|
466
|
-
case
|
480
|
+
case 10:
|
467
481
|
case "end":
|
468
482
|
return _context13.stop();
|
469
483
|
}
|
@@ -480,11 +494,11 @@ var _default = (0, _extends2["default"])({
|
|
480
494
|
*/
|
481
495
|
bindResourceToTopo: function bindResourceToTopo(id, config) {
|
482
496
|
return (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee14() {
|
483
|
-
var groups, resources,
|
497
|
+
var groups, resources, newGroups, obj;
|
484
498
|
return _regenerator["default"].wrap(function _callee14$(_context14) {
|
485
499
|
while (1) switch (_context14.prev = _context14.next) {
|
486
500
|
case 0:
|
487
|
-
groups = config.groups, resources = config.resources
|
501
|
+
groups = config.groups, resources = config.resources;
|
488
502
|
newGroups = Array.isArray(groups) ? groups : [];
|
489
503
|
|
490
504
|
if (resources) {
|
@@ -498,7 +512,7 @@ var _default = (0, _extends2["default"])({
|
|
498
512
|
|
499
513
|
obj = prepareGroupParams(newGroups);
|
500
514
|
_context14.next = 6;
|
501
|
-
return _componentTopologyUtils.request.post(API_ROOT + "/resource/" + id,
|
515
|
+
return _componentTopologyUtils.request.post(API_ROOT + "/resource/" + id, obj);
|
502
516
|
|
503
517
|
case 6:
|
504
518
|
return _context14.abrupt("return", _context14.sent);
|
@@ -47,11 +47,11 @@ function buildIpNode(ip) {
|
|
47
47
|
}
|
48
48
|
|
49
49
|
function getHtSerialize(serialize) {
|
50
|
-
if (serialize) {
|
50
|
+
if (serialize && typeof serialize === 'string') {
|
51
51
|
return JSON.parse(serialize);
|
52
52
|
}
|
53
53
|
|
54
|
-
return
|
54
|
+
return serialize;
|
55
55
|
}
|
56
56
|
|
57
57
|
function isExitLink(link) {
|
@@ -0,0 +1,158 @@
|
|
1
|
+
"use strict";
|
2
|
+
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
4
|
+
|
5
|
+
exports.__esModule = true;
|
6
|
+
exports.buildTopoNode = buildTopoNode;
|
7
|
+
exports.getRelateTopoIdListFromConfig = getRelateTopoIdListFromConfig;
|
8
|
+
exports.processBothTopoData = processBothTopoData;
|
9
|
+
exports.processByConditionTopoData = processByConditionTopoData;
|
10
|
+
|
11
|
+
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
|
12
|
+
|
13
|
+
// 关联拓扑数据
|
14
|
+
|
15
|
+
/**
|
16
|
+
* 升级历史数据:子拓扑节点序列化数据
|
17
|
+
* 构造子拓扑节点
|
18
|
+
* 构造子拓扑链路
|
19
|
+
* @param {*} ctx
|
20
|
+
*/
|
21
|
+
function processBothTopoData(topoData) {
|
22
|
+
var nodes = topoData.nodes,
|
23
|
+
links = topoData.links;
|
24
|
+
var serialize = upgradeSerializeOldTopoNode(topoData.serialize);
|
25
|
+
return (0, _extends2["default"])({}, topoData, {
|
26
|
+
nodes: [].concat(nodes, buildTopoNodeDatasFromSerialize(serialize)),
|
27
|
+
links: buildTopoLinks(links),
|
28
|
+
serialize: serialize
|
29
|
+
});
|
30
|
+
}
|
31
|
+
/**
|
32
|
+
* 构造子拓扑节点
|
33
|
+
* 构造子拓扑链路
|
34
|
+
* @param {*} ctx
|
35
|
+
*/
|
36
|
+
|
37
|
+
|
38
|
+
function processByConditionTopoData(ctx) {
|
39
|
+
var data = ctx.data,
|
40
|
+
config = ctx.config;
|
41
|
+
var nodes = data.nodes,
|
42
|
+
links = data.links;
|
43
|
+
return (0, _extends2["default"])({}, data, {
|
44
|
+
nodes: [].concat(nodes, buildTopoNodeDatas(config)),
|
45
|
+
links: buildTopoLinks(links)
|
46
|
+
});
|
47
|
+
}
|
48
|
+
|
49
|
+
function getRelateTopoIdListFromConfig(groups) {
|
50
|
+
var relateTopoIdList = [];
|
51
|
+
groups.forEach(function (g) {
|
52
|
+
g.resources["static"].filter(function (ciId) {
|
53
|
+
return ciId.startsWith('topo:');
|
54
|
+
}).map(function (ciId) {
|
55
|
+
return ciId.replace('topo:', '');
|
56
|
+
}).map(function (topoId) {
|
57
|
+
if (!relateTopoIdList.includes(topoId)) {
|
58
|
+
relateTopoIdList.push(topoId);
|
59
|
+
}
|
60
|
+
});
|
61
|
+
});
|
62
|
+
return relateTopoIdList;
|
63
|
+
}
|
64
|
+
|
65
|
+
function buildTopoNode(topoId) {
|
66
|
+
return {
|
67
|
+
id: "topo:" + topoId,
|
68
|
+
// name: ,
|
69
|
+
bindType: "topo",
|
70
|
+
// 绑定资源类型。关联资源 值为空,关联IP ip
|
71
|
+
bindTopo: topoId,
|
72
|
+
// TODO 所属区域,从序列化拿
|
73
|
+
// 'groupId': null,
|
74
|
+
// 'groupTag': null,
|
75
|
+
// 'attributes': [],
|
76
|
+
// 'metrics': [],
|
77
|
+
type: "node",
|
78
|
+
isbinding: true,
|
79
|
+
// 'dtype': 'device'
|
80
|
+
operation: "delete"
|
81
|
+
};
|
82
|
+
}
|
83
|
+
|
84
|
+
function buildTopoLinks(links) {
|
85
|
+
return links.map(function (link) {
|
86
|
+
return (0, _extends2["default"])({}, link, {
|
87
|
+
"source": link.sourceType ? link.sourceType + ':' + link.source : link.source,
|
88
|
+
"target": link.targetType ? link.targetType + ':' + link.target : link.target
|
89
|
+
});
|
90
|
+
});
|
91
|
+
}
|
92
|
+
/**
|
93
|
+
* 升级历史数据:子拓扑节点序列化数据
|
94
|
+
* @param {*} serialize
|
95
|
+
*/
|
96
|
+
|
97
|
+
|
98
|
+
function upgradeSerializeOldTopoNode(serialize) {
|
99
|
+
if (serialize) {
|
100
|
+
var isOldTopoNode = function isOldTopoNode(ele) {
|
101
|
+
return isTopoNode(ele) && !ele.p.tag;
|
102
|
+
};
|
103
|
+
|
104
|
+
var oldTopoNodes = serialize.d.filter(isOldTopoNode);
|
105
|
+
oldTopoNodes.forEach(function (node) {
|
106
|
+
var _node$a;
|
107
|
+
|
108
|
+
var topoId = (_node$a = node.a) === null || _node$a === void 0 ? void 0 : _node$a.bindTopo;
|
109
|
+
node.a = (0, _extends2["default"])({}, node.a, buildTopoNode(topoId));
|
110
|
+
node.p.tag = "topo:" + topoId;
|
111
|
+
});
|
112
|
+
}
|
113
|
+
|
114
|
+
return serialize;
|
115
|
+
}
|
116
|
+
|
117
|
+
function isTopoNode(ele) {
|
118
|
+
var _ele$a;
|
119
|
+
|
120
|
+
return !!((_ele$a = ele.a) !== null && _ele$a !== void 0 && _ele$a.bindTopo);
|
121
|
+
}
|
122
|
+
|
123
|
+
function buildTopoNodeDatasFromSerialize(serialize) {
|
124
|
+
if (!serialize) {
|
125
|
+
return [];
|
126
|
+
}
|
127
|
+
|
128
|
+
var topoNodes = serialize.d.filter(isTopoNode);
|
129
|
+
var topoNodeDatas = topoNodes.map(function (node) {
|
130
|
+
var _node$a2;
|
131
|
+
|
132
|
+
var topoId = (_node$a2 = node.a) === null || _node$a2 === void 0 ? void 0 : _node$a2.bindTopo;
|
133
|
+
return buildTopoNode(topoId);
|
134
|
+
});
|
135
|
+
return topoNodeDatas;
|
136
|
+
}
|
137
|
+
|
138
|
+
function buildTopoNodeDatas(config) {
|
139
|
+
var topoNodeDatas = [];
|
140
|
+
config.forEach(function (g) {
|
141
|
+
g.resources["static"].filter(function (ciId) {
|
142
|
+
return ciId.startsWith('topo:');
|
143
|
+
}).map(function (ciId) {
|
144
|
+
return ciId.replace('topo:', '');
|
145
|
+
}).map(function (topoId) {
|
146
|
+
topoNodeDatas.push((0, _extends2["default"])({}, buildTopoNode(topoId), {
|
147
|
+
// 添加资源拓扑节点消失的问题
|
148
|
+
'groupId': g.id,
|
149
|
+
'groupTag': g.tag
|
150
|
+
}));
|
151
|
+
});
|
152
|
+
});
|
153
|
+
return topoNodeDatas;
|
154
|
+
}
|
155
|
+
|
156
|
+
function getRelateTopoIdsFromSerialize(serialize) {
|
157
|
+
return serialize;
|
158
|
+
}
|
@@ -52,23 +52,8 @@ function getResourceConfigFromHt(topo) {
|
|
52
52
|
return {
|
53
53
|
layers: (0, _sortBy["default"])(layers, 'order'),
|
54
54
|
groups: groups,
|
55
|
-
resources: resources
|
56
|
-
relateTopoIdList: getRelateTopoIdList(dataModel)
|
55
|
+
resources: resources
|
57
56
|
};
|
58
|
-
} // 查询关联拓扑id列表
|
59
|
-
|
60
|
-
|
61
|
-
function getRelateTopoIdList(dataModel) {
|
62
|
-
return (0, _htElementUtils.getNodes)(dataModel).reduce(function (topoIds, node) {
|
63
|
-
var bindType = node.a('bindType');
|
64
|
-
var bindTopo = node.a('bindTopo');
|
65
|
-
|
66
|
-
if (bindType === 'topo' && bindTopo && !topoIds.includes(bindTopo)) {
|
67
|
-
return [].concat(topoIds, [bindTopo]);
|
68
|
-
}
|
69
|
-
|
70
|
-
return topoIds;
|
71
|
-
}, []);
|
72
57
|
}
|
73
58
|
|
74
59
|
function getLayerDatas(dataModel) {
|
@@ -199,7 +199,9 @@ function getEdgesBetweenNodes(node1, node2) {
|
|
199
199
|
return edges;
|
200
200
|
}
|
201
201
|
|
202
|
-
node1Edges.toArray().filter(isValidEdge).
|
202
|
+
node1Edges.toArray().filter(isValidEdge).filter(function (edge) {
|
203
|
+
return !isEdgeGroupAgent(edge);
|
204
|
+
}).forEach(function (edge) {
|
203
205
|
var isEdgeBetweenNodes = edge.getSource().getTag() === node2.getTag() || edge.getTarget().getTag() === node2.getTag();
|
204
206
|
|
205
207
|
if (isEdgeBetweenNodes) {
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@riil-frontend/component-topology",
|
3
|
-
"version": "12.1.
|
3
|
+
"version": "12.1.3",
|
4
4
|
"description": "拓扑",
|
5
5
|
"scripts": {
|
6
6
|
"start": "build-scripts start",
|
@@ -123,6 +123,6 @@
|
|
123
123
|
"access": "public"
|
124
124
|
},
|
125
125
|
"license": "MIT",
|
126
|
-
"homepage": "https://unpkg.com/@riil-frontend/component-topology@12.1.
|
126
|
+
"homepage": "https://unpkg.com/@riil-frontend/component-topology@12.1.3/build/index.html",
|
127
127
|
"gitHead": "2da19ffccbb7ca60a8acf396e39f542c68bb33f5"
|
128
128
|
}
|