@riil-frontend/component-topology 3.1.9 → 3.1.12

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.
Files changed (28) hide show
  1. package/CHANGELOG.md +6 -1
  2. package/build/index.js +40 -40
  3. package/demo/1/345/237/272/346/234/254//345/210/207/346/215/242/345/233/276/346/240/207.md +11 -0
  4. package/demo-mock/basic/topo/v1/api/attributes/once +95 -0
  5. package/demo-mock/basic/topo/v1/api/attributes/once.json +96 -1
  6. package/es/components/BatchAttrMetric/index.js +1 -0
  7. package/es/core/common/icons/icon.js +20 -6
  8. package/es/core/components/DisplaySettingDrawer/ResourceDisplay/CommonCheckboxGroup.module.scss +3 -3
  9. package/es/core/components/ResourceViewAttributeSetting/Setting.js +1 -0
  10. package/es/core/models/TopoApp.js +1 -1
  11. package/es/core/viewer/components/plugins/ResourceDetail/ResourceDetail.js +1 -0
  12. package/es/core/viewer/components/plugins/ResourceDetail/ResourceDetailPlugin.js +6 -0
  13. package/es/core/viewer/components/plugins/ResourceDetail/components/ResourceOverview/ResourceOverview.js +660 -0
  14. package/es/core/viewer/components/plugins/ResourceDetail/components/ResourceOverview/index.js +2 -637
  15. package/es/models/customIcon.js +16 -11
  16. package/es/utils/topoData.js +66 -40
  17. package/lib/components/BatchAttrMetric/index.js +1 -0
  18. package/lib/core/common/icons/icon.js +25 -6
  19. package/lib/core/components/DisplaySettingDrawer/ResourceDisplay/CommonCheckboxGroup.module.scss +3 -3
  20. package/lib/core/components/ResourceViewAttributeSetting/Setting.js +1 -0
  21. package/lib/core/models/TopoApp.js +1 -1
  22. package/lib/core/viewer/components/plugins/ResourceDetail/ResourceDetail.js +2 -0
  23. package/lib/core/viewer/components/plugins/ResourceDetail/ResourceDetailPlugin.js +6 -0
  24. package/lib/core/viewer/components/plugins/ResourceDetail/components/ResourceOverview/ResourceOverview.js +691 -0
  25. package/lib/core/viewer/components/plugins/ResourceDetail/components/ResourceOverview/index.js +4 -663
  26. package/lib/models/customIcon.js +16 -11
  27. package/lib/utils/topoData.js +68 -40
  28. package/package.json +2 -2
