@riil-frontend/component-topology 2.15.1 → 2.15.4

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.
@@ -5,5 +5,8 @@
5
5
  .#{$css-prefix}collapse-panel-title:hover {
6
6
  color: var(--collapse-title-font-color);
7
7
  }
8
+ .#{$css-prefix}collapse-panel-title:hover .#{$css-prefix}collapse-panel-icon {
9
+ color: var(--collapse-title-font-color);
10
+ }
8
11
  }
9
12
  }
@@ -4,4 +4,5 @@ export var RESOURCE_LIMIT_TYPES = [// 网络设备
4
4
  'linux', 'windows', // 数据库
5
5
  'oracle', 'asm_disk_group', 'oracle_rac', // 中间件
6
6
  'tomcat', // 业务
7
- 'app', 'service'];
7
+ 'app', 'service', // 虚拟化
8
+ 'virtual_mgmt_node', 'virtual_data_center', 'virtual_cluster', 'virtual_storage', 'virtual_vm', 'virtual_host', 'virtual_switch'];
@@ -3,6 +3,7 @@ import os from '@riil-frontend/component-topology-graph/es/icons/ciTypeIcons/os'
3
3
  import db from '@riil-frontend/component-topology-graph/es/icons/ciTypeIcons/db';
4
4
  import appMiddleware from '@riil-frontend/component-topology-graph/es/icons/ciTypeIcons/app_middleware';
5
5
  import businessSystem from '@riil-frontend/component-topology-graph/es/icons/ciTypeIcons/business_system';
6
+ import virtual from '@riil-frontend/component-topology-graph/es/icons/ciTypeIcons/virtual';
6
7
  export default function getNetworkTopoCiTypeIcons() {
7
- return [].concat(network(), os(), db(), appMiddleware(), businessSystem());
8
+ return [].concat(network(), os(), db(), appMiddleware(), businessSystem(), virtual());
8
9
  }
@@ -3,10 +3,12 @@ import _extends from "@babel/runtime/helpers/extends";
3
3
  import _regeneratorRuntime from "@babel/runtime/regenerator";
4
4
  import topoServer from '@riil-frontend/component-topology-common/es/services/topo';
5
5
  import rlog from '@riil-frontend/component-topology-utils/es/rlog';
6
+ import { keyBy } from 'lodash';
6
7
  import groupBy from 'lodash/groupBy';
7
8
  import { DEFAULT_LINK_TAG_COMMON_CONFIG, DEFAULT_NODE_TAG_COMMON_CONFIG, DEFAULT_TAG_COMMON_CONFIG, DEFAULT_TIP_COMMON_CONFIG } from "../../constants/ResourceInfoDisplay";
8
9
  import { getEdgeGroupByNodeTags } from "../../utils/htElementUtils";
9
10
  import { findItem } from "../../utils/topoData";
11
+ import { queryCisByIds } from "../services";
10
12
  import AttributeFormatter from "./attributeFormatter";
11
13
  import DictCache from "./cache/DictCache";
12
14
 
@@ -292,23 +294,27 @@ var AttributeMetricDisplay = /*#__PURE__*/function () {
292
294
  }
293
295
 
294
296
  return visible;
295
- }
296
- /**
297
- * 根据配置执行节点名称显示隐藏
298
- */
299
- ;
297
+ };
300
298
 
