@riil-frontend/component-topology 12.0.0-dev.30 → 12.0.0-dev.32

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.
@@ -88,12 +88,25 @@ var handleRiskData = function handleRiskData(topo, receivedData) {
88
88
  topo.viewProps.onResourceEvent(topo.alarm.getEvents());
89
89
  }
90
90
  };
91
+ /**
92
+ * 关联拓扑告警级别消息处理
93
+ * @param {*} topo
94
+ * @param {*} data
95
+ */
96
+
91
97
 
92
98
  var handleRelateTopoAlarm = function handleRelateTopoAlarm(topo, data) {
93
99
  var relateTopoAlarm = _extends({}, topo.store.getModelState('topoAlarm').relateTopoAlarm);
94
100
 
95
101
  data.forEach(function (item) {
96
- relateTopoAlarm[item.topoId] = item.alertLevel;
102
+ var alertLevel = item.alertLevel;
103
+
104
+ if (alertLevel === -1) {
105
+ // -1表示删除
106
+ delete relateTopoAlarm[item.topoId];
107
+ } else {
108
+ relateTopoAlarm[item.topoId] = item.alertLevel;
109
+ }
97
110
  });
98
111
  topo.store.getModelDispatchers('topoAlarm').update({
99
112
  relateTopoAlarm: relateTopoAlarm
@@ -41,9 +41,6 @@ export default function useCmpLinkAlarm(props) {
41
41
  resources = props.resources,
42
42
  graphLoaded = props.graphLoaded;
43
43
 
44
- var _topo$store$useModelS = topo.store.useModelState('topoBizMod'),
45
- attrsAndMetrics = _topo$store$useModelS.attrsAndMetrics;
46
-
47
44
  var _useState = useState(getCmpLinIds(resources)),
48
45
  cmpLinkIds = _useState[0],
49
46
  setCmpLinkIds = _useState[1];
@@ -24,7 +24,7 @@ import ElementTagTipConfig from "./tagstips/ElementTagTipConfig";
24
24
  import SelectionModel from "./SelectionModel";
25
25
  import CiCache from "./cache/CiCache"; // eslint-disable-next-line no-undef
26
26
 
27
- var version = typeof "12.0.0-dev.30" === 'string' ? "12.0.0-dev.30" : null;
27
+ var version = typeof "12.0.0-dev.32" === 'string' ? "12.0.0-dev.32" : null;
28
28
  console.info("\u62D3\u6251\u7248\u672C: " + version);
29
29
  /**
30
30
  * 拓扑显示和编辑
@@ -8,243 +8,280 @@ import _regeneratorRuntime from "@babel/runtime/regenerator";
8
8
  *
9
9
  */
10
10
  import { rlog } from '@riil-frontend/component-topology-utils';
11
- export default {
12
- // 定义 model 的初始 state
13
- state: {
14
- loading: true,
15
- id: undefined,
16
- viewState: 'view' // view, create, 2种模式
17
-
18
- },
19
- // 定义改变该模型状态的纯函数
20
- reducers: {
21
- update: function update(prevState, payload) {
22
- return _extends({}, prevState, payload);
23
- }
24
- },
25
- // 定义处理该模型副作用的函数
26
- effects: function effects(dispatch) {
27
- return {
28
- /**
29
- * 初始化。
30
- */
31
- initData: function initData(params, rootState) {
32
- var _this = this;
33
-
34
- return _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee() {
35
- var topoModState, viewType, id, topoTreeModState;
36
- return _regeneratorRuntime.wrap(function _callee$(_context) {
37
- while (1) switch (_context.prev = _context.next) {
38
- case 0:
39
- if (params === void 0) {
40
- params = {};
41
- }
42
-
43
- topoModState = rootState.topoMod;
44
- viewType = params.type || 'view';
45
- id = params.id || topoModState.topoId || '';
46
-
47
- _this.update({
48
- loading: true,
49
- viewState: viewType
50
- }); // 加载功能操作权限
51
-
52
-
53
- _context.next = 7;
54
- return dispatch.functionAuth.init();
55
-
56
- case 7:
57
- // 加载拓扑树数据
58
- topoTreeModState = rootState.topoTreeMod;
59
-
60
- if (topoTreeModState.loaded) {
61
- _context.next = 16;
11
+ import { parseTopoData } from "../../utils/topoData";
12
+ export default function (topo) {
13
+ return {
14
+ // 定义 model 的初始 state
15
+ state: {
16
+ loading: true,
17
+ id: undefined,
18
+ viewState: 'view' // view, create, 2种模式
19
+
20
+ },
21
+ // 定义改变该模型状态的纯函数
22
+ reducers: {
23
+ update: function update(prevState, payload) {
24
+ return _extends({}, prevState, payload);
25
+ }
26
+ },
27
+ // 定义处理该模型副作用的函数
28
+ effects: function effects(dispatch) {
29
+ return {
30
+ /**
31
+ * 初始化。
32
+ */
33
+ initData: function initData(params, rootState) {
34
+ var _this = this;
35
+
36
+ return _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee() {
37
+ var topoModState, viewType, id, topoTreeModState;
38
+ return _regeneratorRuntime.wrap(function _callee$(_context) {
39
+ while (1) switch (_context.prev = _context.next) {
40
+ case 0:
41
+ if (params === void 0) {
42
+ params = {};
43
+ }
44
+
45
+ topoModState = rootState.topoMod;
46
+ viewType = params.type || 'view';
47
+ id = params.id || topoModState.topoId || '';
48
+
49
+ _this.update({
50
+ loading: true,
51
+ viewState: viewType
52
+ }); // 加载功能操作权限
53
+
54
+
55
+ _context.next = 7;
56
+ return dispatch.functionAuth.init();
57
+
58
+ case 7:
59
+ // 加载拓扑树数据
60
+ topoTreeModState = rootState.topoTreeMod;
61
+
62
+ if (topoTreeModState.loaded) {
63
+ _context.next = 16;
64
+ break;
65
+ }
66
+
67
+ _context.next = 11;
68
+ return dispatch.topoTreeMod.fetchTopoTree({
69
+ id: id
70
+ });
71
+
72
+ case 11:
73
+ _context.next = 13;
74
+ return dispatch.topoTreeMod.getSelectedTopoId();
75
+
76
+ case 13:
77
+ id = _context.sent;
78
+ _context.next = 18;
62
79
  break;
63
- }
64
80
 
65
- _context.next = 11;
66
- return dispatch.topoTreeMod.fetchTopoTree({
67
- id: id
68
- });
81
+ case 16:
82
+ _context.next = 18;
83
+ return _this.refreshTopoTree();
69
84
 
70
- case 11:
71
- _context.next = 13;
72
- return dispatch.topoTreeMod.getSelectedTopoId();
85
+ case 18:
86
+ if (id) {
87
+ // 左侧树切换选中
88
+ dispatch.topoTreeMod.selectNode(id);
89
+ }
73
90
 
74
- case 13:
75
- id = _context.sent;
76
- _context.next = 18;
77
- break;
91
+ if (!(viewType === 'create')) {
92
+ _context.next = 24;
93
+ break;
94
+ }
78
95
 
79
- case 16:
80
- _context.next = 18;
81
- return _this.refreshTopoTree();
82
-
83
- case 18:
84
- if (id) {
85
- // 左侧树切换选中
86
- dispatch.topoTreeMod.selectNode(id);
87
- }
96
+ _context.next = 22;
97
+ return _this.openCreateTopoPage({
98
+ id: id
99
+ });
88
100
 
89
- if (!(viewType === 'create')) {
90
- _context.next = 24;
101
+ case 22:
102
+ _context.next = 29;
91
103
  break;
92
- }
93
104
 
94
- _context.next = 22;
95
- return _this.openCreateTopoPage({
96
- id: id
97
- });
105
+ case 24:
106
+ if (!params.selectedElementTag) {
107
+ _context.next = 27;
108
+ break;
109
+ }
98
110
 
99
- case 22:
100
- _context.next = 29;
101
- break;
102
-
103
- case 24:
104
- if (!params.selectedElementTag) {
105
111
  _context.next = 27;
106
- break;
107
- }
112
+ return dispatch.selection.update({
113
+ initSelectionId: params.selectedElementTag
114
+ });
108
115
 
109
- _context.next = 27;
110
- return dispatch.selection.update({
111
- initSelectionId: params.selectedElementTag
112
- });
116
+ case 27:
117
+ _context.next = 29;
118
+ return dispatch.topoMod.initData(_extends({}, params, {
119
+ type: params.type,
120
+ id: id
121
+ }));
113
122
 
114
- case 27:
115
- _context.next = 29;
116
- return dispatch.topoMod.initData(_extends({}, params, {
117
- type: params.type,
118
- id: id
119
- }));
123
+ case 29:
124
+ _this.update({
125
+ loading: false
126
+ }); // 是否打开概览
120
127
 
121
- case 29:
122
- _this.update({
123
- loading: false
124
- }); // 是否打开概览
125
128
 
129
+ if (!params.openResourceOverview) {
130
+ _context.next = 33;
131
+ break;
132
+ }
126
133
 
127
- if (!params.openResourceOverview) {
128
134
  _context.next = 33;
135
+ return dispatch.resourceDetail.update({
136
+ visible: true,
137
+ id: params.openResourceOverview
138
+ });
139
+
140
+ case 33:
141
+ case "end":
142
+ return _context.stop();
143
+ }
144
+ }, _callee);
145
+ }))();
146
+ },
147
+
148
+ /**
149
+ * 退出。
150
+ */
151
+ exit: function exit(playload, rootState) {
152
+ return _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2() {
153
+ return _regeneratorRuntime.wrap(function _callee2$(_context2) {
154
+ while (1) switch (_context2.prev = _context2.next) {
155
+ case 0:
156
+ _context2.next = 2;
157
+ return dispatch.topoMod.exit(playload);
158
+
159
+ case 2:
160
+ case "end":
161
+ return _context2.stop();
162
+ }
163
+ }, _callee2);
164
+ }))();
165
+ },
166
+ openCreateTopoPage: function openCreateTopoPage(playload, state) {
167
+ var _this2 = this;
168
+
169
+ return _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee3() {
170
+ return _regeneratorRuntime.wrap(function _callee3$(_context3) {
171
+ while (1) switch (_context3.prev = _context3.next) {
172
+ case 0:
173
+ if (playload === void 0) {
174
+ playload = {};
175
+ }
176
+
177
+ _this2.update({
178
+ viewState: 'create',
179
+ id: playload.id
180
+ });
181
+
182
+ dispatch.topoCreate.init(playload); // history.replace(`/default/topoCenter?type=create&id=${playload.id}`);
183
+
184
+ case 3:
185
+ case "end":
186
+ return _context3.stop();
187
+ }
188
+ }, _callee3);
189
+ }))();
190
+ },
191
+
192
+ /**
193
+ *
194
+ * @param playload {{id: string, linkTo:?object}}
195
+ */
196
+ openTopoPage: function openTopoPage(playload, rootState) {
197
+ var _this3 = this;
198
+
199
+ return _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee4() {
200
+ var id, viewState;
201
+ return _regeneratorRuntime.wrap(function _callee4$(_context4) {
202
+ while (1) switch (_context4.prev = _context4.next) {
203
+ case 0:
204
+ id = playload.id, viewState = playload.viewState; // 左侧树切换选中
205
+
206
+ dispatch.topoTreeMod.selectNode(id);
207
+
208
+ _this3.update({
209
+ viewState: viewState || 'view'
210
+ });
211
+
212
+ if (!id) {
213
+ _context4.next = 8;
214
+ break;
215
+ }
216
+
217
+ _context4.next = 6;
218
+ return dispatch.topoMod.openTopoPage(playload);
219
+
220
+ case 6:
221
+ _context4.next = 10;
129
222
  break;
130
- }
131
-
132
- _context.next = 33;
133
- return dispatch.resourceDetail.update({
134
- visible: true,
135
- id: params.openResourceOverview
136
- });
137
-
138
- case 33:
139
- case "end":
140
- return _context.stop();
141
- }
142
- }, _callee);
143
- }))();
144
- },
145
-
146
- /**
147
- * 退出。
148
- */
149
- exit: function exit(playload, rootState) {
150
- return _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2() {
151
- return _regeneratorRuntime.wrap(function _callee2$(_context2) {
152
- while (1) switch (_context2.prev = _context2.next) {
153
- case 0:
154
- _context2.next = 2;
155
- return dispatch.topoMod.exit(playload);
156
-
157
- case 2:
158
- case "end":
159
- return _context2.stop();
160
- }
161
- }, _callee2);
162
- }))();
163
- },
164
- openCreateTopoPage: function openCreateTopoPage(playload, state) {
165
- var _this2 = this;
166
-
167
- return _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee3() {
168
- return _regeneratorRuntime.wrap(function _callee3$(_context3) {
169
- while (1) switch (_context3.prev = _context3.next) {
170
- case 0:
171
- if (playload === void 0) {
172
- playload = {};
173
- }
174
-
175
- _this2.update({
176
- viewState: 'create',
177
- id: playload.id
178
- });
179
-
180
- dispatch.topoCreate.init(playload); // history.replace(`/default/topoCenter?type=create&id=${playload.id}`);
181
-
182
- case 3:
183
- case "end":
184
- return _context3.stop();
185
- }
186
- }, _callee3);
187
- }))();
188
- },
189
-
190
- /**
191
- *
192
- * @param playload {{id: string, linkTo:?object}}
193
- */
194
- openTopoPage: function openTopoPage(playload, rootState) {
195
- var _this3 = this;
196
-
197
- return _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee4() {
198
- var id, viewState;
199
- return _regeneratorRuntime.wrap(function _callee4$(_context4) {
200
- while (1) switch (_context4.prev = _context4.next) {
201
- case 0:
202
- id = playload.id, viewState = playload.viewState; // 左侧树切换选中
203
-
204
- dispatch.topoTreeMod.selectNode(id);
205
-
206
- _this3.update({
207
- viewState: viewState || 'view'
208
- });
209
-
210
- if (!id) {
211
- _context4.next = 8;
212
- break;
213
- }
214
-
215
- _context4.next = 6;
216
- return dispatch.topoMod.openTopoPage(playload);
217
-
218
- case 6:
219
- _context4.next = 10;
220
- break;
221
-
222
- case 8:
223
- _context4.next = 10;
224
- return dispatch.topoMod.clearData();
225
-
226
- case 10:
227
- case "end":
228
- return _context4.stop();
229
- }
230
- }, _callee4);
231
- }))();
232
- },
233
- refreshTopoTree: function refreshTopoTree() {
234
- return _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee5() {
235
- return _regeneratorRuntime.wrap(function _callee5$(_context5) {
236
- while (1) switch (_context5.prev = _context5.next) {
237
- case 0:
238
- _context5.next = 2;
239
- return dispatch.topoTreeMod.refreshTree();
240
-
241
- case 2:
242
- case "end":
243
- return _context5.stop();
244
- }
245
- }, _callee5);
246
- }))();
247
- }
248
- };
249
- }
250
- };
223
+
224
+ case 8:
225
+ _context4.next = 10;
226
+ return dispatch.topoMod.clearData();
227
+
228
+ case 10:
229
+ case "end":
230
+ return _context4.stop();
231
+ }
232
+ }, _callee4);
233
+ }))();
234
+ },
235
+ refreshTopoTree: function refreshTopoTree() {
236
+ return _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee5() {
237
+ return _regeneratorRuntime.wrap(function _callee5$(_context5) {
238
+ while (1) switch (_context5.prev = _context5.next) {
239
+ case 0:
240
+ _context5.next = 2;
241
+ return dispatch.topoTreeMod.refreshTree();
242
+
243
+ case 2:
244
+ case "end":
245
+ return _context5.stop();
246
+ }
247
+ }, _callee5);
248
+ }))();
249
+ },
250
+ refreshGlobalConfig: function refreshGlobalConfig() {
251
+ return _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee6() {
252
+ var result, extraConfig;
253
+ return _regeneratorRuntime.wrap(function _callee6$(_context6) {
254
+ while (1) switch (_context6.prev = _context6.next) {
255
+ case 0:
256
+ if (topo.id) {
257
+ _context6.next = 2;
258
+ break;
259
+ }
260
+
261
+ return _context6.abrupt("return");
262
+
263
+ case 2:
264
+ _context6.next = 4;
265
+ return topo.options.loadData(topo.id, topo.serverApi);
266
+
267
+ case 4:
268
+ result = _context6.sent;
269
+ result = parseTopoData(result);
270
+ extraConfig = result.global.extraConfig;
271
+ _context6.next = 9;
272
+ return dispatch.displayConfig.setConfig(_extends({}, extraConfig, {
273
+ alarmSwitch: result.global.alarmSwitch,
274
+ alarmListDefaultOpen: result.global.alarmListDefaultOpen
275
+ }));
276
+
277
+ case 9:
278
+ case "end":
279
+ return _context6.stop();
280
+ }
281
+ }, _callee6);
282
+ }))();
283
+ }
284
+ };
285
+ }
286
+ };
287
+ }
@@ -102,11 +102,24 @@ var handleRiskData = function handleRiskData(topo, receivedData) {
102
102
  topo.viewProps.onResourceEvent(topo.alarm.getEvents());
103
103
  }