@@ -0,0 +1,660 @@
1
+ import _Message from "@alifd/next/es/message";
2
+ import _Table from "@alifd/next/es/table";
3
+ import _extends from "@babel/runtime/helpers/extends";
4
+ import _Button from "@alifd/next/es/button";
5
+ import _Icon from "@alifd/next/es/icon";
6
+ import _asyncToGenerator from "@babel/runtime/helpers/asyncToGenerator";
7
+ import _regeneratorRuntime from "@babel/runtime/regenerator";
8
+ import topoService from '@riil-frontend/component-topology-common/es/services/topo';
9
+ import moment from 'moment';
10
+ import React, { useEffect, useMemo, useState } from 'react';
11
+ import { Link } from 'react-router-dom';
12
+ import { findItem } from "../../../../../../../utils/topoData";
13
+ import { queryCisByIds } from "../../../../../../services";
14
+ import alarmService from "../../../../../../services/alarm";
15
+ import service from "../../../../../../services/overview";
16
+ import BaseInfoBlock from "./BaseInfoBlock";
17
+ import BlockBox from "./BlockBox";
18
+ import styles from "./index.module.scss";
19
+ import ResourceOverviewMetric from "./ResourceOverviewMetric";
20
+ import useCiAttrAndMetricData from "./useCiAttrAndMetricData"; // url 处理,UICBB 的地址需截取前缀
21
+
22
+ function formatUrl(url) {
23
+ var _window, _window$location;
24
+
25
+ var prefix = '/default/pagecenter';
26
+
27
+ if (((_window = window) === null || _window === void 0 ? void 0 : (_window$location = _window.location) === null || _window$location === void 0 ? void 0 : _window$location.pathname.indexOf(prefix)) === 0 && (url === null || url === void 0 ? void 0 : url.indexOf(prefix)) === 0) {
28
+ return url.split(prefix)[1];
29
+ } else {
30
+ return url;
31
+ }
32
+ }
33
+ /**
34
+ * 资源概览
35
+ */
36
+
37
+
38
+ export default function ResourceOverview(props) {
39
+ var _viewerProps$resource, _baseInfo$resource;
40
+
41
+ var topo = props.topo,
42
+ id = props.id,
43
+ type = props.type,
44
+ ciType = props.ciType,
45
+ userId = props.userId,
46
+ viewerProps = props.viewerProps;
47
+ var resourceOverviewProps = (viewerProps === null || viewerProps === void 0 ? void 0 : (_viewerProps$resource = viewerProps.resourceDetailProps) === null || _viewerProps$resource === void 0 ? void 0 : _viewerProps$resource.resourceOverviewProps) || {};
48
+ var data = useMemo(function () {
49
+ return topo.dataModel.getDataById(id);
50
+ }, [id]);
51
+ var ciAttrAndMetricData = useCiAttrAndMetricData({
52
+ topo: topo,
53
+ id: id
54
+ });
55
+
56
+ var _useState = useState({
57
+ // 资源
58
+ resource: {
59
+ display_name: '',
60
+ // 资源名称/显示名称
61
+ link: '' // 资源跳转链接
62
+
63
+ },
64
+ ipv4_address: '',
65
+ // IP地址
66
+ asset_number: '',
67
+ // 资产编号
68
+ ciName: '',
69
+ // 资源类型
70
+ res_address: '',
71
+ // 资源位置
72
+ // principal: '', // 负责人
73
+ // 链路
74
+ rated_bandwidth: '',
75
+ // 链路带宽
76
+ source_ipv4: '',
77
+ // 源IP地址
78
+ destination_ipv4: '',
79
+ // 目的IP地址
80
+ source_Interface: '',
81
+ // 源端口
82
+ destination_Interface: '' // 目的端口
83
+
84
+ }),
85
+ baseInfo = _useState[0],
86
+ setBaseInfo = _useState[1];
87
+
88
+ var _useState2 = useState([]),
89
+ indicator = _useState2[0],
90
+ setIndicator = _useState2[1];
91
+
92
+ var _useState3 = useState([]),
93
+ alarmRiskList = _useState3[0],
94
+ setAlarmRiskList = _useState3[1];
95
+
96
+ var _useState4 = useState(false),
97
+ isAppTopo = _useState4[0],
98
+ setIsAppTopo = _useState4[1];
99
+
100
+ var ciTypeMeta = useMemo(function () {
101
+ var typeMeta;
102
+
103
+ if (ciType === 'network_link') {
104
+ // 网络链路要按链路类型查询属性、指标
105
+ var link = topo.dataModel.getDataById(id);
106
+ var linkConnectType = link.attributes['network_link.connect_type'];
107
+ typeMeta = topo.ciTyeCache.getNetworkLinkCiType(linkConnectType);
108
+ } else {
109
+ typeMeta = topo.ciTyeCache.getCiType(ciType);
110
+ }
111
+
112
+ return typeMeta;
113
+ }, [id]);
114
+ useEffect(function () {
115
+ init();
116
+ }, [ciAttrAndMetricData, ciTypeMeta, id]);
117
+
118
+ function init() {
119
+ return _init.apply(this, arguments);
120
+ }
121
+
122
+ function _init() {
123
+ _init = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee() {
124
+ var _topo$options$resourc, _modelAttributeMap$ow, _modelAttributeMap$, _modelAttributeMap$2, _modelAttributeMap$3, _modelAttributeMap$di, _modelAttributeMap$ip, _modelAttributeMap$as, _modelAttributeMap$5, _modelAttributeMap$6, _modelAttributeMap$so, _attributeMap$source_, _modelAttributeMap$de, _attributeMap$destina;
125
+
126
+ var modelMetrics, ciName, modelAttributeMap, domain, displayMetricModels, metricCodes, isAppTopoFlag, attributeMap, metrics, res_address, _attributeMap$, rated_bandwidth, _modelAttributeMap$4;
127
+
128
+ return _regeneratorRuntime.wrap(function _callee$(_context) {
129
+ while (1) {
130
+ switch (_context.prev = _context.next) {
131
+ case 0:
132
+ console.log('初始化/更新概览 props', props); // 指标模型
133
+
134
+ modelMetrics = ciTypeMeta.metrics, ciName = ciTypeMeta.displayName, modelAttributeMap = ciTypeMeta.attributeMap, domain = ciTypeMeta.domain;
135
+ displayMetricModels = modelMetrics.slice(0, 6);
136
+
137
+ if (resourceOverviewProps !== null && resourceOverviewProps !== void 0 && resourceOverviewProps.getMetricCodes) {
138
+ metricCodes = resourceOverviewProps === null || resourceOverviewProps === void 0 ? void 0 : resourceOverviewProps.getMetricCodes({
139
+ id: id,
140
+ type: type,
141
+ ciType: ciType
142
+ });
143
+
144
+ if (metricCodes) {
145
+ displayMetricModels = metricCodes.map(function (code) {
146
+ return modelMetrics.find(function (item) {
147
+ return item.code === code;
148
+ });
149
+ }).filter(function (item) {
150
+ return !!item;
151
+ });
152
+ }
153
+ }
154
+
155
+ displayMetricModels = displayMetricModels.slice(0, 6); // 应用拓扑处理
156
+
157
+ isAppTopoFlag = !!((_topo$options$resourc = topo.options.resourceOverviewDrawer) !== null && _topo$options$resourc !== void 0 && _topo$options$resourc.getData);
158
+ console.log('应用拓扑判断', topo, isAppTopoFlag);
159
+ setIsAppTopo(isAppTopoFlag);
160
+
161
+ if (!isAppTopoFlag) {
162
+ _context.next = 11;
163
+ break;
164
+ }
165
+
166
+ initAppTopo(displayMetricModels, modelAttributeMap, ciName, domain);
167
+ return _context.abrupt("return");
168
+
169
+ case 11:
170
+ // 拓扑(默认) ---------------------------
171
+ // 基本信息
172
+ attributeMap = ciAttrAndMetricData.attributeMap, metrics = ciAttrAndMetricData.metrics;
173
+ console.log('基本信息', attributeMap, modelAttributeMap); // userVisible
174
+ // 位置
175
+
176
+ res_address = false;
177
+
178
+ if (!((_modelAttributeMap$ow = modelAttributeMap.owned_computer_room) !== null && _modelAttributeMap$ow !== void 0 && _modelAttributeMap$ow.userVisible)) {
179
+ _context.next = 20;
180
+ break;
181
+ }
182
+
183
+ _context.next = 17;
184
+ return getAddressFormat(attributeMap);
185
+
186
+ case 17:
187
+ res_address = _context.sent;
188
+ _context.next = 21;
189
+ break;
190
+
191
+ case 20:
192
+ if ((_modelAttributeMap$ = modelAttributeMap[ciType + ".computer_room"]) !== null && _modelAttributeMap$ !== void 0 && _modelAttributeMap$.userVisible || (_modelAttributeMap$2 = modelAttributeMap[ciType + ".area"]) !== null && _modelAttributeMap$2 !== void 0 && _modelAttributeMap$2.userVisible) {
193
+ res_address = attributeMap[ciType + ".computer_room "] || attributeMap[ciType + ".area"] ? " " + (((_attributeMap$ = attributeMap[ciType + ".area_object"]) === null || _attributeMap$ === void 0 ? void 0 : _attributeMap$.displayName) || '') + " " + (attributeMap[ciType + ".computer_room"] || '') : false;
194
+ }
195
+
196
+ case 21:
197
+ // 链路带宽(取实际带宽)
198
+ rated_bandwidth = false;
199
+
200
+ if ((_modelAttributeMap$3 = modelAttributeMap[ciType + ".actual_bandwidth"]) !== null && _modelAttributeMap$3 !== void 0 && _modelAttributeMap$3.userVisible) {
201
+ rated_bandwidth = attributeMap[ciType + ".actual_bandwidth"] ? attributeMap[ciType + ".actual_bandwidth"] + " " + ((_modelAttributeMap$4 = modelAttributeMap[ciType + ".actual_bandwidth"]) === null || _modelAttributeMap$4 === void 0 ? void 0 : _modelAttributeMap$4.unit) : '';
202
+ }
203
+
204
+ setBaseInfo({
205
+ // 资源
206
+ // display_name: modelAttributeMap['display_name'] ? attributeMap.display_name : false,
207
+ resource: (_modelAttributeMap$di = modelAttributeMap.display_name) !== null && _modelAttributeMap$di !== void 0 && _modelAttributeMap$di.userVisible ? {
208
+ display_name: attributeMap.display_name,
209
+ // 资源名称/显示名称
210
+ link: "/default/pagecenter/resDetail/view/" + id + "?resId=" + id + "&domainCode=" + domain + "&title=" + attributeMap.display_name + "&ciCode=" + ciType // 资源跳转链接
211
+
212
+ } : false,
213
+ ipv4_address: (_modelAttributeMap$ip = modelAttributeMap.ipv4_address) !== null && _modelAttributeMap$ip !== void 0 && _modelAttributeMap$ip.userVisible ? attributeMap.ipv4_address : false,
214
+ asset_number: (_modelAttributeMap$as = modelAttributeMap.asset_number) !== null && _modelAttributeMap$as !== void 0 && _modelAttributeMap$as.userVisible ? attributeMap.asset_number : false,
215
+ ciName: ciName,
216
+ res_address: res_address,
217
+ // principal: modelAttributeMap[`${ciType}.principal`] ? attributeMap[`${ciType}.principal`] : false,
218
+ // 链路
219
+ rated_bandwidth: rated_bandwidth,
220
+ source_ipv4: (_modelAttributeMap$5 = modelAttributeMap[ciType + ".source_ipv4"]) !== null && _modelAttributeMap$5 !== void 0 && _modelAttributeMap$5.userVisible ? attributeMap[ciType + ".source_ipv4"] : false,
221
+ destination_ipv4: (_modelAttributeMap$6 = modelAttributeMap[ciType + ".destination_ipv4"]) !== null && _modelAttributeMap$6 !== void 0 && _modelAttributeMap$6.userVisible ? attributeMap[ciType + ".destination_ipv4"] : false,
222
+ source_Interface: (_modelAttributeMap$so = modelAttributeMap.source_id) !== null && _modelAttributeMap$so !== void 0 && _modelAttributeMap$so.userVisible ? (_attributeMap$source_ = attributeMap.source_id_object) === null || _attributeMap$source_ === void 0 ? void 0 : _attributeMap$source_.displayName : false,
223
+ destination_Interface: (_modelAttributeMap$de = modelAttributeMap.destination_id) !== null && _modelAttributeMap$de !== void 0 && _modelAttributeMap$de.userVisible ? (_attributeMap$destina = attributeMap.destination_id_object) === null || _attributeMap$destina === void 0 ? void 0 : _attributeMap$destina.displayName : false
224
+ }); // 资源/链路-关键指标 数据 metrics,模型 topo.ciTyeCache.getCiType(ciType)
225
+
226
+ setIndicator(displayMetricModels.map(function (item) {
227
+ var _findItem;
228
+
229
+ return _extends({}, item, {
230
+ value: ((_findItem = findItem(metrics, 'code', item.code)) === null || _findItem === void 0 ? void 0 : _findItem.value) || ''
231
+ });
232
+ })); // 资源-告警/风险
233
+
234
+ getAlarmRiskData(id);
235
+
236
+ case 26:
237
+ case "end":
238
+ return _context.stop();
239
+ }
240
+ }
241
+ }, _callee);
242
+ }));
243
+ return _init.apply(this, arguments);
244
+ }
245
+
246
+ function initAppTopo(_x, _x2, _x3, _x4) {
247
+ return _initAppTopo.apply(this, arguments);
248
+ } // 获取属性信息(应用拓扑)
249
+
250
+
251
+ function _initAppTopo() {
252
+ _initAppTopo = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2(topModelMetrics, modelAttributeMap, ciName, domain) {
253
+ var _topo$options$resourc2, _modelAttributeMap$ow2, _modelAttributeMap$7, _modelAttributeMap$8, _modelAttributeMap$di2, _modelAttributeMap$ip2, _modelAttributeMap$as2, _alarmList;
254
+
255
+ var _yield$topo$options$r, metrics, alarmList, attributeMap, res_address, _attributeMap$2;
256
+
257
+ return _regeneratorRuntime.wrap(function _callee2$(_context2) {
258
+ while (1) {
259
+ switch (_context2.prev = _context2.next) {
260
+ case 0:
261
+ topo.resourceOverviewDrawer = {
262
+ refreshData: function refreshData() {
263
+ init();
264
+ }
265
+ };
266
+ _context2.next = 3;
267
+ return (_topo$options$resourc2 = topo.options.resourceOverviewDrawer) === null || _topo$options$resourc2 === void 0 ? void 0 : _topo$options$resourc2.getData({
268
+ id: id,
269
+ metrics: topModelMetrics
270
+ });
271
+
272
+ case 3:
273
+ _yield$topo$options$r = _context2.sent;
274
+ metrics = _yield$topo$options$r.metrics;
275
+ alarmList = _yield$topo$options$r.alarms;
276
+ console.log('应用拓扑 参数获取', metrics, alarmList);
277
+ _context2.next = 9;
278
+ return getAttribute(id);
279
+
280
+ case 9:
281
+ attributeMap = _context2.sent;
282
+ // 位置
283
+ res_address = false;
284
+
285
+ if (!((_modelAttributeMap$ow2 = modelAttributeMap.owned_computer_room) !== null && _modelAttributeMap$ow2 !== void 0 && _modelAttributeMap$ow2.userVisible)) {
286
+ _context2.next = 17;
287
+ break;
288
+ }
289
+
290
+ _context2.next = 14;
291
+ return getAddressFormat(attributeMap);
292
+
293
+ case 14:
294
+ res_address = _context2.sent;
295
+ _context2.next = 18;
296
+ break;
297
+
298
+ case 17:
299
+ if ((_modelAttributeMap$7 = modelAttributeMap[ciType + ".computer_room"]) !== null && _modelAttributeMap$7 !== void 0 && _modelAttributeMap$7.userVisible || (_modelAttributeMap$8 = modelAttributeMap[ciType + ".area"]) !== null && _modelAttributeMap$8 !== void 0 && _modelAttributeMap$8.userVisible) {
300
+ res_address = attributeMap[ciType + ".computer_room "] || attributeMap[ciType + ".area"] ? " " + (((_attributeMap$2 = attributeMap[ciType + ".area_object"]) === null || _attributeMap$2 === void 0 ? void 0 : _attributeMap$2.displayName) || '') + " " + (attributeMap[ciType + ".computer_room"] || '') : false;
301
+ }
302
+
303
+ case 18:
304
+ setBaseInfo({
305
+ // 资源
306
+ // display_name: modelAttributeMap['display_name'] ? attributeMap.display_name : false,
307
+ resource: (_modelAttributeMap$di2 = modelAttributeMap.display_name) !== null && _modelAttributeMap$di2 !== void 0 && _modelAttributeMap$di2.userVisible ? {
308
+ display_name: attributeMap.display_name,
309
+ // 资源名称/显示名称
310
+ link: "/default/pagecenter/resDetail/view/" + id + "?resId=" + id + "&domainCode=" + domain + "&title=" + attributeMap.display_name + "&ciCode=" + ciType // 资源跳转链接
311
+
312
+ } : false,
313
+ ipv4_address: (_modelAttributeMap$ip2 = modelAttributeMap.ipv4_address) !== null && _modelAttributeMap$ip2 !== void 0 && _modelAttributeMap$ip2.userVisible ? attributeMap.ipv4_address : false,
314
+ asset_number: (_modelAttributeMap$as2 = modelAttributeMap.asset_number) !== null && _modelAttributeMap$as2 !== void 0 && _modelAttributeMap$as2.userVisible ? attributeMap.asset_number : false,
315
+ ciName: ciName,
316
+ res_address: res_address // principal: modelAttributeMap[`${ciType}.principal`] ? attributeMap[`${ciType}.principal`] : false,
317
+
318
+ });
319
+ setIndicator(topModelMetrics.map(function (item) {
320
+ return _extends({}, item, {
321
+ value: metrics[item.code] || ''
322
+ });
323
+ }));
324
+ alarmList = ((_alarmList = alarmList) === null || _alarmList === void 0 ? void 0 : _alarmList.map(function (item) {
325
+ return {
326
+ type: 'alarm',
327
+ icon: 'gaojing-3',
328
+ className: "alarm-color-icon-lv" + item.alertLevel,
329
+ title: "[" + item.alertObject + "] " + item.alertTitle,
330
+ link: "/default/pagecenter/alertDetail/view/" + item.alertId + "?alertId=" + item.alertId + "&resId=" + item.ciId + "&title=" + item.alertObject + "&ruleId=" + item.ruleId,
331
+ time: item.createTime,
332
+ status: item.status,
333
+ params: [{
334
+ alertId: item.alertId,
335
+ status: 'dealing',
336
+ userId: userId,
337
+ isBaseAlert: false
338
+ }]
339
+ };
340
+ })) || [];
341
+ setAlarmRiskList(alarmList);
342
+
343
+ case 22:
344
+ case "end":
345
+ return _context2.stop();
346
+ }
347
+ }
348
+ }, _callee2);
349
+ }));
350
+ return _initAppTopo.apply(this, arguments);
351
+ }
352
+
353
+ function getAttribute(_x5) {
354
+ return _getAttribute.apply(this, arguments);
355
+ } // 获取地址信息:机房 机柜 起始U-结束U
356
+
357
+
358
+ function _getAttribute() {
359
+ _getAttribute = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee3(id) {
360
+ var res, _ref2, attributes, attributeMap;
361
+
362
+ return _regeneratorRuntime.wrap(function _callee3$(_context3) {
363
+ while (1) {
364
+ switch (_context3.prev = _context3.next) {
365
+ case 0:
366
+ _context3.next = 2;
367
+ return topoService.ciInfo.batchQueryCiInfo({
368
+ ciId: [{
369
+ ciId: id,
370
+ operation: 'delete'
371
+ }],
372
+ codes: [],
373
+ relationId: []
374
+ });
375
+
376
+ case 2:
377
+ res = _context3.sent;
378
+ _ref2 = res[0] || {}, attributes = _ref2.attributes;
379
+ attributeMap = {};
380
+ attributes.forEach(function (item) {
381
+ attributeMap[item.code] = item.value;
382
+ });
383
+ return _context3.abrupt("return", attributeMap);
384
+
385
+ case 7:
386
+ case "end":
387
+ return _context3.stop();
388
+ }
389
+ }
390
+ }, _callee3);
391
+ }));
392
+ return _getAttribute.apply(this, arguments);
393
+ }
394
+
395
+ function getAddressFormat(_x6) {
396
+ return _getAddressFormat.apply(this, arguments);
397
+ } // 获取告警/风险信息
398
+
399
+
400
+ function _getAddressFormat() {
401
+ _getAddressFormat = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee4(_ref) {
402
+ var owned_computer_room, owned_cabinet, start_u_location, end_u_location, address, _res$find, _res$find$attributes, _res$find2, _res$find2$attributes, res, u;
403
+
404
+ return _regeneratorRuntime.wrap(function _callee4$(_context4) {
405
+ while (1) {
406
+ switch (_context4.prev = _context4.next) {
407
+ case 0:
408
+ owned_computer_room = _ref.owned_computer_room, owned_cabinet = _ref.owned_cabinet, start_u_location = _ref.start_u_location, end_u_location = _ref.end_u_location;
409
+ console.log('获取地址信息:', {
410
+ owned_computer_room: owned_computer_room,
411
+ owned_cabinet: owned_cabinet,
412
+ start_u_location: start_u_location,
413
+ end_u_location: end_u_location
414
+ });
415
+ address = '';
416
+
417
+ if (!(owned_computer_room && owned_cabinet)) {
418
+ _context4.next = 8;
419
+ break;
420
+ }
421
+
422
+ _context4.next = 6;
423
+ return queryCisByIds([owned_computer_room, owned_cabinet]);
424
+
425
+ case 6:
426
+ res = _context4.sent;
427
+ address = (((_res$find = res.find(function (item) {
428
+ return item.id === owned_computer_room;
429
+ })) === null || _res$find === void 0 ? void 0 : (_res$find$attributes = _res$find.attributes) === null || _res$find$attributes === void 0 ? void 0 : _res$find$attributes.display_name) || '') + " " + (((_res$find2 = res.find(function (item) {
430
+ return item.id === owned_cabinet;
431
+ })) === null || _res$find2 === void 0 ? void 0 : (_res$find2$attributes = _res$find2.attributes) === null || _res$find2$attributes === void 0 ? void 0 : _res$find2$attributes.display_name) || '');
432
+
433
+ case 8:
434
+ u = '';
435
+
436
+ if (start_u_location || end_u_location) {
437
+ u = (start_u_location || '') + "-" + (end_u_location || '');
438
+ }
439
+
440
+ return _context4.abrupt("return", address || u ? "" + (address || '') + (u ? " " + u : '') : '');
441
+
442
+ case 11:
443
+ case "end":
444
+ return _context4.stop();
445
+ }
446
+ }
447
+ }, _callee4);
448
+ }));
449
+ return _getAddressFormat.apply(this, arguments);
450
+ }
451
+
452
+ function getAlarmRiskData(_x7) {
453
+ return _getAlarmRiskData.apply(this, arguments);
454
+ } // 告警table列配置
455
+
456
+
457
+ function _getAlarmRiskData() {
458
+ _getAlarmRiskData = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee5(id) {
459
+ var _yield$alarmService$g, alarmList, _yield$service$getRis, riskList;
460
+
461
+ return _regeneratorRuntime.wrap(function _callee5$(_context5) {
462
+ while (1) {
463
+ switch (_context5.prev = _context5.next) {
464
+ case 0:
465
+ _context5.next = 2;
466
+ return alarmService.getAlarmByIds([id], {
467
+ alertStatusList: ['toDeal', 'dealing'],
468
+ // toDeal: 待处理, dealing:处理中
469
+ pageNum: 1,
470
+ pageSize: 999,
471
+ sortField: 'alertLevel',
472
+ sortOrder: 'desc'
473
+ });
474
+
475
+ case 2:
476
+ _yield$alarmService$g = _context5.sent;
477
+ alarmList = _yield$alarmService$g.datas;
478
+ alarmList = alarmList.map(function (item) {
479
+ return {
480
+ type: 'alarm',
481
+ icon: 'gaojing-3',
482
+ className: "alarm-color-icon-lv" + item.alertLevel,
483
+ title: "[" + item.alertObject + "] " + item.alertTitle,
484
+ link: "/default/pagecenter/alertDetail/view/" + item.alertId + "?alertId=" + item.alertId + "&resId=" + item.ciId + "&title=" + item.alertObject + "&ruleId=" + item.ruleId,
485
+ time: item.createTime,
486
+ status: item.status,
487
+ params: [{
488
+ alertId: item.alertId,
489
+ status: 'dealing',
490
+ userId: userId,
491
+ isBaseAlert: false
492
+ }]
493
+ };
494
+ });
495
+ _context5.next = 7;
496
+ return service.getRiskByIds({
497
+ ciIdList: [id],
498
+ statusList: ['toDeal', 'dealing'],
499
+ current: 1,
500
+ pageSize: 999
501
+ });
502
+
503
+ case 7:
504
+ _yield$service$getRis = _context5.sent;
505
+ riskList = _yield$service$getRis.content;
506
+ riskList = riskList.map(function (item) {
507
+ return {
508
+ type: 'risk',
509
+ icon: 'Overall_risk_full',
510
+ className: 'risk-icon',
511
+ title: item.itemName,
512
+ link: "/default/inspectionTaskList/inspectionReport?title=" + item.ciName + "&reportId=" + item.executeId + "&reportTime=" + item.executeTime + "&reportType=" + item.viewType + "&reportName=" + item.ciName,
513
+ time: item.firstFoundTime
514
+ };
515
+ });
516
+ console.log('告警和风险', alarmList, riskList);
517
+ setAlarmRiskList([].concat(alarmList, riskList));
518
+
519
+ case 12:
520
+ case "end":
521
+ return _context5.stop();
522
+ }
523
+ }
524
+ }, _callee5);
525
+ }));
526
+ return _getAlarmRiskData.apply(this, arguments);
527
+ }
528
+
529
+ var columns = [{
530
+ title: '描述',
531
+ dataIndex: 'title',
532
+ key: 'title',
533
+ cell: function cell(value, index, record) {
534
+ return /*#__PURE__*/React.createElement("div", {
535
+ className: styles['alarm-title'],
536
+ title: value
537
+ }, /*#__PURE__*/React.createElement(_Icon, {
538
+ type: record.icon,
539
+ size: "xs",
540
+ className: styles['alarm-color-icon'] + " " + record.className
541
+ }), /*#__PURE__*/React.createElement(Link, {
542
+ className: styles.link,
543
+ to: formatUrl(record.link)
544
+ }, value));
545
+ }
546
+ }, {
547
+ title: '时间',
548
+ dataIndex: 'time',
549
+ key: 'time',
550
+ width: 144,
551
+ cell: function cell(value, index, record) {
552
+ return /*#__PURE__*/React.createElement("div", {
553
+ title: moment(value).format('YYYY-MM-DD HH:mm:ss')
554
+ }, moment(value).format('YYYY-MM-DD HH:mm:ss'));
555
+ }
556
+ }, {
557
+ title: '操作',
558
+ dataIndex: 'status',
559
+ key: 'status',
560
+ width: 64,
561
+ cell: function cell(status, index, record) {
562
+ if (record.type === 'alarm') {
563
+ return status === 'toDeal' ? /*#__PURE__*/React.createElement(_Button, {
564
+ text: true,
565
+ type: "primary",
566
+ onClick: function onClick() {
567
+ return alarmRiskOperation(record.type, record.params);
568
+ }
569
+ }, "\u53D7\u7406") : /*#__PURE__*/React.createElement(_Button, {
570
+ disabled: true,
571
+ text: true,
572
+ type: "primary"
573
+ }, "\u5DF2\u53D7\u7406");
574
+ } else {
575
+ // return <Button text type="primary" onClick={() => alarmRiskOperation(record.type, record)}>受理</Button>
576
+ return '';
577
+ }
578
+ }
579
+ }]; // 告警/风险 操作 (受理)
580
+
581
+ function alarmRiskOperation(_x8, _x9) {
582
+ return _alarmRiskOperation.apply(this, arguments);
583
+ }
584
+
585
+ function _alarmRiskOperation() {
586
+ _alarmRiskOperation = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee6(type, params) {
587
+ var res, _topo$ciTyeCache$getC, modelMetrics, ciName, modelAttributeMap, domain, topModelMetrics;
588
+
589
+ return _regeneratorRuntime.wrap(function _callee6$(_context6) {
590
+ while (1) {
591
+ switch (_context6.prev = _context6.next) {
592
+ case 0:
593
+ if (!(type === 'alarm')) {
594
+ _context6.next = 6;
595
+ break;
596
+ }
597
+
598
+ _context6.next = 3;
599
+ return service.handleAlarm(params);
600
+
601
+ case 3:
602
+ res = _context6.sent;
603
+
604
+ _Message.success('受理成功');
605
+
606
+ if (isAppTopo) {
607
+ _topo$ciTyeCache$getC = topo.ciTyeCache.getCiType(ciType), modelMetrics = _topo$ciTyeCache$getC.metrics, ciName = _topo$ciTyeCache$getC.displayName, modelAttributeMap = _topo$ciTyeCache$getC.attributeMap, domain = _topo$ciTyeCache$getC.domain;
608
+ topModelMetrics = modelMetrics.slice(0, 6);
609
+ initAppTopo(topModelMetrics, modelAttributeMap, ciName, domain);
610
+ } else {
611
+ getAlarmRiskData(id);
612
+ }
613
+
614
+ case 6:
615
+ case "end":
616
+ return _context6.stop();
617
+ }
618
+ }
619
+ }, _callee6);
620
+ }));
621
+ return _alarmRiskOperation.apply(this, arguments);
622
+ }
623
+
624
+ var elementData = {
625
+ id: id,
626
+ ciType: ciType,
627
+ type: type,
628
+ name: baseInfo === null || baseInfo === void 0 ? void 0 : (_baseInfo$resource = baseInfo.resource) === null || _baseInfo$resource === void 0 ? void 0 : _baseInfo$resource.display_name
629
+ };
630
+ return /*#__PURE__*/React.createElement("div", {
631
+ className: styles['resource-overview']
632
+ }, /*#__PURE__*/React.createElement(BaseInfoBlock, _extends({
633
+ data: elementData,
634
+ ciTypeMeta: ciTypeMeta,
635
+ baseInfo: baseInfo
636
+ }, resourceOverviewProps === null || resourceOverviewProps === void 0 ? void 0 : resourceOverviewProps.baseInfoProps)), /*#__PURE__*/React.createElement(BlockBox, {
637
+ headerTitle: "\u5173\u952E\u6307\u6807"
638
+ }, /*#__PURE__*/React.createElement(ResourceOverviewMetric, {
639
+ topo: topo,
640
+ type: type,
641
+ x: {
642
+ data: data,
643
+ ciAttrAndMetricData: ciAttrAndMetricData
644
+ },
645
+ data: indicator
646
+ })), /*#__PURE__*/React.createElement(BlockBox, {
647
+ headerTitle: "\u6700\u8FD1\u7684\u544A\u8B66\u548C\u98CE\u9669"
648
+ }, /*#__PURE__*/React.createElement("div", {
649
+ className: styles.alarm
650
+ }, /*#__PURE__*/React.createElement(_Table, {
651
+ hasBorder: false,
652
+ fixedHeader: true,
653
+ columns: columns,
654
+ maxBodyHeight: "auto",
655
+ dataSource: alarmRiskList,
656
+ emptyContent: /*#__PURE__*/React.createElement("div", {
657
+ className: styles['no-data']
658
+ }, "\u6682\u65E0\u6570\u636E")
659
+ }))));
660
+ }