@riil-frontend/component-topology 12.1.2 → 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/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/package.json +2 -2
@@ -46,40 +46,34 @@ export function isAggLink(link) {
|
|
46
46
|
|
47
47
|
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";
|
48
48
|
}
|
49
|
-
export function mergeLinksData(links, linkCis, nodes,
|
49
|
+
export function mergeLinksData(links, linkCis, nodes, ciMap, interfaceDoc) {
|
50
50
|
var linkCiMap = keyBy(links, "id");
|
51
51
|
return links.map(function (link) {
|
52
|
-
var
|
52
|
+
var _ciMap$attributes$net, _ciMap$attributes$net2, _ciMap$attributes$sou, _ciMap$attributes$des;
|
53
53
|
|
54
54
|
var linkCi = linkCiMap[link.id];
|
55
55
|
|
56
|
-
var attributes = _extends({}, linkCi === null || linkCi === void 0 ? void 0 : linkCi.attributes);
|
56
|
+
var attributes = _extends({}, linkCi === null || linkCi === void 0 ? void 0 : linkCi.attributes); // 翻译
|
57
57
|
|
58
|
-
var sourceNode = nodes.find(function (node) {
|
59
|
-
return node.id === attributes["network_link.source_device_id"];
|
60
|
-
});
|
61
|
-
var targetNode = nodes.find(function (node) {
|
62
|
-
return node.id === attributes["network_link.destination_device_id"];
|
63
|
-
}); // 翻译
|
64
58
|
|
65
59
|
return _extends({}, link, {
|
66
60
|
attributes: _extends({}, attributes, {
|
67
61
|
// 源/目的设备
|
68
62
|
"network_link.source_device_id_object": {
|
69
|
-
displayName:
|
63
|
+
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"]
|
70
64
|
},
|
71
65
|
"network_link.destination_device_id_object": {
|
72
|
-
displayName:
|
66
|
+
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"]
|
73
67
|
},
|
74
68
|
// 源/目的接口类型
|
75
69
|
source_type_object: interfaceDoc[attributes.source_type],
|
76
70
|
destination_type_object: interfaceDoc[attributes.destination_type],
|
77
71
|
// 源/目的接口
|
78
72
|
source_id_object: {
|
79
|
-
displayName: (
|
73
|
+
displayName: (_ciMap$attributes$sou = ciMap[attributes.source_id]) === null || _ciMap$attributes$sou === void 0 ? void 0 : _ciMap$attributes$sou.attributes["display_name"]
|
80
74
|
},
|
81
75
|
destination_id_object: {
|
82
|
-
displayName: (
|
76
|
+
displayName: (_ciMap$attributes$des = ciMap[attributes.destination_id]) === null || _ciMap$attributes$des === void 0 ? void 0 : _ciMap$attributes$des.attributes["display_name"]
|
83
77
|
}
|
84
78
|
})
|
85
79
|
});
|
@@ -91,7 +85,7 @@ export function getLinksDetail(_x, _x2) {
|
|
91
85
|
|
92
86
|
function _getLinksDetail() {
|
93
87
|
_getLinksDetail = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(links, nodes) {
|
94
|
-
var linkCis,
|
88
|
+
var linkCis, ciMap, ciIds, interfaceTypes, loadCiMap, interfaceDoc;
|
95
89
|
return _regeneratorRuntime.wrap(function _callee$(_context) {
|
96
90
|
while (1) switch (_context.prev = _context.next) {
|
97
91
|
case 0:
|
@@ -104,11 +98,20 @@ function _getLinksDetail() {
|
|
104
98
|
|
105
99
|
case 2:
|
106
100
|
linkCis = links;
|
107
|
-
|
101
|
+
ciMap = keyBy(nodes, "id");
|
102
|
+
ciIds = _.uniq([].concat(linkCis.map(function (item) {
|
103
|
+
return item.attributes['network_link.destination_device_id'];
|
104
|
+
}), linkCis.map(function (item) {
|
105
|
+
return item.attributes['network_link.source_device_id'];
|
106
|
+
}), linkCis.map(function (item) {
|
108
107
|
return item.attributes.source_id;
|
109
108
|
}), linkCis.map(function (item) {
|
110
109
|
return item.attributes.destination_id;
|
111
|
-
}))
|
110
|
+
}))).filter(function (item) {
|
111
|
+
return !!item;
|
112
|
+
}).filter(function (item) {
|
113
|
+
return !ciMap[item];
|
114
|
+
});
|
112
115
|
interfaceTypes = _.compact(_.uniq([].concat(linkCis.map(function (item) {
|
113
116
|
return item.attributes.source_type;
|
114
117
|
}), linkCis.map(function (item) {
|
@@ -116,19 +119,21 @@ function _getLinksDetail() {
|
|
116
119
|
})))).filter(function (item) {
|
117
120
|
return item !== "ip";
|
118
121
|
});
|
119
|
-
_context.next =
|
120
|
-
return CiCache.load(
|
122
|
+
_context.next = 8;
|
123
|
+
return CiCache.load(ciIds);
|
121
124
|
|
122
|
-
case
|
123
|
-
|
124
|
-
_context.next =
|
125
|
+
case 8:
|
126
|
+
loadCiMap = _context.sent;
|
127
|
+
_context.next = 11;
|
125
128
|
return CiTypeCache.load(interfaceTypes);
|
126
129
|
|
127
|
-
case
|
130
|
+
case 11:
|
128
131
|
interfaceDoc = _context.sent;
|
129
|
-
|
132
|
+
Object.assign(ciMap, loadCiMap); // console.log('getLinksDetail-mergeLinksData', { relations, interfaceIds, interfaceCis, })
|
133
|
+
|
134
|
+
return _context.abrupt("return", mergeLinksData(links, linkCis, nodes, ciMap, interfaceDoc));
|
130
135
|
|
131
|
-
case
|
136
|
+
case 14:
|
132
137
|
case "end":
|
133
138
|
return _context.stop();
|
134
139
|
}
|
@@ -395,7 +395,8 @@ export default function (topoApp) {
|
|
395
395
|
globalConfig: extraConfig,
|
396
396
|
type: (_result$config = result.config) === null || _result$config === void 0 ? void 0 : _result$config.showType,
|
397
397
|
topoData: topoData,
|
398
|
-
resAndMetrics: resAndMetrics
|
398
|
+
resAndMetrics: resAndMetrics,
|
399
|
+
loading: false
|
399
400
|
});
|
400
401
|
|
401
402
|
case 47:
|
@@ -425,11 +426,7 @@ export default function (topoApp) {
|
|
425
426
|
rlog.info('topoMod.initTopoData 初始化拓扑图数据完成. 耗时: ', endTime.diff(startTime, 'seconds', true));
|
426
427
|
topoApp.options.onLoad();
|
427
428
|
|
428
|
-
|
429
|
-
loading: false
|
430
|
-
});
|
431
|
-
|
432
|
-
case 62:
|
429
|
+
case 61:
|
433
430
|
case "end":
|
434
431
|
return _context4.stop();
|
435
432
|
}
|
package/es/core/viewer/components/plugins/ResourceDetail/components/ResourceOverview/EventsCard.js
CHANGED
@@ -10,11 +10,11 @@ import Link from "../../../../../../../components/Link";
|
|
10
10
|
import service from "../../../../../../services/overview";
|
11
11
|
import styles from "./index.module.scss";
|
12
12
|
import { getHistory } from '@riil-frontend/component-topology-utils';
|
13
|
+
import loglevel from 'loglevel';
|
13
14
|
|
14
15
|
function formatUrl(url) {
|
15
16
|
var _window, _window$location;
|
16
17
|
|
17
|
-
console.log(url);
|
18
18
|
var prefix = '/default/pagecenter';
|
19
19
|
|
20
20
|
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) {
|
@@ -28,12 +28,14 @@ function EventsCard(props) {
|
|
28
28
|
var alarmRiskList = props.alarmRiskList,
|
29
29
|
closeDetailDrawer = props.closeDetailDrawer,
|
30
30
|
onHandleAlarm = props.onHandleAlarm;
|
31
|
+
var log = loglevel.getLogger('topo');
|
31
32
|
|
32
33
|
var jumpTo = function jumpTo(url) {
|
33
34
|
closeDetailDrawer();
|
34
35
|
|
35
36
|
if (topo.viewProps.jumpto) {
|
36
|
-
|
37
|
+
log.debug('formatUrl(url)', url);
|
38
|
+
topo.viewProps.jumpto(url);
|
37
39
|
} else {
|
38
40
|
getHistory().push(formatUrl(url));
|
39
41
|
}
|
@@ -883,7 +883,8 @@ export default function ResourceOverview(props) {
|
|
883
883
|
return item.code;
|
884
884
|
}),
|
885
885
|
getOverviewConfig: resourceOverviewProps.getOverviewConfig,
|
886
|
-
saveOverviewConfig: resourceOverviewProps.saveOverviewConfig
|
886
|
+
saveOverviewConfig: resourceOverviewProps.saveOverviewConfig,
|
887
|
+
jumpto: topo.viewProps.jumpto
|
887
888
|
}) : /*#__PURE__*/React.createElement(BlockBox, {
|
888
889
|
headerTitle: "\u5173\u952E\u6307\u6807",
|
889
890
|
headerExtra: /*#__PURE__*/React.createElement(Configurator, {
|
@@ -7,7 +7,8 @@ import styles from "./LinkTopo.module.scss";
|
|
7
7
|
export default function LinkTopo(props) {
|
8
8
|
var data = props.data,
|
9
9
|
linkMetricCodes = props.linkMetricCodes,
|
10
|
-
openFlow = props.openFlow
|
10
|
+
openFlow = props.openFlow,
|
11
|
+
jumpto = props.jumpto;
|
11
12
|
var metricData = useMetricPolling({
|
12
13
|
linkCi: data,
|
13
14
|
linkMetricCodes: linkMetricCodes
|
@@ -33,7 +34,7 @@ export default function LinkTopo(props) {
|
|
33
34
|
data: data // 链路ci数据
|
34
35
|
,
|
35
36
|
isNarrow: true,
|
36
|
-
jumpto: getHistory().push
|
37
|
+
jumpto: jumpto || getHistory().push
|
37
38
|
}, metricData, {
|
38
39
|
openFlow: openFlow
|
39
40
|
})));
|
@@ -13,7 +13,8 @@ export default function LinkTopoCard(props) {
|
|
13
13
|
defaultCols = props.defaultCols,
|
14
14
|
metricCol = props.metricCol,
|
15
15
|
metricColChange = props.metricColChange,
|
16
|
-
metricCodes = props.metricCodes
|
16
|
+
metricCodes = props.metricCodes,
|
17
|
+
jumpto = props.jumpto; // eslint-disable-next-line camelcase
|
17
18
|
|
18
19
|
var supportTemplates = (data === null || data === void 0 ? void 0 : (_data$attributes = data.attributes) === null || _data$attributes === void 0 ? void 0 : _data$attributes.support_templates) || ''; // 该资源监控模板
|
19
20
|
|
@@ -104,6 +105,7 @@ export default function LinkTopoCard(props) {
|
|
104
105
|
linkMetricCodes: openFlow && openFlow.name == '查看流量构成' ? metricCodes : metricCodes.filter(function (i) {
|
105
106
|
return i != 'netDelayRatio' && i != 'retansRatio';
|
106
107
|
}),
|
107
|
-
openFlow: openFlow
|
108
|
+
openFlow: openFlow,
|
109
|
+
jumpto: jumpto
|
108
110
|
}));
|
109
111
|
}
|
@@ -1,7 +1,5 @@
|
|
1
|
-
import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/objectWithoutPropertiesLoose";
|
2
1
|
import _asyncToGenerator from "@babel/runtime/helpers/asyncToGenerator";
|
3
2
|
import _extends from "@babel/runtime/helpers/extends";
|
4
|
-
var _excluded = ["groups", "resources"];
|
5
3
|
import _regeneratorRuntime from "@babel/runtime/regenerator";
|
6
4
|
import { request } from '@riil-frontend/component-topology-utils';
|
7
5
|
import { rlog } from '@riil-frontend/component-topology-utils';
|
@@ -9,6 +7,7 @@ import blackList from "./blacklist";
|
|
9
7
|
import { TOPO_API_ROOT } from "./constants";
|
10
8
|
import { getBatchCi as _getBatchCi, getBatchCiMetric as _getBatchCiMetric } from "../model";
|
11
9
|
import { processByConditionResult, processExitLink } from "../../utils/exitLinkUtil";
|
10
|
+
import * as relateTopoDataUtil from "../../utils/relateTopoDataUtil";
|
12
11
|
var API_ROOT = TOPO_API_ROOT;
|
13
12
|
/**
|
14
13
|
* 拓扑图(看做一个容器)的“父容器”ID
|
@@ -49,7 +48,7 @@ function prepareResourceParams(conditions, query) {
|
|
49
48
|
return {
|
50
49
|
dynamicCondition: dynamicCondition,
|
51
50
|
fixedConditionIdList: (staticRes || []).filter(function (ciId) {
|
52
|
-
return !ciId.
|
51
|
+
return !ciId.includes(':');
|
53
52
|
}),
|
54
53
|
linkIps: (staticRes || []).filter(function (ciId) {
|
55
54
|
return ciId.startsWith('ip:');
|
@@ -98,7 +97,8 @@ function prepareGroupParams(modifiedGroups) {
|
|
98
97
|
};
|
99
98
|
}).filter(Boolean);
|
100
99
|
return {
|
101
|
-
groups: groups
|
100
|
+
groups: groups,
|
101
|
+
relateTopoIdList: relateTopoDataUtil.getRelateTopoIdListFromConfig(modifiedGroups)
|
102
102
|
};
|
103
103
|
}
|
104
104
|
|
@@ -389,16 +389,20 @@ export default _extends({
|
|
389
389
|
|
390
390
|
case 2:
|
391
391
|
result = _context12.sent;
|
392
|
-
|
392
|
+
result = _extends({}, result, {
|
393
393
|
nodes: (_result$nodes = result.nodes) !== null && _result$nodes !== void 0 ? _result$nodes : [],
|
394
394
|
links: ((_result$links = result.links) !== null && _result$links !== void 0 ? _result$links : []).map(function (item) {
|
395
395
|
return _extends({}, item, {
|
396
396
|
ciType: 'network_link'
|
397
397
|
});
|
398
|
-
})
|
399
|
-
|
398
|
+
}),
|
399
|
+
serialize: result.serialize ? JSON.parse(result.serialize) : undefined
|
400
|
+
});
|
401
|
+
result = relateTopoDataUtil.processBothTopoData(result);
|
402
|
+
result = processExitLink(result);
|
403
|
+
return _context12.abrupt("return", result);
|
400
404
|
|
401
|
-
case
|
405
|
+
case 7:
|
402
406
|
case "end":
|
403
407
|
return _context12.stop();
|
404
408
|
}
|
@@ -417,7 +421,7 @@ export default _extends({
|
|
417
421
|
return _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee13() {
|
418
422
|
var _result$nodes2, _result$links2;
|
419
423
|
|
420
|
-
var data,
|
424
|
+
var data, params, result;
|
421
425
|
return _regeneratorRuntime.wrap(function _callee13$(_context13) {
|
422
426
|
while (1) switch (_context13.prev = _context13.next) {
|
423
427
|
case 0:
|
@@ -431,22 +435,28 @@ export default _extends({
|
|
431
435
|
});
|
432
436
|
}
|
433
437
|
|
434
|
-
|
438
|
+
params = prepareGroupParams(data);
|
435
439
|
_context13.next = 5;
|
436
|
-
return request.post(API_ROOT + "/structure/byCondition/" + id,
|
440
|
+
return request.post(API_ROOT + "/structure/byCondition/" + id, params);
|
437
441
|
|
438
442
|
case 5:
|
439
443
|
result = _context13.sent;
|
440
|
-
|
444
|
+
result = _extends({}, result, {
|
441
445
|
nodes: (_result$nodes2 = result.nodes) !== null && _result$nodes2 !== void 0 ? _result$nodes2 : [],
|
442
446
|
links: ((_result$links2 = result.links) !== null && _result$links2 !== void 0 ? _result$links2 : []).map(function (item) {
|
443
447
|
return _extends({}, item, {
|
444
448
|
ciType: 'network_link'
|
445
449
|
});
|
446
450
|
})
|
447
|
-
})
|
451
|
+
});
|
452
|
+
result = relateTopoDataUtil.processByConditionTopoData({
|
453
|
+
data: result,
|
454
|
+
config: data
|
455
|
+
});
|
456
|
+
result = processByConditionResult(result, params.groups);
|
457
|
+
return _context13.abrupt("return", result);
|
448
458
|
|
449
|
-
case
|
459
|
+
case 10:
|
450
460
|
case "end":
|
451
461
|
return _context13.stop();
|
452
462
|
}
|
@@ -463,11 +473,11 @@ export default _extends({
|
|
463
473
|
*/
|
464
474
|
bindResourceToTopo: function bindResourceToTopo(id, config) {
|
465
475
|
return _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee14() {
|
466
|
-
var groups, resources,
|
476
|
+
var groups, resources, newGroups, obj;
|
467
477
|
return _regeneratorRuntime.wrap(function _callee14$(_context14) {
|
468
478
|
while (1) switch (_context14.prev = _context14.next) {
|
469
479
|
case 0:
|
470
|
-
groups = config.groups, resources = config.resources
|
480
|
+
groups = config.groups, resources = config.resources;
|
471
481
|
newGroups = Array.isArray(groups) ? groups : [];
|
472
482
|
|
473
483
|
if (resources) {
|
@@ -481,7 +491,7 @@ export default _extends({
|
|
481
491
|
|
482
492
|
obj = prepareGroupParams(newGroups);
|
483
493
|
_context14.next = 6;
|
484
|
-
return request.post(API_ROOT + "/resource/" + id,
|
494
|
+
return request.post(API_ROOT + "/resource/" + id, obj);
|
485
495
|
|
486
496
|
case 6:
|
487
497
|
return _context14.abrupt("return", _context14.sent);
|
@@ -36,11 +36,11 @@ export function buildIpNode(ip) {
|
|
36
36
|
}
|
37
37
|
|
38
38
|
function getHtSerialize(serialize) {
|
39
|
-
if (serialize) {
|
39
|
+
if (serialize && typeof serialize === 'string') {
|
40
40
|
return JSON.parse(serialize);
|
41
41
|
}
|
42
42
|
|
43
|
-
return
|
43
|
+
return serialize;
|
44
44
|
}
|
45
45
|
|
46
46
|
function isExitLink(link) {
|
@@ -0,0 +1,144 @@
|
|
1
|
+
import _extends from "@babel/runtime/helpers/extends";
|
2
|
+
// 关联拓扑数据
|
3
|
+
|
4
|
+
/**
|
5
|
+
* 升级历史数据:子拓扑节点序列化数据
|
6
|
+
* 构造子拓扑节点
|
7
|
+
* 构造子拓扑链路
|
8
|
+
* @param {*} ctx
|
9
|
+
*/
|
10
|
+
export function processBothTopoData(topoData) {
|
11
|
+
var nodes = topoData.nodes,
|
12
|
+
links = topoData.links;
|
13
|
+
var serialize = upgradeSerializeOldTopoNode(topoData.serialize);
|
14
|
+
return _extends({}, topoData, {
|
15
|
+
nodes: [].concat(nodes, buildTopoNodeDatasFromSerialize(serialize)),
|
16
|
+
links: buildTopoLinks(links),
|
17
|
+
serialize: serialize
|
18
|
+
});
|
19
|
+
}
|
20
|
+
/**
|
21
|
+
* 构造子拓扑节点
|
22
|
+
* 构造子拓扑链路
|
23
|
+
* @param {*} ctx
|
24
|
+
*/
|
25
|
+
|
26
|
+
export function processByConditionTopoData(ctx) {
|
27
|
+
var data = ctx.data,
|
28
|
+
config = ctx.config;
|
29
|
+
var nodes = data.nodes,
|
30
|
+
links = data.links;
|
31
|
+
return _extends({}, data, {
|
32
|
+
nodes: [].concat(nodes, buildTopoNodeDatas(config)),
|
33
|
+
links: buildTopoLinks(links)
|
34
|
+
});
|
35
|
+
}
|
36
|
+
export function getRelateTopoIdListFromConfig(groups) {
|
37
|
+
var relateTopoIdList = [];
|
38
|
+
groups.forEach(function (g) {
|
39
|
+
g.resources["static"].filter(function (ciId) {
|
40
|
+
return ciId.startsWith('topo:');
|
41
|
+
}).map(function (ciId) {
|
42
|
+
return ciId.replace('topo:', '');
|
43
|
+
}).map(function (topoId) {
|
44
|
+
if (!relateTopoIdList.includes(topoId)) {
|
45
|
+
relateTopoIdList.push(topoId);
|
46
|
+
}
|
47
|
+
});
|
48
|
+
});
|
49
|
+
return relateTopoIdList;
|
50
|
+
}
|
51
|
+
export function buildTopoNode(topoId) {
|
52
|
+
return {
|
53
|
+
id: "topo:" + topoId,
|
54
|
+
// name: ,
|
55
|
+
bindType: "topo",
|
56
|
+
// 绑定资源类型。关联资源 值为空,关联IP ip
|
57
|
+
bindTopo: topoId,
|
58
|
+
// TODO 所属区域,从序列化拿
|
59
|
+
// 'groupId': null,
|
60
|
+
// 'groupTag': null,
|
61
|
+
// 'attributes': [],
|
62
|
+
// 'metrics': [],
|
63
|
+
type: "node",
|
64
|
+
isbinding: true,
|
65
|
+
// 'dtype': 'device'
|
66
|
+
operation: "delete"
|
67
|
+
};
|
68
|
+
}
|
69
|
+
|
70
|
+
function buildTopoLinks(links) {
|
71
|
+
return links.map(function (link) {
|
72
|
+
return _extends({}, link, {
|
73
|
+
"source": link.sourceType ? link.sourceType + ':' + link.source : link.source,
|
74
|
+
"target": link.targetType ? link.targetType + ':' + link.target : link.target
|
75
|
+
});
|
76
|
+
});
|
77
|
+
}
|
78
|
+
/**
|
79
|
+
* 升级历史数据:子拓扑节点序列化数据
|
80
|
+
* @param {*} serialize
|
81
|
+
*/
|
82
|
+
|
83
|
+
|
84
|
+
function upgradeSerializeOldTopoNode(serialize) {
|
85
|
+
if (serialize) {
|
86
|
+
var isOldTopoNode = function isOldTopoNode(ele) {
|
87
|
+
return isTopoNode(ele) && !ele.p.tag;
|
88
|
+
};
|
89
|
+
|
90
|
+
var oldTopoNodes = serialize.d.filter(isOldTopoNode);
|
91
|
+
oldTopoNodes.forEach(function (node) {
|
92
|
+
var _node$a;
|
93
|
+
|
94
|
+
var topoId = (_node$a = node.a) === null || _node$a === void 0 ? void 0 : _node$a.bindTopo;
|
95
|
+
node.a = _extends({}, node.a, buildTopoNode(topoId));
|
96
|
+
node.p.tag = "topo:" + topoId;
|
97
|
+
});
|
98
|
+
}
|
99
|
+
|
100
|
+
return serialize;
|
101
|
+
}
|
102
|
+
|
103
|
+
function isTopoNode(ele) {
|
104
|
+
var _ele$a;
|
105
|
+
|
106
|
+
return !!((_ele$a = ele.a) !== null && _ele$a !== void 0 && _ele$a.bindTopo);
|
107
|
+
}
|
108
|
+
|
109
|
+
function buildTopoNodeDatasFromSerialize(serialize) {
|
110
|
+
if (!serialize) {
|
111
|
+
return [];
|
112
|
+
}
|
113
|
+
|
114
|
+
var topoNodes = serialize.d.filter(isTopoNode);
|
115
|
+
var topoNodeDatas = topoNodes.map(function (node) {
|
116
|
+
var _node$a2;
|
117
|
+
|
118
|
+
var topoId = (_node$a2 = node.a) === null || _node$a2 === void 0 ? void 0 : _node$a2.bindTopo;
|
119
|
+
return buildTopoNode(topoId);
|
120
|
+
});
|
121
|
+
return topoNodeDatas;
|
122
|
+
}
|
123
|
+
|
124
|
+
function buildTopoNodeDatas(config) {
|
125
|
+
var topoNodeDatas = [];
|
126
|
+
config.forEach(function (g) {
|
127
|
+
g.resources["static"].filter(function (ciId) {
|
128
|
+
return ciId.startsWith('topo:');
|
129
|
+
}).map(function (ciId) {
|
130
|
+
return ciId.replace('topo:', '');
|
131
|
+
}).map(function (topoId) {
|
132
|
+
topoNodeDatas.push(_extends({}, buildTopoNode(topoId), {
|
133
|
+
// 添加资源拓扑节点消失的问题
|
134
|
+
'groupId': g.id,
|
135
|
+
'groupTag': g.tag
|
136
|
+
}));
|
137
|
+
});
|
138
|
+
});
|
139
|
+
return topoNodeDatas;
|
140
|
+
}
|
141
|
+
|
142
|
+
function getRelateTopoIdsFromSerialize(serialize) {
|
143
|
+
return serialize;
|
144
|
+
}
|
@@ -41,23 +41,8 @@ function getResourceConfigFromHt(topo) {
|
|
41
41
|
return {
|
42
42
|
layers: sortBy(layers, 'order'),
|
43
43
|
groups: groups,
|
44
|
-
resources: resources
|
45
|
-
relateTopoIdList: getRelateTopoIdList(dataModel)
|
44
|
+
resources: resources
|
46
45
|
};
|
47
|
-
} // 查询关联拓扑id列表
|
48
|
-
|
49
|
-
|
50
|
-
function getRelateTopoIdList(dataModel) {
|
51
|
-
return getNodes(dataModel).reduce(function (topoIds, node) {
|
52
|
-
var bindType = node.a('bindType');
|
53
|
-
var bindTopo = node.a('bindTopo');
|
54
|
-
|
55
|
-
if (bindType === 'topo' && bindTopo && !topoIds.includes(bindTopo)) {
|
56
|
-
return [].concat(topoIds, [bindTopo]);
|
57
|
-
}
|
58
|
-
|
59
|
-
return topoIds;
|
60
|
-
}, []);
|
61
46
|
}
|
62
47
|
|
63
48
|
function getLayerDatas(dataModel) {
|