@riil-frontend/component-topology 11.0.22 → 11.0.24
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.js +1 -1
- package/es/core/components/DisplaySettingDrawer/DisplaySettingDrawer.js +1 -1
- package/es/core/hooks/useCiAttributeChange.js +1 -2
- package/es/core/hooks/usePolling.js +53 -27
- package/es/core/models/TopoApp.js +9 -36
- package/es/core/models/attributeFormatter/formatter/commonTransform.js +5 -0
- package/es/core/models/cache/CiTypeCache.js +8 -8
- package/es/core/models/utils/linkUtils.js +1 -1
- package/es/core/store/models/topoConfig.js +1 -1
- package/es/core/store/models/topoMod.js +14 -20
- package/es/core/viewer/components/plugins/ResourceDetail/components/ClusterMemberTable.js +1 -1
- package/es/networkTopo/utils/exitLinkUtil.js +4 -1
- package/lib/core/components/DisplaySettingDrawer/DisplaySettingDrawer.js +1 -1
- package/lib/core/hooks/useCiAttributeChange.js +1 -3
- package/lib/core/hooks/usePolling.js +52 -25
- package/lib/core/models/TopoApp.js +9 -36
- package/lib/core/models/attributeFormatter/formatter/commonTransform.js +5 -0
- package/lib/core/models/cache/CiTypeCache.js +8 -8
- package/lib/core/models/utils/linkUtils.js +1 -1
- package/lib/core/store/models/topoConfig.js +1 -1
- package/lib/core/store/models/topoMod.js +14 -20
- package/lib/core/viewer/components/plugins/ResourceDetail/components/ClusterMemberTable.js +1 -1
- package/lib/networkTopo/utils/exitLinkUtil.js +4 -1
- package/package.json +2 -2
@@ -1,12 +1,11 @@
|
|
1
1
|
import _extends from "@babel/runtime/helpers/extends";
|
2
2
|
import rlog from '@riil-frontend/component-topology-utils/es/rlog';
|
3
|
-
import { useEffect } from 'react';
|
4
3
|
import CiCache from "../models/cache/CiCache";
|
5
4
|
import useTopoEventListener from "./useTopoEventListener";
|
6
5
|
|
7
6
|
function mergeData(cis, ciChangeData) {
|
8
7
|
if (!cis.find(function (item) {
|
9
|
-
return item.id === ciChangeData.id;
|
8
|
+
return item.id === ciChangeData.id || item.ciId === ciChangeData.id;
|
10
9
|
})) {
|
11
10
|
return cis;
|
12
11
|
}
|
@@ -43,16 +43,30 @@ var usePolling = function usePolling(props) {
|
|
43
43
|
|
44
44
|
function _fetchData() {
|
45
45
|
_fetchData = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee() {
|
46
|
-
var _topo$store$getModelS, resIdsList, nodeIdsList, codes, param, _yield$Promise$all, ciMetricResult, transformLinkData;
|
46
|
+
var _topo$store$getModelS, resIdsList, nodeIdsList, codes, param, _yield$Promise$all, ciMetricResult, mergeData, transformLinkData, adapterIpv6;
|
47
47
|
|
48
48
|
return _regeneratorRuntime.wrap(function _callee$(_context) {
|
49
49
|
while (1) {
|
50
50
|
switch (_context.prev = _context.next) {
|
51
51
|
case 0:
|
52
|
+
adapterIpv6 = function _adapterIpv(data) {
|
53
|
+
var ipv6 = data.attributeMap.ipv6_address;
|
54
|
+
|
55
|
+
if (!ipv6 && data.attributeMap.ipv6_address_list) {
|
56
|
+
ipv6 = (data.attributeMap.ipv6_address_list || '').split(',')[0];
|
57
|
+
}
|
58
|
+
|
59
|
+
return _extends({}, data, {
|
60
|
+
attributeMap: _extends({}, data.attributeMap, {
|
61
|
+
ipv6_address: ipv6
|
62
|
+
})
|
63
|
+
});
|
64
|
+
};
|
65
|
+
|
52
66
|
transformLinkData = function _transformLinkData(data) {
|
53
|
-
var _topo$dataModel$
|
54
|
-
links = _topo$dataModel$
|
55
|
-
linkGroups = _topo$dataModel$
|
67
|
+
var _topo$dataModel$getDa2 = topo.dataModel.getData(),
|
68
|
+
links = _topo$dataModel$getDa2.links,
|
69
|
+
linkGroups = _topo$dataModel$getDa2.linkGroups;
|
56
70
|
|
57
71
|
var link = [].concat(links, linkGroups).find(function (item) {
|
58
72
|
return item.id === data.id;
|
@@ -67,17 +81,44 @@ var usePolling = function usePolling(props) {
|
|
67
81
|
});
|
68
82
|
};
|
69
83
|
|
84
|
+
mergeData = function _mergeData(metricResult) {
|
85
|
+
// 合并属性、指标
|
86
|
+
var _topo$dataModel$getDa = topo.dataModel.getData(),
|
87
|
+
nodes = _topo$dataModel$getDa.nodes,
|
88
|
+
links = _topo$dataModel$getDa.links;
|
89
|
+
|
90
|
+
return [].concat(nodes, links).filter(function (item) {
|
91
|
+
return !!item.ciType;
|
92
|
+
}).map(function (ciData) {
|
93
|
+
var resultData = _extends({}, ciData, {
|
94
|
+
attributeMap: _extends({}, (ciData === null || ciData === void 0 ? void 0 : ciData.attributes) || {})
|
95
|
+
});
|
96
|
+
|
97
|
+
resultData = transformLinkData(resultData);
|
98
|
+
resultData = adapterIpv6(resultData);
|
99
|
+
return resultData;
|
100
|
+
}).map(function (ciData) {
|
101
|
+
var _metricResult$find;
|
102
|
+
|
103
|
+
return _extends({}, ciData, {
|
104
|
+
metrics: ((_metricResult$find = metricResult.find(function (item) {
|
105
|
+
return item.id === ciData.ciId || ciData.id;
|
106
|
+
})) === null || _metricResult$find === void 0 ? void 0 : _metricResult$find.metrics) || {}
|
107
|
+
});
|
108
|
+
});
|
109
|
+
};
|
110
|
+
|
70
111
|
_topo$store$getModelS = topo.store.getModelState('topoBizMod').resAndMetrics, resIdsList = _topo$store$getModelS.resIdsList, nodeIdsList = _topo$store$getModelS.nodeIdsList; // rlog.debug('根据ci的id获取属性的值-getCiArrByIds', resIdsList, metrics);
|
71
112
|
// 无资源,不查询
|
72
113
|
|
73
114
|
if (resIdsList.length) {
|
74
|
-
_context.next =
|
115
|
+
_context.next = 6;
|
75
116
|
break;
|
76
117
|
}
|
77
118
|
|
78
119
|
return _context.abrupt("return", []);
|
79
120
|
|
80
|
-
case
|
121
|
+
case 6:
|
81
122
|
// 需要查询的指标列表
|
82
123
|
codes = topo.attributeMetricDisplay.getResourceMetricCodes();
|
83
124
|
param = {
|
@@ -94,36 +135,21 @@ var usePolling = function usePolling(props) {
|
|
94
135
|
_context.t0 = Promise;
|
95
136
|
_context.t1 = // 查询指标值
|
96
137
|
topo.serverApi.ciInfo.batchQueryCiInfo(param);
|
97
|
-
_context.next =
|
138
|
+
_context.next = 12;
|
98
139
|
return DictCache.init();
|
99
140
|
|
100
|
-
case
|
141
|
+
case 12:
|
101
142
|
_context.t2 = _context.sent;
|
102
143
|
_context.t3 = [_context.t1, _context.t2];
|
103
|
-
_context.next =
|
144
|
+
_context.next = 16;
|
104
145
|
return _context.t0.all.call(_context.t0, _context.t3);
|
105
146
|
|
106
|
-
case
|
147
|
+
case 16:
|
107
148
|
_yield$Promise$all = _context.sent;
|
108
149
|
ciMetricResult = _yield$Promise$all[0];
|
109
|
-
return _context.abrupt("return", ciMetricResult
|
110
|
-
var ci = topo.dataModel.getDataById(data.id);
|
111
|
-
|
112
|
-
var resultData = _extends({}, data, ci, {
|
113
|
-
attributeMap: _extends({}, (ci === null || ci === void 0 ? void 0 : ci.attributes) || {})
|
114
|
-
});
|
115
|
-
|
116
|
-
resultData = transformLinkData(resultData); // 特殊处理:ipv6 从ipv6_address_list取第一个
|
117
|
-
|
118
|
-
// 特殊处理:ipv6 从ipv6_address_list取第一个
|
119
|
-
if (resultData.attributeMap.ipv6_address_list && !resultData.attributeMap.ipv6_address) {
|
120
|
-
resultData.attributeMap.ipv6_address = (resultData.attributeMap.ipv6_address_list || '').split(',')[0];
|
121
|
-
}
|
122
|
-
|
123
|
-
return resultData;
|
124
|
-
}));
|
150
|
+
return _context.abrupt("return", mergeData(ciMetricResult));
|
125
151
|
|
126
|
-
case
|
152
|
+
case 19:
|
127
153
|
case "end":
|
128
154
|
return _context.stop();
|
129
155
|
}
|
@@ -24,7 +24,7 @@ import ElementTagTipConfig from "./tagstips/ElementTagTipConfig";
|
|
24
24
|
import SelectionModel from "./SelectionModel";
|
25
25
|
import CiCache from "./cache/CiCache"; // eslint-disable-next-line no-undef
|
26
26
|
|
27
|
-
var version = typeof "11.0.
|
27
|
+
var version = typeof "11.0.24" === 'string' ? "11.0.24" : null;
|
28
28
|
console.info("\u62D3\u6251\u7248\u672C: " + version);
|
29
29
|
/**
|
30
30
|
* 拓扑显示和编辑
|
@@ -730,17 +730,10 @@ var Topo = /*#__PURE__*/function () {
|
|
730
730
|
this.alarm.updateState({
|
731
731
|
alarmList: alarmList
|
732
732
|
});
|
733
|
-
}
|
734
|
-
/**
|
735
|
-
* TODO 待定
|
736
|
-
* @param {*} data
|
737
|
-
*/
|
738
|
-
;
|
733
|
+
};
|
739
734
|
|
740
|
-
_proto.
|
741
|
-
|
742
|
-
function () {
|
743
|
-
var _loadAttrsAndMetrics = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee17(data) {
|
735
|
+
_proto.switchToViewMode = /*#__PURE__*/function () {
|
736
|
+
var _switchToViewMode = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee17() {
|
744
737
|
return _regeneratorRuntime.wrap(function _callee17$(_context17) {
|
745
738
|
while (1) {
|
746
739
|
switch (_context17.prev = _context17.next) {
|
@@ -752,26 +745,6 @@ var Topo = /*#__PURE__*/function () {
|
|
752
745
|
}, _callee17);
|
753
746
|
}));
|
754
747
|
|
755
|
-
function loadAttrsAndMetrics(_x11) {
|
756
|
-
return _loadAttrsAndMetrics.apply(this, arguments);
|
757
|
-
}
|
758
|
-
|
759
|
-
return loadAttrsAndMetrics;
|
760
|
-
}();
|
761
|
-
|
762
|
-
_proto.switchToViewMode = /*#__PURE__*/function () {
|
763
|
-
var _switchToViewMode = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee18() {
|
764
|
-
return _regeneratorRuntime.wrap(function _callee18$(_context18) {
|
765
|
-
while (1) {
|
766
|
-
switch (_context18.prev = _context18.next) {
|
767
|
-
case 0:
|
768
|
-
case "end":
|
769
|
-
return _context18.stop();
|
770
|
-
}
|
771
|
-
}
|
772
|
-
}, _callee18);
|
773
|
-
}));
|
774
|
-
|
775
748
|
function switchToViewMode() {
|
776
749
|
return _switchToViewMode.apply(this, arguments);
|
777
750
|
}
|
@@ -780,16 +753,16 @@ var Topo = /*#__PURE__*/function () {
|
|
780
753
|
}();
|
781
754
|
|
782
755
|
_proto.switchToEditMode = /*#__PURE__*/function () {
|
783
|
-
var _switchToEditMode = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function
|
784
|
-
return _regeneratorRuntime.wrap(function
|
756
|
+
var _switchToEditMode = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee18() {
|
757
|
+
return _regeneratorRuntime.wrap(function _callee18$(_context18) {
|
785
758
|
while (1) {
|
786
|
-
switch (
|
759
|
+
switch (_context18.prev = _context18.next) {
|
787
760
|
case 0:
|
788
761
|
case "end":
|
789
|
-
return
|
762
|
+
return _context18.stop();
|
790
763
|
}
|
791
764
|
}
|
792
|
-
},
|
765
|
+
}, _callee18);
|
793
766
|
}));
|
794
767
|
|
795
768
|
function switchToEditMode() {
|
@@ -13,6 +13,11 @@ export default function commonTransform(options) {
|
|
13
13
|
if (ciData[attrType + "Map"][fieldCode + "_object"]) {
|
14
14
|
fieldValue = ciData[attrType + "Map"][fieldCode + "_object"].displayName;
|
15
15
|
}
|
16
|
+
} // 分级字典特殊处理
|
17
|
+
|
18
|
+
|
19
|
+
if (fieldMeta.dict) {
|
20
|
+
fieldValue = fieldMeta.dict[fieldValue];
|
16
21
|
}
|
17
22
|
|
18
23
|
return {
|
@@ -11,7 +11,7 @@ import keyBy from 'lodash/keyBy';
|
|
11
11
|
|
12
12
|
var CiTypeCache = /*#__PURE__*/function () {
|
13
13
|
function CiTypeCache() {
|
14
|
-
this.
|
14
|
+
this.ciTypeMap = {};
|
15
15
|
}
|
16
16
|
|
17
17
|
var _proto = CiTypeCache.prototype;
|
@@ -36,7 +36,7 @@ var CiTypeCache = /*#__PURE__*/function () {
|
|
36
36
|
rlog.error('查询Ci模型异常', _context.t0);
|
37
37
|
|
38
38
|
case 8:
|
39
|
-
return _context.abrupt("return", this.
|
39
|
+
return _context.abrupt("return", this.ciTypeMap);
|
40
40
|
|
41
41
|
case 9:
|
42
42
|
case "end":
|
@@ -63,7 +63,7 @@ var CiTypeCache = /*#__PURE__*/function () {
|
|
63
63
|
switch (_context2.prev = _context2.next) {
|
64
64
|
case 0:
|
65
65
|
unLoadCiTypeIds = ciTypeIds.filter(function (id) {
|
66
|
-
return !_this.
|
66
|
+
return !_this.ciTypeMap[id];
|
67
67
|
});
|
68
68
|
_context2.next = 3;
|
69
69
|
return topoService.ciInfo.batchQueryCiTypeInfo(unLoadCiTypeIds);
|
@@ -71,7 +71,7 @@ var CiTypeCache = /*#__PURE__*/function () {
|
|
71
71
|
case 3:
|
72
72
|
ciTypeMetas = _context2.sent;
|
73
73
|
this.addCiTypes(ciTypeMetas);
|
74
|
-
return _context2.abrupt("return", this.
|
74
|
+
return _context2.abrupt("return", this.ciTypeMap);
|
75
75
|
|
76
76
|
case 6:
|
77
77
|
case "end":
|
@@ -97,7 +97,7 @@ var CiTypeCache = /*#__PURE__*/function () {
|
|
97
97
|
};
|
98
98
|
|
99
99
|
_proto.addCiType = function addCiType(ciTypeMeta) {
|
100
|
-
var cache = _extends({}, this.
|
100
|
+
var cache = _extends({}, this.ciTypeMap);
|
101
101
|
|
102
102
|
var attributes = adapterNetworkLinkAttributes(ciTypeMeta, ciTypeMeta.attributes || []);
|
103
103
|
var metrics = ciTypeMeta.metrics || [];
|
@@ -107,11 +107,11 @@ var CiTypeCache = /*#__PURE__*/function () {
|
|
107
107
|
metrics: metrics,
|
108
108
|
metricMap: keyBy(metrics, 'code')
|
109
109
|
});
|
110
|
-
this.
|
110
|
+
this.ciTypeMap = cache;
|
111
111
|
};
|
112
112
|
|
113
113
|
_proto.getCiType = function getCiType(typeCode) {
|
114
|
-
return this.
|
114
|
+
return this.ciTypeMap[typeCode];
|
115
115
|
};
|
116
116
|
|
117
117
|
_proto.getCiTypeByCi = function getCiTypeByCi(ci) {
|
@@ -131,7 +131,7 @@ var CiTypeCache = /*#__PURE__*/function () {
|
|
131
131
|
_createClass(CiTypeCache, [{
|
132
132
|
key: "ciTypes",
|
133
133
|
get: function get() {
|
134
|
-
return this.
|
134
|
+
return this.ciTypeMap;
|
135
135
|
}
|
136
136
|
}]);
|
137
137
|
|
@@ -339,7 +339,7 @@ export default function (topoApp) {
|
|
339
339
|
case 11:
|
340
340
|
data = _context4.sent;
|
341
341
|
_context4.next = 14;
|
342
|
-
return Promise.all([addLinkData(data), topoApp.ciTyeCache.
|
342
|
+
return Promise.all([addLinkData(data), topoApp.ciTyeCache.load(getCiTypes(data)), dispatch.customIcon.loadCustomIcons()]);
|
343
343
|
|
344
344
|
case 14:
|
345
345
|
_yield$Promise$all = _context4.sent;
|
@@ -307,7 +307,7 @@ export default function (topoApp) {
|
|
307
307
|
return _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee6() {
|
308
308
|
var _result$config;
|
309
309
|
|
310
|
-
var startTime, topoId, data, linkToData, refresh, clear, linkTo, startState, permission, result, graphConfig, topoConfig,
|
310
|
+
var startTime, topoId, data, linkToData, refresh, clear, linkTo, startState, permission, result, graphConfig, topoConfig, extraConfig, _combTopoData, topoData, resAndMetrics, _yield$Promise$all, newData, endTime;
|
311
311
|
|
312
312
|
return _regeneratorRuntime.wrap(function _callee6$(_context6) {
|
313
313
|
while (1) {
|
@@ -434,23 +434,17 @@ export default function (topoApp) {
|
|
434
434
|
result = parseTopoData(result);
|
435
435
|
rlog.debug('topoMod.initTopoData 查询数据完成', topoId, linkTo, result);
|
436
436
|
_context6.next = 41;
|
437
|
-
return
|
438
|
-
dispatch.customIcon.loadCustomIcons() // topoApp.elementTagTipConfig.init(result), // 暂停新配置开发
|
439
|
-
]);
|
437
|
+
return dispatch.customIcon.loadCustomIcons();
|
440
438
|
|
441
439
|
case 41:
|
442
|
-
_yield$Promise$all = _context6.sent;
|
443
|
-
ciTypeMap = _yield$Promise$all[0];
|
444
|
-
customIcons = _yield$Promise$all[1];
|
445
|
-
xxx = _yield$Promise$all[2];
|
446
440
|
extraConfig = result.global.extraConfig;
|
447
|
-
_context6.next =
|
441
|
+
_context6.next = 44;
|
448
442
|
return dispatch.displayConfig.setConfig(_extends({}, extraConfig, {
|
449
443
|
alarmSwitch: result.global.alarmSwitch,
|
450
444
|
alarmListDefaultOpen: result.global.alarmListDefaultOpen
|
451
445
|
}));
|
452
446
|
|
453
|
-
case
|
447
|
+
case 44:
|
454
448
|
_combTopoData = combTopoData({
|
455
449
|
engine: topoApp,
|
456
450
|
data: result,
|
@@ -458,7 +452,7 @@ export default function (topoApp) {
|
|
458
452
|
globalConfig: extraConfig
|
459
453
|
}), topoData = _combTopoData.topoData, resAndMetrics = _combTopoData.resAndMetrics; // rlog.debug("topoMod.initTopoData combTopoData", { topoData, resAndMetrics, });
|
460
454
|
|
461
|
-
_context6.next =
|
455
|
+
_context6.next = 47;
|
462
456
|
return _this5.update({
|
463
457
|
currentTopo: topoData.config,
|
464
458
|
data: result,
|
@@ -468,25 +462,25 @@ export default function (topoApp) {
|
|
468
462
|
resAndMetrics: resAndMetrics
|
469
463
|
});
|
470
464
|
|
471
|
-
case
|
465
|
+
case 47:
|
472
466
|
dispatch.topoBizMod.combBatchCiInfo(resAndMetrics);
|
473
467
|
dispatch.background.init(extraConfig); // TODO 优化打开拓扑图显示告警速度:打开拓扑图立即请求告警
|
474
468
|
|
475
469
|
topoApp.alarm.open(); // 加载标注悬浮框数据
|
476
470
|
|
477
|
-
_context6.next =
|
478
|
-
return Promise.all([addLinkData(result), topoApp.ciTyeCache.
|
471
|
+
_context6.next = 52;
|
472
|
+
return Promise.all([addLinkData(result), topoApp.ciTyeCache.load(getCiTypes(result)), topoApp.elementTagTipConfig.init(result) // 暂停新配置开发
|
479
473
|
]);
|
480
474
|
|
481
|
-
case
|
482
|
-
_yield$Promise$
|
483
|
-
newData = _yield$Promise$
|
484
|
-
_context6.next =
|
475
|
+
case 52:
|
476
|
+
_yield$Promise$all = _context6.sent;
|
477
|
+
newData = _yield$Promise$all[0];
|
478
|
+
_context6.next = 56;
|
485
479
|
return _this5.update({
|
486
480
|
data: newData
|
487
481
|
});
|
488
482
|
|
489
|
-
case
|
483
|
+
case 56:
|
490
484
|
dispatch.topoBizMod.update({
|
491
485
|
pollingSwitch: true
|
492
486
|
});
|
@@ -499,7 +493,7 @@ export default function (topoApp) {
|
|
499
493
|
loading: false
|
500
494
|
});
|
501
495
|
|
502
|
-
case
|
496
|
+
case 62:
|
503
497
|
case "end":
|
504
498
|
return _context6.stop();
|
505
499
|
}
|
@@ -131,7 +131,7 @@ export default function ClusterMemberTableContainer(props) {
|
|
131
131
|
ciDataResult = _yield$Promise$all[0];
|
132
132
|
memberRoleMetrics = _yield$Promise$all[1];
|
133
133
|
_context.next = 10;
|
134
|
-
return topo.ciTyeCache.
|
134
|
+
return topo.ciTyeCache.load(ciDataResult.data.map(function (item) {
|
135
135
|
return item.typeCode;
|
136
136
|
}));
|
137
137
|
|
@@ -167,8 +167,11 @@ export function processExitLink(topoData) {
|
|
167
167
|
}
|
168
168
|
|
169
169
|
function findElementSerializeById(serialize, id) {
|
170
|
+
// 背景图没有a
|
170
171
|
return serialize.d.find(function (item) {
|
171
|
-
|
172
|
+
var _item$a;
|
173
|
+
|
174
|
+
return ((_item$a = item.a) === null || _item$a === void 0 ? void 0 : _item$a.id) === id;
|
172
175
|
});
|
173
176
|
}
|
174
177
|
/**
|
@@ -9,15 +9,13 @@ var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends")
|
|
9
9
|
|
10
10
|
var _rlog = _interopRequireDefault(require("@riil-frontend/component-topology-utils/es/rlog"));
|
11
11
|
|
12
|
-
var _react = require("react");
|
13
|
-
|
14
12
|
var _CiCache = _interopRequireDefault(require("../models/cache/CiCache"));
|
15
13
|
|
16
14
|
var _useTopoEventListener = _interopRequireDefault(require("./useTopoEventListener"));
|
17
15
|
|
18
16
|
function mergeData(cis, ciChangeData) {
|
19
17
|
if (!cis.find(function (item) {
|
20
|
-
return item.id === ciChangeData.id;
|
18
|
+
return item.id === ciChangeData.id || item.ciId === ciChangeData.id;
|
21
19
|
})) {
|
22
20
|
return cis;
|
23
21
|
}
|
@@ -60,16 +60,30 @@ var usePolling = function usePolling(props) {
|
|
60
60
|
|
61
61
|
function _fetchData() {
|
62
62
|
_fetchData = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee() {
|
63
|
-
var _topo$store$getModelS, resIdsList, nodeIdsList, codes, param, _yield$Promise$all, ciMetricResult, transformLinkData;
|
63
|
+
var _topo$store$getModelS, resIdsList, nodeIdsList, codes, param, _yield$Promise$all, ciMetricResult, mergeData, transformLinkData, adapterIpv6;
|
64
64
|
|
65
65
|
return _regenerator["default"].wrap(function _callee$(_context) {
|
66
66
|
while (1) {
|
67
67
|
switch (_context.prev = _context.next) {
|
68
68
|
case 0:
|
69
|
+
adapterIpv6 = function _adapterIpv(data) {
|
70
|
+
var ipv6 = data.attributeMap.ipv6_address;
|
71
|
+
|
72
|
+
if (!ipv6 && data.attributeMap.ipv6_address_list) {
|
73
|
+
ipv6 = (data.attributeMap.ipv6_address_list || '').split(',')[0];
|
74
|
+
}
|
75
|
+
|
76
|
+
return (0, _extends2["default"])({}, data, {
|
77
|
+
attributeMap: (0, _extends2["default"])({}, data.attributeMap, {
|
78
|
+
ipv6_address: ipv6
|
79
|
+
})
|
80
|
+
});
|
81
|
+
};
|
82
|
+
|
69
83
|
transformLinkData = function _transformLinkData(data) {
|
70
|
-
var _topo$dataModel$
|
71
|
-
links = _topo$dataModel$
|
72
|
-
linkGroups = _topo$dataModel$
|
84
|
+
var _topo$dataModel$getDa2 = topo.dataModel.getData(),
|
85
|
+
links = _topo$dataModel$getDa2.links,
|
86
|
+
linkGroups = _topo$dataModel$getDa2.linkGroups;
|
73
87
|
|
74
88
|
var link = [].concat(links, linkGroups).find(function (item) {
|
75
89
|
return item.id === data.id;
|
@@ -84,17 +98,43 @@ var usePolling = function usePolling(props) {
|
|
84
98
|
});
|
85
99
|
};
|
86
100
|
|
101
|
+
mergeData = function _mergeData(metricResult) {
|
102
|
+
// 合并属性、指标
|
103
|
+
var _topo$dataModel$getDa = topo.dataModel.getData(),
|
104
|
+
nodes = _topo$dataModel$getDa.nodes,
|
105
|
+
links = _topo$dataModel$getDa.links;
|
106
|
+
|
107
|
+
return [].concat(nodes, links).filter(function (item) {
|
108
|
+
return !!item.ciType;
|
109
|
+
}).map(function (ciData) {
|
110
|
+
var resultData = (0, _extends2["default"])({}, ciData, {
|
111
|
+
attributeMap: (0, _extends2["default"])({}, (ciData === null || ciData === void 0 ? void 0 : ciData.attributes) || {})
|
112
|
+
});
|
113
|
+
resultData = transformLinkData(resultData);
|
114
|
+
resultData = adapterIpv6(resultData);
|
115
|
+
return resultData;
|
116
|
+
}).map(function (ciData) {
|
117
|
+
var _metricResult$find;
|
118
|
+
|
119
|
+
return (0, _extends2["default"])({}, ciData, {
|
120
|
+
metrics: ((_metricResult$find = metricResult.find(function (item) {
|
121
|
+
return item.id === ciData.ciId || ciData.id;
|
122
|
+
})) === null || _metricResult$find === void 0 ? void 0 : _metricResult$find.metrics) || {}
|
123
|
+
});
|
124
|
+
});
|
125
|
+
};
|
126
|
+
|
87
127
|
_topo$store$getModelS = topo.store.getModelState('topoBizMod').resAndMetrics, resIdsList = _topo$store$getModelS.resIdsList, nodeIdsList = _topo$store$getModelS.nodeIdsList; // rlog.debug('根据ci的id获取属性的值-getCiArrByIds', resIdsList, metrics);
|
88
128
|
// 无资源,不查询
|
89
129
|
|
90
130
|
if (resIdsList.length) {
|
91
|
-
_context.next =
|
131
|
+
_context.next = 6;
|
92
132
|
break;
|
93
133
|
}
|
94
134
|
|
95
135
|
return _context.abrupt("return", []);
|
96
136
|
|
97
|
-
case
|
137
|
+
case 6:
|
98
138
|
// 需要查询的指标列表
|
99
139
|
codes = topo.attributeMetricDisplay.getResourceMetricCodes();
|
100
140
|
param = {
|
@@ -111,34 +151,21 @@ var usePolling = function usePolling(props) {
|
|
111
151
|
_context.t0 = Promise;
|
112
152
|
_context.t1 = // 查询指标值
|
113
153
|
topo.serverApi.ciInfo.batchQueryCiInfo(param);
|
114
|
-
_context.next =
|
154
|
+
_context.next = 12;
|
115
155
|
return _DictCache["default"].init();
|
116
156
|
|
117
|
-
case
|
157
|
+
case 12:
|
118
158
|
_context.t2 = _context.sent;
|
119
159
|
_context.t3 = [_context.t1, _context.t2];
|
120
|
-
_context.next =
|
160
|
+
_context.next = 16;
|
121
161
|
return _context.t0.all.call(_context.t0, _context.t3);
|
122
162
|
|
123
|
-
case
|
163
|
+
case 16:
|
124
164
|
_yield$Promise$all = _context.sent;
|
125
165
|
ciMetricResult = _yield$Promise$all[0];
|
126
|
-
return _context.abrupt("return", ciMetricResult
|
127
|
-
var ci = topo.dataModel.getDataById(data.id);
|
128
|
-
var resultData = (0, _extends2["default"])({}, data, ci, {
|
129
|
-
attributeMap: (0, _extends2["default"])({}, (ci === null || ci === void 0 ? void 0 : ci.attributes) || {})
|
130
|
-
});
|
131
|
-
resultData = transformLinkData(resultData); // 特殊处理:ipv6 从ipv6_address_list取第一个
|
132
|
-
|
133
|
-
// 特殊处理:ipv6 从ipv6_address_list取第一个
|
134
|
-
if (resultData.attributeMap.ipv6_address_list && !resultData.attributeMap.ipv6_address) {
|
135
|
-
resultData.attributeMap.ipv6_address = (resultData.attributeMap.ipv6_address_list || '').split(',')[0];
|
136
|
-
}
|
137
|
-
|
138
|
-
return resultData;
|
139
|
-
}));
|
166
|
+
return _context.abrupt("return", mergeData(ciMetricResult));
|
140
167
|
|
141
|
-
case
|
168
|
+
case 19:
|
142
169
|
case "end":
|
143
170
|
return _context.stop();
|
144
171
|
}
|