104
104
  };
105
+ /**
106
+ * 关联拓扑告警级别消息处理
107
+ * @param {*} topo
108
+ * @param {*} data
109
+ */
110
+
105
111
 
106
112
  var handleRelateTopoAlarm = function handleRelateTopoAlarm(topo, data) {
107
113
  var relateTopoAlarm = (0, _extends2["default"])({}, topo.store.getModelState('topoAlarm').relateTopoAlarm);
108
114
  data.forEach(function (item) {
109
- relateTopoAlarm[item.topoId] = item.alertLevel;
115
+ var alertLevel = item.alertLevel;
116
+
117
+ if (alertLevel === -1) {
118
+ // -1表示删除
119
+ delete relateTopoAlarm[item.topoId];
120
+ } else {
121
+ relateTopoAlarm[item.topoId] = item.alertLevel;
122
+ }
110
123
  });
111
124
  topo.store.getModelDispatchers('topoAlarm').update({
112
125
  relateTopoAlarm: relateTopoAlarm
@@ -53,9 +53,6 @@ function useCmpLinkAlarm(props) {
53
53
  resources = props.resources,
54
54
  graphLoaded = props.graphLoaded;
55
55
 
56
- var _topo$store$useModelS = topo.store.useModelState('topoBizMod'),
57
- attrsAndMetrics = _topo$store$useModelS.attrsAndMetrics;
58
-
59
56
  var _useState = (0, _react.useState)(getCmpLinIds(resources)),
60
57
  cmpLinkIds = _useState[0],
61
58
  setCmpLinkIds = _useState[1];
@@ -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.30" === 'string' ? "12.0.0-dev.30" : null;
57
+ var version = typeof "12.0.0-dev.32" === 'string' ? "12.0.0-dev.32" : null;
58
58
  console.info("\u62D3\u6251\u7248\u672C: " + version);
59
59
  /**
60
60
  * 拓扑显示和编辑