301
- _proto.updateNodesNameVisible = function updateNodesNameVisible() {
299
+ _proto.getNodesNameVisible = function getNodesNameVisible() {
302
300
  var _this3 = this;
303
301
 
304
- var dm = this.topo.getDataModel();
305
302
  var nodes = this.topo.store.getModelState('topoMod').data.nodes;
306
- nodes.map(function (node) {
303
+ return nodes.map(function (node) {
307
304
  return {
308
305
  id: node.id,
309
306
  visible: _this3.getNodeNameVisible(node)
310
307
  };
311
- }).forEach(function (_ref3) {
308
+ });
309
+ }
310
+ /**
311
+ * 根据配置执行节点名称显示隐藏
312
+ */
313
+ ;
314
+
315
+ _proto.updateNodesNameVisible = function updateNodesNameVisible() {
316
+ var dm = this.topo.getDataModel();
317
+ this.getNodesNameVisible().forEach(function (_ref3) {
312
318
  var id = _ref3.id,
313
319
  visible = _ref3.visible;
314
320
  dm.getDataByTag(id).a('isShowName', visible);
@@ -431,25 +437,37 @@ var AttributeMetricDisplay = /*#__PURE__*/function () {
431
437
  /*#__PURE__*/
432
438
  function () {
433
439
  var _loadAttributeAndMetric = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2(data) {
434
- var topo, bizDispatchers;
440
+ var topo, ciDatas, bizDispatchers;
435
441
  return _regeneratorRuntime.wrap(function _callee2$(_context2) {
436
442
  while (1) {
437
443
  switch (_context2.prev = _context2.next) {
438
444
  case 0:
439
445
  // rlog.debug('AttributeMetricDisplay.loadAttributeAndMetric', data);
440
- topo = this.topo;
441
- bizDispatchers = topo.store.getModelDispatchers('topoBizMod');
446
+ topo = this.topo; // 设置ciType
447
+
448
+ ciDatas = data.map(function (item) {
449
+ return _extends({
450
+ ciType: topo.dataModel.getDataById(item.id).ciType
451
+ }, item);
452
+ }); // 翻译引用属性
453
+
442
454
  _context2.next = 4;
443
- return bizDispatchers.setAttrsAndMetrics(data);
455
+ return this.translateRefAttribute(ciDatas);
444
456
 
445
457
  case 4:
446
- _context2.next = 6;
458
+ ciDatas = _context2.sent;
459
+ bizDispatchers = topo.store.getModelDispatchers('topoBizMod');
460
+ _context2.next = 8;
461
+ return bizDispatchers.setAttrsAndMetrics(ciDatas);
462
+
463
+ case 8:
464
+ _context2.next = 10;
447
465
  return DictCache.init();
448
466
 
449
- case 6:
467
+ case 10:
450
468
  this.updateTagsTips();
451
469
 
452
- case 7:
470
+ case 11:
453
471
  case "end":
454
472
  return _context2.stop();
455
473
  }
@@ -463,6 +481,95 @@ var AttributeMetricDisplay = /*#__PURE__*/function () {
463
481
 
464
482
  return loadAttributeAndMetric;
465
483
  }()
484
+ /**
485
+ * 临时由前端翻译引用属性名称
486
+ * @param {*} ciDatas
487
+ * @returns
488
+ */
489
+ ;
490
+
491
+ _proto.translateRefAttribute =
492
+ /*#__PURE__*/
493
+ function () {
494
+ var _translateRefAttribute = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee3(ciDatas) {
495
+ var _this5 = this;
496
+
497
+ var refIdMap, ciRefAttributeMap, refIds, refCis, refCiMap;
498
+ return _regeneratorRuntime.wrap(function _callee3$(_context3) {
499
+ while (1) {
500
+ switch (_context3.prev = _context3.next) {
501
+ case 0:
502
+ // 查找引用字段及值
503
+ refIdMap = {};
504
+ ciRefAttributeMap = {};
505
+ ciDatas.forEach(function (ciData) {
506
+ var id = ciData.id,
507
+ ciType = ciData.ciType,
508
+ attributeMap = ciData.attributeMap;
509
+ ciRefAttributeMap[id] = [];
510
+
511
+ _this5.topo.ciTyeCache.getCiType(ciType).attributes.filter(function (attributeMeta) {
512
+ return !!attributeMeta.refCi;
513
+ }).forEach(function (attributeMeta) {
514
+ var refId = attributeMap[attributeMeta.code];
515
+
516
+ if (refId && !refIdMap[refId]) {
517
+ refIdMap[refId] = true;
518
+ }
519
+
520
+ ciRefAttributeMap[id].push({
521
+ attrCode: attributeMeta.code,
522
+ id: refId
523
+ });
524
+ });
525
+ });
526
+ refIds = Object.keys(refIdMap); // 查询引用对象
527
+
528
+ _context3.next = 6;
529
+ return queryCisByIds(refIds);
530
+
531
+ case 6:
532
+ refCis = _context3.sent;
533
+ refCiMap = keyBy(refCis, 'id');
534
+ rlog.debug('translateRefAttribute', {
535
+ ciRefAttributeMap: ciRefAttributeMap,
536
+ refIds: refIds,
537
+ refCiMap: refCiMap
538
+ }); // 引用对象设置到数据
539
+
540
+ return _context3.abrupt("return", ciDatas.map(function (ciData) {
541
+ var id = ciData.id;
542
+
543
+ var attributeMap = _extends({}, ciData);
544
+
545
+ ciRefAttributeMap[id].forEach(function (refAttrs) {
546
+ var refCi = refCiMap[refAttrs.id];
547
+
548
+ if (refCi) {
549
+ attributeMap[refAttrs.attrCode + "_object"] = {
550
+ displayName: refCi.attributes.display_name
551
+ };
552
+ }
553
+ });
554
+ return _extends({}, ciData, {
555
+ attributeMap: attributeMap
556
+ });
557
+ }));
558
+
559
+ case 10:
560
+ case "end":
561
+ return _context3.stop();
562
+ }
563
+ }
564
+ }, _callee3);
565
+ }));
566
+
567
+ function translateRefAttribute(_x2) {
568
+ return _translateRefAttribute.apply(this, arguments);
569
+ }
570
+
571
+ return translateRefAttribute;
572
+ }()
466
573
  /**
467
574
  * 推送标注、悬浮框数据 => ht
468
575
  * @returns
@@ -538,7 +645,7 @@ var AttributeMetricDisplay = /*#__PURE__*/function () {
538
645
  ;
539
646
 
540
647
  _proto.getEdgeGroupTagsAndTips = function getEdgeGroupTagsAndTips(data, ciConfigs) {
541
- var _this5 = this;
648
+ var _this6 = this;
542
649
 
543
650
  // 查询没有关联链路的连线组及对应子链路列表
544
651
  var _this$topo$store$getM2 = this.topo.store.getModelState('topoMod').data,
@@ -605,7 +712,7 @@ var AttributeMetricDisplay = /*#__PURE__*/function () {
605
712
  var edgeGroupsTagsTips = Object.keys(groupMap) // 过滤非连线组
606
713
  .filter(function (groupId) {
607
714
  var linkChildren = groupMap[groupId];
608
- var edgeGroup = getEdgeGroupByNodeTags(_this5.topo.getDataModel(), linkChildren[0].source, linkChildren[0].target);
715
+ var edgeGroup = getEdgeGroupByNodeTags(_this6.topo.getDataModel(), linkChildren[0].source, linkChildren[0].target);
609
716
  return !!edgeGroup;
610
717
  }).map(function (groupId) {
611
718
  var linkChildren = groupMap[groupId]; // 查询配置,过滤不在范围内的属性
@@ -650,7 +757,7 @@ var AttributeMetricDisplay = /*#__PURE__*/function () {
650
757
  }); // console.error(groupId, {config, linkChildrenData, mergeData})
651
758
  // 构造标注、悬浮框数据
652
759
 
653
- var formatter = new AttributeFormatter(_this5.topo);
760
+ var formatter = new AttributeFormatter(_this6.topo);
654
761
  return {
655
762
  type: 'edgeGroup',
656
763
  edgeGroupId: groupId,
@@ -18,7 +18,7 @@ import DataModel from "./DataModel";
18
18
  import GraphDataModel from "./GraphDataModel";
19
19
  import { updateEdgeExpanded } from "../utils/edgeUtil"; // eslint-disable-next-line no-undef
20
20
 
21
- var version = typeof "2.15.1" === 'string' ? "2.15.1" : null;
21
+ var version = typeof "2.15.4" === 'string' ? "2.15.4" : null;
22
22
  console.info("\u62D3\u6251\u7248\u672C: " + version);
23
23
  var topoDebug = {};
24
24
  window.topoDebug = topoDebug;
@@ -57,7 +57,7 @@ var CiTyeCache = /*#__PURE__*/function () {
57
57
  var _load = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2(ciTypeIds) {
58
58
  var _this = this;
59
59
 
60
- var unLoadCiTypeIds, ciTypes, cache;
60
+ var unLoadCiTypeIds, ciTypeMetas, cache;
61
61
  return _regeneratorRuntime.wrap(function _callee2$(_context2) {
62
62
  while (1) {
63
63
  switch (_context2.prev = _context2.next) {
@@ -69,12 +69,16 @@ var CiTyeCache = /*#__PURE__*/function () {
69
69
  return topoService.ciInfo.batchQueryCiTypeInfo(unLoadCiTypeIds);
70
70
 
71
71
  case 3:
72
- ciTypes = _context2.sent;
72
+ ciTypeMetas = _context2.sent;
73
73
  cache = _extends({}, this.cache);
74
- ciTypes.forEach(function (ciTypeMeta) {
74
+ ciTypeMetas.forEach(function (ciTypeMeta) {
75
+ var attributes = ciTypeMeta.attributes || [];
76
+ var metrics = ciTypeMeta.metrics || [];
75
77
  cache[ciTypeMeta.code] = _extends({}, ciTypeMeta, {
76
- attributeMap: keyBy(ciTypeMeta.attributes || [], 'code'),
77
- metricMap: keyBy(ciTypeMeta.metrics || [], 'code')
78
+ attributes: attributes,
79
+ metrics: metrics,
80
+ attributeMap: keyBy(attributes, 'code'),
81
+ metricMap: keyBy(metrics, 'code')
78
82
  });
79
83
  });
80
84
  this.cache = cache;
@@ -10,13 +10,12 @@ export default function EditButton(props) {
10
10
  var topo = props.topo,
11
11
  onEnterEdit = props.onEnterEdit,
12
12
  style = props.style;
13
- var store = topo.store;
13
+ var store = topo.store; // const [topoState] = store.useModel('topoMod');
14
+ // const { topoPermission, } = topoState;
14
15
 
15
- var _store$useModel = store.useModel('topoMod'),
16
- topoState = _store$useModel[0];
16
+ var functionAuthState = store.useModelState('functionAuth'); // let show = topo.options.usePermission ? topoPermissonUtil.isEditable(topoPermission) : true;
17
17
 
18
- var topoPermission = topoState.topoPermission;
19
- var show = topo.options.usePermission ? topoPermissonUtil.isEditable(topoPermission) : true;
18
+ var show = topo.options.usePermission ? functionAuthState.permissions.createTopo : true;
20
19
 
21
20
  if (!show) {
22
21
  return null;
@@ -427,6 +427,10 @@ export default function (topoApp) {
427
427
  customIcons = _yield$Promise$all[1];
428
428
  rlog.debug("topoMod.initTopoData Ci属性指标元数据", ciTypeMap);
429
429
  globalConfig = result.global.extraConfig;
430
+ _context6.next = 47;
431
+ return dispatch.displayConfig.setConfig(globalConfig);
432
+
433
+ case 47:
430
434
  _combTopoData = combTopoData({
431
435
  engine: topoApp,
432
436
  data: result,
@@ -445,7 +449,6 @@ export default function (topoApp) {
445
449
  });
446
450
 
447
451
  dispatch.topoBizMod.combBatchCiInfo(resAndMetrics);
448
- dispatch.displayConfig.setConfig(globalConfig);
449
452
  dispatch.background.init(globalConfig); // TODO 优化打开拓扑图显示告警速度:打开拓扑图立即请求告警
450
453
 
451
454
  if (getAlarmSwitch(topoData)) {
@@ -457,7 +460,7 @@ export default function (topoApp) {
457
460
  rlog.info("topoMod.initTopoData 初始化拓扑图数据完成. 耗时: ", endTime.diff(startTime, "seconds", true));
458
461
  topoApp.options.onLoad();
459
462
 
460
- case 55:
463
+ case 56:
461
464
  case "end":
462
465
  return _context6.stop();
463
466
  }
@@ -273,13 +273,8 @@ export var combTopoData = function combTopoData(_ref2) {
273
273
  globalConfig = _ref2.globalConfig,
274
274
  ciTypeMap = _ref2.ciTypeMap,
275
275
  engine = _ref2.engine;
276
- // rlog.debug("combTopoData-接收到数据", result, engine, globalConfig);
277
- // 当前拓扑资源字典
278
- var ciDoc = {};
279
- var ciTypesDoc = {}; //
280
-
281
- var bindingCiSet = {};
282
276
 
277
+ // rlog.debug("combTopoData-接收到数据", result, engine, globalConfig);
283
278
  var config = _extends({
284
279
  type: "auto"
285
280
  }, result.config); // global
@@ -337,12 +332,74 @@ export var combTopoData = function combTopoData(_ref2) {
337
332
  var linkGroups = result.linkGroups.map(function (link) {
338
333
  var linkObj = tfLink(engine, link, result.nodes);
339
334
  return linkObj;
340
- }); // 所有资源
335
+ });
336
+ var topoData = {
337
+ config: config,
338
+ global: global,
339
+ groups: groups,
340
+ nodes: nodes,
341
+ linkGroups: linkGroups,
342
+ links: links,
343
+ serialize: result.serialize
344
+ }; // 所有资源
341
345
 
342
346
  var allCis = [].concat(nodes, links, linkGroups);
347
+
348
+ var resAndMetrics = _extends({
349
+ // topo所有ci的id集合
350
+ resIdsList: allCis.map(function (item) {
351
+ return item.id;
352
+ }),
353
+ ciTypes: getCiTypes(result),
354
+ // ci类型集合
355
+ ciTypeMap: ciTypeMap,
356
+ // ci类型模型map
357
+ metrics: [],
358
+ // 所有指标
359
+ metricsDoc: {},
360
+ //
361
+ attrsDoc: {},
362
+ allMetrics: Object.values(ciTypeMap),
363
+ allAttrs: Object.values(ciTypeMap),
364
+ globalConfig: globalConfig,
365
+ nodeIdsList: result.nodes.map(function (item) {
366
+ return {
367
+ ciId: item.id,
368
+ operation: item.operation
369
+ };
370
+ }),
371
+ linkIdsList: [].concat(result.links, result.linkGroups).map(function (linkObj) {
372
+ return {
373
+ ciId: linkObj.id,
374
+ operation: linkObj.operation
375
+ };
376
+ })
377
+ }, getCiModSet({
378
+ engine: engine,
379
+ allCis: allCis,
380
+ ciTypeMap: ciTypeMap,
381
+ globalConfig: globalConfig
382
+ })); // rlog.debug("combTopoData-格式化后数据", topoData, resAndMetrics);
383
+
384
+
385
+ return {
386
+ topoData: topoData,
387
+ resAndMetrics: resAndMetrics
388
+ };
389
+ };
390
+ export function getCiModSet(params) {
391
+ var engine = params.engine,
392
+ allCis = params.allCis,
393
+ ciTypeMap = params.ciTypeMap,
394
+ globalConfig = params.globalConfig; // 当前拓扑资源字典
395
+
396
+ var ciDoc = {};
397
+ var ciTypesDoc = {}; //
398
+
399
+ var bindingCiSet = {};
343
400
  var allCiModSet = {};
344
401
  var allLinkModSet = {};
345
- Object.keys(ciTypeMap).map(function (key) {
402
+ Object.keys(ciTypeMap).forEach(function (key) {
346
403
  var ciTypeObj = {};
347
404
  var linkKeyArr = [{
348
405
  code: "phy",
@@ -401,62 +458,19 @@ export var combTopoData = function combTopoData(_ref2) {
401
458
  });
402
459
  }
403
460
 
404
- var resAndMetrics = {
405
- // topo所有ci的id集合
406
- resIdsList: [].concat(result.nodes, result.links, result.linkGroups).map(function (item) {
407
- return item.id;
408
- }),
409
- nodeIdsList: result.nodes.map(function (item) {
410
- return {
411
- ciId: item.id,
412
- operation: item.operation
413
- };
414
- }),
415
- linkIdsList: [].concat(result.links, result.linkGroups).map(function (linkObj) {
416
- return {
417
- ciId: linkObj.id,
418
- operation: linkObj.operation
419
- };
420
- }),
421
- // alarmCiDoc, // 用于告警ciId的集合,因为链路的ciId不同于关系id(r开头) 弃用
461
+ return {
422
462
  ciDoc: ciDoc,
423
463
  // ci信息集合
424
- ciTypes: getCiTypes(result),
425
- // ci类型集合
426
464
  ciTypesDoc: ciTypesDoc,
427
465
  // 每种ci含有的ci
428
- ciTypeMap: ciTypeMap,
429
- // ci类型模型map
430
- allCiModSet: allCiModSet,
431
- // 资源类型含有属性和指标集合
432
- allLinkModSet: allLinkModSet,
433
- // 链路类型含有属性和指标集合
434
- metrics: [],
435
- // 所有指标
436
- metricsDoc: {},
437
- //
438
- attrsDoc: {},
439
466
  bindingCiSet: bindingCiSet,
440
467
  // 可能没用了
441
- allMetrics: Object.values(ciTypeMap),
442
- allAttrs: Object.values(ciTypeMap),
443
- globalConfig: globalConfig
444
- };
445
- var topoData = {
446
- config: config,
447
- global: global,
448
- groups: groups,
449
- nodes: nodes,
450
- linkGroups: linkGroups,
451
- links: links,
452
- serialize: result.serialize
453
- }; // rlog.debug("combTopoData-格式化后数据", topoData, resAndMetrics);
468
+ allCiModSet: allCiModSet,
469
+ // 资源类型含有属性和指标集合
470
+ allLinkModSet: allLinkModSet // 链路类型含有属性和指标集合
454
471
 
455
- return {
456
- topoData: topoData,
457
- resAndMetrics: resAndMetrics
458
472
  };
459
- };
473
+ }
460
474
  /**
461
475
  * 获得两个节点间的连线列表
462
476
  * @param {*} links
@@ -5,5 +5,8 @@
5
5
  .#{$css-prefix}collapse-panel-title:hover {
6
6
  color: var(--collapse-title-font-color);
7
7
  }
8
+ .#{$css-prefix}collapse-panel-title:hover .#{$css-prefix}collapse-panel-icon {
9
+ color: var(--collapse-title-font-color);
10
+ }
8
11
  }
9
12
  }
@@ -8,5 +8,6 @@ var RESOURCE_LIMIT_TYPES = [// 网络设备
8
8
  'linux', 'windows', // 数据库
9
9
  'oracle', 'asm_disk_group', 'oracle_rac', // 中间件
10
10
  'tomcat', // 业务
11
- 'app', 'service'];
11
+ 'app', 'service', // 虚拟化
12
+ 'virtual_mgmt_node', 'virtual_data_center', 'virtual_cluster', 'virtual_storage', 'virtual_vm', 'virtual_host', 'virtual_switch'];
12
13
  exports.RESOURCE_LIMIT_TYPES = RESOURCE_LIMIT_TYPES;
@@ -15,6 +15,8 @@ var _app_middleware = _interopRequireDefault(require("@riil-frontend/component-t
15
15
 
16
16
  var _business_system = _interopRequireDefault(require("@riil-frontend/component-topology-graph/es/icons/ciTypeIcons/business_system"));
17
17
 
18
+ var _virtual = _interopRequireDefault(require("@riil-frontend/component-topology-graph/es/icons/ciTypeIcons/virtual"));
19
+
18
20
  function getNetworkTopoCiTypeIcons() {
19
- return [].concat((0, _network["default"])(), (0, _os["default"])(), (0, _db["default"])(), (0, _app_middleware["default"])(), (0, _business_system["default"])());
21
+ return [].concat((0, _network["default"])(), (0, _os["default"])(), (0, _db["default"])(), (0, _app_middleware["default"])(), (0, _business_system["default"])(), (0, _virtual["default"])());
20
22
  }