@riil-frontend/component-topology 9.0.0-a.1 → 9.0.0-a.11
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 +7 -7
- package/es/components/VerticalIconTab/VerticalIconTab.module.scss +11 -5
- package/es/core/editor/components/BackgroundView/index.module.scss +3 -0
- package/es/core/editor/components/Sidebar/Sidebar.module.scss +7 -7
- package/es/core/editor/components/Sidebar/views/CanvasPanel/CanvasPanel.module.scss +1 -0
- package/es/core/editor/components/Sidebar/views/ComponentPanel.js +1 -1
- package/es/core/editor/components/Sidebar/views/ImagePanel/ImagePanel.js +2 -1
- package/es/core/editor/components/Sidebar/views/LinkPanel.js +1 -1
- package/es/core/editor/components/Toolbar/widgets/EdgeTypeButton/LineType.js +1 -1
- package/es/core/event/topoEventListener.js +22 -0
- package/es/core/hooks/useAlarm.js +18 -12
- package/es/core/hooks/useCiAttributeChange.js +60 -0
- package/es/core/hooks/usePolling.js +163 -60
- package/es/core/hooks/useTopoEventListener.js +4 -18
- package/es/core/models/Alarm.js +4 -13
- 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/core/store/models/viewer/resourceDetail.js +7 -0
- package/es/core/viewer/components/plugins/ResourceDetail/ResourceDetailDrawer.js +10 -9
- package/es/core/viewer/components/plugins/ResourceDetail/components/ResourceOverview/ResourceOverview.js +100 -46
- package/es/core/viewer/components/plugins/ResourceDetail/components/ResourceOverview/components/LinkTopo/LinkTopoCard.js +8 -6
- package/es/core/viewer/components/plugins/ResourceDetail/components/ResourceOverview/components/LinkTopo/hooks/useMetricPolling.js +8 -26
- package/es/core/viewer/components/plugins/ResourceDetail/components/ResourceOverview/hooks/useMetricModels.js +13 -52
- package/es/style.js +1 -1
- package/lib/components/VerticalIconTab/VerticalIconTab.module.scss +11 -5
- package/lib/core/editor/components/BackgroundView/index.module.scss +3 -0
- package/lib/core/editor/components/Sidebar/Sidebar.module.scss +7 -7
- package/lib/core/editor/components/Sidebar/views/CanvasPanel/CanvasPanel.module.scss +1 -0
- package/lib/core/editor/components/Sidebar/views/ComponentPanel.js +1 -1
- package/lib/core/editor/components/Sidebar/views/ImagePanel/ImagePanel.js +2 -1
- package/lib/core/editor/components/Sidebar/views/LinkPanel.js +1 -1
- package/lib/core/editor/components/Toolbar/widgets/EdgeTypeButton/LineType.js +1 -1
- package/lib/core/event/topoEventListener.js +27 -0
- package/lib/core/hooks/useAlarm.js +19 -12
- package/lib/core/hooks/useCiAttributeChange.js +70 -0
- package/lib/core/hooks/usePolling.js +166 -61
- package/lib/core/hooks/useTopoEventListener.js +3 -17
- package/lib/core/models/Alarm.js +5 -16
- 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/core/store/models/viewer/resourceDetail.js +7 -0
- package/lib/core/viewer/components/plugins/ResourceDetail/ResourceDetailDrawer.js +10 -9
- package/lib/core/viewer/components/plugins/ResourceDetail/components/ResourceOverview/ResourceOverview.js +99 -45
- package/lib/core/viewer/components/plugins/ResourceDetail/components/ResourceOverview/components/LinkTopo/LinkTopoCard.js +8 -6
- package/lib/core/viewer/components/plugins/ResourceDetail/components/ResourceOverview/components/LinkTopo/hooks/useMetricPolling.js +8 -26
- package/lib/core/viewer/components/plugins/ResourceDetail/components/ResourceOverview/hooks/useMetricModels.js +13 -53
- package/lib/style.js +1 -1
- package/package.json +3 -3
@@ -3,8 +3,8 @@
|
|
3
3
|
|
4
4
|
.tabs {
|
5
5
|
height: 100%;
|
6
|
-
|
7
|
-
}
|
6
|
+
display: flex;
|
7
|
+
}
|
8
8
|
|
9
9
|
// 导航
|
10
10
|
.nav {
|
@@ -49,17 +49,23 @@
|
|
49
49
|
|
50
50
|
// 标签页内容区
|
51
51
|
.content {
|
52
|
-
width: 260px;
|
52
|
+
// width: 260px;
|
53
53
|
height: 100%;
|
54
54
|
border-left: none !important;
|
55
|
-
border-right: 1px solid var(--tab-wrapped-border-line-color);
|
56
55
|
transition: width .1s linear;
|
56
|
+
overflow: initial !important;
|
57
57
|
|
58
58
|
:global {
|
59
59
|
.#{$css-prefix}tabs-tabpane {
|
60
|
-
|
60
|
+
position: absolute;
|
61
|
+
left: 0;
|
62
|
+
top: 0;
|
63
|
+
z-index: 1;
|
64
|
+
// width: 250px;
|
61
65
|
height: 100%;
|
62
66
|
overflow: auto;
|
67
|
+
background: #FFF;
|
68
|
+
border-right: 1px solid var(--tab-wrapped-border-line-color);
|
63
69
|
}
|
64
70
|
}
|
65
71
|
|
@@ -1,19 +1,19 @@
|
|
1
1
|
.sidebar {
|
2
2
|
// border-right: 1px solid #E6E7EB;
|
3
3
|
position: relative;
|
4
|
-
width: 60px;
|
4
|
+
// width: 60px;
|
5
5
|
|
6
6
|
.tabsContainer {
|
7
|
-
position: absolute;
|
8
|
-
|
7
|
+
// position: absolute;
|
8
|
+
// left: 0;
|
9
|
+
// top: 0;
|
10
|
+
// z-index: 1;
|
11
|
+
// width: 60px;
|
9
12
|
height: 100%;
|
10
|
-
left: 0;
|
11
|
-
top: 0;
|
12
|
-
z-index: 1;
|
13
13
|
background: #FFF;
|
14
14
|
|
15
15
|
&.expanded {
|
16
|
-
width: 320px;
|
16
|
+
// width: 320px;
|
17
17
|
}
|
18
18
|
}
|
19
19
|
}
|
@@ -0,0 +1,22 @@
|
|
1
|
+
var n = 0;
|
2
|
+
export function createTopoEventListener(type, onMessage) {
|
3
|
+
var eventListenerName = "topo_" + n++;
|
4
|
+
var EE = window.EE;
|
5
|
+
|
6
|
+
if (EE) {
|
7
|
+
EE.on('topo', eventListenerName, function (data) {
|
8
|
+
if (data.type === type) {
|
9
|
+
onMessage(data.data);
|
10
|
+
}
|
11
|
+
});
|
12
|
+
}
|
13
|
+
|
14
|
+
return {
|
15
|
+
eventListenerName: eventListenerName,
|
16
|
+
close: function close() {
|
17
|
+
if (EE) {
|
18
|
+
window.EE.removeListener('topo', eventListenerName);
|
19
|
+
}
|
20
|
+
}
|
21
|
+
};
|
22
|
+
}
|
@@ -1,8 +1,8 @@
|
|
1
1
|
import _extends from "@babel/runtime/helpers/extends";
|
2
2
|
import { useEffect } from "react";
|
3
3
|
import rlog from "@riil-frontend/component-topology-utils/es/rlog";
|
4
|
-
import { useCbbEventListener } from "@riil-frontend/component-riil-event-emitter";
|
5
4
|
import useGraphAlarmDisplay from "./useGraphAlarmDisplay";
|
5
|
+
import useTopoEventListener from "./useTopoEventListener";
|
6
6
|
/**
|
7
7
|
*
|
8
8
|
*
|
@@ -104,20 +104,26 @@ export default function useAlarm(options) {
|
|
104
104
|
received: data,
|
105
105
|
all: relateTopoAlarm
|
106
106
|
});
|
107
|
-
};
|
107
|
+
}; // 订阅消息
|
108
|
+
|
108
109
|
|
109
|
-
|
110
|
-
|
110
|
+
useTopoEventListener({
|
111
|
+
type: 'alarm',
|
111
112
|
onMessage: function onMessage(data) {
|
112
113
|
rlog.debug("Topoget--AlertMesage------------", topo, data);
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
114
|
+
topo.alarm.handleAlarmEvent(data);
|
115
|
+
}
|
116
|
+
});
|
117
|
+
useTopoEventListener({
|
118
|
+
type: 'risk',
|
119
|
+
onMessage: function onMessage(data) {
|
120
|
+
handleRiskData(data);
|
121
|
+
}
|
122
|
+
});
|
123
|
+
useTopoEventListener({
|
124
|
+
type: 'relateTopoAlarm',
|
125
|
+
onMessage: function onMessage(data) {
|
126
|
+
handleRelateTopoAlarm(data);
|
121
127
|
}
|
122
128
|
});
|
123
129
|
}
|
@@ -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
|
@@ -1,26 +1,12 @@
|
|
1
|
-
import { useEffect
|
2
|
-
|
1
|
+
import { useEffect } from 'react';
|
2
|
+
import { createTopoEventListener } from "../event/topoEventListener";
|
3
3
|
export default function useTopoEventListener(props) {
|
4
4
|
var type = props.type,
|
5
5
|
onMessage = props.onMessage;
|
6
|
-
var eventListenerName = useMemo(function () {
|
7
|
-
return "topo_" + n++;
|
8
|
-
}, []);
|
9
6
|
useEffect(function () {
|
10
|
-
var
|
11
|
-
|
12
|
-
if (EE) {
|
13
|
-
window.EE.on('topo', eventListenerName, function (data) {
|
14
|
-
if (data.type === type) {
|
15
|
-
onMessage(data.data);
|
16
|
-
}
|
17
|
-
});
|
18
|
-
}
|
19
|
-
|
7
|
+
var listener = createTopoEventListener(type, onMessage);
|
20
8
|
return function () {
|
21
|
-
|
22
|
-
window.EE.removeListener('topo', eventListenerName);
|
23
|
-
}
|
9
|
+
listener.close();
|
24
10
|
};
|
25
11
|
}, [type, onMessage]);
|
26
12
|
}
|
package/es/core/models/Alarm.js
CHANGED
@@ -5,9 +5,8 @@ import topoService from "@riil-frontend/component-topology-common/es/services/to
|
|
5
5
|
import rlog from "@riil-frontend/component-topology-utils/es/rlog";
|
6
6
|
import { EE } from "@riil-frontend/component-riil-event-emitter";
|
7
7
|
import { isAvailableArray } from "@riil-frontend/utils";
|
8
|
+
import { createTopoEventListener } from "../event/topoEventListener";
|
8
9
|
|
9
|
-
// import moment from "moment";
|
10
|
-
// import { alarmListDemo } from "./mocks";
|
11
10
|
var Alarm = /*#__PURE__*/function () {
|
12
11
|
function Alarm() {
|
13
12
|
this.topo = void 0;
|
@@ -375,8 +374,6 @@ var Alarm = /*#__PURE__*/function () {
|
|
375
374
|
/*#__PURE__*/
|
376
375
|
function () {
|
377
376
|
var _openTopoAlarm = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee6(id) {
|
378
|
-
var _this2 = this;
|
379
|
-
|
380
377
|
var _this$getState2, alarmOpening, topoAlarmIsOpen, alarmDispatchers;
|
381
378
|
|
382
379
|
return _regeneratorRuntime.wrap(function _callee6$(_context6) {
|
@@ -409,17 +406,12 @@ var Alarm = /*#__PURE__*/function () {
|
|
409
406
|
case 10:
|
410
407
|
this.secretKey = _context6.sent;
|
411
408
|
// rlog.debug("openTopoAlarm 获取初始化告警-------------------开始");
|
412
|
-
EE.on("topo", "topo", function (data, other) {
|
413
|
-
rlog.debug("openTopoAlarm 获取初始化告警------收到信息", data);
|
414
|
-
|
415
|
-
_this2.handleAlarmEvent(data);
|
416
|
-
});
|
417
409
|
this.updateState({
|
418
410
|
alarmOpening: false,
|
419
411
|
alarmIsOpened: true
|
420
412
|
});
|
421
413
|
|
422
|
-
case
|
414
|
+
case 12:
|
423
415
|
case "end":
|
424
416
|
return _context6.stop();
|
425
417
|
}
|
@@ -463,16 +455,15 @@ var Alarm = /*#__PURE__*/function () {
|
|
463
455
|
case 3:
|
464
456
|
this.currentTopoId = null;
|
465
457
|
rlog.debug("useAlarm.useEffect 告警WebSocket 结束");
|
466
|
-
EE.removeListener("topo", "topo");
|
467
458
|
this.updateState({
|
468
459
|
topoAlarmIsOpen: false,
|
469
460
|
alarmOpening: false,
|
470
461
|
alarmPanelIsOpen: false
|
471
462
|
});
|
472
|
-
_context7.next =
|
463
|
+
_context7.next = 8;
|
473
464
|
return this.topo.serverApi.closeTopoAlarm(id, this.secretKey);
|
474
465
|
|
475
|
-
case
|
466
|
+
case 8:
|
476
467
|
case "end":
|
477
468
|
return _context7.stop();
|
478
469
|
}
|