@riil-frontend/component-topology 13.0.0-dev.1 → 13.0.0-dev.10

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 (92) hide show
  1. package/build/1.js +1 -1
  2. package/build/index.css +1 -1
  3. package/build/index.js +29 -29
  4. package/es/components/ColorPanel/index.js +68 -58
  5. package/es/components/ResourceSelectDrawer/ResourceSelectDrawer.js +1 -1
  6. package/es/core/components/TopoView/topoView.js +7 -4
  7. package/es/core/editor/components/Toolbar/widgets/EdgeColorButton/EdgeColorButton.js +2 -2
  8. package/es/core/editor/components/Toolbar/widgets/EdgeTypeButton/LineType.js +5 -15
  9. package/es/core/editor/components/Toolbar/widgets/FontColorButton.js +10 -91
  10. package/es/core/editor/components/Toolbar/widgets/FontFamilyWidget.js +2 -27
  11. package/es/core/editor/components/Toolbar/widgets/FontSizeWidget.js +3 -28
  12. package/es/core/editor/components/Toolbar/widgets/FontStyleButton.js +6 -52
  13. package/es/core/editor/components/Toolbar/widgets/components/FontColorDropdown.js +120 -0
  14. package/es/core/editor/components/Toolbar/widgets/components/FontFamilySelect.js +29 -0
  15. package/es/core/editor/components/Toolbar/widgets/components/FontSizeSelect.js +29 -0
  16. package/es/core/editor/components/Toolbar/widgets/components/FontStyleSelect.js +77 -0
  17. package/es/core/editor/components/settings/core/updateElementProperty.js +3 -2
  18. package/es/core/editor/components/settings/propertyViews/view/GlobalEdgeToggle.js +2 -2
  19. package/es/core/editor/hooks/useKeyboardShortcut.js +4 -0
  20. package/es/core/editor/hooks/useNewElementTheme.js +20 -16
  21. package/es/core/editor/utils/edgeTypeStyleUtil.js +11 -32
  22. package/es/core/hooks/useGraphAlarmDisplay.js +4 -0
  23. package/es/core/hooks/usePolling.js +2 -1
  24. package/es/core/hooks/useResourceConfig.js +1 -2
  25. package/es/core/hooks/useTopoEdit.js +210 -248
  26. package/es/core/models/AttributeMetricDisplay.js +4 -3
  27. package/es/core/models/HistoryManager.js +11 -9
  28. package/es/core/models/TopoApp.js +39 -45
  29. package/es/core/models/topoData.js +9 -17
  30. package/es/core/models/utils/linkUtils.js +65 -52
  31. package/es/core/store/models/topoConfig.js +7 -11
  32. package/es/core/utils/edgeUtil.js +7 -10
  33. package/es/core/viewer/components/plugins/ElementDetailDrawer/hooks/useElementDetailManager.js +2 -2
  34. package/es/core/viewer/components/plugins/ResourceDetail/components/ResourceOverview/EventsCard.js +4 -2
  35. package/es/networkTopo/models/EdgeGroupTagTipBuilder.js +7 -7
  36. package/es/networkTopo/models/LinkDynamicStyleExecutor.js +7 -63
  37. package/es/networkTopo/services/topo/basic.js +27 -17
  38. package/es/networkTopo/utils/__tests__/relateTopoData.js +205 -0
  39. package/es/networkTopo/utils/edgeGroupTagUtil.js +2 -2
  40. package/es/networkTopo/utils/exitLinkUtil.js +25 -13
  41. package/es/networkTopo/utils/relateTopoDataUtil.js +149 -0
  42. package/es/style.js +1 -1
  43. package/es/utils/ResourceConfigUtil.js +1 -16
  44. package/es/utils/clusterUtil.js +3 -3
  45. package/es/utils/htElementUtils.js +19 -85
  46. package/lib/components/ColorPanel/index.js +71 -59
  47. package/lib/components/ResourceSelectDrawer/ResourceSelectDrawer.js +1 -1
  48. package/lib/core/components/TopoView/topoView.js +15 -19
  49. package/lib/core/editor/components/Toolbar/widgets/EdgeColorButton/EdgeColorButton.js +2 -2
  50. package/lib/core/editor/components/Toolbar/widgets/EdgeTypeButton/LineType.js +5 -14
  51. package/lib/core/editor/components/Toolbar/widgets/FontColorButton.js +11 -95
  52. package/lib/core/editor/components/Toolbar/widgets/FontFamilyWidget.js +3 -28
  53. package/lib/core/editor/components/Toolbar/widgets/FontSizeWidget.js +3 -28
  54. package/lib/core/editor/components/Toolbar/widgets/FontStyleButton.js +6 -56
  55. package/lib/core/editor/components/Toolbar/widgets/components/FontColorDropdown.js +136 -0
  56. package/lib/core/editor/components/Toolbar/widgets/components/FontFamilySelect.js +38 -0
  57. package/lib/core/editor/components/Toolbar/widgets/components/FontSizeSelect.js +38 -0
  58. package/lib/core/editor/components/Toolbar/widgets/components/FontStyleSelect.js +89 -0
  59. package/lib/core/editor/components/settings/core/updateElementProperty.js +7 -2
  60. package/lib/core/editor/components/settings/propertyViews/view/GlobalEdgeToggle.js +2 -2
  61. package/lib/core/editor/hooks/useKeyboardShortcut.js +4 -0
  62. package/lib/core/editor/hooks/useNewElementTheme.js +20 -16
  63. package/lib/core/editor/utils/edgeTypeStyleUtil.js +10 -33
  64. package/lib/core/hooks/useGraphAlarmDisplay.js +4 -0
  65. package/lib/core/hooks/usePolling.js +6 -5
  66. package/lib/core/hooks/useResourceConfig.js +1 -2
  67. package/lib/core/hooks/useTopoEdit.js +216 -272
  68. package/lib/core/models/AttributeMetricDisplay.js +6 -6
  69. package/lib/core/models/HistoryManager.js +13 -17
  70. package/lib/core/models/TopoApp.js +39 -43
  71. package/lib/core/models/topoData.js +9 -17
  72. package/lib/core/models/utils/linkUtils.js +65 -51
  73. package/lib/core/store/models/topoConfig.js +13 -25
  74. package/lib/core/utils/edgeUtil.js +8 -10
  75. package/lib/core/viewer/components/plugins/ElementDetailDrawer/hooks/useElementDetailManager.js +3 -2
  76. package/lib/core/viewer/components/plugins/ResourceDetail/components/ResourceOverview/EventsCard.js +6 -2
  77. package/lib/networkTopo/models/EdgeGroupTagTipBuilder.js +6 -6
  78. package/lib/networkTopo/models/LinkDynamicStyleExecutor.js +6 -64
  79. package/lib/networkTopo/services/topo/basic.js +32 -18
  80. package/lib/networkTopo/utils/__tests__/relateTopoData.js +210 -0
  81. package/lib/networkTopo/utils/edgeGroupTagUtil.js +2 -2
  82. package/lib/networkTopo/utils/exitLinkUtil.js +25 -13
  83. package/lib/networkTopo/utils/relateTopoDataUtil.js +164 -0
  84. package/lib/style.js +1 -1
  85. package/lib/utils/ResourceConfigUtil.js +1 -16
  86. package/lib/utils/clusterUtil.js +2 -2
  87. package/lib/utils/htElementUtils.js +22 -94
  88. package/package.json +2 -2
  89. package/es/networkTopo/models/LinkTagsTipsBuilder.js +0 -235
  90. package/lib/networkTopo/models/LinkTagsTipsBuilder.js +0 -245
  91. /package/es/core/editor/components/Toolbar/widgets/{FontColorButton.module.scss → components/FontColorDropdown.module.scss} +0 -0
  92. /package/lib/core/editor/components/Toolbar/widgets/{FontColorButton.module.scss → components/FontColorDropdown.module.scss} +0 -0
