@riil-frontend/component-topology 8.0.8 → 8.0.10
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 +7 -7
- package/es/core/editor/components/Toolbar/widgets/EdgeTypeButton/LineType.js +1 -1
- package/es/core/hooks/useCiAttributeChange.js +60 -0
- package/es/core/hooks/usePolling.js +163 -60
- package/es/core/models/AttributeMetricDisplay.js +44 -127
- package/es/core/models/TopoApp.js +4 -2
- package/es/core/models/attributeFormatter/index.js +5 -6
- package/es/core/models/cache/CiCache.d.ts +18 -0
- package/es/core/models/cache/CiCache.js +78 -0
- package/es/core/models/utils/linkUtils.js +10 -13
- package/es/core/store/models/topoBizMod.js +4 -0
- package/es/style.js +1 -1
- package/lib/core/editor/components/Toolbar/widgets/EdgeTypeButton/LineType.js +1 -1
- package/lib/core/hooks/useCiAttributeChange.js +70 -0
- package/lib/core/hooks/usePolling.js +166 -61
- package/lib/core/models/AttributeMetricDisplay.js +44 -126
- package/lib/core/models/TopoApp.js +4 -1
- package/lib/core/models/attributeFormatter/index.js +5 -7
- package/lib/core/models/cache/CiCache.d.ts +18 -0
- package/lib/core/models/cache/CiCache.js +89 -0
- package/lib/core/models/utils/linkUtils.js +10 -12
- package/lib/core/store/models/topoBizMod.js +4 -0
- package/lib/style.js +1 -1
- package/package.json +2 -2
@@ -0,0 +1,60 @@
|
|
1
|
+
import _extends from "@babel/runtime/helpers/extends";
|
2
|
+
import rlog from '@riil-frontend/component-topology-utils/es/rlog';
|
3
|
+
import { useEffect } from 'react';
|
4
|
+
import CiCache from "../models/cache/CiCache";
|
5
|
+
import useTopoEventListener from "./useTopoEventListener";
|
6
|
+
|
7
|
+
function mergeData(cis, ciChangeData) {
|
8
|
+
if (!cis.find(function (item) {
|
9
|
+
return item.id === ciChangeData.id;
|
10
|
+
})) {
|
11
|
+
return cis;
|
12
|
+
}
|
13
|
+
|
14
|
+
return cis.map(function (ci) {
|
15
|
+
if (ci.id === ciChangeData.id) {
|
16
|
+
return _extends({}, ci, {
|
17
|
+
attributes: _extends({}, ci.attributes, ciChangeData.attributes)
|
18
|
+
});
|
19
|
+
}
|
20
|
+
|
21
|
+
return ci;
|
22
|
+
});
|
23
|
+
}
|
24
|
+
/**
|
25
|
+
* 监听ci属性变更
|
26
|
+
*
|
27
|
+
* @param {*} props
|
28
|
+
*/
|
29
|
+
|
30
|
+
|
31
|
+
export default function useCiAttributeChange(props) {
|
32
|
+
var topo = props.topo;
|
33
|
+
useTopoEventListener({
|
34
|
+
type: 'attribute',
|
35
|
+
onMessage: function onMessage(ciChangeData) {
|
36
|
+
// 更新拓扑数据
|
37
|
+
var topoData = topo.store.getModelState('topoMod').data;
|
38
|
+
|
39
|
+
if (topoData) {
|
40
|
+
var newData = _extends({}, topoData, {
|
41
|
+
nodes: mergeData(topoData.nodes, ciChangeData),
|
42
|
+
links: mergeData(topoData.links, ciChangeData),
|
43
|
+
linkGroups: mergeData(topoData.linkGroups, ciChangeData)
|
44
|
+
});
|
45
|
+
|
46
|
+
var topoDispatchers = topo.store.getModelDispatchers('topoMod');
|
47
|
+
topoDispatchers.update({
|
48
|
+
data: newData
|
49
|
+
});
|
50
|
+
} // 更新缓存
|
51
|
+
|
52
|
+
|
53
|
+
var ci = CiCache.getCi(ciChangeData.id);
|
54
|
+
|
55
|
+
if (ci) {
|
56
|
+
ci.attributes = _extends({}, ci.attributes, ciChangeData.attributes);
|
57
|
+
}
|
58
|
+
}
|
59
|
+
});
|
60
|
+
}
|
@@ -1,10 +1,14 @@
|
|
1
|
-
import _asyncToGenerator from "@babel/runtime/helpers/asyncToGenerator";
|
2
1
|
import _extends from "@babel/runtime/helpers/extends";
|
2
|
+
import _asyncToGenerator from "@babel/runtime/helpers/asyncToGenerator";
|
3
3
|
import _regeneratorRuntime from "@babel/runtime/regenerator";
|
4
4
|
import { useEffect } from 'react';
|
5
5
|
import { useRequest } from 'ahooks';
|
6
6
|
import _ from 'lodash';
|
7
7
|
import rlog from '@riil-frontend/component-topology-utils/es/rlog';
|
8
|
+
import topoServer from '@riil-frontend/component-topology-common/es/services/topo';
|
9
|
+
import { useCbbEventListener } from '@riil-frontend/component-riil-event-emitter';
|
10
|
+
import DictCache from "../models/cache/DictCache";
|
11
|
+
import useCiAttributeChange from "./useCiAttributeChange";
|
8
12
|
/**
|
9
13
|
* 轮询获取指标hooks
|
10
14
|
* @param {*} props
|
@@ -13,12 +17,158 @@ import rlog from '@riil-frontend/component-topology-utils/es/rlog';
|
|
13
17
|
var usePolling = function usePolling(props) {
|
14
18
|
var topo = props.topo;
|
15
19
|
var store = topo.store;
|
20
|
+
useCiAttributeChange({
|
21
|
+
topo: topo
|
22
|
+
});
|
16
23
|
var bizState = store.useModelState('topoBizMod');
|
17
24
|
var resAndMetrics = bizState.resAndMetrics,
|
18
25
|
pollingSwitch = bizState.pollingSwitch;
|
19
26
|
var displayConfig = topo.store.useModelState('displayConfig');
|
20
27
|
var resourceOverviewState = topo.store.useModelState('topoBaseInfoOverview');
|
21
|
-
var resIdsList = resAndMetrics === null || resAndMetrics === void 0 ? void 0 : resAndMetrics.resIdsList;
|
28
|
+
var resIdsList = resAndMetrics === null || resAndMetrics === void 0 ? void 0 : resAndMetrics.resIdsList;
|
29
|
+
/**
|
30
|
+
* 查询拓扑图资源的属性指标
|
31
|
+
*
|
32
|
+
* @returns {array}
|
33
|
+
*/
|
34
|
+
|
35
|
+
function fetchData() {
|
36
|
+
return _fetchData.apply(this, arguments);
|
37
|
+
}
|
38
|
+
/**
|
39
|
+
*
|
40
|
+
* @returns {{id, attributes: object[], metrics: object[]}[]} 属性和指标
|
41
|
+
*/
|
42
|
+
|
43
|
+
|
44
|
+
function _fetchData() {
|
45
|
+
_fetchData = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee() {
|
46
|
+
var _topo$store$getModelS, resIdsList, nodeIdsList, codes, param, _yield$Promise$all, ciMetricResult, transformLinkData;
|
47
|
+
|
48
|
+
return _regeneratorRuntime.wrap(function _callee$(_context) {
|
49
|
+
while (1) {
|
50
|
+
switch (_context.prev = _context.next) {
|
51
|
+
case 0:
|
52
|
+
transformLinkData = function _transformLinkData(data) {
|
53
|
+
var _topo$dataModel$getDa = topo.dataModel.getData(),
|
54
|
+
links = _topo$dataModel$getDa.links,
|
55
|
+
linkGroups = _topo$dataModel$getDa.linkGroups;
|
56
|
+
|
57
|
+
var link = [].concat(links, linkGroups).find(function (item) {
|
58
|
+
return item.id === data.id;
|
59
|
+
});
|
60
|
+
|
61
|
+
if (!link) {
|
62
|
+
return data;
|
63
|
+
}
|
64
|
+
|
65
|
+
return _extends({}, data, {
|
66
|
+
attributeMap: link.attributes || {}
|
67
|
+
});
|
68
|
+
};
|
69
|
+
|
70
|
+
_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
|
+
// 无资源,不查询
|
72
|
+
|
73
|
+
if (resIdsList.length) {
|
74
|
+
_context.next = 4;
|
75
|
+
break;
|
76
|
+
}
|
77
|
+
|
78
|
+
return _context.abrupt("return", []);
|
79
|
+
|
80
|
+
case 4:
|
81
|
+
// 需要查询的指标列表
|
82
|
+
codes = topo.attributeMetricDisplay.getResourceMetricCodes();
|
83
|
+
param = {
|
84
|
+
ciId: nodeIdsList,
|
85
|
+
codes: codes,
|
86
|
+
// 过滤掉不需要查询的
|
87
|
+
relationId: topo.attributeMetricDisplay.getEdges().map(function (edge) {
|
88
|
+
return {
|
89
|
+
ciId: edge.id,
|
90
|
+
operation: edge.operation
|
91
|
+
};
|
92
|
+
})
|
93
|
+
};
|
94
|
+
_context.t0 = Promise;
|
95
|
+
_context.t1 = // 查询指标值
|
96
|
+
topoServer.ciInfo.batchQueryCiInfo(param);
|
97
|
+
_context.next = 10;
|
98
|
+
return DictCache.init();
|
99
|
+
|
100
|
+
case 10:
|
101
|
+
_context.t2 = _context.sent;
|
102
|
+
_context.t3 = [_context.t1, _context.t2];
|
103
|
+
_context.next = 14;
|
104
|
+
return _context.t0.all.call(_context.t0, _context.t3);
|
105
|
+
|
106
|
+
case 14:
|
107
|
+
_yield$Promise$all = _context.sent;
|
108
|
+
ciMetricResult = _yield$Promise$all[0];
|
109
|
+
return _context.abrupt("return", ciMetricResult.map(function (data) {
|
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
|
+
}));
|
125
|
+
|
126
|
+
case 17:
|
127
|
+
case "end":
|
128
|
+
return _context.stop();
|
129
|
+
}
|
130
|
+
}
|
131
|
+
}, _callee);
|
132
|
+
}));
|
133
|
+
return _fetchData.apply(this, arguments);
|
134
|
+
}
|
135
|
+
|
136
|
+
function refresh() {
|
137
|
+
return _refresh.apply(this, arguments);
|
138
|
+
} // 轮询hooks
|
139
|
+
|
140
|
+
|
141
|
+
function _refresh() {
|
142
|
+
_refresh = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2() {
|
143
|
+
var data;
|
144
|
+
return _regeneratorRuntime.wrap(function _callee2$(_context2) {
|
145
|
+
while (1) {
|
146
|
+
switch (_context2.prev = _context2.next) {
|
147
|
+
case 0:
|
148
|
+
if (!(!pollingSwitch || !(resAndMetrics !== null && resAndMetrics !== void 0 && resAndMetrics.resIdsList.length))) {
|
149
|
+
_context2.next = 2;
|
150
|
+
break;
|
151
|
+
}
|
152
|
+
|
153
|
+
return _context2.abrupt("return");
|
154
|
+
|
155
|
+
case 2:
|
156
|
+
_context2.next = 4;
|
157
|
+
return fetchData();
|
158
|
+
|
159
|
+
case 4:
|
160
|
+
data = _context2.sent;
|
161
|
+
return _context2.abrupt("return", data);
|
162
|
+
|
163
|
+
case 6:
|
164
|
+
case "end":
|
165
|
+
return _context2.stop();
|
166
|
+
}
|
167
|
+
}
|
168
|
+
}, _callee2);
|
169
|
+
}));
|
170
|
+
return _refresh.apply(this, arguments);
|
171
|
+
}
|
22
172
|
|
23
173
|
var _useRequest = useRequest(refresh, {
|
24
174
|
pollingInterval: 60 * 1000,
|
@@ -29,30 +179,13 @@ var usePolling = function usePolling(props) {
|
|
29
179
|
if (result) {
|
30
180
|
var dd = _.cloneDeep(result);
|
31
181
|
|
32
|
-
topo.attributeMetricDisplay.
|
182
|
+
topo.attributeMetricDisplay.loadData(dd);
|
33
183
|
}
|
34
184
|
}
|
35
185
|
}),
|
36
186
|
loading = _useRequest.loading,
|
37
187
|
startPoll = _useRequest.run,
|
38
|
-
stopPoll = _useRequest.cancel;
|
39
|
-
|
40
|
-
function convertData(data) {
|
41
|
-
return data.map(function (item) {
|
42
|
-
return _extends({}, item, {
|
43
|
-
attributes: convertAttrMap(item.attributes),
|
44
|
-
metrics: convertAttrMap(item.metrics)
|
45
|
-
});
|
46
|
-
});
|
47
|
-
}
|
48
|
-
|
49
|
-
function convertAttrMap(attrs) {
|
50
|
-
var map = {};
|
51
|
-
attrs.forEach(function (attr) {
|
52
|
-
map[attr.code] = attr.value;
|
53
|
-
});
|
54
|
-
return map;
|
55
|
-
} // 需要刷新数据的场景:显示模式、资源变化、配置变化、开关开启、概览
|
188
|
+
stopPoll = _useRequest.cancel; // 需要刷新数据的场景:显示模式、资源变化、配置变化、开关开启、概览
|
56
189
|
|
57
190
|
|
58
191
|
useEffect(function () {
|
@@ -72,46 +205,16 @@ var usePolling = function usePolling(props) {
|
|
72
205
|
stopPoll();
|
73
206
|
}
|
74
207
|
};
|
75
|
-
}, [pollingSwitch, resIdsList, displayConfig, resourceOverviewState.id, resourceOverviewState.metricCodes]);
|
76
|
-
/**
|
77
|
-
*
|
78
|
-
* @returns {{id, attributes: object[], metrics: object[]}[]} 属性和指标
|
79
|
-
*/
|
80
|
-
|
81
|
-
function refresh() {
|
82
|
-
return _refresh.apply(this, arguments);
|
83
|
-
}
|
84
|
-
|
85
|
-
function _refresh() {
|
86
|
-
_refresh = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee() {
|
87
|
-
return _regeneratorRuntime.wrap(function _callee$(_context) {
|
88
|
-
while (1) {
|
89
|
-
switch (_context.prev = _context.next) {
|
90
|
-
case 0:
|
91
|
-
if (!(!pollingSwitch || !(resAndMetrics !== null && resAndMetrics !== void 0 && resAndMetrics.resIdsList.length))) {
|
92
|
-
_context.next = 2;
|
93
|
-
break;
|
94
|
-
}
|
95
|
-
|
96
|
-
return _context.abrupt("return");
|
97
|
-
|
98
|
-
case 2:
|
99
|
-
_context.next = 4;
|
100
|
-
return topo.attributeMetricDisplay.fetchData();
|
101
|
-
|
102
|
-
case 4:
|
103
|
-
return _context.abrupt("return", _context.sent);
|
104
|
-
|
105
|
-
case 5:
|
106
|
-
case "end":
|
107
|
-
return _context.stop();
|
108
|
-
}
|
109
|
-
}
|
110
|
-
}, _callee);
|
111
|
-
}));
|
112
|
-
return _refresh.apply(this, arguments);
|
113
|
-
}
|
208
|
+
}, [pollingSwitch, resIdsList, displayConfig, resourceOverviewState.id, resourceOverviewState.metricCodes]); // 属性变更监听更新
|
114
209
|
|
210
|
+
useCbbEventListener('topo', {
|
211
|
+
name: 'topo',
|
212
|
+
onMessage: function onMessage(message) {
|
213
|
+
if (message.type === 'attribute') {
|
214
|
+
var data = message.data;
|
215
|
+
}
|
216
|
+
}
|
217
|
+
});
|
115
218
|
return {
|
116
219
|
startPoll: startPoll,
|
117
220
|
stopPoll: stopPoll
|
@@ -346,107 +346,50 @@ var AttributeMetricDisplay = /*#__PURE__*/function () {
|
|
346
346
|
});
|
347
347
|
}
|
348
348
|
/**
|
349
|
-
*
|
349
|
+
* 加载标注、悬浮框数据
|
350
350
|
*
|
351
|
-
* @
|
351
|
+
* @param {array<{id, attributeMap: {}, metricMap: {}}>} data
|
352
352
|
*/
|
353
353
|
;
|
354
354
|
|
355
|
-
_proto.
|
355
|
+
_proto.loadData =
|
356
356
|
/*#__PURE__*/
|
357
357
|
function () {
|
358
|
-
var
|
359
|
-
var topo,
|
360
|
-
|
358
|
+
var _loadData = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(data) {
|
359
|
+
var topo, ciDatas, bizDispatchers;
|
361
360
|
return _regeneratorRuntime.wrap(function _callee$(_context) {
|
362
361
|
while (1) {
|
363
362
|
switch (_context.prev = _context.next) {
|
364
363
|
case 0:
|
365
|
-
|
366
|
-
|
367
|
-
links = _topo$dataModel$getDa.links,
|
368
|
-
linkGroups = _topo$dataModel$getDa.linkGroups;
|
369
|
-
|
370
|
-
var link = [].concat(links, linkGroups).find(function (item) {
|
371
|
-
return item.id === data.id;
|
372
|
-
});
|
373
|
-
|
374
|
-
if (!link) {
|
375
|
-
return data;
|
376
|
-
}
|
377
|
-
|
378
|
-
var attributeMap = data.attributeMap;
|
379
|
-
attributeMap = _extends({}, link.attributes || {});
|
380
|
-
return _extends({}, data, {
|
381
|
-
attributeMap: attributeMap
|
382
|
-
});
|
383
|
-
};
|
364
|
+
// rlog.debug('AttributeMetricDisplay.loadAttributeAndMetric', data);
|
365
|
+
topo = this.topo; // 设置ciType
|
384
366
|
|
385
|
-
|
386
|
-
|
387
|
-
|
367
|
+
ciDatas = data.filter(function (item) {
|
368
|
+
// 过滤不存在的ci,解决编辑模式删除资源后切换到显示模式报错
|
369
|
+
return !!topo.dataModel.getDataById(item.id);
|
370
|
+
}).map(function (item) {
|
371
|
+
return _extends({
|
372
|
+
ciType: topo.dataModel.getDataById(item.id).ciType
|
373
|
+
}, item);
|
374
|
+
}); // 翻译引用属性
|
388
375
|
|
389
|
-
|
390
|
-
|
391
|
-
break;
|
392
|
-
}
|
376
|
+
_context.next = 4;
|
377
|
+
return this.translateRefAttribute(ciDatas);
|
393
378
|
|
394
|
-
|
379
|
+
case 4:
|
380
|
+
ciDatas = _context.sent;
|
381
|
+
bizDispatchers = topo.store.getModelDispatchers('topoBizMod');
|
382
|
+
_context.next = 8;
|
383
|
+
return bizDispatchers.setAttrsAndMetrics(ciDatas);
|
395
384
|
|
396
|
-
case
|
397
|
-
_context.next =
|
385
|
+
case 8:
|
386
|
+
_context.next = 10;
|
398
387
|
return DictCache.init();
|
399
388
|
|
400
|
-
case
|
401
|
-
|
402
|
-
codes = this.getResourceMetricCodes();
|
403
|
-
param = {
|
404
|
-
ciId: nodeIdsList,
|
405
|
-
codes: codes,
|
406
|
-
// 过滤掉不需要查询的
|
407
|
-
relationId: this.getEdges().map(function (edge) {
|
408
|
-
return {
|
409
|
-
ciId: edge.id,
|
410
|
-
operation: edge.operation
|
411
|
-
};
|
412
|
-
})
|
413
|
-
};
|
414
|
-
/**
|
415
|
-
* 链路属性适配
|
416
|
-
* @param {*} data
|
417
|
-
* @returns
|
418
|
-
*/
|
419
|
-
|
420
|
-
_context.next = 11;
|
421
|
-
return topoServer.ciInfo.batchQueryCiInfo(param);
|
389
|
+
case 10:
|
390
|
+
this.updateTagsTips();
|
422
391
|
|
423
392
|
case 11:
|
424
|
-
result = _context.sent;
|
425
|
-
return _context.abrupt("return", result.map(function (data) {
|
426
|
-
var list2map = function list2map(list) {
|
427
|
-
var map = {};
|
428
|
-
(list || []).forEach(function (item) {
|
429
|
-
map[item.code] = item.value;
|
430
|
-
});
|
431
|
-
return map;
|
432
|
-
};
|
433
|
-
|
434
|
-
var resultData = _extends({}, data, {
|
435
|
-
attributeMap: list2map(data.attributes),
|
436
|
-
metricMap: list2map(data.metrics)
|
437
|
-
});
|
438
|
-
|
439
|
-
resultData = transformLinkData(resultData); // 特殊处理:ipv6 从ipv6_address_list取第一个
|
440
|
-
|
441
|
-
// 特殊处理:ipv6 从ipv6_address_list取第一个
|
442
|
-
if (resultData.attributeMap.ipv6_address_list && !resultData.attributeMap.ipv6_address) {
|
443
|
-
resultData.attributeMap.ipv6_address = (resultData.attributeMap.ipv6_address_list || '').split(',')[0];
|
444
|
-
}
|
445
|
-
|
446
|
-
return resultData;
|
447
|
-
}));
|
448
|
-
|
449
|
-
case 13:
|
450
393
|
case "end":
|
451
394
|
return _context.stop();
|
452
395
|
}
|
@@ -454,16 +397,17 @@ var AttributeMetricDisplay = /*#__PURE__*/function () {
|
|
454
397
|
}, _callee, this);
|
455
398
|
}));
|
456
399
|
|
457
|
-
function
|
458
|
-
return
|
400
|
+
function loadData(_x) {
|
401
|
+
return _loadData.apply(this, arguments);
|
459
402
|
}
|
460
403
|
|
461
|
-
return
|
404
|
+
return loadData;
|
462
405
|
}()
|
463
406
|
/**
|
464
407
|
* 加载标注、悬浮框数据
|
408
|
+
* 业务拓扑使用
|
465
409
|
*
|
466
|
-
* @param {array} data
|
410
|
+
* @param {array<{id, attributes: [], attributeMap: {}, metrics: [], metricMap: {}}>} data
|
467
411
|
*/
|
468
412
|
;
|
469
413
|
|
@@ -471,40 +415,14 @@ var AttributeMetricDisplay = /*#__PURE__*/function () {
|
|
471
415
|
/*#__PURE__*/
|
472
416
|
function () {
|
473
417
|
var _loadAttributeAndMetric = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2(data) {
|
474
|
-
var topo, ciDatas, bizDispatchers;
|
475
418
|
return _regeneratorRuntime.wrap(function _callee2$(_context2) {
|
476
419
|
while (1) {
|
477
420
|
switch (_context2.prev = _context2.next) {
|
478
421
|
case 0:
|
479
|
-
|
480
|
-
|
481
|
-
|
482
|
-
ciDatas = data.filter(function (item) {
|
483
|
-
// 过滤不存在的ci,解决编辑模式删除资源后切换到显示模式报错
|
484
|
-
return !!topo.dataModel.getDataById(item.id);
|
485
|
-
}).map(function (item) {
|
486
|
-
return _extends({
|
487
|
-
ciType: topo.dataModel.getDataById(item.id).ciType
|
488
|
-
}, item);
|
489
|
-
}); // 翻译引用属性
|
490
|
-
|
491
|
-
_context2.next = 4;
|
492
|
-
return this.translateRefAttribute(ciDatas);
|
493
|
-
|
494
|
-
case 4:
|
495
|
-
ciDatas = _context2.sent;
|
496
|
-
bizDispatchers = topo.store.getModelDispatchers('topoBizMod');
|
497
|
-
_context2.next = 8;
|
498
|
-
return bizDispatchers.setAttrsAndMetrics(ciDatas);
|
422
|
+
_context2.next = 2;
|
423
|
+
return this.loadData(data);
|
499
424
|
|
500
|
-
case
|
501
|
-
_context2.next = 10;
|
502
|
-
return DictCache.init();
|
503
|
-
|
504
|
-
case 10:
|
505
|
-
this.updateTagsTips();
|
506
|
-
|
507
|
-
case 11:
|
425
|
+
case 2:
|
508
426
|
case "end":
|
509
427
|
return _context2.stop();
|
510
428
|
}
|
@@ -512,7 +430,7 @@ var AttributeMetricDisplay = /*#__PURE__*/function () {
|
|
512
430
|
}, _callee2, this);
|
513
431
|
}));
|
514
432
|
|
515
|
-
function loadAttributeAndMetric(
|
433
|
+
function loadAttributeAndMetric(_x2) {
|
516
434
|
return _loadAttributeAndMetric.apply(this, arguments);
|
517
435
|
}
|
518
436
|
|
@@ -520,7 +438,7 @@ var AttributeMetricDisplay = /*#__PURE__*/function () {
|
|
520
438
|
}()
|
521
439
|
/**
|
522
440
|
* 临时由前端翻译引用属性名称
|
523
|
-
* @param {array} ciDatas
|
441
|
+
* @param {array<{id, ciType, attributeMap: {}, ...}>} ciDatas
|
524
442
|
* @returns
|
525
443
|
*/
|
526
444
|
;
|
@@ -531,7 +449,7 @@ var AttributeMetricDisplay = /*#__PURE__*/function () {
|
|
531
449
|
var _translateRefAttribute = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee3(ciDatas) {
|
532
450
|
var _this5 = this;
|
533
451
|
|
534
|
-
var refIdMap, ciRefAttributeMap, refIds,
|
452
|
+
var refIdMap, ciRefAttributeMap, refIds, refCiMap;
|
535
453
|
return _regeneratorRuntime.wrap(function _callee3$(_context3) {
|
536
454
|
while (1) {
|
537
455
|
switch (_context3.prev = _context3.next) {
|
@@ -577,11 +495,10 @@ var AttributeMetricDisplay = /*#__PURE__*/function () {
|
|
577
495
|
|
578
496
|
case 6:
|
579
497
|
_context3.next = 8;
|
580
|
-
return
|
498
|
+
return this.topo.ciCache.load(refIds);
|
581
499
|
|
582
500
|
case 8:
|
583
|
-
|
584
|
-
refCiMap = keyBy(refCis, 'id');
|
501
|
+
refCiMap = _context3.sent;
|
585
502
|
rlog.debug('translateRefAttribute', {
|
586
503
|
ciRefAttributeMap: ciRefAttributeMap,
|
587
504
|
refIds: refIds,
|
@@ -607,15 +524,15 @@ var AttributeMetricDisplay = /*#__PURE__*/function () {
|
|
607
524
|
});
|
608
525
|
}));
|
609
526
|
|
610
|
-
case
|
527
|
+
case 11:
|
611
528
|
case "end":
|
612
529
|
return _context3.stop();
|
613
530
|
}
|
614
531
|
}
|
615
|
-
}, _callee3);
|
532
|
+
}, _callee3, this);
|
616
533
|
}));
|
617
534
|
|
618
|
-
function translateRefAttribute(
|
535
|
+
function translateRefAttribute(_x3) {
|
619
536
|
return _translateRefAttribute.apply(this, arguments);
|
620
537
|
}
|
621
538
|
|
@@ -636,8 +553,8 @@ var AttributeMetricDisplay = /*#__PURE__*/function () {
|
|
636
553
|
|
637
554
|
var elementTagsAndTips = this.buildTagsTips() // 开锁状态下禁用悬停展示悬浮框
|
638
555
|
.map(function (item) {
|
639
|
-
var _topo$store$
|
640
|
-
lock = _topo$store$
|
556
|
+
var _topo$store$getModelS = topo.store.getModelState('lock'),
|
557
|
+
lock = _topo$store$getModelS.lock;
|
641
558
|
|
642
559
|
return lock ? item : _extends({}, item, {
|
643
560
|
tips: []
|
@@ -21,9 +21,10 @@ import { updateEdgeExpanded } from "../utils/edgeUtil";
|
|
21
21
|
import PluginManager from "./PluginManager";
|
22
22
|
import topoFactory from "./topoFactory";
|
23
23
|
import ElementTagTipConfig from "./tagstips/ElementTagTipConfig";
|
24
|
-
import SelectionModel from "./SelectionModel";
|
24
|
+
import SelectionModel from "./SelectionModel";
|
25
|
+
import CiCache from "./cache/CiCache"; // eslint-disable-next-line no-undef
|
25
26
|
|
26
|
-
var version = typeof "8.0.
|
27
|
+
var version = typeof "8.0.10" === 'string' ? "8.0.10" : null;
|
27
28
|
console.info("\u62D3\u6251\u7248\u672C: " + version);
|
28
29
|
/**
|
29
30
|
* 拓扑显示和编辑
|
@@ -43,6 +44,7 @@ var Topo = /*#__PURE__*/function () {
|
|
43
44
|
this.CiTypeCache = CiTypeCache;
|
44
45
|
this.ciTyeCache = CiTypeCache;
|
45
46
|
this.dictCache = DictCache;
|
47
|
+
this.ciCache = CiCache;
|
46
48
|
this.elementTagTipConfig = new ElementTagTipConfig(this);
|
47
49
|
this.test = void 0;
|
48
50
|
this.uid = void 0;
|
@@ -1,6 +1,5 @@
|
|
1
1
|
import rlog from '@riil-frontend/component-topology-utils/es/rlog';
|
2
2
|
import { metricValueFormat } from '@riil-frontend/utils';
|
3
|
-
import { findItem } from "../../../utils/topoData";
|
4
3
|
import DictCache from "../cache/DictCache";
|
5
4
|
/**
|
6
5
|
* 格式化指标
|
@@ -54,14 +53,14 @@ var AttributeFormatter = /*#__PURE__*/function () {
|
|
54
53
|
};
|
55
54
|
|
56
55
|
_proto.commonTransform = function commonTransform(item, ciData, attrType) {
|
57
|
-
var _findItem;
|
58
|
-
|
59
56
|
var fieldCode = item.code;
|
60
57
|
var fieldMeta = this.topo.ciTyeCache.getCiType(ciData.ciType)[attrType + "Map"][fieldCode];
|
61
|
-
var fieldValue = ciData[attrType + "Map"]
|
58
|
+
var fieldValue = (ciData[attrType + "Map"] || ciData[attrType + "s"])[fieldCode]; // 引用属性
|
62
59
|
|
63
|
-
if (
|
64
|
-
|
60
|
+
if (attrType === 'attribute') {
|
61
|
+
if (ciData[attrType + "Map"][fieldCode + "_object"]) {
|
62
|
+
fieldValue = ciData[attrType + "Map"][fieldCode + "_object"].displayName;
|
63
|
+
}
|
65
64
|
}
|
66
65
|
|
67
66
|
return {
|
@@ -0,0 +1,18 @@
|
|
1
|
+
/**
|
2
|
+
* Ci缓存
|
3
|
+
*/
|
4
|
+
declare class CiCache {
|
5
|
+
/**
|
6
|
+
* @param {object<string, object>}
|
7
|
+
*/
|
8
|
+
ciMap: {};
|
9
|
+
/**
|
10
|
+
*
|
11
|
+
* @param ids {string[]}
|
12
|
+
* @returns {Promise<Object>}
|
13
|
+
*/
|
14
|
+
load(ids: string[]): Promise<Object>;
|
15
|
+
getCi(id: string): Object;
|
16
|
+
}
|
17
|
+
declare const _default: CiCache;
|
18
|
+
export default _default;
|