@riil-frontend/component-topology 12.0.0-dev.4 → 12.0.0-dev.41
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 +13 -13
- package/es/components/BatchAttrMetric/setting.js +1 -1
- package/es/components/ModelAttrSelectDrawer/components/MultipleTypeAttributeSelectDrawer.js +1 -1
- package/es/components/ResourceSelectDrawer/ResourceSelectDrawer.js +1 -1
- package/es/components/TemplateButton/index.module.scss +1 -1
- package/es/core/components/AlarmListPanel/components/AlarmListItem.js +59 -4
- package/es/core/components/AlarmListPanel/index.js +1 -1
- package/es/core/components/DisplaySettingDrawer/DisplaySetting.js +1 -1
- package/es/core/components/DisplaySettingDrawer/DisplaySettingDrawer.js +2 -2
- package/es/core/components/DisplaySettingDrawer/ResourceDisplay/BasicConfig.js +1 -1
- package/es/core/components/DisplaySettingDrawer/components/NodeAttrSettingDrawer.js +1 -1
- package/es/core/components/ResourceViewAttributeSetting/Setting.js +1 -1
- package/es/core/components/TopoView/topoView.js +6 -2
- package/es/core/editor/components/BackgroundView/index.js +1 -1
- package/es/core/editor/components/CustomIconPlugin/UploadIconDialog.js +1 -1
- package/es/core/editor/components/EditorPlugin.js +1 -1
- package/es/core/editor/components/Sidebar/views/ComponentPanel.js +1 -1
- package/es/core/editor/components/Sidebar/views/ImagePanel/CiTypeImagePanel.js +1 -1
- package/es/core/editor/components/Sidebar/views/ImagePanel/CustomImagePanel.js +1 -1
- package/es/core/editor/components/Sidebar/views/ImagePanel/HtCustomImagePanel.js +1 -1
- package/es/core/editor/components/Sidebar/views/ImagePanel/HtImagePalette.js +1 -1
- package/es/core/editor/components/Sidebar/views/ImagePanel/ImagePalette.js +1 -1
- package/es/core/editor/components/Sidebar/views/LinkPanel.js +1 -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 +17 -3
- package/es/core/editor/components/settings/common/NodeSizeInput/NodeSizeInput.js +1 -1
- package/es/core/editor/components/settings/common/SizeInput/NodeSizeInput.js +1 -1
- package/es/core/editor/components/settings/propertyViews/layer/BasicSetting.js +1 -1
- package/es/core/editor/components/settings/propertyViews/layer/SettingTab/Setting.js +1 -1
- package/es/core/editor/components/settings/propertyViews/view/hooks/useBackgroundSizeConfig.js +1 -1
- package/es/core/editor/hooks/useKeyboardShortcut.js +3 -1
- package/es/core/editor/store/background.js +1 -1
- package/es/core/editor/store/historyManager.js +1 -1
- package/es/core/editor/store/topoEdit.js +1 -1
- package/es/core/editor/utils/copyElementUtil.js +12 -0
- package/es/core/editor/utils/edgeTypeStyleUtil.js +8 -7
- package/es/core/hooks/ht/useHtDataPropertyChangeListener.js +1 -1
- package/es/core/hooks/useAlarm.js +131 -81
- package/es/core/hooks/useCiAttributeChange.js +1 -1
- 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/useManageStatus.js +1 -1
- package/es/core/hooks/usePolling.js +1 -1
- package/es/core/hooks/useResourceConfig.js +1 -3
- package/es/core/hooks/useTopoEdit.js +51 -54
- package/es/core/models/Alarm.js +69 -143
- package/es/core/models/AttributeMetricDisplay.js +15 -6
- package/es/core/models/HistoryManager.js +1 -1
- package/es/core/models/SelectionModel.js +1 -1
- package/es/core/models/TopoApp.js +2 -2
- package/es/core/models/attributeFormatter/formatter/graphTransform.js +1 -1
- package/es/core/models/attributeFormatter/index.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/cache/CiTypeCache.js +5 -1
- package/es/core/models/cache/DictCache.js +1 -1
- package/es/core/models/plugins/resourceWebControllUrl.js +1 -1
- package/es/core/models/tagstips/ElementTagTipConfig.js +1 -1
- package/es/core/models/topoData.js +0 -1
- package/es/core/services/alarm.js +1 -1
- package/es/core/services/index.js +1 -1
- package/es/core/services/topo/basic.js +2 -2
- package/es/core/store/models/customIcon.js +1 -1
- package/es/core/store/models/displayConfig.js +1 -1
- package/es/core/store/models/selection.js +1 -1
- package/es/core/store/models/topoBaseInfoOverview.js +1 -1
- package/es/core/store/models/topoBizMod.js +1 -1
- package/es/core/store/models/topoConfig.js +7 -10
- package/es/core/store/models/topoGraphView.js +1 -1
- package/es/core/store/models/topoMod.js +82 -135
- package/es/core/store/models/viewer/lock.js +1 -1
- package/es/core/store/models/viewer/resourceDetail.js +1 -1
- package/es/core/store/models/viewer/resourceWebControllUrlSetting.js +1 -1
- package/es/core/utils/edgeUtil.js +10 -1
- package/es/core/utils/metricUtil.js +8 -4
- package/es/core/utils/showGraphManageStatusUtil.js +3 -2
- package/es/core/utils/showMessage.js +1 -1
- package/es/core/viewer/components/plugins/ResourceDetail/ResourceDetail.js +1 -0
- package/es/core/viewer/components/plugins/ResourceDetail/components/ResourceOverview/EventsCard.js +46 -21
- package/es/core/viewer/components/plugins/ResourceDetail/components/ResourceOverview/ResourceOverview.js +3 -1
- package/es/core/viewer/components/plugins/ResourceDetail/components/ResourceOverview/components/LinkTopo/LinkTopoCard.js +4 -2
- package/es/core/viewer/components/plugins/ResourceDetail/components/ResourceOverview/components/LinkTopo/hooks/useMetricPolling.js +1 -1
- package/es/core/viewer/components/plugins/ResourceDetail/components/ResourceOverview/components/LinkTopo/services/index.js +1 -1
- package/es/core/viewer/components/plugins/ResourceDetail/components/ResourceOverview/hooks/useAlarmAndRiskData.js +20 -18
- package/es/core/viewer/components/plugins/ResourceDetail/components/ResourceOverview/index.module.scss +8 -0
- package/es/core/viewer/components/plugins/ResourceDetail/components/WebConsole/WebConsoleForm/hooks/useWebConsole.js +1 -1
- 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/Link/index.js +1 -1
- package/es/networkTopo/components/TopoView.js +6 -11
- package/es/networkTopo/hooks/useEdgeExpand.js +2 -3
- package/es/networkTopo/hooks/viewer/useRelateTopo.js +1 -1
- package/es/networkTopo/models/LinkDynamicStyleExecutor.js +1 -1
- package/es/networkTopo/models/LinkTagsTipsBuilder.js +1 -1
- package/es/networkTopo/models/TopoCenter.js +1 -1
- package/es/networkTopo/services/model.js +1 -1
- package/es/networkTopo/services/topo/basic.js +4 -4
- package/es/networkTopo/services/topo/ciInfo.js +1 -1
- package/es/networkTopo/store/functionAuth.js +1 -1
- package/es/networkTopo/store/topoCenter.js +261 -224
- package/es/networkTopo/store/topoTreeMod.js +1 -1
- package/es/networkTopo/utils/exportData.js +1 -1
- package/es/style.js +2 -2
- package/es/utils/ResourceConfigUtil.js +4 -37
- package/es/utils/ciRefAttributeTranslateUtil.d.ts +19 -0
- package/es/utils/ciRefAttributeTranslateUtil.js +155 -0
- package/es/utils/format.js +1 -1
- package/es/utils/topoData.js +4 -2
- package/lib/components/BatchAttrMetric/setting.js +2 -2
- package/lib/components/ModelAttrSelectDrawer/components/MultipleTypeAttributeSelectDrawer.js +2 -2
- package/lib/components/ResourceSelectDrawer/ResourceSelectDrawer.js +2 -2
- package/lib/components/TemplateButton/index.module.scss +1 -1
- package/lib/core/components/AlarmListPanel/components/AlarmListItem.js +61 -4
- package/lib/core/components/AlarmListPanel/index.js +1 -1
- package/lib/core/components/DisplaySettingDrawer/DisplaySetting.js +2 -2
- package/lib/core/components/DisplaySettingDrawer/DisplaySettingDrawer.js +2 -2
- package/lib/core/components/DisplaySettingDrawer/ResourceDisplay/BasicConfig.js +3 -3
- package/lib/core/components/DisplaySettingDrawer/components/NodeAttrSettingDrawer.js +2 -2
- package/lib/core/components/ResourceViewAttributeSetting/Setting.js +2 -2
- package/lib/core/components/TopoView/topoView.js +14 -10
- package/lib/core/editor/components/BackgroundView/index.js +3 -3
- package/lib/core/editor/components/CustomIconPlugin/UploadIconDialog.js +2 -2
- package/lib/core/editor/components/EditorPlugin.js +3 -3
- package/lib/core/editor/components/Sidebar/views/ComponentPanel.js +2 -4
- package/lib/core/editor/components/Sidebar/views/ImagePanel/CiTypeImagePanel.js +1 -1
- package/lib/core/editor/components/Sidebar/views/ImagePanel/CustomImagePanel.js +1 -1
- package/lib/core/editor/components/Sidebar/views/ImagePanel/HtCustomImagePanel.js +2 -2
- package/lib/core/editor/components/Sidebar/views/ImagePanel/HtImagePalette.js +2 -2
- package/lib/core/editor/components/Sidebar/views/ImagePanel/ImagePalette.js +2 -4
- package/lib/core/editor/components/Sidebar/views/LinkPanel.js +2 -4
- 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/components/settings/common/NodeSizeInput/NodeSizeInput.js +5 -5
- package/lib/core/editor/components/settings/common/SizeInput/NodeSizeInput.js +1 -1
- package/lib/core/editor/components/settings/propertyViews/layer/BasicSetting.js +1 -1
- package/lib/core/editor/components/settings/propertyViews/layer/SettingTab/Setting.js +3 -3
- package/lib/core/editor/components/settings/propertyViews/view/hooks/useBackgroundSizeConfig.js +2 -2
- package/lib/core/editor/hooks/useKeyboardShortcut.js +2 -0
- package/lib/core/editor/store/background.js +1 -1
- package/lib/core/editor/store/historyManager.js +1 -1
- package/lib/core/editor/store/topoEdit.js +1 -1
- package/lib/core/editor/utils/copyElementUtil.js +15 -0
- package/lib/core/editor/utils/edgeTypeStyleUtil.js +8 -6
- package/lib/core/hooks/ht/useHtDataPropertyChangeListener.js +1 -3
- package/lib/core/hooks/useAlarm.js +130 -79
- package/lib/core/hooks/useCiAttributeChange.js +1 -1
- 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/useManageStatus.js +1 -1
- package/lib/core/hooks/usePolling.js +3 -3
- package/lib/core/hooks/useResourceConfig.js +1 -3
- package/lib/core/hooks/useTopoEdit.js +50 -53
- package/lib/core/models/Alarm.js +76 -152
- package/lib/core/models/AttributeMetricDisplay.js +18 -6
- package/lib/core/models/HistoryManager.js +8 -8
- package/lib/core/models/SelectionModel.js +5 -5
- package/lib/core/models/TopoApp.js +4 -6
- package/lib/core/models/attributeFormatter/formatter/graphTransform.js +2 -4
- package/lib/core/models/attributeFormatter/index.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/cache/CiTypeCache.js +6 -2
- package/lib/core/models/cache/DictCache.js +2 -2
- package/lib/core/models/plugins/resourceWebControllUrl.js +2 -2
- package/lib/core/models/tagstips/ElementTagTipConfig.js +2 -2
- package/lib/core/models/topoData.js +0 -1
- package/lib/core/services/alarm.js +2 -2
- package/lib/core/services/index.js +1 -1
- package/lib/core/services/topo/basic.js +2 -2
- package/lib/core/store/models/customIcon.js +3 -3
- package/lib/core/store/models/displayConfig.js +1 -1
- package/lib/core/store/models/selection.js +1 -1
- package/lib/core/store/models/topoBaseInfoOverview.js +1 -1
- package/lib/core/store/models/topoBizMod.js +1 -1
- package/lib/core/store/models/topoConfig.js +7 -10
- package/lib/core/store/models/topoGraphView.js +1 -1
- package/lib/core/store/models/topoMod.js +89 -142
- package/lib/core/store/models/viewer/lock.js +1 -1
- package/lib/core/store/models/viewer/resourceDetail.js +1 -1
- package/lib/core/store/models/viewer/resourceWebControllUrlSetting.js +1 -1
- package/lib/core/utils/edgeUtil.js +12 -1
- package/lib/core/utils/metricUtil.js +8 -4
- package/lib/core/utils/showGraphManageStatusUtil.js +3 -2
- package/lib/core/utils/showMessage.js +2 -2
- package/lib/core/viewer/components/plugins/ResourceDetail/ResourceDetail.js +1 -0
- package/lib/core/viewer/components/plugins/ResourceDetail/components/ResourceOverview/EventsCard.js +48 -21
- package/lib/core/viewer/components/plugins/ResourceDetail/components/ResourceOverview/ResourceOverview.js +3 -1
- package/lib/core/viewer/components/plugins/ResourceDetail/components/ResourceOverview/components/LinkTopo/LinkTopoCard.js +4 -2
- package/lib/core/viewer/components/plugins/ResourceDetail/components/ResourceOverview/components/LinkTopo/hooks/useMetricPolling.js +6 -6
- package/lib/core/viewer/components/plugins/ResourceDetail/components/ResourceOverview/components/LinkTopo/services/index.js +3 -5
- package/lib/core/viewer/components/plugins/ResourceDetail/components/ResourceOverview/hooks/useAlarmAndRiskData.js +20 -18
- package/lib/core/viewer/components/plugins/ResourceDetail/components/ResourceOverview/index.module.scss +8 -0
- package/lib/core/viewer/components/plugins/ResourceDetail/components/WebConsole/WebConsoleForm/hooks/useWebConsole.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/Link/index.js +2 -2
- package/lib/networkTopo/components/TopoView.js +5 -14
- package/lib/networkTopo/hooks/useEdgeExpand.js +2 -3
- package/lib/networkTopo/hooks/viewer/useRelateTopo.js +4 -4
- package/lib/networkTopo/models/LinkDynamicStyleExecutor.js +3 -5
- package/lib/networkTopo/models/LinkTagsTipsBuilder.js +3 -3
- package/lib/networkTopo/models/TopoCenter.js +1 -1
- package/lib/networkTopo/services/model.js +1 -3
- package/lib/networkTopo/services/topo/basic.js +4 -6
- package/lib/networkTopo/services/topo/ciInfo.js +0 -2
- package/lib/networkTopo/store/functionAuth.js +1 -1
- package/lib/networkTopo/store/topoCenter.js +263 -226
- package/lib/networkTopo/store/topoTreeMod.js +5 -5
- package/lib/networkTopo/utils/exportData.js +1 -3
- package/lib/style.js +2 -2
- package/lib/utils/ResourceConfigUtil.js +4 -39
- package/lib/utils/ciRefAttributeTranslateUtil.d.ts +19 -0
- package/lib/utils/ciRefAttributeTranslateUtil.js +168 -0
- package/lib/utils/format.js +1 -1
- package/lib/utils/topoData.js +4 -2
- package/package.json +4 -4
@@ -4,7 +4,7 @@ import _extends from "@babel/runtime/helpers/extends";
|
|
4
4
|
* 动态设置链路样式 Model
|
5
5
|
*/
|
6
6
|
// import _ from 'lodash';
|
7
|
-
import rlog from '@riil-frontend/component-topology-utils
|
7
|
+
import { rlog } from '@riil-frontend/component-topology-utils';
|
8
8
|
var defaultState = {
|
9
9
|
undoable: false,
|
10
10
|
redoable: false
|
@@ -5,7 +5,7 @@ import _regeneratorRuntime from "@babel/runtime/regenerator";
|
|
5
5
|
/**
|
6
6
|
* 拓扑编辑 Model
|
7
7
|
*/
|
8
|
-
import rlog from '@riil-frontend/component-topology-utils
|
8
|
+
import { rlog } from '@riil-frontend/component-topology-utils';
|
9
9
|
var initState = {
|
10
10
|
// 是否就绪
|
11
11
|
ready: false,
|
@@ -9,6 +9,18 @@ export function handleCopyHotkey(event, options) {
|
|
9
9
|
copy(options.topo);
|
10
10
|
}
|
11
11
|
}
|
12
|
+
export function initPasteEventListener() {
|
13
|
+
document.addEventListener("paste", handlePasteEventListener);
|
14
|
+
}
|
15
|
+
export function destroyPasteEventListener() {
|
16
|
+
document.removeEventListener("paste", handlePasteEventListener);
|
17
|
+
}
|
18
|
+
|
19
|
+
function handlePasteEventListener(e) {
|
20
|
+
var clipdata = e.clipboardData || window.clipboardData;
|
21
|
+
console.log("主动粘贴", clipdata.getData("text/plain"));
|
22
|
+
}
|
23
|
+
|
12
24
|
export function handlePasteHotkey(event, options) {
|
13
25
|
var target = event.target || event.srcElement;
|
14
26
|
var tagName = target.tagName;
|
@@ -1,5 +1,4 @@
|
|
1
|
-
import { getEdges } from "../../../utils/htElementUtils";
|
2
|
-
import { getEdgesBetweenNodes } from "../../../utils/htElementUtils";
|
1
|
+
import { getEdges, getEdgesBetweenNodes } from "../../../utils/htElementUtils";
|
3
2
|
var ht = window.ht;
|
4
3
|
export function getEdgesBySelection(topo) {
|
5
4
|
var getChildrenNodeIds = function getChildrenNodeIds(nodes) {
|
@@ -105,16 +104,18 @@ export function loopEdgesAndChildren(topo, edges, operateEdgeFn) {
|
|
105
104
|
* 设置连线及子连线。带回退事务控制
|
106
105
|
* @param {*} topo
|
107
106
|
* @param {*} edges
|
108
|
-
* @param {*}
|
107
|
+
* @param {*} updateEdgeFn
|
109
108
|
*/
|
110
109
|
|
111
|
-
export function
|
110
|
+
export function updateEdgesData(topo, edges, updateEdgeFn) {
|
112
111
|
topo.historyManager.beginTransaction();
|
113
|
-
|
112
|
+
edges.forEach(function (edge) {
|
113
|
+
updateEdgeFn(edge);
|
114
|
+
});
|
114
115
|
topo.historyManager.endTransaction();
|
115
116
|
}
|
116
117
|
/**
|
117
|
-
*
|
118
|
+
* 批量设置连线线形。带回退事务控制
|
118
119
|
*
|
119
120
|
* @param {*} edges
|
120
121
|
* @param {*} type
|
@@ -123,7 +124,7 @@ export function setEdgesAndChildren(topo, edges, operateEdgeFn) {
|
|
123
124
|
|
124
125
|
export function setEdgesType(edges, type, topo) {
|
125
126
|
var htTopo = topo.getHtTopo();
|
126
|
-
|
127
|
+
updateEdgesData(topo, edges, function (edge) {
|
127
128
|
htTopo.setGraphLinear(edge, {
|
128
129
|
type: type
|
129
130
|
});
|
@@ -2,128 +2,178 @@ 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
4
|
import useGraphAlarmDisplay from "./useGraphAlarmDisplay";
|
5
|
-
import useTopoEventListener from "./useTopoEventListener";
|
5
|
+
import useTopoEventListener from "./useTopoEventListener"; // 告警在活状态
|
6
|
+
|
7
|
+
var showAlarmStatus = ["toDeal", "dealing", "change", "woDealing"];
|
6
8
|
/**
|
7
|
-
*
|
8
|
-
*
|
9
|
-
* @
|
9
|
+
* 告警是否在活
|
10
|
+
* @param {*} alarm
|
11
|
+
* @returns
|
10
12
|
*/
|
11
13
|
|
12
|
-
|
13
|
-
|
14
|
-
|
14
|
+
var isAlarmAlive = function isAlarmAlive(alarm) {
|
15
|
+
return showAlarmStatus.indexOf(alarm.status) >= 0;
|
16
|
+
};
|
15
17
|
|
16
|
-
|
17
|
-
|
18
|
-
alarmListDefaultOpen = _topo$store$useModelS.alarmListDefaultOpen;
|
18
|
+
var handleRiskData = function handleRiskData(topo, receivedData) {
|
19
|
+
var _risks, _topo$viewProps, _topo$viewProps2;
|
19
20
|
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
21
|
+
// 非在活状态:
|
22
|
+
// 已修复 recovered
|
23
|
+
// 已关闭 closed
|
24
|
+
var prevRisks = topo.store.getModelState('topoAlarm').risks;
|
25
|
+
|
26
|
+
var isLiveRisk = function isLiveRisk(data) {
|
27
|
+
return ['recovered', 'closed'].indexOf(data.status) === -1;
|
28
|
+
};
|
29
|
+
|
30
|
+
var hasCiPermission = function hasCiPermission(data) {
|
31
|
+
var _data$resourceId;
|
24
32
|
|
25
|
-
|
26
|
-
var
|
33
|
+
var ciId = (_data$resourceId = data.resourceId) !== null && _data$resourceId !== void 0 ? _data$resourceId : data.ciId;
|
34
|
+
var ci = topo.dataModel.getDataById(ciId);
|
35
|
+
return !!(ci !== null && ci !== void 0 && ci.operation);
|
36
|
+
}; // 合并
|
27
37
|
|
28
|
-
// 非在活状态:
|
29
|
-
// 已修复 recovered
|
30
|
-
// 已关闭 closed
|
31
|
-
var prevRisks = topo.store.getModelState('topoAlarm').risks;
|
32
38
|
|
33
|
-
|
34
|
-
|
35
|
-
|
39
|
+
var risks = prevRisks.map(function (risk) {
|
40
|
+
var newRisk = receivedData.find(function (item) {
|
41
|
+
return item.id === risk.id;
|
42
|
+
});
|
43
|
+
return newRisk || risk;
|
44
|
+
}); // 新的
|
36
45
|
|
37
|
-
|
38
|
-
|
46
|
+
var addRisks = receivedData.filter(function (risk) {
|
47
|
+
return !prevRisks.find(function (item) {
|
48
|
+
return item.id === risk.id;
|
49
|
+
});
|
50
|
+
}).filter(hasCiPermission);
|
39
51
|
|
40
|
-
|
41
|
-
var ci = topo.dataModel.getDataById(ciId);
|
42
|
-
return ci && ci.operation;
|
43
|
-
}; // 合并
|
52
|
+
(_risks = risks).push.apply(_risks, addRisks); // 过滤掉无权限、非在活的
|
44
53
|
|
45
54
|
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
55
|
+
risks = risks.filter(isLiveRisk).filter(hasCiPermission).sort(function (a, b) {
|
56
|
+
return a.executeTime - b.executeTime;
|
57
|
+
});
|
58
|
+
rlog.debug('更新风险', {
|
59
|
+
prevRisks: prevRisks,
|
60
|
+
receivedData: receivedData,
|
61
|
+
risks: risks
|
62
|
+
});
|
63
|
+
topo.store.getModelDispatchers('topoAlarm').update({
|
64
|
+
risks: risks
|
65
|
+
}); // 获取配置
|
52
66
|
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
});
|
57
|
-
}).filter(hasCiPermission);
|
67
|
+
var _topo$store$getModelS = topo.store.getModelState('displayConfig'),
|
68
|
+
alarmSwitch = _topo$store$getModelS.alarmSwitch,
|
69
|
+
alarmListDefaultOpen = _topo$store$getModelS.alarmListDefaultOpen; // 告警静默
|
58
70
|
|
59
|
-
(_risks = risks).push.apply(_risks, addRisks); // 过滤掉无权限、非在活的
|
60
71
|
|
72
|
+
if (alarmSwitch === false) {
|
73
|
+
return;
|
74
|
+
} // 告警列表
|
61
75
|
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
prevRisks: prevRisks,
|
67
|
-
receivedData: receivedData,
|
68
|
-
risks: risks
|
69
|
-
});
|
70
|
-
topo.store.getModelDispatchers('topoAlarm').update({
|
71
|
-
risks: risks
|
76
|
+
|
77
|
+
if (addRisks.length && alarmListDefaultOpen) {
|
78
|
+
topo.alarm.updateState({
|
79
|
+
alarmPanelIsOpen: true
|
72
80
|
});
|
81
|
+
}
|
73
82
|
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
}
|
83
|
+
if ((_topo$viewProps = topo.viewProps) !== null && _topo$viewProps !== void 0 && _topo$viewProps.onRisk) {
|
84
|
+
topo.viewProps.onRisk(risks);
|
85
|
+
}
|
78
86
|
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
87
|
+
if ((_topo$viewProps2 = topo.viewProps) !== null && _topo$viewProps2 !== void 0 && _topo$viewProps2.onResourceEvent) {
|
88
|
+
topo.viewProps.onResourceEvent(topo.alarm.getEvents());
|
89
|
+
}
|
90
|
+
};
|
91
|
+
/**
|
92
|
+
* 关联拓扑告警级别消息处理
|
93
|
+
* @param {*} topo
|
94
|
+
* @param {*} data
|
95
|
+
*/
|
84
96
|
|
85
|
-
if ((_topo$viewProps = topo.viewProps) !== null && _topo$viewProps !== void 0 && _topo$viewProps.onRisk) {
|
86
|
-
topo.viewProps.onRisk(risks);
|
87
|
-
}
|
88
97
|
|
89
|
-
|
90
|
-
|
91
|
-
}
|
92
|
-
};
|
98
|
+
var handleRelateTopoAlarm = function handleRelateTopoAlarm(topo, data) {
|
99
|
+
var relateTopoAlarm = _extends({}, topo.store.getModelState('topoAlarm').relateTopoAlarm);
|
93
100
|
|
94
|
-
|
95
|
-
var
|
101
|
+
data.forEach(function (item) {
|
102
|
+
var alertLevel = item.alertLevel;
|
96
103
|
|
97
|
-
|
104
|
+
if (alertLevel === -1) {
|
105
|
+
// -1表示删除
|
106
|
+
delete relateTopoAlarm[item.topoId];
|
107
|
+
} else {
|
98
108
|
relateTopoAlarm[item.topoId] = item.alertLevel;
|
109
|
+
}
|
110
|
+
});
|
111
|
+
topo.store.getModelDispatchers('topoAlarm').update({
|
112
|
+
relateTopoAlarm: relateTopoAlarm
|
113
|
+
});
|
114
|
+
rlog.debug("\u5173\u8054\u62D3\u6251\u544A\u8B66\uFF1A\u6536\u5230 " + data.length, {
|
115
|
+
received: data,
|
116
|
+
all: relateTopoAlarm
|
117
|
+
});
|
118
|
+
};
|
119
|
+
/**
|
120
|
+
* 处理分级告警
|
121
|
+
* @param {*} alarms
|
122
|
+
* @returns
|
123
|
+
*/
|
124
|
+
|
125
|
+
|
126
|
+
function convertAlarmData(alarms) {
|
127
|
+
return alarms.map(function (alarm) {
|
128
|
+
var resourceId = alarm.resourceId; // 分级资源id转换
|
129
|
+
|
130
|
+
if (alarm.cmpAlertId) {
|
131
|
+
resourceId = "sub:" + alarm.mainCiId;
|
132
|
+
}
|
133
|
+
|
134
|
+
return _extends({}, alarm, {
|
135
|
+
// 数据id
|
136
|
+
resourceId: resourceId,
|
137
|
+
// 是否在活
|
138
|
+
alive: isAlarmAlive(alarm)
|
99
139
|
});
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
140
|
+
});
|
141
|
+
}
|
142
|
+
/**
|
143
|
+
*
|
144
|
+
*
|
145
|
+
* @param {*} options
|
146
|
+
*/
|
147
|
+
|
148
|
+
|
149
|
+
export default function useAlarm(options) {
|
150
|
+
var topo = options.topo;
|
151
|
+
|
152
|
+
var _topo$store$useModelS = topo.store.useModelState('displayConfig'),
|
153
|
+
alarmSwitch = _topo$store$useModelS.alarmSwitch;
|
108
154
|
|
155
|
+
useGraphAlarmDisplay({
|
156
|
+
topo: topo,
|
157
|
+
alarmSwitch: alarmSwitch
|
158
|
+
}); // 订阅消息
|
109
159
|
|
110
160
|
useTopoEventListener({
|
111
161
|
type: 'alarm',
|
112
162
|
onMessage: function onMessage(data) {
|
113
163
|
rlog.debug("Topoget--AlertMesage------------", topo, data);
|
114
|
-
topo.alarm.handleAlarmEvent(data);
|
164
|
+
topo.alarm.handleAlarmEvent(convertAlarmData(data));
|
115
165
|
}
|
116
166
|
});
|
117
167
|
useTopoEventListener({
|
118
168
|
type: 'risk',
|
119
169
|
onMessage: function onMessage(data) {
|
120
|
-
handleRiskData(data);
|
170
|
+
handleRiskData(topo, data);
|
121
171
|
}
|
122
172
|
});
|
123
173
|
useTopoEventListener({
|
124
174
|
type: 'relateTopoAlarm',
|
125
175
|
onMessage: function onMessage(data) {
|
126
|
-
handleRelateTopoAlarm(data);
|
176
|
+
handleRelateTopoAlarm(topo, data);
|
127
177
|
}
|
128
178
|
});
|
129
179
|
}
|
@@ -1,5 +1,5 @@
|
|
1
1
|
import _extends from "@babel/runtime/helpers/extends";
|
2
|
-
import rlog from '@riil-frontend/component-topology-utils
|
2
|
+
import { rlog } from '@riil-frontend/component-topology-utils';
|
3
3
|
import CiCache from "../models/cache/CiCache";
|
4
4
|
import useTopoEventListener from "./useTopoEventListener";
|
5
5
|
|
@@ -0,0 +1,153 @@
|
|
1
|
+
import _asyncToGenerator from "@babel/runtime/helpers/asyncToGenerator";
|
2
|
+
import _extends from "@babel/runtime/helpers/extends";
|
3
|
+
import _regeneratorRuntime from "@babel/runtime/regenerator";
|
4
|
+
import { useEffect, useState, useMemo } from "react";
|
5
|
+
import { useRequest } from 'ahooks';
|
6
|
+
import DictCache from "../models/cache/DictCache";
|
7
|
+
|
8
|
+
function addCmpLinkOfflineStatusForDisplayLineColor(cis, cmpLinkRunStatusList) {
|
9
|
+
return cis.map(function (ci) {
|
10
|
+
var cmpLinkRunStatusData = cmpLinkRunStatusList.find(function (item) {
|
11
|
+
return item.id === ci.id;
|
12
|
+
});
|
13
|
+
|
14
|
+
if (cmpLinkRunStatusData) {
|
15
|
+
return _extends({}, ci, {
|
16
|
+
manageStatus: cmpLinkRunStatusData.runStatus === '2' ? 0 : 3
|
17
|
+
});
|
18
|
+
}
|
19
|
+
|
20
|
+
return ci;
|
21
|
+
});
|
22
|
+
}
|
23
|
+
|
24
|
+
function getCmpLinIds(datas) {
|
25
|
+
var linkIds = datas.filter(function (item) {
|
26
|
+
return item.isSubResource && item.typeCode === 'network_link';
|
27
|
+
}).map(function (item) {
|
28
|
+
return item.ciId;
|
29
|
+
});
|
30
|
+
return linkIds;
|
31
|
+
}
|
32
|
+
/**
|
33
|
+
* 分级链路下級鏈路
|
34
|
+
* @param {*} props
|
35
|
+
* @returns
|
36
|
+
*/
|
37
|
+
|
38
|
+
|
39
|
+
export default function useCmpLinkAlarm(props) {
|
40
|
+
var topo = props.topo,
|
41
|
+
resources = props.resources,
|
42
|
+
graphLoaded = props.graphLoaded;
|
43
|
+
|
44
|
+
var _useState = useState(getCmpLinIds(resources)),
|
45
|
+
cmpLinkIds = _useState[0],
|
46
|
+
setCmpLinkIds = _useState[1];
|
47
|
+
|
48
|
+
var _useState2 = useState([]),
|
49
|
+
cmpLinkRunStatus = _useState2[0],
|
50
|
+
setCmpLinkRunStatus = _useState2[1];
|
51
|
+
|
52
|
+
var cmpLinkAlarmLevels = useMemo(function () {
|
53
|
+
return cmpLinkRunStatus // 3:fault:重要故障; 4:urgently:紧急故障 』为红色
|
54
|
+
.filter(function (item) {
|
55
|
+
return ['3', '4'].includes(item.runStatus);
|
56
|
+
}).map(function (item) {
|
57
|
+
return {
|
58
|
+
id: item.id,
|
59
|
+
level: 1
|
60
|
+
};
|
61
|
+
});
|
62
|
+
}, [cmpLinkRunStatus]);
|
63
|
+
useEffect(function () {
|
64
|
+
var ids = getCmpLinIds(resources);
|
65
|
+
|
66
|
+
if (cmpLinkIds.join(',') !== ids.join(',')) {
|
67
|
+
setCmpLinkIds(ids);
|
68
|
+
}
|
69
|
+
}, [resources]);
|
70
|
+
|
71
|
+
function getCmpLinkRunStatus(_x) {
|
72
|
+
return _getCmpLinkRunStatus.apply(this, arguments);
|
73
|
+
} // 轮询hooks
|
74
|
+
|
75
|
+
|
76
|
+
function _getCmpLinkRunStatus() {
|
77
|
+
_getCmpLinkRunStatus = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(ids) {
|
78
|
+
var _yield$Promise$all, ciMetricsResult;
|
79
|
+
|
80
|
+
return _regeneratorRuntime.wrap(function _callee$(_context) {
|
81
|
+
while (1) switch (_context.prev = _context.next) {
|
82
|
+
case 0:
|
83
|
+
if (ids.length) {
|
84
|
+
_context.next = 2;
|
85
|
+
break;
|
86
|
+
}
|
87
|
+
|
88
|
+
return _context.abrupt("return", []);
|
89
|
+
|
90
|
+
case 2:
|
91
|
+
_context.t0 = Promise;
|
92
|
+
_context.t1 = // 查询指标值
|
93
|
+
topo.serverApi.ciInfo.batchQueryCiInfo({
|
94
|
+
ciId: [],
|
95
|
+
codes: ['run_status'],
|
96
|
+
relationId: ids.map(function (id) {
|
97
|
+
return {
|
98
|
+
ciId: id,
|
99
|
+
operation: "delete"
|
100
|
+
};
|
101
|
+
})
|
102
|
+
});
|
103
|
+
_context.next = 6;
|
104
|
+
return DictCache.init();
|
105
|
+
|
106
|
+
case 6:
|
107
|
+
_context.t2 = _context.sent;
|
108
|
+
_context.t3 = [_context.t1, _context.t2];
|
109
|
+
_context.next = 10;
|
110
|
+
return _context.t0.all.call(_context.t0, _context.t3);
|
111
|
+
|
112
|
+
case 10:
|
113
|
+
_yield$Promise$all = _context.sent;
|
114
|
+
ciMetricsResult = _yield$Promise$all[0];
|
115
|
+
return _context.abrupt("return", ciMetricsResult);
|
116
|
+
|
117
|
+
case 13:
|
118
|
+
case "end":
|
119
|
+
return _context.stop();
|
120
|
+
}
|
121
|
+
}, _callee);
|
122
|
+
}));
|
123
|
+
return _getCmpLinkRunStatus.apply(this, arguments);
|
124
|
+
}
|
125
|
+
|
126
|
+
var _useRequest = useRequest(getCmpLinkRunStatus, {
|
127
|
+
pollingInterval: 60 * 1000,
|
128
|
+
pollingWhenHidden: false,
|
129
|
+
// debounceInterval: 200,
|
130
|
+
manual: true,
|
131
|
+
onSuccess: function onSuccess(result) {
|
132
|
+
setCmpLinkRunStatus(result.map(function (item) {
|
133
|
+
return {
|
134
|
+
id: "sub:" + item.id,
|
135
|
+
runStatus: item.metrics.run_status
|
136
|
+
};
|
137
|
+
}));
|
138
|
+
}
|
139
|
+
}),
|
140
|
+
run = _useRequest.run;
|
141
|
+
|
142
|
+
useEffect(function () {
|
143
|
+
if (graphLoaded) {
|
144
|
+
run(cmpLinkIds);
|
145
|
+
}
|
146
|
+
}, [graphLoaded, cmpLinkIds]);
|
147
|
+
return {
|
148
|
+
cmpLinkRunStatus: cmpLinkRunStatus,
|
149
|
+
cmpLinkAlarmLevels: cmpLinkAlarmLevels,
|
150
|
+
addCmpLinkOfflineStatusForDisplayLineColor: addCmpLinkOfflineStatusForDisplayLineColor
|
151
|
+
};
|
152
|
+
}
|
153
|
+
;
|
@@ -1,7 +1,6 @@
|
|
1
1
|
import _extends from "@babel/runtime/helpers/extends";
|
2
2
|
export default function useEventData(props) {
|
3
|
-
var topo = props.topo;
|
4
|
-
var topoDatas = topo.dataModel.useDatas();
|
3
|
+
var topo = props.topo; // const topoDatas = topo.dataModel.useDatas()
|
5
4
|
|
6
5
|
var _topo$store$useModelS = topo.store.useModelState('topoAlarm'),
|
7
6
|
risks = _topo$store$useModelS.risks,
|