@@ -11,7 +11,7 @@ var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/
11
11
 
12
12
  var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
13
13
 
14
- var _componentTopologyUtils = require("@riil-frontend/component-topology-utils");
14
+ var _loglevel = _interopRequireDefault(require("loglevel"));
15
15
 
16
16
  var _ResourceInfoDisplay = require("../../constants/ResourceInfoDisplay");
17
17
 
@@ -25,6 +25,8 @@ var _nodeNameVisibleUtil = require("./utils/nodeNameVisibleUtil");
25
25
 
26
26
  var _ciRefAttributeTranslateUtil = require("../../utils/ciRefAttributeTranslateUtil");
27
27
 
28
+ var rlog = _loglevel["default"].getLogger('topo');
29
+
28
30
  function isGraphField(item) {
29
31
  return item.type === 'graph';
30
32
  }
@@ -451,7 +453,7 @@ var AttributeMetricDisplay = /*#__PURE__*/function () {
451
453
  });
452
454
  });
453
455
  } else {
454
- _componentTopologyUtils.rlog.warn("\u63A8\u9001\u5C5E\u6027\u6307\u6807\u6570\u636E\uFF1A\u672A\u67E5\u8BE2\u5230ciType " + ciType, ciData);
456
+ rlog.warn("\u63A8\u9001\u5C5E\u6027\u6307\u6807\u6570\u636E\uFF1A\u672A\u67E5\u8BE2\u5230ciType " + ciType, ciData);
455
457
  }
