@riil-frontend/component-topology 12.0.0-dev.9 → 12.1.0-dev.1
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/1.js +1 -1
- package/build/index.css +1 -1
- package/build/index.js +14 -14
- package/es/components/TemplateButton/index.module.scss +1 -1
- package/es/core/components/AlarmListPanel/components/AlarmListItem.js +58 -3
- package/es/core/components/TopoView/topoView.js +5 -1
- package/es/core/editor/components/Toolbar/widgets/EdgeColorButton/EdgeColorButton.js +5 -12
- package/es/core/editor/components/Toolbar/widgets/EdgeTypeButton/EdgeType.js +27 -10
- package/es/core/editor/components/Toolbar/widgets/EdgeTypeButton/EdgeType.module.scss +21 -1
- package/es/core/editor/components/Toolbar/widgets/EdgeTypeButton/LineType.js +9 -0
- package/es/core/editor/components/Toolbar/widgets/EdgeTypeButton/index.js +2 -2
- package/es/core/editor/components/Toolbar/widgets/Layout/index.js +16 -2
- package/es/core/editor/hooks/useKeyboardShortcut.js +3 -1
- package/es/core/editor/utils/copyElementUtil.js +12 -0
- package/es/core/editor/utils/edgeTypeStyleUtil.js +8 -30
- package/es/core/hooks/useAlarm.js +131 -81
- package/es/core/hooks/useCmpLinkAlarm.js +153 -0
- package/es/core/hooks/useEventData.js +1 -2
- package/es/core/hooks/useGraphAlarmDisplay.js +91 -56
- package/es/core/hooks/useResourceConfig.js +1 -3
- package/es/core/hooks/useTopoEdit.js +31 -43
- package/es/core/models/Alarm.js +69 -142
- package/es/core/models/AttributeMetricDisplay.js +9 -3
- package/es/core/models/TopoApp.js +1 -1
- package/es/core/models/cache/CiCache.d.ts +1 -1
- package/es/core/models/cache/CiCache.js +3 -3
- package/es/core/models/topoData.js +0 -1
- package/es/core/models/utils/linkUtils.js +20 -13
- package/es/core/services/topo/basic.js +2 -2
- package/es/core/store/models/topoConfig.js +7 -10
- package/es/core/store/models/topoMod.js +81 -134
- package/es/core/utils/edgeUtil.js +8 -0
- package/es/core/utils/metricUtil.js +8 -4
- package/es/core/utils/showGraphManageStatusUtil.js +3 -2
- package/es/core/viewer/components/plugins/ResourceDetail/components/ResourceOverview/components/LinkTopo/LinkTopoCard.js +2 -2
- package/es/core/viewer/components/plugins/ViewerPlugin.js +3 -1
- package/es/core/viewer/components/titlebar/widgets/AlarmButton.js +1 -5
- package/es/networkTopo/components/TopoView.js +6 -11
- package/es/networkTopo/hooks/useEdgeExpand.js +2 -3
- package/es/networkTopo/services/topo/basic.js +3 -3
- package/es/networkTopo/store/topoCenter.js +260 -223
- package/es/style.js +1 -1
- package/es/utils/ResourceConfigUtil.js +3 -36
- package/es/utils/ciRefAttributeTranslateUtil.d.ts +9 -2
- package/es/utils/ciRefAttributeTranslateUtil.js +8 -9
- package/es/utils/topoData.js +1 -1
- package/lib/components/TemplateButton/index.module.scss +1 -1
- package/lib/core/components/AlarmListPanel/components/AlarmListItem.js +60 -3
- package/lib/core/components/TopoView/topoView.js +5 -1
- package/lib/core/editor/components/Toolbar/widgets/EdgeColorButton/EdgeColorButton.js +6 -12
- package/lib/core/editor/components/Toolbar/widgets/EdgeTypeButton/EdgeType.js +27 -9
- package/lib/core/editor/components/Toolbar/widgets/EdgeTypeButton/EdgeType.module.scss +21 -1
- package/lib/core/editor/components/Toolbar/widgets/EdgeTypeButton/LineType.js +8 -0
- package/lib/core/editor/components/Toolbar/widgets/EdgeTypeButton/index.js +1 -1
- package/lib/core/editor/components/Toolbar/widgets/Layout/index.js +16 -2
- package/lib/core/editor/hooks/useKeyboardShortcut.js +2 -0
- package/lib/core/editor/utils/copyElementUtil.js +15 -0
- package/lib/core/editor/utils/edgeTypeStyleUtil.js +8 -31
- package/lib/core/hooks/useAlarm.js +130 -79
- package/lib/core/hooks/useCmpLinkAlarm.js +166 -0
- package/lib/core/hooks/useEventData.js +1 -2
- package/lib/core/hooks/useGraphAlarmDisplay.js +91 -55
- package/lib/core/hooks/useResourceConfig.js +1 -3
- package/lib/core/hooks/useTopoEdit.js +30 -42
- package/lib/core/models/Alarm.js +69 -144
- package/lib/core/models/AttributeMetricDisplay.js +10 -2
- package/lib/core/models/TopoApp.js +1 -1
- package/lib/core/models/cache/CiCache.d.ts +1 -1
- package/lib/core/models/cache/CiCache.js +3 -3
- package/lib/core/models/topoData.js +0 -1
- package/lib/core/models/utils/linkUtils.js +21 -13
- package/lib/core/services/topo/basic.js +2 -2
- package/lib/core/store/models/topoConfig.js +7 -10
- package/lib/core/store/models/topoMod.js +81 -134
- package/lib/core/utils/edgeUtil.js +10 -0
- package/lib/core/utils/metricUtil.js +8 -4
- package/lib/core/utils/showGraphManageStatusUtil.js +3 -2
- package/lib/core/viewer/components/plugins/ResourceDetail/components/ResourceOverview/components/LinkTopo/LinkTopoCard.js +2 -2
- package/lib/core/viewer/components/plugins/ViewerPlugin.js +3 -1
- package/lib/core/viewer/components/titlebar/widgets/AlarmButton.js +1 -5
- package/lib/networkTopo/components/TopoView.js +5 -14
- package/lib/networkTopo/hooks/useEdgeExpand.js +2 -3
- package/lib/networkTopo/services/topo/basic.js +3 -3
- package/lib/networkTopo/store/topoCenter.js +262 -225
- package/lib/style.js +1 -1
- package/lib/utils/ResourceConfigUtil.js +3 -38
- package/lib/utils/ciRefAttributeTranslateUtil.d.ts +9 -2
- package/lib/utils/ciRefAttributeTranslateUtil.js +8 -9
- package/lib/utils/topoData.js +1 -1
- package/package.json +2 -2
@@ -15,129 +15,180 @@ var _useGraphAlarmDisplay = _interopRequireDefault(require("./useGraphAlarmDispl
|
|
15
15
|
|
16
16
|
var _useTopoEventListener = _interopRequireDefault(require("./useTopoEventListener"));
|
17
17
|
|
18
|
+
// 告警在活状态
|
19
|
+
var showAlarmStatus = ["toDeal", "dealing", "change", "woDealing"];
|
18
20
|
/**
|
19
|
-
*
|
20
|
-
*
|
21
|
-
* @
|
21
|
+
* 告警是否在活
|
22
|
+
* @param {*} alarm
|
23
|
+
* @returns
|
22
24
|
*/
|
23
|
-
function useAlarm(options) {
|
24
|
-
var topo = options.topo;
|
25
|
-
var store = topo.store;
|
26
25
|
|
27
|
-
|
28
|
-
|
29
|
-
|
26
|
+
var isAlarmAlive = function isAlarmAlive(alarm) {
|
27
|
+
return showAlarmStatus.indexOf(alarm.status) >= 0;
|
28
|
+
};
|
30
29
|
|
31
|
-
|
32
|
-
|
33
|
-
alarmSwitch: alarmSwitch
|
34
|
-
});
|
30
|
+
var handleRiskData = function handleRiskData(topo, receivedData) {
|
31
|
+
var _risks, _topo$viewProps, _topo$viewProps2;
|
35
32
|
|
36
|
-
|
37
|
-
|
33
|
+
// 非在活状态:
|
34
|
+
// 已修复 recovered
|
35
|
+
// 已关闭 closed
|
36
|
+
var prevRisks = topo.store.getModelState('topoAlarm').risks;
|
38
37
|
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
var prevRisks = topo.store.getModelState('topoAlarm').risks;
|
38
|
+
var isLiveRisk = function isLiveRisk(data) {
|
39
|
+
return ['recovered', 'closed'].indexOf(data.status) === -1;
|
40
|
+
};
|
43
41
|
|
44
|
-
|
45
|
-
|
46
|
-
};
|
42
|
+
var hasCiPermission = function hasCiPermission(data) {
|
43
|
+
var _data$resourceId;
|
47
44
|
|
48
|
-
var
|
49
|
-
|
45
|
+
var ciId = (_data$resourceId = data.resourceId) !== null && _data$resourceId !== void 0 ? _data$resourceId : data.ciId;
|
46
|
+
var ci = topo.dataModel.getDataById(ciId);
|
47
|
+
return !!(ci !== null && ci !== void 0 && ci.operation);
|
48
|
+
}; // 合并
|
50
49
|
|
51
|
-
var ciId = (_data$resourceId = data.resourceId) !== null && _data$resourceId !== void 0 ? _data$resourceId : data.ciId;
|
52
|
-
var ci = topo.dataModel.getDataById(ciId);
|
53
|
-
return ci && ci.operation;
|
54
|
-
}; // 合并
|
55
50
|
|
51
|
+
var risks = prevRisks.map(function (risk) {
|
52
|
+
var newRisk = receivedData.find(function (item) {
|
53
|
+
return item.id === risk.id;
|
54
|
+
});
|
55
|
+
return newRisk || risk;
|
56
|
+
}); // 新的
|
56
57
|
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
}); // 新的
|
58
|
+
var addRisks = receivedData.filter(function (risk) {
|
59
|
+
return !prevRisks.find(function (item) {
|
60
|
+
return item.id === risk.id;
|
61
|
+
});
|
62
|
+
}).filter(hasCiPermission);
|
63
63
|
|
64
|
-
|
65
|
-
return !prevRisks.find(function (item) {
|
66
|
-
return item.id === risk.id;
|
67
|
-
});
|
68
|
-
}).filter(hasCiPermission);
|
64
|
+
(_risks = risks).push.apply(_risks, addRisks); // 过滤掉无权限、非在活的
|
69
65
|
|
70
|
-
(_risks = risks).push.apply(_risks, addRisks); // 过滤掉无权限、非在活的
|
71
66
|
|
67
|
+
risks = risks.filter(isLiveRisk).filter(hasCiPermission).sort(function (a, b) {
|
68
|
+
return a.executeTime - b.executeTime;
|
69
|
+
});
|
72
70
|
|
73
|
-
|
74
|
-
|
75
|
-
|
71
|
+
_rlog["default"].debug('更新风险', {
|
72
|
+
prevRisks: prevRisks,
|
73
|
+
receivedData: receivedData,
|
74
|
+
risks: risks
|
75
|
+
});
|
76
|
+
|
77
|
+
topo.store.getModelDispatchers('topoAlarm').update({
|
78
|
+
risks: risks
|
79
|
+
}); // 获取配置
|
80
|
+
|
81
|
+
var _topo$store$getModelS = topo.store.getModelState('displayConfig'),
|
82
|
+
alarmSwitch = _topo$store$getModelS.alarmSwitch,
|
83
|
+
alarmListDefaultOpen = _topo$store$getModelS.alarmListDefaultOpen; // 告警静默
|
84
|
+
|
85
|
+
|
86
|
+
if (alarmSwitch === false) {
|
87
|
+
return;
|
88
|
+
} // 告警列表
|
76
89
|
|
77
|
-
_rlog["default"].debug('更新风险', {
|
78
|
-
prevRisks: prevRisks,
|
79
|
-
receivedData: receivedData,
|
80
|
-
risks: risks
|
81
|
-
});
|
82
90
|
|
83
|
-
|
84
|
-
|
91
|
+
if (addRisks.length && alarmListDefaultOpen) {
|
92
|
+
topo.alarm.updateState({
|
93
|
+
alarmPanelIsOpen: true
|
85
94
|
});
|
95
|
+
}
|
86
96
|
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
}
|
97
|
+
if ((_topo$viewProps = topo.viewProps) !== null && _topo$viewProps !== void 0 && _topo$viewProps.onRisk) {
|
98
|
+
topo.viewProps.onRisk(risks);
|
99
|
+
}
|
91
100
|
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
101
|
+
if ((_topo$viewProps2 = topo.viewProps) !== null && _topo$viewProps2 !== void 0 && _topo$viewProps2.onResourceEvent) {
|
102
|
+
topo.viewProps.onResourceEvent(topo.alarm.getEvents());
|
103
|
+
}
|
104
|
+
};
|
105
|
+
/**
|
106
|
+
* 关联拓扑告警级别消息处理
|
107
|
+
* @param {*} topo
|
108
|
+
* @param {*} data
|
109
|
+
*/
|
110
|
+
|
111
|
+
|
112
|
+
var handleRelateTopoAlarm = function handleRelateTopoAlarm(topo, data) {
|
113
|
+
var relateTopoAlarm = (0, _extends2["default"])({}, topo.store.getModelState('topoAlarm').relateTopoAlarm);
|
114
|
+
data.forEach(function (item) {
|
115
|
+
var alertLevel = item.alertLevel;
|
97
116
|
|
98
|
-
if (
|
99
|
-
|
117
|
+
if (alertLevel === -1) {
|
118
|
+
// -1表示删除
|
119
|
+
delete relateTopoAlarm[item.topoId];
|
120
|
+
} else {
|
121
|
+
relateTopoAlarm[item.topoId] = item.alertLevel;
|
100
122
|
}
|
123
|
+
});
|
124
|
+
topo.store.getModelDispatchers('topoAlarm').update({
|
125
|
+
relateTopoAlarm: relateTopoAlarm
|
126
|
+
});
|
127
|
+
|
128
|
+
_rlog["default"].debug("\u5173\u8054\u62D3\u6251\u544A\u8B66\uFF1A\u6536\u5230 " + data.length, {
|
129
|
+
received: data,
|
130
|
+
all: relateTopoAlarm
|
131
|
+
});
|
132
|
+
};
|
133
|
+
/**
|
134
|
+
* 处理分级告警
|
135
|
+
* @param {*} alarms
|
136
|
+
* @returns
|
137
|
+
*/
|
101
138
|
|
102
|
-
|
103
|
-
|
139
|
+
|
140
|
+
function convertAlarmData(alarms) {
|
141
|
+
return alarms.map(function (alarm) {
|
142
|
+
var resourceId = alarm.resourceId; // 分级资源id转换
|
143
|
+
|
144
|
+
if (alarm.cmpAlertId) {
|
145
|
+
resourceId = "sub:" + alarm.mainCiId;
|
104
146
|
}
|
105
|
-
};
|
106
147
|
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
topo.store.getModelDispatchers('topoAlarm').update({
|
113
|
-
relateTopoAlarm: relateTopoAlarm
|
148
|
+
return (0, _extends2["default"])({}, alarm, {
|
149
|
+
// 数据id
|
150
|
+
resourceId: resourceId,
|
151
|
+
// 是否在活
|
152
|
+
alive: isAlarmAlive(alarm)
|
114
153
|
});
|
154
|
+
});
|
155
|
+
}
|
156
|
+
/**
|
157
|
+
*
|
158
|
+
*
|
159
|
+
* @param {*} options
|
160
|
+
*/
|
115
161
|
|
116
|
-
_rlog["default"].debug("\u5173\u8054\u62D3\u6251\u544A\u8B66\uFF1A\u6536\u5230 " + data.length, {
|
117
|
-
received: data,
|
118
|
-
all: relateTopoAlarm
|
119
|
-
});
|
120
|
-
}; // 订阅消息
|
121
162
|
|
163
|
+
function useAlarm(options) {
|
164
|
+
var topo = options.topo;
|
165
|
+
|
166
|
+
var _topo$store$useModelS = topo.store.useModelState('displayConfig'),
|
167
|
+
alarmSwitch = _topo$store$useModelS.alarmSwitch;
|
168
|
+
|
169
|
+
(0, _useGraphAlarmDisplay["default"])({
|
170
|
+
topo: topo,
|
171
|
+
alarmSwitch: alarmSwitch
|
172
|
+
}); // 订阅消息
|
122
173
|
|
123
174
|
(0, _useTopoEventListener["default"])({
|
124
175
|
type: 'alarm',
|
125
176
|
onMessage: function onMessage(data) {
|
126
177
|
_rlog["default"].debug("Topoget--AlertMesage------------", topo, data);
|
127
178
|
|
128
|
-
topo.alarm.handleAlarmEvent(data);
|
179
|
+
topo.alarm.handleAlarmEvent(convertAlarmData(data));
|
129
180
|
}
|
130
181
|
});
|
131
182
|
(0, _useTopoEventListener["default"])({
|
132
183
|
type: 'risk',
|
133
184
|
onMessage: function onMessage(data) {
|
134
|
-
handleRiskData(data);
|
185
|
+
handleRiskData(topo, data);
|
135
186
|
}
|
136
187
|
});
|
137
188
|
(0, _useTopoEventListener["default"])({
|
138
189
|
type: 'relateTopoAlarm',
|
139
190
|
onMessage: function onMessage(data) {
|
140
|
-
handleRelateTopoAlarm(data);
|
191
|
+
handleRelateTopoAlarm(topo, data);
|
141
192
|
}
|
142
193
|
});
|
143
194
|
}
|
@@ -0,0 +1,166 @@
|
|
1
|
+
"use strict";
|
2
|
+
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
4
|
+
|
5
|
+
exports.__esModule = true;
|
6
|
+
exports["default"] = useCmpLinkAlarm;
|
7
|
+
|
8
|
+
var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
|
9
|
+
|
10
|
+
var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
|
11
|
+
|
12
|
+
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
|
13
|
+
|
14
|
+
var _react = require("react");
|
15
|
+
|
16
|
+
var _ahooks = require("ahooks");
|
17
|
+
|
18
|
+
var _DictCache = _interopRequireDefault(require("../models/cache/DictCache"));
|
19
|
+
|
20
|
+
function addCmpLinkOfflineStatusForDisplayLineColor(cis, cmpLinkRunStatusList) {
|
21
|
+
return cis.map(function (ci) {
|
22
|
+
var cmpLinkRunStatusData = cmpLinkRunStatusList.find(function (item) {
|
23
|
+
return item.id === ci.id;
|
24
|
+
});
|
25
|
+
|
26
|
+
if (cmpLinkRunStatusData) {
|
27
|
+
return (0, _extends2["default"])({}, ci, {
|
28
|
+
manageStatus: cmpLinkRunStatusData.runStatus === '2' ? 0 : 3
|
29
|
+
});
|
30
|
+
}
|
31
|
+
|
32
|
+
return ci;
|
33
|
+
});
|
34
|
+
}
|
35
|
+
|
36
|
+
function getCmpLinIds(datas) {
|
37
|
+
var linkIds = datas.filter(function (item) {
|
38
|
+
return item.isSubResource && item.typeCode === 'network_link';
|
39
|
+
}).map(function (item) {
|
40
|
+
return item.ciId;
|
41
|
+
});
|
42
|
+
return linkIds;
|
43
|
+
}
|
44
|
+
/**
|
45
|
+
* 分级链路下級鏈路
|
46
|
+
* @param {*} props
|
47
|
+
* @returns
|
48
|
+
*/
|
49
|
+
|
50
|
+
|
51
|
+
function useCmpLinkAlarm(props) {
|
52
|
+
var topo = props.topo,
|
53
|
+
resources = props.resources,
|
54
|
+
graphLoaded = props.graphLoaded;
|
55
|
+
|
56
|
+
var _useState = (0, _react.useState)(getCmpLinIds(resources)),
|
57
|
+
cmpLinkIds = _useState[0],
|
58
|
+
setCmpLinkIds = _useState[1];
|
59
|
+
|
60
|
+
var _useState2 = (0, _react.useState)([]),
|
61
|
+
cmpLinkRunStatus = _useState2[0],
|
62
|
+
setCmpLinkRunStatus = _useState2[1];
|
63
|
+
|
64
|
+
var cmpLinkAlarmLevels = (0, _react.useMemo)(function () {
|
65
|
+
return cmpLinkRunStatus // 3:fault:重要故障; 4:urgently:紧急故障 』为红色
|
66
|
+
.filter(function (item) {
|
67
|
+
return ['3', '4'].includes(item.runStatus);
|
68
|
+
}).map(function (item) {
|
69
|
+
return {
|
70
|
+
id: item.id,
|
71
|
+
level: 1
|
72
|
+
};
|
73
|
+
});
|
74
|
+
}, [cmpLinkRunStatus]);
|
75
|
+
(0, _react.useEffect)(function () {
|
76
|
+
var ids = getCmpLinIds(resources);
|
77
|
+
|
78
|
+
if (cmpLinkIds.join(',') !== ids.join(',')) {
|
79
|
+
setCmpLinkIds(ids);
|
80
|
+
}
|
81
|
+
}, [resources]);
|
82
|
+
|
83
|
+
function getCmpLinkRunStatus(_x) {
|
84
|
+
return _getCmpLinkRunStatus.apply(this, arguments);
|
85
|
+
} // 轮询hooks
|
86
|
+
|
87
|
+
|
88
|
+
function _getCmpLinkRunStatus() {
|
89
|
+
_getCmpLinkRunStatus = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee(ids) {
|
90
|
+
var _yield$Promise$all, ciMetricsResult;
|
91
|
+
|
92
|
+
return _regenerator["default"].wrap(function _callee$(_context) {
|
93
|
+
while (1) switch (_context.prev = _context.next) {
|
94
|
+
case 0:
|
95
|
+
if (ids.length) {
|
96
|
+
_context.next = 2;
|
97
|
+
break;
|
98
|
+
}
|
99
|
+
|
100
|
+
return _context.abrupt("return", []);
|
101
|
+
|
102
|
+
case 2:
|
103
|
+
_context.t0 = Promise;
|
104
|
+
_context.t1 = // 查询指标值
|
105
|
+
topo.serverApi.ciInfo.batchQueryCiInfo({
|
106
|
+
ciId: [],
|
107
|
+
codes: ['run_status'],
|
108
|
+
relationId: ids.map(function (id) {
|
109
|
+
return {
|
110
|
+
ciId: id,
|
111
|
+
operation: "delete"
|
112
|
+
};
|
113
|
+
})
|
114
|
+
});
|
115
|
+
_context.next = 6;
|
116
|
+
return _DictCache["default"].init();
|
117
|
+
|
118
|
+
case 6:
|
119
|
+
_context.t2 = _context.sent;
|
120
|
+
_context.t3 = [_context.t1, _context.t2];
|
121
|
+
_context.next = 10;
|
122
|
+
return _context.t0.all.call(_context.t0, _context.t3);
|
123
|
+
|
124
|
+
case 10:
|
125
|
+
_yield$Promise$all = _context.sent;
|
126
|
+
ciMetricsResult = _yield$Promise$all[0];
|
127
|
+
return _context.abrupt("return", ciMetricsResult);
|
128
|
+
|
129
|
+
case 13:
|
130
|
+
case "end":
|
131
|
+
return _context.stop();
|
132
|
+
}
|
133
|
+
}, _callee);
|
134
|
+
}));
|
135
|
+
return _getCmpLinkRunStatus.apply(this, arguments);
|
136
|
+
}
|
137
|
+
|
138
|
+
var _useRequest = (0, _ahooks.useRequest)(getCmpLinkRunStatus, {
|
139
|
+
pollingInterval: 60 * 1000,
|
140
|
+
pollingWhenHidden: false,
|
141
|
+
// debounceInterval: 200,
|
142
|
+
manual: true,
|
143
|
+
onSuccess: function onSuccess(result) {
|
144
|
+
setCmpLinkRunStatus(result.map(function (item) {
|
145
|
+
return {
|
146
|
+
id: "sub:" + item.id,
|
147
|
+
runStatus: item.metrics.run_status
|
148
|
+
};
|
149
|
+
}));
|
150
|
+
}
|
151
|
+
}),
|
152
|
+
run = _useRequest.run;
|
153
|
+
|
154
|
+
(0, _react.useEffect)(function () {
|
155
|
+
if (graphLoaded) {
|
156
|
+
run(cmpLinkIds);
|
157
|
+
}
|
158
|
+
}, [graphLoaded, cmpLinkIds]);
|
159
|
+
return {
|
160
|
+
cmpLinkRunStatus: cmpLinkRunStatus,
|
161
|
+
cmpLinkAlarmLevels: cmpLinkAlarmLevels,
|
162
|
+
addCmpLinkOfflineStatusForDisplayLineColor: addCmpLinkOfflineStatusForDisplayLineColor
|
163
|
+
};
|
164
|
+
}
|
165
|
+
|
166
|
+
;
|
@@ -8,8 +8,7 @@ exports["default"] = useEventData;
|
|
8
8
|
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
|
9
9
|
|
10
10
|
function useEventData(props) {
|
11
|
-
var topo = props.topo;
|
12
|
-
var topoDatas = topo.dataModel.useDatas();
|
11
|
+
var topo = props.topo; // const topoDatas = topo.dataModel.useDatas()
|
13
12
|
|
14
13
|
var _topo$store$useModelS = topo.store.useModelState('topoAlarm'),
|
15
14
|
risks = _topo$store$useModelS.risks,
|
@@ -13,16 +13,17 @@ var _htElementUtils = require("../../utils/htElementUtils");
|
|
13
13
|
|
14
14
|
var _showGraphManageStatusUtil = require("../utils/showGraphManageStatusUtil");
|
15
15
|
|
16
|
-
|
17
|
-
var ciIdLevelMap = {};
|
18
|
-
[].concat(alarmList, risks.map(function (item) {
|
19
|
-
var _item$resourceId;
|
16
|
+
var _useCmpLinkAlarm2 = _interopRequireDefault(require("./useCmpLinkAlarm"));
|
20
17
|
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
18
|
+
/**
|
19
|
+
* 获取ci的最高告警级别
|
20
|
+
* @param {Array} alarmList
|
21
|
+
* @param {*} risks
|
22
|
+
* @returns
|
23
|
+
*/
|
24
|
+
function getCiAlarmLevelMap(alarmList) {
|
25
|
+
var ciIdLevelMap = {};
|
26
|
+
alarmList.forEach(function (item) {
|
26
27
|
var level = ciIdLevelMap[item.id]; // 优先显示高等级告警。值小的等级高
|
27
28
|
|
28
29
|
if (!level || item.level < level) {
|
@@ -31,13 +32,53 @@ function getCiAlarmLevels(alarmList, risks) {
|
|
31
32
|
|
32
33
|
ciIdLevelMap[item.id] = level;
|
33
34
|
});
|
35
|
+
return ciIdLevelMap;
|
36
|
+
}
|
37
|
+
|
38
|
+
function getGraphCiElementAlarmLevels(resources, alarmList) {
|
39
|
+
var ciIdLevelMap = getCiAlarmLevelMap(alarmList);
|
34
40
|
return Object.keys(ciIdLevelMap).map(function (id) {
|
35
41
|
return {
|
36
42
|
id: id,
|
37
43
|
level: ciIdLevelMap[id]
|
38
44
|
};
|
45
|
+
}).filter(function (alarm) {
|
46
|
+
var resource = resources.find(function (item) {
|
47
|
+
return item.id === alarm.id;
|
48
|
+
});
|
49
|
+
return !!resource;
|
39
50
|
});
|
40
51
|
}
|
52
|
+
/**
|
53
|
+
* 获得关联拓扑节点告警级别
|
54
|
+
* @param {*} topo
|
55
|
+
* @param {*} relateTopoAlarm
|
56
|
+
* @returns
|
57
|
+
*/
|
58
|
+
|
59
|
+
|
60
|
+
function getRelateTopoNodeAlarmLevels(topo, relateTopoAlarm) {
|
61
|
+
return Object.keys(relateTopoAlarm).map(function (topoId) {
|
62
|
+
var level = relateTopoAlarm[topoId];
|
63
|
+
var relateTopoNode = topo.getDataModel().getDatas().toArray().find(function (node) {
|
64
|
+
return "" + node.a('bindTopo') === "" + topoId;
|
65
|
+
});
|
66
|
+
|
67
|
+
if (!level || !relateTopoNode) {
|
68
|
+
return null;
|
69
|
+
}
|
70
|
+
|
71
|
+
return {
|
72
|
+
elementId: relateTopoNode.getId(),
|
73
|
+
level: level
|
74
|
+
};
|
75
|
+
}).filter(function (item) {
|
76
|
+
return !!item;
|
77
|
+
});
|
78
|
+
} // 获取拓扑图元素最高告警级别。包含资源、链路、关联拓扑节点
|
79
|
+
|
80
|
+
|
81
|
+
function getGraphElementAlarmLevels(resources) {}
|
41
82
|
/**
|
42
83
|
* 告警显示到ht拓扑
|
43
84
|
*
|
@@ -48,7 +89,6 @@ function getCiAlarmLevels(alarmList, risks) {
|
|
48
89
|
function useGraphAlarmDisplay(options) {
|
49
90
|
var topo = options.topo,
|
50
91
|
alarmSwitch = options.alarmSwitch;
|
51
|
-
var store = topo.store;
|
52
92
|
var topoState = topo.store.useModelState('topoMod');
|
53
93
|
var graphLoaded = topoState.graphLoaded,
|
54
94
|
viewState = topoState.viewState;
|
@@ -59,22 +99,32 @@ function useGraphAlarmDisplay(options) {
|
|
59
99
|
risks = _topo$alarm$useState.risks,
|
60
100
|
relateTopoAlarm = _topo$alarm$useState.relateTopoAlarm;
|
61
101
|
|
62
|
-
var
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
102
|
+
var oldResources = topo.dataModel.useCis(); // 分级拓扑下级链路特殊处理
|
103
|
+
|
104
|
+
var _useCmpLinkAlarm = (0, _useCmpLinkAlarm2["default"])({
|
105
|
+
topo: topo,
|
106
|
+
resources: oldResources,
|
107
|
+
graphLoaded: graphLoaded
|
108
|
+
}),
|
109
|
+
cmpLinkAlarmLevels = _useCmpLinkAlarm.cmpLinkAlarmLevels,
|
110
|
+
cmpLinkRunStatus = _useCmpLinkAlarm.cmpLinkRunStatus,
|
111
|
+
addCmpLinkOfflineStatusForDisplayLineColor = _useCmpLinkAlarm.addCmpLinkOfflineStatusForDisplayLineColor;
|
112
|
+
|
113
|
+
var resources = (0, _react.useMemo)(function () {
|
114
|
+
return addCmpLinkOfflineStatusForDisplayLineColor(oldResources, cmpLinkRunStatus);
|
115
|
+
}, [oldResources, cmpLinkRunStatus]); // ci告警级别
|
116
|
+
|
117
|
+
var cisEventLevel = (0, _react.useMemo)(function () {
|
118
|
+
var levels = [].concat(alarmList || [], cmpLinkAlarmLevels, risks.map(function (item) {
|
119
|
+
var _item$resourceId;
|
120
|
+
|
121
|
+
return {
|
122
|
+
id: (_item$resourceId = item.resourceId) !== null && _item$resourceId !== void 0 ? _item$resourceId : item.ciId,
|
123
|
+
level: 5
|
124
|
+
};
|
125
|
+
}));
|
126
|
+
return getGraphCiElementAlarmLevels(resources, levels);
|
127
|
+
}, [resources, alarmList, cmpLinkAlarmLevels, risks]);
|
78
128
|
(0, _react.useEffect)(function () {
|
79
129
|
showAlarm();
|
80
130
|
(0, _showGraphManageStatusUtil.showManageStatus)({
|
@@ -82,8 +132,8 @@ function useGraphAlarmDisplay(options) {
|
|
82
132
|
resources: resources,
|
83
133
|
isEditMode: isEditMode,
|
84
134
|
graphLoaded: graphLoaded,
|
85
|
-
|
86
|
-
cisEventLevel:
|
135
|
+
alarmSwitch: alarmSwitch,
|
136
|
+
cisEventLevel: cisEventLevel
|
87
137
|
});
|
88
138
|
|
89
139
|
function showAlarm() {
|
@@ -95,45 +145,31 @@ function useGraphAlarmDisplay(options) {
|
|
95
145
|
// 告警静默
|
96
146
|
topo.view.loadAlarm([]);
|
97
147
|
return;
|
98
|
-
}
|
148
|
+
} // 关联拓扑告警
|
99
149
|
|
100
|
-
|
150
|
+
|
151
|
+
var relateTopoAlarms = getRelateTopoNodeAlarmLevels(topo, relateTopoAlarm);
|
152
|
+
var elementsAlarmLevels = [].concat(cisEventLevel, relateTopoAlarms); // 将告警级别放入ht元素,便于测试
|
101
153
|
|
102
154
|
(0, _htElementUtils.getElements)(topo.getDataModel()).filter(function (item) {
|
103
155
|
return !!item.getTag();
|
104
156
|
}).forEach(function (element) {
|
105
|
-
var
|
157
|
+
var _elementsAlarmLevels$;
|
106
158
|
|
107
|
-
var alarmLevel = (
|
108
|
-
return item.id === element.getTag();
|
109
|
-
})) === null ||
|
159
|
+
var alarmLevel = (_elementsAlarmLevels$ = elementsAlarmLevels.find(function (item) {
|
160
|
+
return item.id === element.getTag() || item.elementId === element.getId();
|
161
|
+
})) === null || _elementsAlarmLevels$ === void 0 ? void 0 : _elementsAlarmLevels$.level;
|
110
162
|
element.a('alarmLevel', alarmLevel);
|
111
163
|
});
|
112
|
-
var relateTopoAlarms = Object.keys(relateTopoAlarm).map(function (topoId) {
|
113
|
-
var level = relateTopoAlarm[topoId];
|
114
|
-
var relateTopoNode = topo.getDataModel().getDatas().toArray().find(function (node) {
|
115
|
-
return "" + node.a('bindTopo') === "" + topoId;
|
116
|
-
});
|
117
|
-
|
118
|
-
if (!level || !relateTopoNode) {
|
119
|
-
return null;
|
120
|
-
}
|
121
|
-
|
122
|
-
return {
|
123
|
-
elementId: relateTopoNode.getId(),
|
124
|
-
level: level
|
125
|
-
};
|
126
|
-
}).filter(function (item) {
|
127
|
-
return !!item;
|
128
|
-
});
|
129
164
|
|
130
|
-
_rlog["default"].debug('
|
131
|
-
|
165
|
+
_rlog["default"].debug('推送告警 => ht', {
|
166
|
+
alarms: elementsAlarmLevels,
|
167
|
+
relateTopoAlarmMap: relateTopoAlarm,
|
132
168
|
relateTopoAlarms: relateTopoAlarms
|
133
169
|
}); // 更新到ht拓扑
|
134
170
|
|
135
171
|
|
136
|
-
topo.view.loadAlarm(
|
172
|
+
topo.view.loadAlarm(elementsAlarmLevels);
|
137
173
|
}
|
138
174
|
|
139
175
|
return function () {
|
@@ -142,5 +178,5 @@ function useGraphAlarmDisplay(options) {
|
|
142
178
|
resources: resources
|
143
179
|
});
|
144
180
|
};
|
145
|
-
}, [graphLoaded, resources, alarmSwitch,
|
181
|
+
}, [graphLoaded, resources, alarmSwitch, cisEventLevel, relateTopoAlarm]);
|
146
182
|
}
|
@@ -56,9 +56,7 @@ function _default(props) {
|
|
56
56
|
return {
|
57
57
|
resources: config.resources,
|
58
58
|
groups: config.groups,
|
59
|
-
|
60
|
-
relateTopoIdList: config.relateTopoIdList //linkIps: config.linkIps,
|
61
|
-
|
59
|
+
relateTopoIdList: config.relateTopoIdList
|
62
60
|
};
|
63
61
|
};
|
64
62
|
|