@riil-frontend/component-topology 12.0.0-dev.3 → 12.0.0-dev.30
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 +58 -3
- 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 +16 -2
- 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/__tests__/useCiAttributeChange.test.js +0 -0
- package/es/core/hooks/ht/useHtDataPropertyChangeListener.js +1 -1
- package/es/core/hooks/useAlarm.js +119 -82
- package/es/core/hooks/useCiAttributeChange.js +31 -15
- package/es/core/hooks/useCmpLinkAlarm.js +156 -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 +70 -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 +12 -13
- 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/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 +1 -1
- 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 +60 -3
- 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/__tests__/useCiAttributeChange.test.js +1 -0
- package/lib/core/hooks/ht/useHtDataPropertyChangeListener.js +1 -3
- package/lib/core/hooks/useAlarm.js +118 -80
- package/lib/core/hooks/useCiAttributeChange.js +30 -14
- package/lib/core/hooks/useCmpLinkAlarm.js +169 -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 +77 -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 +12 -13
- 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/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 +1 -1
- 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
@@ -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
|
});
|
File without changes
|
@@ -2,128 +2,165 @@ 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
|
+
};
|
24
29
|
|
25
|
-
var
|
26
|
-
var
|
30
|
+
var hasCiPermission = function hasCiPermission(data) {
|
31
|
+
var _data$resourceId;
|
27
32
|
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
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
|
+
}; // 合并
|
32
37
|
|
33
|
-
var isLiveRisk = function isLiveRisk(data) {
|
34
|
-
return ['recovered', 'closed'].indexOf(data.status) === -1;
|
35
|
-
};
|
36
38
|
|
37
|
-
|
38
|
-
|
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
|
+
}); // 新的
|
39
45
|
|
40
|
-
|
41
|
-
|
42
|
-
return
|
43
|
-
};
|
46
|
+
var addRisks = receivedData.filter(function (risk) {
|
47
|
+
return !prevRisks.find(function (item) {
|
48
|
+
return item.id === risk.id;
|
49
|
+
});
|
50
|
+
}).filter(hasCiPermission);
|
44
51
|
|
52
|
+
(_risks = risks).push.apply(_risks, addRisks); // 过滤掉无权限、非在活的
|
45
53
|
|
46
|
-
var risks = prevRisks.map(function (risk) {
|
47
|
-
var newRisk = receivedData.find(function (item) {
|
48
|
-
return item.id === risk.id;
|
49
|
-
});
|
50
|
-
return newRisk || risk;
|
51
|
-
}); // 新的
|
52
54
|
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
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
|
+
}); // 获取配置
|
58
66
|
|
59
|
-
|
67
|
+
var _topo$store$getModelS = topo.store.getModelState('displayConfig'),
|
68
|
+
alarmSwitch = _topo$store$getModelS.alarmSwitch,
|
69
|
+
alarmListDefaultOpen = _topo$store$getModelS.alarmListDefaultOpen; // 告警静默
|
60
70
|
|
61
71
|
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
topo.store.getModelDispatchers('topoAlarm').update({
|
71
|
-
risks: risks
|
72
|
+
if (alarmSwitch === false) {
|
73
|
+
return;
|
74
|
+
} // 告警列表
|
75
|
+
|
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
|
+
};
|
84
91
|
|
85
|
-
|
86
|
-
|
87
|
-
}
|
92
|
+
var handleRelateTopoAlarm = function handleRelateTopoAlarm(topo, data) {
|
93
|
+
var relateTopoAlarm = _extends({}, topo.store.getModelState('topoAlarm').relateTopoAlarm);
|
88
94
|
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
95
|
+
data.forEach(function (item) {
|
96
|
+
relateTopoAlarm[item.topoId] = item.alertLevel;
|
97
|
+
});
|
98
|
+
topo.store.getModelDispatchers('topoAlarm').update({
|
99
|
+
relateTopoAlarm: relateTopoAlarm
|
100
|
+
});
|
101
|
+
rlog.debug("\u5173\u8054\u62D3\u6251\u544A\u8B66\uFF1A\u6536\u5230 " + data.length, {
|
102
|
+
received: data,
|
103
|
+
all: relateTopoAlarm
|
104
|
+
});
|
105
|
+
};
|
106
|
+
/**
|
107
|
+
* 处理分级告警
|
108
|
+
* @param {*} alarms
|
109
|
+
* @returns
|
110
|
+
*/
|
93
111
|
|
94
|
-
var handleRelateTopoAlarm = function handleRelateTopoAlarm(data) {
|
95
|
-
var relateTopoAlarm = _extends({}, topo.store.getModelState('topoAlarm').relateTopoAlarm);
|
96
112
|
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
113
|
+
function convertAlarmData(alarms) {
|
114
|
+
return alarms.map(function (alarm) {
|
115
|
+
var resourceId = alarm.resourceId; // 分级资源id转换
|
116
|
+
|
117
|
+
if (alarm.cmpAlertId) {
|
118
|
+
resourceId = "sub:" + alarm.mainCiId;
|
119
|
+
}
|
120
|
+
|
121
|
+
return _extends({}, alarm, {
|
122
|
+
// 数据id
|
123
|
+
resourceId: resourceId,
|
124
|
+
// 是否在活
|
125
|
+
alive: isAlarmAlive(alarm)
|
106
126
|
});
|
107
|
-
};
|
127
|
+
});
|
128
|
+
}
|
129
|
+
/**
|
130
|
+
*
|
131
|
+
*
|
132
|
+
* @param {*} options
|
133
|
+
*/
|
134
|
+
|
135
|
+
|
136
|
+
export default function useAlarm(options) {
|
137
|
+
var topo = options.topo;
|
138
|
+
|
139
|
+
var _topo$store$useModelS = topo.store.useModelState('displayConfig'),
|
140
|
+
alarmSwitch = _topo$store$useModelS.alarmSwitch;
|
108
141
|
|
142
|
+
useGraphAlarmDisplay({
|
143
|
+
topo: topo,
|
144
|
+
alarmSwitch: alarmSwitch
|
145
|
+
}); // 订阅消息
|
109
146
|
|
110
147
|
useTopoEventListener({
|
111
148
|
type: 'alarm',
|
112
149
|
onMessage: function onMessage(data) {
|
113
150
|
rlog.debug("Topoget--AlertMesage------------", topo, data);
|
114
|
-
topo.alarm.handleAlarmEvent(data);
|
151
|
+
topo.alarm.handleAlarmEvent(convertAlarmData(data));
|
115
152
|
}
|
116
153
|
});
|
117
154
|
useTopoEventListener({
|
118
155
|
type: 'risk',
|
119
156
|
onMessage: function onMessage(data) {
|
120
|
-
handleRiskData(data);
|
157
|
+
handleRiskData(topo, data);
|
121
158
|
}
|
122
159
|
});
|
123
160
|
useTopoEventListener({
|
124
161
|
type: 'relateTopoAlarm',
|
125
162
|
onMessage: function onMessage(data) {
|
126
|
-
handleRelateTopoAlarm(data);
|
163
|
+
handleRelateTopoAlarm(topo, data);
|
127
164
|
}
|
128
165
|
});
|
129
166
|
}
|
@@ -1,11 +1,22 @@
|
|
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
|
|
6
|
+
function ciExistTopo(topoData, ciChangeData) {
|
7
|
+
if (!topoData) {
|
8
|
+
return false;
|
9
|
+
}
|
10
|
+
|
11
|
+
var ciIds = [].concat(topoData.nodes, topoData.links, topoData.linkGroups).map(function (data) {
|
12
|
+
return data.ciId || data.id;
|
13
|
+
});
|
14
|
+
return ciIds.includes(ciChangeData.id);
|
15
|
+
}
|
16
|
+
|
6
17
|
function mergeData(cis, ciChangeData) {
|
7
18
|
var matchData = function matchData(item) {
|
8
|
-
return item.
|
19
|
+
return (item.ciId || item.id) === ciChangeData.id;
|
9
20
|
};
|
10
21
|
|
11
22
|
if (!cis.find(matchData)) {
|
@@ -13,16 +24,26 @@ function mergeData(cis, ciChangeData) {
|
|
13
24
|
}
|
14
25
|
|
15
26
|
return cis.map(function (ci) {
|
16
|
-
if (matchData(ci)) {
|
17
|
-
return
|
18
|
-
id: ci.id,
|
19
|
-
attributes: _extends({}, ci.attributes, ciChangeData.attributes)
|
20
|
-
});
|
27
|
+
if (!matchData(ci)) {
|
28
|
+
return ci;
|
21
29
|
}
|
22
30
|
|
23
|
-
return ci
|
31
|
+
return _extends({}, ci, {
|
32
|
+
id: ci.id,
|
33
|
+
attributes: _extends({}, ci.attributes, ciChangeData.attributes)
|
34
|
+
});
|
24
35
|
});
|
25
36
|
}
|
37
|
+
|
38
|
+
function mergeTopoData(topoData, ciChangeData) {
|
39
|
+
var newData = _extends({}, topoData, {
|
40
|
+
nodes: mergeData(topoData.nodes, ciChangeData),
|
41
|
+
links: mergeData(topoData.links, ciChangeData),
|
42
|
+
linkGroups: mergeData(topoData.linkGroups, ciChangeData)
|
43
|
+
});
|
44
|
+
|
45
|
+
return newData;
|
46
|
+
}
|
26
47
|
/**
|
27
48
|
* 监听ci属性变更
|
28
49
|
*
|
@@ -38,13 +59,8 @@ export default function useCiAttributeChange(props) {
|
|
38
59
|
// 更新拓扑数据
|
39
60
|
var topoData = topo.store.getModelState('topoMod').data;
|
40
61
|
|
41
|
-
if (topoData) {
|
42
|
-
var newData =
|
43
|
-
nodes: mergeData(topoData.nodes, ciChangeData),
|
44
|
-
links: mergeData(topoData.links, ciChangeData),
|
45
|
-
linkGroups: mergeData(topoData.linkGroups, ciChangeData)
|
46
|
-
});
|
47
|
-
|
62
|
+
if (ciExistTopo(topoData, ciChangeData)) {
|
63
|
+
var newData = mergeTopoData(topoData, ciChangeData);
|
48
64
|
var topoDispatchers = topo.store.getModelDispatchers('topoMod');
|
49
65
|
topoDispatchers.update({
|
50
66
|
data: newData
|
@@ -0,0 +1,156 @@
|
|
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 _topo$store$useModelS = topo.store.useModelState('topoBizMod'),
|
45
|
+
attrsAndMetrics = _topo$store$useModelS.attrsAndMetrics;
|
46
|
+
|
47
|
+
var _useState = useState(getCmpLinIds(resources)),
|
48
|
+
cmpLinkIds = _useState[0],
|
49
|
+
setCmpLinkIds = _useState[1];
|
50
|
+
|
51
|
+
var _useState2 = useState([]),
|
52
|
+
cmpLinkRunStatus = _useState2[0],
|
53
|
+
setCmpLinkRunStatus = _useState2[1];
|
54
|
+
|
55
|
+
var cmpLinkAlarmLevels = useMemo(function () {
|
56
|
+
return cmpLinkRunStatus // 3:fault:重要故障; 4:urgently:紧急故障 』为红色
|
57
|
+
.filter(function (item) {
|
58
|
+
return ['3', '4'].includes(item.runStatus);
|
59
|
+
}).map(function (item) {
|
60
|
+
return {
|
61
|
+
id: item.id,
|
62
|
+
level: 1
|
63
|
+
};
|
64
|
+
});
|
65
|
+
}, [cmpLinkRunStatus]);
|
66
|
+
useEffect(function () {
|
67
|
+
var ids = getCmpLinIds(resources);
|
68
|
+
|
69
|
+
if (cmpLinkIds.join(',') !== ids.join(',')) {
|
70
|
+
setCmpLinkIds(ids);
|
71
|
+
}
|
72
|
+
}, [resources]);
|
73
|
+
|
74
|
+
function getCmpLinkRunStatus(_x) {
|
75
|
+
return _getCmpLinkRunStatus.apply(this, arguments);
|
76
|
+
} // 轮询hooks
|
77
|
+
|
78
|
+
|
79
|
+
function _getCmpLinkRunStatus() {
|
80
|
+
_getCmpLinkRunStatus = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(ids) {
|
81
|
+
var _yield$Promise$all, ciMetricsResult;
|
82
|
+
|
83
|
+
return _regeneratorRuntime.wrap(function _callee$(_context) {
|
84
|
+
while (1) switch (_context.prev = _context.next) {
|
85
|
+
case 0:
|
86
|
+
if (ids.length) {
|
87
|
+
_context.next = 2;
|
88
|
+
break;
|
89
|
+
}
|
90
|
+
|
91
|
+
return _context.abrupt("return", []);
|
92
|
+
|
93
|
+
case 2:
|
94
|
+
_context.t0 = Promise;
|
95
|
+
_context.t1 = // 查询指标值
|
96
|
+
topo.serverApi.ciInfo.batchQueryCiInfo({
|
97
|
+
ciId: [],
|
98
|
+
codes: ['run_status'],
|
99
|
+
relationId: ids.map(function (id) {
|
100
|
+
return {
|
101
|
+
ciId: id,
|
102
|
+
operation: "delete"
|
103
|
+
};
|
104
|
+
})
|
105
|
+
});
|
106
|
+
_context.next = 6;
|
107
|
+
return DictCache.init();
|
108
|
+
|
109
|
+
case 6:
|
110
|
+
_context.t2 = _context.sent;
|
111
|
+
_context.t3 = [_context.t1, _context.t2];
|
112
|
+
_context.next = 10;
|
113
|
+
return _context.t0.all.call(_context.t0, _context.t3);
|
114
|
+
|
115
|
+
case 10:
|
116
|
+
_yield$Promise$all = _context.sent;
|
117
|
+
ciMetricsResult = _yield$Promise$all[0];
|
118
|
+
return _context.abrupt("return", ciMetricsResult);
|
119
|
+
|
120
|
+
case 13:
|
121
|
+
case "end":
|
122
|
+
return _context.stop();
|
123
|
+
}
|
124
|
+
}, _callee);
|
125
|
+
}));
|
126
|
+
return _getCmpLinkRunStatus.apply(this, arguments);
|
127
|
+
}
|
128
|
+
|
129
|
+
var _useRequest = useRequest(getCmpLinkRunStatus, {
|
130
|
+
pollingInterval: 60 * 1000,
|
131
|
+
pollingWhenHidden: false,
|
132
|
+
// debounceInterval: 200,
|
133
|
+
manual: true,
|
134
|
+
onSuccess: function onSuccess(result) {
|
135
|
+
setCmpLinkRunStatus(result.map(function (item) {
|
136
|
+
return {
|
137
|
+
id: "sub:" + item.id,
|
138
|
+
runStatus: item.metrics.run_status
|
139
|
+
};
|
140
|
+
}));
|
141
|
+
}
|
142
|
+
}),
|
143
|
+
run = _useRequest.run;
|
144
|
+
|
145
|
+
useEffect(function () {
|
146
|
+
if (graphLoaded) {
|
147
|
+
run(cmpLinkIds);
|
148
|
+
}
|
149
|
+
}, [graphLoaded, cmpLinkIds]);
|
150
|
+
return {
|
151
|
+
cmpLinkRunStatus: cmpLinkRunStatus,
|
152
|
+
cmpLinkAlarmLevels: cmpLinkAlarmLevels,
|
153
|
+
addCmpLinkOfflineStatusForDisplayLineColor: addCmpLinkOfflineStatusForDisplayLineColor
|
154
|
+
};
|
155
|
+
}
|
156
|
+
;
|
@@ -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,
|