456
458
  });
457
459
  refIds = Object.keys(refIdMap);
@@ -540,9 +542,7 @@ var AttributeMetricDisplay = /*#__PURE__*/function () {
540
542
  tags: tags
541
543
  });
542
544
  });
543
-
544
- _componentTopologyUtils.rlog.debug('推送标注 => ht', elementTagsAndTips);
545
-
545
+ rlog.debug(' ==> ht: 推送标注', elementTagsAndTips);
546
546
  var htTopo = topo.getHtTopo();
547
547
 
548
548
  if (htTopo) {
@@ -553,7 +553,7 @@ var AttributeMetricDisplay = /*#__PURE__*/function () {
553
553
  try {
554
554
  htTopo.loadTagAndTip(JSON.parse(JSON.stringify(elementTagsAndTips)));
555
555
  } catch (error) {
556
- _componentTopologyUtils.rlog.error('推送标注 => ht 失败', error);
556
+ rlog.error(' ==> ht: 推送标注失败', error);
557
557
  }
558
558
 
559
559
  (_topo$historyManager2 = topo.historyManager) === null || _topo$historyManager2 === void 0 ? void 0 : _topo$historyManager2.setDisabled(false, '加载标注');
@@ -9,6 +9,10 @@ var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends")
9
9
 
10
10
  var _componentTopologyUtils = require("@riil-frontend/component-topology-utils");
11
11
 
12
+ var _loglevel = _interopRequireDefault(require("loglevel"));
13
+
14
+ var log = _loglevel["default"].getLogger('topo.HistoryManager');
15
+
12
16
  var ht = window.ht;
13
17
 
14
18
  var HistoryManager = /*#__PURE__*/function () {
@@ -19,9 +23,7 @@ var HistoryManager = /*#__PURE__*/function () {
19
23
  this.topo = topo;
20
24
  this.htHistoryManager = htHistoryManager;
21
25
  htHistoryManager.clear();
22
-
23
- _componentTopologyUtils.rlog.info('HistoryManager 初始化', htHistoryManager);
24
-
26
+ log.info('HistoryManager 初始化', htHistoryManager);
25
27
  this.updateStore = this.updateStore.bind(this);
26
28
  this.init();
27
29
  }
@@ -69,11 +71,10 @@ var HistoryManager = /*#__PURE__*/function () {
69
71
 
70
72
  _proto.setDisabled = function setDisabled(disabled, message) {
71
73
  this.htHistoryManager.setDisabled(disabled);
72
-
73
- _componentTopologyUtils.rlog.debug("HistoryManager.setDisabled " + (disabled ? '禁用' : '启用') + (message ? "(" + message + ")" : '') + ": " + this.toString(), this.getHistories());
74
+ log.debug("HistoryManager.setDisabled: " + (disabled ? '禁用' : '启用') + ". <" + message + ">, " + this.toString() + ", ", 'Histories: ', this.getHistories());
74
75
  };
75
76
 
76
- _proto.beginTransaction = function beginTransaction() {
77
+ _proto.beginTransaction = function beginTransaction(name) {
77
78
  var _this = this;
78
79
 
79
80
  this.htHistoryManager.beginTransaction();
@@ -104,8 +105,7 @@ var HistoryManager = /*#__PURE__*/function () {
104
105
  oldValue: _this.topo.store.getModelState(item.modelName)[item.property]
105
106
  });
106
107
  });
107
-
108
- _componentTopologyUtils.rlog.debug("HistoryManager.beginTransaction: " + this.toString(), this.getHistories());
108
+ log.debug("HistoryManager.beginTransaction: " + this.toString(), this.getHistories());
109
109
  };
110
110
 
111
111
  _proto.addStoreHistory = function addStoreHistory() {
@@ -130,18 +130,16 @@ var HistoryManager = /*#__PURE__*/function () {
130
130
  type: 'store',
131
131
  data: storeChanged
132
132
  });
133
-
134
- _componentTopologyUtils.rlog.debug('HistoryManager.addStoreHistory', storeChanged);
133
+ log.debug('HistoryManager.addStoreHistory', storeChanged);
135
134
  }
136
135
 
137
136
  this.storeHistory = [];
138
137
  };
139
138
 
