@riil-frontend/component-topology 12.0.0-dev.13 → 12.0.0-dev.17
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.js +14 -14
- package/es/core/components/AlarmListPanel/components/AlarmListItem.js +56 -3
- package/es/core/editor/components/Toolbar/widgets/Layout/index.js +16 -2
- package/es/core/hooks/useGraphAlarmDisplay.js +62 -40
- package/es/core/hooks/useTopoEdit.js +3 -2
- package/es/core/models/Alarm.js +28 -16
- 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/store/models/topoMod.js +81 -134
- package/es/core/utils/showGraphManageStatusUtil.js +3 -2
- package/es/core/viewer/components/plugins/ViewerPlugin.js +3 -1
- package/es/utils/ciRefAttributeTranslateUtil.d.ts +6 -2
- package/es/utils/ciRefAttributeTranslateUtil.js +7 -8
- package/lib/core/components/AlarmListPanel/components/AlarmListItem.js +58 -3
- package/lib/core/editor/components/Toolbar/widgets/Layout/index.js +16 -2
- package/lib/core/hooks/useGraphAlarmDisplay.js +62 -40
- package/lib/core/hooks/useTopoEdit.js +3 -2
- package/lib/core/models/Alarm.js +28 -16
- 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/store/models/topoMod.js +81 -134
- package/lib/core/utils/showGraphManageStatusUtil.js +3 -2
- package/lib/core/viewer/components/plugins/ViewerPlugin.js +3 -1
- package/lib/utils/ciRefAttributeTranslateUtil.d.ts +6 -2
- package/lib/utils/ciRefAttributeTranslateUtil.js +7 -8
- package/package.json +2 -2
@@ -40,6 +40,11 @@ function Layout(props) {
|
|
40
40
|
selection = _topo$store$useModelS.selection;
|
41
41
|
|
42
42
|
var setDisabled = function setDisabled(data) {
|
43
|
+
if (topoShowType !== 'layers' && selection.length === 1) {
|
44
|
+
//中心节点布局,选中一个节点非分层情况下,需要星型和树形布局亮起来
|
45
|
+
return data == 'rectangle' || data == 'hierarchical';
|
46
|
+
}
|
47
|
+
|
43
48
|
if (topoShowType == 'layers' && selection.length == 1 && !(0, _htElementDataUtil.isGroup)(selection[0])) {
|
44
49
|
return data != 'rectangle';
|
45
50
|
} else {
|
@@ -57,7 +62,11 @@ function Layout(props) {
|
|
57
62
|
|
58
63
|
|
59
64
|
if (topoShowType != 'layers' && selection.length == 1) {
|
60
|
-
|
65
|
+
if (layouType == 'hierarchical') {
|
66
|
+
topo.getHtTopo().layoutInContainer(layouType);
|
67
|
+
} else {
|
68
|
+
topo.getHtTopo().layoutTopoBySelectNode(layouType, selectionElements[0]);
|
69
|
+
}
|
61
70
|
} // eslint-disable-next-line eqeqeq
|
62
71
|
|
63
72
|
|
@@ -72,7 +81,7 @@ function Layout(props) {
|
|
72
81
|
topo.historyManager.beginTransaction();
|
73
82
|
setLayout(v); // eslint-disable-next-line eqeqeq
|
74
83
|
|
75
|
-
if (topoShowType != 'layers' && ((_selection$ = selection[0]) === null || _selection$ === void 0 ? void 0 : _selection$.className) != 'ht.Node' || topoShowType == 'partition' && selection.length == 1 || topoShowType == 'layers' && selection.length == 1) {
|
84
|
+
if (topoShowType != 'layers' && ((_selection$ = selection[0]) === null || _selection$ === void 0 ? void 0 : _selection$.className) != 'ht.Node' || topoShowType == 'partition' && selection.length == 1 || topoShowType == 'layers' && selection.length == 1 || topoShowType !== 'layers' && selection.length === 1) {
|
76
85
|
globalLayout(v);
|
77
86
|
}
|
78
87
|
|
@@ -150,6 +159,11 @@ function isLayoutEnabled(props) {
|
|
150
159
|
|
151
160
|
if (topoShowType !== 'layers' && !selection.length) {
|
152
161
|
return true;
|
162
|
+
} //中心节点布局,选中一个节点不是分层的情况下,按钮亮起
|
163
|
+
|
164
|
+
|
165
|
+
if (topoShowType !== 'layers' && selection.length === 1) {
|
166
|
+
return true;
|
153
167
|
}
|
154
168
|
|
155
169
|
return false;
|
@@ -13,7 +13,13 @@ var _htElementUtils = require("../../utils/htElementUtils");
|
|
13
13
|
|
14
14
|
var _showGraphManageStatusUtil = require("../utils/showGraphManageStatusUtil");
|
15
15
|
|
16
|
-
|
16
|
+
/**
|
17
|
+
* 获取ci的最高告警级别
|
18
|
+
* @param {Array} alarmList
|
19
|
+
* @param {*} risks
|
20
|
+
* @returns
|
21
|
+
*/
|
22
|
+
function getCiAlarmLevelMap(alarmList, risks) {
|
17
23
|
var ciIdLevelMap = {};
|
18
24
|
[].concat(alarmList, risks.map(function (item) {
|
19
25
|
var _item$resourceId;
|
@@ -31,13 +37,53 @@ function getCiAlarmLevels(alarmList, risks) {
|
|
31
37
|
|
32
38
|
ciIdLevelMap[item.id] = level;
|
33
39
|
});
|
40
|
+
return ciIdLevelMap;
|
41
|
+
}
|
42
|
+
|
43
|
+
function getGraphCiElementAlarmLevels(resources, alarmList, risks) {
|
44
|
+
var ciIdLevelMap = getCiAlarmLevelMap(alarmList, risks);
|
34
45
|
return Object.keys(ciIdLevelMap).map(function (id) {
|
35
46
|
return {
|
36
47
|
id: id,
|
37
48
|
level: ciIdLevelMap[id]
|
38
49
|
};
|
50
|
+
}).filter(function (alarm) {
|
51
|
+
var resource = resources.find(function (item) {
|
52
|
+
return item.id === alarm.id;
|
53
|
+
});
|
54
|
+
return !!resource;
|
39
55
|
});
|
40
56
|
}
|
57
|
+
/**
|
58
|
+
* 获得关联拓扑节点告警级别
|
59
|
+
* @param {*} topo
|
60
|
+
* @param {*} relateTopoAlarm
|
61
|
+
* @returns
|
62
|
+
*/
|
63
|
+
|
64
|
+
|
65
|
+
function getRelateTopoNodeAlarmLevels(topo, relateTopoAlarm) {
|
66
|
+
return Object.keys(relateTopoAlarm).map(function (topoId) {
|
67
|
+
var level = relateTopoAlarm[topoId];
|
68
|
+
var relateTopoNode = topo.getDataModel().getDatas().toArray().find(function (node) {
|
69
|
+
return "" + node.a('bindTopo') === "" + topoId;
|
70
|
+
});
|
71
|
+
|
72
|
+
if (!level || !relateTopoNode) {
|
73
|
+
return null;
|
74
|
+
}
|
75
|
+
|
76
|
+
return {
|
77
|
+
elementId: relateTopoNode.getId(),
|
78
|
+
level: level
|
79
|
+
};
|
80
|
+
}).filter(function (item) {
|
81
|
+
return !!item;
|
82
|
+
});
|
83
|
+
} // 获取拓扑图元素最高告警级别。包含资源、链路、关联拓扑节点
|
84
|
+
|
85
|
+
|
86
|
+
function getGraphElementAlarmLevels(resources) {}
|
41
87
|
/**
|
42
88
|
* 告警显示到ht拓扑
|
43
89
|
*
|
@@ -48,7 +94,6 @@ function getCiAlarmLevels(alarmList, risks) {
|
|
48
94
|
function useGraphAlarmDisplay(options) {
|
49
95
|
var topo = options.topo,
|
50
96
|
alarmSwitch = options.alarmSwitch;
|
51
|
-
var store = topo.store;
|
52
97
|
var topoState = topo.store.useModelState('topoMod');
|
53
98
|
var graphLoaded = topoState.graphLoaded,
|
54
99
|
viewState = topoState.viewState;
|
@@ -62,17 +107,7 @@ function useGraphAlarmDisplay(options) {
|
|
62
107
|
var resources = topo.dataModel.useCis();
|
63
108
|
|
64
109
|
function getCisEventLevel() {
|
65
|
-
return
|
66
|
-
var resource = resources.find(function (item) {
|
67
|
-
return item.id === alarm.id;
|
68
|
-
});
|
69
|
-
|
70
|
-
if (!resource) {
|
71
|
-
return false;
|
72
|
-
}
|
73
|
-
|
74
|
-
return true;
|
75
|
-
});
|
110
|
+
return getGraphCiElementAlarmLevels(resources, alarmList || [], risks);
|
76
111
|
}
|
77
112
|
|
78
113
|
(0, _react.useEffect)(function () {
|
@@ -82,8 +117,8 @@ function useGraphAlarmDisplay(options) {
|
|
82
117
|
resources: resources,
|
83
118
|
isEditMode: isEditMode,
|
84
119
|
graphLoaded: graphLoaded,
|
85
|
-
|
86
|
-
cisEventLevel:
|
120
|
+
alarmSwitch: alarmSwitch,
|
121
|
+
cisEventLevel: getCisEventLevel()
|
87
122
|
});
|
88
123
|
|
89
124
|
function showAlarm() {
|
@@ -97,43 +132,30 @@ function useGraphAlarmDisplay(options) {
|
|
97
132
|
return;
|
98
133
|
}
|
99
134
|
|
100
|
-
var finalAlarms = getCisEventLevel(); //
|
135
|
+
var finalAlarms = getCisEventLevel(); // 关联拓扑告警
|
136
|
+
|
137
|
+
var relateTopoAlarms = getRelateTopoNodeAlarmLevels(topo, relateTopoAlarm);
|
138
|
+
var elementsAlarmLevels = [].concat(finalAlarms, relateTopoAlarms); // 将告警级别放入ht元素,便于测试
|
101
139
|
|
102
140
|
(0, _htElementUtils.getElements)(topo.getDataModel()).filter(function (item) {
|
103
141
|
return !!item.getTag();
|
104
142
|
}).forEach(function (element) {
|
105
|
-
var
|
143
|
+
var _elementsAlarmLevels$;
|
106
144
|
|
107
|
-
var alarmLevel = (
|
108
|
-
return item.id === element.getTag();
|
109
|
-
})) === null ||
|
145
|
+
var alarmLevel = (_elementsAlarmLevels$ = elementsAlarmLevels.find(function (item) {
|
146
|
+
return item.id === element.getTag() || item.elementId === element.getId();
|
147
|
+
})) === null || _elementsAlarmLevels$ === void 0 ? void 0 : _elementsAlarmLevels$.level;
|
110
148
|
element.a('alarmLevel', alarmLevel);
|
111
149
|
});
|
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
150
|
|
130
|
-
_rlog["default"].debug('
|
131
|
-
|
151
|
+
_rlog["default"].debug('推送告警 => ht', {
|
152
|
+
alarms: elementsAlarmLevels,
|
153
|
+
relateTopoAlarmMap: relateTopoAlarm,
|
132
154
|
relateTopoAlarms: relateTopoAlarms
|
133
155
|
}); // 更新到ht拓扑
|
134
156
|
|
135
157
|
|
136
|
-
topo.view.loadAlarm(
|
158
|
+
topo.view.loadAlarm(elementsAlarmLevels);
|
137
159
|
}
|
138
160
|
|
139
161
|
return function () {
|
@@ -1001,11 +1001,12 @@ var useTopoEdit = function useTopoEdit(params) {
|
|
1001
1001
|
break;
|
1002
1002
|
}
|
1003
1003
|
|
1004
|
+
topo.historyManager.endTransaction();
|
1005
|
+
|
1004
1006
|
_message["default"].error("关联资源失败");
|
1005
1007
|
|
1006
|
-
_rlog["default"].
|
1008
|
+
_rlog["default"].error("关联资源失败");
|
1007
1009
|
|
1008
|
-
topo.historyManager.endTransaction();
|
1009
1010
|
return _context9.abrupt("return", false);
|
1010
1011
|
|
1011
1012
|
case 23:
|
package/lib/core/models/Alarm.js
CHANGED
@@ -557,25 +557,34 @@ var Alarm = /*#__PURE__*/function () {
|
|
557
557
|
resAndMetrics = this.topo.store.getState().topoMod.resAndMetrics;
|
558
558
|
resIdsList = resAndMetrics.resIdsList, nodeIdsList = resAndMetrics.nodeIdsList, linkIdsList = resAndMetrics.linkIdsList;
|
559
559
|
alarmDispatchers = this.topo.store.getModelDispatchers('topoAlarm'); // 添加事件
|
560
|
-
|
560
|
+
|
561
|
+
console.log("handleAlarmEvent-接收到推送的原始告警信息", alertData);
|
561
562
|
|
562
563
|
if (!((0, _utils.isAvailableArray)(alertData) && (0, _utils.isAvailableArray)(resIdsList))) {
|
563
|
-
_context9.next =
|
564
|
+
_context9.next = 27;
|
564
565
|
break;
|
565
566
|
}
|
566
567
|
|
567
568
|
sendAl = [];
|
568
569
|
idsList = [].concat(nodeIdsList, linkIdsList);
|
569
570
|
operations = [];
|
571
|
+
console.log('idsList---------', idsList);
|
570
572
|
idsList.forEach(function (idItem) {
|
571
573
|
if (idItem.operation === null) {
|
572
574
|
operations.push(idItem.ciId);
|
573
575
|
}
|
574
576
|
});
|
575
577
|
alertData.forEach(function (item, index) {
|
576
|
-
var _item$resourceId;
|
578
|
+
var _item$resourceId, _item$alertCode;
|
577
579
|
|
578
580
|
var ciId = (_item$resourceId = item.resourceId) !== null && _item$resourceId !== void 0 ? _item$resourceId : item.ciId;
|
581
|
+
var isSub = false;
|
582
|
+
|
583
|
+
if ((_item$alertCode = item.alertCode) !== null && _item$alertCode !== void 0 && _item$alertCode.startsWith("cmp")) {
|
584
|
+
ciId = "sub:" + item.mainCiId;
|
585
|
+
isSub = true;
|
586
|
+
}
|
587
|
+
|
579
588
|
var obj = {
|
580
589
|
id: ciId,
|
581
590
|
level: item.alertLevel,
|
@@ -584,28 +593,31 @@ var Alarm = /*#__PURE__*/function () {
|
|
584
593
|
obj: item,
|
585
594
|
info: item.alertType,
|
586
595
|
ciCode: item === null || item === void 0 ? void 0 : item.ciCode,
|
587
|
-
ruleId: item === null || item === void 0 ? void 0 : item.ruleId
|
596
|
+
ruleId: item === null || item === void 0 ? void 0 : item.ruleId,
|
597
|
+
isSub: isSub
|
588
598
|
};
|
589
599
|
|
590
600
|
if (resIdsList.indexOf(ciId) >= 0 && operations.indexOf(ciId) < 0) {
|
591
601
|
sendAl.push(obj);
|
592
|
-
}
|
593
|
-
|
602
|
+
} // const ciId = `${isSub}+${item.resourceId ?? item.ciId}`;
|
603
|
+
|
604
|
+
});
|
605
|
+
console.log("before-combAlarmData", sendAl, idsList);
|
594
606
|
|
595
607
|
if (!(sendAl.length > 0)) {
|
596
|
-
_context9.next =
|
608
|
+
_context9.next = 27;
|
597
609
|
break;
|
598
610
|
}
|
599
611
|
|
600
612
|
_componentTopologyUtils.rlog.debug('过滤掉非本拓扑的告警信息 告警开关-推送告警到ht-alarmIsOpened-sendAl', alarmIsOpened, sendAl);
|
601
613
|
|
602
|
-
_context9.prev =
|
603
|
-
_context9.next =
|
614
|
+
_context9.prev = 15;
|
615
|
+
_context9.next = 18;
|
604
616
|
return alarmDispatchers.combAlarmData({
|
605
617
|
alarmdata: sendAl
|
606
618
|
});
|
607
619
|
|
608
|
-
case
|
620
|
+
case 18:
|
609
621
|
_yield$alarmDispatche2 = _context9.sent;
|
610
622
|
eqFlag = _yield$alarmDispatche2.eqFlag;
|
611
623
|
alarmlist = _yield$alarmDispatche2.alarmlist;
|
@@ -626,20 +638,20 @@ var Alarm = /*#__PURE__*/function () {
|
|
626
638
|
}
|
627
639
|
}
|
628
640
|
|
629
|
-
_context9.next =
|
641
|
+
_context9.next = 27;
|
630
642
|
break;
|
631
643
|
|
632
|
-
case
|
633
|
-
_context9.prev =
|
634
|
-
_context9.t0 = _context9["catch"](
|
644
|
+
case 24:
|
645
|
+
_context9.prev = 24;
|
646
|
+
_context9.t0 = _context9["catch"](15);
|
635
647
|
|
636
648
|
_componentTopologyUtils.rlog.error('告警发送异常', _context9.t0);
|
637
649
|
|
638
|
-
case
|
650
|
+
case 27:
|
639
651
|
case "end":
|
640
652
|
return _context9.stop();
|
641
653
|
}
|
642
|
-
}, _callee9, this, [[
|
654
|
+
}, _callee9, this, [[15, 24]]);
|
643
655
|
}));
|
644
656
|
|
645
657
|
function handleAlarmEvent(_x7) {
|
@@ -54,7 +54,7 @@ var _SelectionModel = _interopRequireDefault(require("./SelectionModel"));
|
|
54
54
|
var _CiCache = _interopRequireDefault(require("./cache/CiCache"));
|
55
55
|
|
56
56
|
// eslint-disable-next-line no-undef
|
57
|
-
var version = typeof "12.0.0-dev.
|
57
|
+
var version = typeof "12.0.0-dev.17" === 'string' ? "12.0.0-dev.17" : null;
|
58
58
|
console.info("\u62D3\u6251\u7248\u672C: " + version);
|
59
59
|
/**
|
60
60
|
* 拓扑显示和编辑
|
@@ -11,7 +11,7 @@ declare class CiCache {
|
|
11
11
|
* @param ids {string[]}
|
12
12
|
* @returns {Promise<Object>}
|
13
13
|
*/
|
14
|
-
load(ids: string[]): Promise<Object>;
|
14
|
+
load(ids: string[], refreshCiCache?: boolean): Promise<Object>;
|
15
15
|
getCi(id: string): Object;
|
16
16
|
}
|
17
17
|
declare const _default: CiCache;
|
@@ -32,14 +32,14 @@ var CiCache = /*#__PURE__*/function () {
|
|
32
32
|
_proto.load =
|
33
33
|
/*#__PURE__*/
|
34
34
|
function () {
|
35
|
-
var _load = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee(ids) {
|
35
|
+
var _load = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee(ids, refreshCiCache) {
|
36
36
|
var _this = this;
|
37
37
|
|
38
38
|
var unloadCiIds, cis, map;
|
39
39
|
return _regenerator["default"].wrap(function _callee$(_context) {
|
40
40
|
while (1) switch (_context.prev = _context.next) {
|
41
41
|
case 0:
|
42
|
-
unloadCiIds = ids.filter(function (id) {
|
42
|
+
unloadCiIds = refreshCiCache === true ? ids : ids.filter(function (id) {
|
43
43
|
return !_this.ciMap[id];
|
44
44
|
});
|
45
45
|
|
@@ -71,7 +71,7 @@ var CiCache = /*#__PURE__*/function () {
|
|
71
71
|
}, _callee, this);
|
72
72
|
}));
|
73
73
|
|
74
|
-
function load(_x) {
|
74
|
+
function load(_x, _x2) {
|
75
75
|
return _load.apply(this, arguments);
|
76
76
|
}
|
77
77
|
|