140
- _proto.endTransaction = function endTransaction() {
139
+ _proto.endTransaction = function endTransaction(name) {
141
140
  this.addStoreHistory();
142
141
  this.htHistoryManager.endTransaction();
143
-
144
- _componentTopologyUtils.rlog.debug("HistoryManager.endTransaction: " + this.toString(), this.getHistories());
142
+ log.debug("HistoryManager.endTransaction: " + this.toString(), this.getHistories());
145
143
  };
146
144
 
147
145
  _proto.clear = function clear() {
@@ -185,8 +183,7 @@ var HistoryManager = /*#__PURE__*/function () {
185
183
  return;
186
184
  }
187
185
 
188
- _componentTopologyUtils.rlog.debug('HistoryManager.undo', this.getHistories(), this.getHistoryIndex());
189
-
186
+ log.debug('HistoryManager.undo', this.getHistories(), this.getHistoryIndex());
190
187
  var storeHistory = this.getCurrentStoreHistory(true);
191
188
 
192
189
  if (storeHistory) {
@@ -204,8 +201,7 @@ var HistoryManager = /*#__PURE__*/function () {
204
201
  _proto.redo = function redo() {
205
202
  var _this4 = this;
206
203
 
207
- _componentTopologyUtils.rlog.debug('HistoryManager.redo', this.getHistories(), this.getHistoryIndex());
208
-
204
+ log.debug('HistoryManager.redo', this.getHistories(), this.getHistoryIndex());
209
205
  var storeHistory = this.getCurrentStoreHistory(false);
210
206
 
211
207
  if (storeHistory) {
@@ -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 "13.0.0-dev.1" === 'string' ? "13.0.0-dev.1" : null;
57
+ var version = typeof "13.0.0-dev.10" === 'string' ? "13.0.0-dev.10" : null;
58
58
  console.info("\u62D3\u6251\u7248\u672C: " + version);
59
59
  /**
60
60
  * 拓扑显示和编辑
@@ -218,37 +218,29 @@ var Topo = /*#__PURE__*/function () {
218
218
 
219
219
  _proto.getData = function getData() {
220
220
  return {
221
- groups: this.getGroups(),
222
- nodes: this.getNodes(),
223
- lines: this.getLines(),
221
+ groups: (0, _htElementUtils.getGroupDatas)(this.getDataModel()),
222
+ nodes: (0, _htElementUtils.getNodes)(this.getDataModel()).filter(function (node) {
223
+ return !!node.getTag();
224
+ }).map(_htElementUtils.getNodeData),
224
225
  customNodes: (0, _htElementUtils.getNodeDatas)(this.getDataModel()).filter(function (item) {
225
226
  return !item.id;
226
227
  }),
227
- customLines: this.getEdges().filter(function (item) {
228
+ lines: (0, _htElementUtils.getEdgeDatas)(this.getDataModel()).filter(function (item) {
229
+ return !!item.id;
230
+ }),
231
+ customLines: (0, _htElementUtils.getEdgeDatas)(this.getDataModel()).filter(function (item) {
228
232
  return !item.id;
229
233
  })
230
234
  };
231
- };
232
-
233
- _proto.getGroups = function getGroups() {
234
- return (0, _htElementUtils.getGroupDatas)(this.getDataModel());
235
- };
236
-
237
- _proto.getNodes = function getNodes() {
238
- var nodes = (0, _htElementUtils.getNodes)(this.getDataModel()).filter(function (node) {
239
- return !!node.getTag();
240
- });
241
- return nodes.map(_htElementUtils.getNodeData);
242
- };
235
+ }
236
+ /**
237
+ * @deprecated 待移除。uicbb有使用
238
+ * @returns
239
+ */
240
+ ;
243
241
 
244
242
  _proto.getLines = function getLines() {
245
- return this.getEdges().filter(function (item) {
246
- return !!item.id;
247
- });
248
- };
249
-
250
- _proto.getEdges = function getEdges() {
251
- return (0, _htElementUtils.getEdgeDatas)(this.getDataModel());
243
+ return this.getData().lines;
252
244
  }
253
245
  /**
254
246
  * 全量更新数据
@@ -307,18 +299,19 @@ var Topo = /*#__PURE__*/function () {
307
299
  /*#__PURE__*/
308
300
  function () {
309
301
  var _addElements = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee5(elements) {
310
- var data;
302
+ var prevData, data;
311
303
  return _regenerator["default"].wrap(function _callee5$(_context5) {
312
304
  while (1) switch (_context5.prev = _context5.next) {
313
305
  case 0:
306
+ prevData = this.getData();
314
307
  data = {
315
- groups: [].concat(this.getGroups(), elements.groups || []),
316
- nodes: [].concat(this.getNodes(), elements.nodes || []),
317
- lines: [].concat(this.getLines(), elements.lines || [])
308
+ groups: [].concat(prevData.groups, elements.groups || []),
309
+ nodes: [].concat(prevData.nodes, elements.nodes || []),
310
+ lines: [].concat(prevData.lines, elements.lines || [])
318
311
  };
319
312
  this.updateElements(data); // TODO 更新store,触发属性、指标模型加载,更新指标
320
313
 
321
- case 2:
314
+ case 3:
322
315
  case "end":
323
316
  return _context5.stop();
324
317
  }
@@ -547,37 +540,39 @@ var Topo = /*#__PURE__*/function () {
547
540
  case 0:
548
541
  _componentTopologyUtils.rlog.info('TopoApp.enterEditMode');
549
542
 
543
+ this.historyManager = null;
544
+
550
545
  if (!this.options.onSwitchToEditModeBegin) {
551
- _context12.next = 4;
546
+ _context12.next = 5;
552
547
  break;
553
548
  }
554
549
 
555
- _context12.next = 4;
550
+ _context12.next = 5;
556
551
  return this.options.onSwitchToEditModeBegin(this);
557
552
 
558
- case 4:
553
+ case 5:
559
554
  topoDispatchers = this.store.getModelDispatchers('topoMod');
560
- _context12.next = 7;
555
+ _context12.next = 8;
561
556
  return topoDispatchers.update({
562
557
  viewState: 'edit'
563
558
  });
564
559
 
565
- case 7:
566
- _context12.next = 9;
560
+ case 8:
561
+ _context12.next = 10;
567
562
  return this.view.switchToEditMode();
568
563
 
569
- case 9:
564
+ case 10:
570
565
  (0, _edgeUtil.updateEdgeExpanded)(this);
571
566
 
572
567
  if (!this.options.onSwitchToEditMode) {
573
- _context12.next = 13;
568
+ _context12.next = 14;
574
569
  break;
575
570
  }
576
571
 
577
- _context12.next = 13;
572
+ _context12.next = 14;
578
573
  return this.options.onSwitchToEditMode(this);
579
574
 
580
- case 13:
575
+ case 14:
581
576
  if (this.getDataModel()) {
582
577
  // 更新节点名称显示隐藏
583
578
  this.attributeMetricDisplay.updateNodesNameVisible();
@@ -587,7 +582,7 @@ var Topo = /*#__PURE__*/function () {
587
582
  iconManageDispatchers = this.store.getModelDispatchers('customIcon');
588
583
  iconManageDispatchers.loadEditorIcons();
589
584
 
590
- case 16:
585
+ case 17:
591
586
  case "end":
592
587
  return _context12.stop();
593
588
  }
@@ -611,18 +606,19 @@ var Topo = /*#__PURE__*/function () {
611
606
  return this.view.switchToViewMode();
612
607
 
613
608
  case 2:
609
+ this.historyManager = null;
614
610
  editDispatchers = this.store.getModelDispatchers('topoConfig');
615
611
  editDispatchers.switchToViewMode(this.id);
616
612
 
617
613
  if (!this.options.onSwitchToViewMode) {
618
- _context13.next = 7;
614
+ _context13.next = 8;
619
615
  break;
620
616
  }
621
617
 
622
- _context13.next = 7;
618
+ _context13.next = 8;
623
619
  return this.options.onSwitchToViewMode(this);
624
620
 
625
- case 7:
621
+ case 8:
626
622
  case "end":
627
623
  return _context13.stop();
628
624
  }
@@ -57,11 +57,11 @@ function saveTopo(_x) {
57
57
 
58
58
  function _saveTopo() {
59
59
  _saveTopo = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee(data) {
60
- var topoService, topoId, template, layout, backgroundId, globalConfig, serialize, resources, groups, relateTopoIdList, viewGroupId, groupInfo, viewResources, linkIps;
60
+ var topoService, topoId, template, layout, backgroundId, globalConfig, serialize, resources, groups, viewGroupId, groupInfo, viewResources;
61
61
  return _regenerator["default"].wrap(function _callee$(_context) {
62
62
  while (1) switch (_context.prev = _context.next) {
63
63
  case 0:
64
- topoService = data.topoService, topoId = data.id, template = data.template, layout = data.layout, backgroundId = data.backgroundId, globalConfig = data.globalConfig, serialize = data.serialize, resources = data.resources, groups = data.groups, relateTopoIdList = data.relateTopoIdList, viewGroupId = data.viewGroupId;
64
+ topoService = data.topoService, topoId = data.id, template = data.template, layout = data.layout, backgroundId = data.backgroundId, globalConfig = data.globalConfig, serialize = data.serialize, resources = data.resources, groups = data.groups, viewGroupId = data.viewGroupId;
65
65
 
66
66
  _rlog["default"].debug("saveTopo", data); // 保存布局
67
67
 
@@ -90,7 +90,7 @@ function _saveTopo() {
90
90
 
91
91
  case 8:
92
92
  if (!(resources || groups)) {
93
- _context.next = 16;
93
+ _context.next = 15;
94
94
  break;
95
95
  }
96
96
 
@@ -112,31 +112,23 @@ function _saveTopo() {
112
112
  });
113
113
  }
114
114
 
115
- linkIps = []; // resources?.static.map((nodeId) => {
116
- // if (nodeId.startsWith("ip_")) {
117
- // linkIps.push(nodeId.replace("ip_", ""));
118
- // }
119
- // });
120
-
121
115
  _rlog["default"].debug("saveTopo-groupInfo", groupInfo);
122
116
 
123
- _context.next = 16;
117
+ _context.next = 15;
124
118
  return topoService.bindResourceToTopo(topoId, {
125
- groups: groupInfo,
126
- linkIps: linkIps,
127
- relateTopoIdList: relateTopoIdList
119
+ groups: groupInfo
128
120
  });
129
121
 
130
- case 16:
122
+ case 15:
131
123
  if (!serialize) {
132
- _context.next = 19;
124
+ _context.next = 18;
133
125
  break;
134
126
  }
135
127
 
136
- _context.next = 19;
128
+ _context.next = 18;
137
129
  return topoService.saveSerializeData(topoId, serialize);
138
130
 
139
- case 19:
131
+ case 18:
140
132
  case "end":
141
133
  return _context.stop();
142
134
  }
@@ -6,6 +6,7 @@ exports.__esModule = true;
6
6
  exports.buildTopoLinkData = buildTopoLinkData;
7
7
  exports.compatibleWith = void 0;
8
8
  exports.getLinksDetail = getLinksDetail;
9
+ exports.isAggLink = isAggLink;
9
10
  exports.isCrucialLink = isCrucialLink;
10
11
  exports.isExitLink = isExitLink;
11
12
  exports.mergeExportLinkData = void 0;
@@ -22,8 +23,6 @@ var _keyBy = _interopRequireDefault(require("lodash/keyBy"));
22
23
 
23
24
  var _lodash = _interopRequireDefault(require("lodash"));
24
25
 
25
- var _services = require("../../services");
26
-
27
26
  var _htElementUtils = require("../../../utils/htElementUtils");
28
27
 
29
28
  var _CiTypeCache = _interopRequireDefault(require("../cache/CiTypeCache"));
@@ -56,41 +55,49 @@ function isCrucialLink(link) {
56
55
 
57
56
 
58
57
  function isExitLink(link) {
59
- return (link === null || link === void 0 ? void 0 : link.attributes) && !(link !== null && link !== void 0 && link.attributes["destination_id"]);
58
+ var _link$attributes;
59
+
60
+ return (link === null || link === void 0 ? void 0 : (_link$attributes = link.attributes) === null || _link$attributes === void 0 ? void 0 : _link$attributes.destination_type) === "ip";
60
61
  }
62
+ /**
63
+ * 是否聚合链路
64
+ * @param {*} link
65
+ * @returns
66
+ */
67
+
68
+
69
+ function isAggLink(link) {
70
+ var _link$attributes2, _link$attributes3;
61
71
 
62
- function mergeLinksData(links, linkCis, nodes, interfaceCiMap, interfaceDoc) {
72
+ return (link === null || link === void 0 ? void 0 : (_link$attributes2 = link.attributes) === null || _link$attributes2 === void 0 ? void 0 : _link$attributes2.destination_type) === "network.agg_interface" && (link === null || link === void 0 ? void 0 : (_link$attributes3 = link.attributes) === null || _link$attributes3 === void 0 ? void 0 : _link$attributes3.source_type) === "network.agg_interface";
73
+ }
74
+
75
+ function mergeLinksData(links, linkCis, nodes, ciMap, interfaceDoc) {
63
76
  var linkCiMap = (0, _keyBy["default"])(links, "id");
64
77
  return links.map(function (link) {
65
- var _interfaceCiMap$attri, _interfaceCiMap$attri2;
78
+ var _ciMap$attributes$net, _ciMap$attributes$net2, _ciMap$attributes$sou, _ciMap$attributes$des;
66
79
 
67
80
  var linkCi = linkCiMap[link.id];
68
- var attributes = (0, _extends2["default"])({}, linkCi === null || linkCi === void 0 ? void 0 : linkCi.attributes);
69
- var sourceNode = nodes.find(function (node) {
70
- return node.id === attributes["network_link.source_device_id"];
71
- });
72
- var targetNode = nodes.find(function (node) {
73
- return node.id === attributes["network_link.destination_device_id"];
74
- }); // 翻译
81
+ var attributes = (0, _extends2["default"])({}, linkCi === null || linkCi === void 0 ? void 0 : linkCi.attributes); // 翻译
75
82
 
76
83
  return (0, _extends2["default"])({}, link, {
77
84
  attributes: (0, _extends2["default"])({}, attributes, {
78
85
  // 源/目的设备
79
86
  "network_link.source_device_id_object": {
80
- displayName: sourceNode === null || sourceNode === void 0 ? void 0 : sourceNode.name
87
+ displayName: (_ciMap$attributes$net = ciMap[attributes["network_link.source_device_id"]]) === null || _ciMap$attributes$net === void 0 ? void 0 : _ciMap$attributes$net.attributes["display_name"]
81
88
  },
82
89
  "network_link.destination_device_id_object": {
83
- displayName: targetNode === null || targetNode === void 0 ? void 0 : targetNode.name
90
+ displayName: (_ciMap$attributes$net2 = ciMap[attributes["network_link.destination_device_id"]]) === null || _ciMap$attributes$net2 === void 0 ? void 0 : _ciMap$attributes$net2.attributes["display_name"]
84
91
  },
85
92
  // 源/目的接口类型
86
93
  source_type_object: interfaceDoc[attributes.source_type],
87
94
  destination_type_object: interfaceDoc[attributes.destination_type],
88
95
  // 源/目的接口
89
96
  source_id_object: {
90
- displayName: (_interfaceCiMap$attri = interfaceCiMap[attributes.source_id]) === null || _interfaceCiMap$attri === void 0 ? void 0 : _interfaceCiMap$attri.attributes["display_name"]
97
+ displayName: (_ciMap$attributes$sou = ciMap[attributes.source_id]) === null || _ciMap$attributes$sou === void 0 ? void 0 : _ciMap$attributes$sou.attributes["display_name"]
91
98
  },
92
99
  destination_id_object: {
93
- displayName: (_interfaceCiMap$attri2 = interfaceCiMap[attributes.destination_id]) === null || _interfaceCiMap$attri2 === void 0 ? void 0 : _interfaceCiMap$attri2.attributes["display_name"]
100
+ displayName: (_ciMap$attributes$des = ciMap[attributes.destination_id]) === null || _ciMap$attributes$des === void 0 ? void 0 : _ciMap$attributes$des.attributes["display_name"]
94
101
  }
95
102
  })
96
103
  });
@@ -103,11 +110,11 @@ function getLinksDetail(_x, _x2) {
103
110
 
104
111
  function _getLinksDetail() {
105
112
  _getLinksDetail = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee(links, nodes) {
106
- var linkCis, interfaceIds, interfaceTypes, interfaceCiMap, interfaceDoc;
113
+ var linkCis, ciMap, ciIds, interfaceTypes, loadCiMap, interfaceDoc;
107
114
  return _regenerator["default"].wrap(function _callee$(_context) {
108
115
  while (1) switch (_context.prev = _context.next) {
109
116
  case 0:
110
- if (!(!links || !links.length)) {
117
+ if (links !== null && links !== void 0 && links.length) {
111
118
  _context.next = 2;
112
119
  break;
113
120
  }
@@ -115,15 +122,21 @@ function _getLinksDetail() {
115
122
  return _context.abrupt("return", []);
116
123
 
117
124
  case 2:
118
- // const linkCis = await topoService.relation.batchQueryRelation(
119
- // links.map((link) => link.id)
120
- // );
121
125
  linkCis = links;
122
- interfaceIds = [].concat(linkCis.map(function (item) {
126
+ ciMap = (0, _keyBy["default"])(nodes, "id");
127
+ ciIds = _lodash["default"].uniq([].concat(linkCis.map(function (item) {
128
+ return item.attributes['network_link.destination_device_id'];
129
+ }), linkCis.map(function (item) {
130
+ return item.attributes['network_link.source_device_id'];
131
+ }), linkCis.map(function (item) {
123
132
  return item.attributes.source_id;
124
133
  }), linkCis.map(function (item) {
125
134
  return item.attributes.destination_id;
126
- }));
135
+ }))).filter(function (item) {
136
+ return !!item;
137
+ }).filter(function (item) {
138
+ return !ciMap[item];
139
+ });
127
140
  interfaceTypes = _lodash["default"].compact(_lodash["default"].uniq([].concat(linkCis.map(function (item) {
128
141
  return item.attributes.source_type;
129
142
  }), linkCis.map(function (item) {
@@ -131,19 +144,21 @@ function _getLinksDetail() {
131
144
  })))).filter(function (item) {
132
145
  return item !== "ip";
133
146
  });
134
- _context.next = 7;
135
- return _CiCache["default"].load(interfaceIds);
147
+ _context.next = 8;
148
+ return _CiCache["default"].load(ciIds);
136
149
 
137
- case 7:
138
- interfaceCiMap = _context.sent;
139
- _context.next = 10;
150
+ case 8:
151
+ loadCiMap = _context.sent;
152
+ _context.next = 11;
140
153
  return _CiTypeCache["default"].load(interfaceTypes);
141
154
 
142
- case 10:
155
+ case 11:
143
156
  interfaceDoc = _context.sent;
144
- return _context.abrupt("return", mergeLinksData(links, linkCis, nodes, interfaceCiMap, interfaceDoc));
157
+ Object.assign(ciMap, loadCiMap); // console.log('getLinksDetail-mergeLinksData', { relations, interfaceIds, interfaceCis, })
158
+
159
+ return _context.abrupt("return", mergeLinksData(links, linkCis, nodes, ciMap, interfaceDoc));
145
160
 
146
- case 12:
161
+ case 14:
147
162
  case "end":
148
163
  return _context.stop();
149
164
  }
@@ -176,7 +191,8 @@ var plurals = {
176
191
  2: ["phy"],
177
192
  3: ["agg"],
178
193
  4: ["phy", "agg"]
179
- };
194
+ }; // 待办:移到网络拓扑组件
195
+
180
196
  exports.plurals = plurals;
181
197
 
182
198
  var showLinkByConfig = function showLinkByConfig(props) {
@@ -190,31 +206,29 @@ var showLinkByConfig = function showLinkByConfig(props) {
190
206
 
191
207
  var gv = topo.getGraphView();
192
208
  var dm = gv.getDataModel();
193
- var edges = (0, _htElementUtils.getEdges)(dm); // console.log("edges", edges);
209
+ var edges = (0, _htElementUtils.getEdges)(dm).filter(function (edge) {
210
+ return !(0, _htElementUtils.isEdgeGroupAgent)(edge);
211
+ }); // console.log("edges", edges);
194
212
 
195
213
  var showPhy = types.indexOf("phy") >= 0;
196
214
  var showAgg = types.indexOf("agg") >= 0; // console.log("edges----types",showType, types,showPhy, showAgg);
197
215
 
198
- if (Array.isArray(edges) && edges.length > 0) {
199
- edges.forEach(function (edge) {
200
- if (showType === 1 || showType === true) {
201
- // 单链路全部显示
202
- // console.log("单链路全部显示", edge);
203
- edge.s("2d.visible", true);
204
- } else {
205
- var _d$attributes, _d$attributes2;
206
-
207
- var d = topo.dataModel.getDataById(edge.getTag()); // 判断是否聚合链路
216
+ edges.forEach(function (edge) {
217
+ if (showType === 1 || showType === true) {
218
+ // 单链路全部显示
219
+ // console.log("单链路全部显示", edge);
220
+ edge.s("x.visible", true);
221
+ } else {
222
+ var d = topo.dataModel.getDataById(edge.getTag()); // 判断是否聚合链路
208
223
 
209
- if ((d === null || d === void 0 ? void 0 : (_d$attributes = d.attributes) === null || _d$attributes === void 0 ? void 0 : _d$attributes.destination_type) === "network.agg_interface" && (d === null || d === void 0 ? void 0 : (_d$attributes2 = d.attributes) === null || _d$attributes2 === void 0 ? void 0 : _d$attributes2.source_type) === "network.agg_interface") {
210
- edge.s("2d.visible", showAgg);
211
- } else {
212
- // console.log("edge", edge, d, showAgg);
213
- edge.s("2d.visible", showPhy);
214
- }
224
+ if (isAggLink(d)) {
225
+ edge.s("x.visible", showAgg);
226
+ } else {
227
+ // console.log("edge", edge, d, showAgg);
228
+ edge.s("x.visible", showPhy);
215
229
  }
216
- });
217
- }
230
+ }
231
+ });
218
232
  };
219
233
 
220
234
  exports.showLinkByConfig = showLinkByConfig;