@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
@@ -1,13 +1,14 @@
1
1
  import _asyncToGenerator from "@babel/runtime/helpers/asyncToGenerator";
2
2
  import _extends from "@babel/runtime/helpers/extends";
3
3
  import _regeneratorRuntime from "@babel/runtime/regenerator";
4
- import { rlog } from '@riil-frontend/component-topology-utils';
4
+ import Logger from 'loglevel';
5
5
  import { DEFAULT_NODE_TAG_COMMON_CONFIG, DEFAULT_TIP_COMMON_CONFIG } from "../../constants/ResourceInfoDisplay";
6
6
  import { isMonitoring } from "../utils/manageStatusUtil";
7
7
  import AttributeFormatter from "./attributeFormatter";
8
8
  import DictCache from "./cache/DictCache";
9
9
  import { getNodesNameVisible as _getNodesNameVisible, updateNodesNameVisible as _updateNodesNameVisible } from "./utils/nodeNameVisibleUtil";
10
10
  import { translateCisRefAttributeName } from "../../utils/ciRefAttributeTranslateUtil";
11
+ var rlog = Logger.getLogger('topo');
11
12
 
12
13
  function isGraphField(item) {
13
14
  return item.type === 'graph';
@@ -526,7 +527,7 @@ var AttributeMetricDisplay = /*#__PURE__*/function () {
526
527
  tags: tags
527
528
  });
528
529
  });
529
- rlog.debug('推送标注 => ht', elementTagsAndTips);
530
+ rlog.debug(' ==> ht: 推送标注', elementTagsAndTips);
530
531
  var htTopo = topo.getHtTopo();
531
532
 
532
533
  if (htTopo) {
@@ -537,7 +538,7 @@ var AttributeMetricDisplay = /*#__PURE__*/function () {
537
538
  try {
538
539
  htTopo.loadTagAndTip(JSON.parse(JSON.stringify(elementTagsAndTips)));
539
540
  } catch (error) {
540
- rlog.error('推送标注 => ht 失败', error);
541
+ rlog.error(' ==> ht: 推送标注失败', error);
541
542
  }
542
543
 
543
544
  (_topo$historyManager2 = topo.historyManager) === null || _topo$historyManager2 === void 0 ? void 0 : _topo$historyManager2.setDisabled(false, '加载标注');
@@ -1,5 +1,7 @@
1
1
  import _extends from "@babel/runtime/helpers/extends";
2
2
  import { rlog } from '@riil-frontend/component-topology-utils';
3
+ import Logger from 'loglevel';
4
+ var log = Logger.getLogger('topo.HistoryManager');
3
5
  var ht = window.ht;
4
6
 
5
7
  var HistoryManager = /*#__PURE__*/function () {
@@ -10,7 +12,7 @@ var HistoryManager = /*#__PURE__*/function () {
10
12
  this.topo = topo;
11
13
  this.htHistoryManager = htHistoryManager;
12
14
  htHistoryManager.clear();
13
- rlog.info('HistoryManager 初始化', htHistoryManager);
15
+ log.info('HistoryManager 初始化', htHistoryManager);
14
16
  this.updateStore = this.updateStore.bind(this);
15
17
  this.init();
16
18
  }
@@ -58,10 +60,10 @@ var HistoryManager = /*#__PURE__*/function () {
58
60
 
59
61
  _proto.setDisabled = function setDisabled(disabled, message) {
60
62
  this.htHistoryManager.setDisabled(disabled);
61
- rlog.debug("HistoryManager.setDisabled " + (disabled ? '禁用' : '启用') + (message ? "(" + message + ")" : '') + ": " + this.toString(), this.getHistories());
63
+ log.debug("HistoryManager.setDisabled: " + (disabled ? '禁用' : '启用') + ". <" + message + ">, " + this.toString() + ", ", 'Histories: ', this.getHistories());
62
64
  };
63
65
 
64
- _proto.beginTransaction = function beginTransaction() {
66
+ _proto.beginTransaction = function beginTransaction(name) {
65
67
  var _this = this;
66
68
 
67
69
  this.htHistoryManager.beginTransaction();
@@ -92,7 +94,7 @@ var HistoryManager = /*#__PURE__*/function () {
92
94
  oldValue: _this.topo.store.getModelState(item.modelName)[item.property]
93
95
  });
94
96
  });
95
- rlog.debug("HistoryManager.beginTransaction: " + this.toString(), this.getHistories());
97
+ log.debug("HistoryManager.beginTransaction: " + this.toString(), this.getHistories());
96
98
  };
97
99
 
98
100
  _proto.addStoreHistory = function addStoreHistory() {
@@ -117,16 +119,16 @@ var HistoryManager = /*#__PURE__*/function () {
117
119
  type: 'store',
118
120
  data: storeChanged
119
121
  });
120
- rlog.debug('HistoryManager.addStoreHistory', storeChanged);
122
+ log.debug('HistoryManager.addStoreHistory', storeChanged);
121
123
  }
122
124
 
123
125
  this.storeHistory = [];
124
126
  };
125
127
 
126
- _proto.endTransaction = function endTransaction() {
128
+ _proto.endTransaction = function endTransaction(name) {
127
129
  this.addStoreHistory();
128
130
  this.htHistoryManager.endTransaction();
129
- rlog.debug("HistoryManager.endTransaction: " + this.toString(), this.getHistories());
131
+ log.debug("HistoryManager.endTransaction: " + this.toString(), this.getHistories());
130
132
  };
131
133
 
132
134
  _proto.clear = function clear() {
@@ -170,7 +172,7 @@ var HistoryManager = /*#__PURE__*/function () {
170
172
  return;
171
173
  }
172
174
 
173
- rlog.debug('HistoryManager.undo', this.getHistories(), this.getHistoryIndex());
175
+ log.debug('HistoryManager.undo', this.getHistories(), this.getHistoryIndex());
174
176
  var storeHistory = this.getCurrentStoreHistory(true);
175
177
 
176
178
  if (storeHistory) {
@@ -188,7 +190,7 @@ var HistoryManager = /*#__PURE__*/function () {
188
190
  _proto.redo = function redo() {
189
191
  var _this4 = this;
190
192
 
191
- rlog.debug('HistoryManager.redo', this.getHistories(), this.getHistoryIndex());
193
+ log.debug('HistoryManager.redo', this.getHistories(), this.getHistoryIndex());
192
194
  var storeHistory = this.getCurrentStoreHistory(false);
193
195
 
194
196
  if (storeHistory) {
@@ -10,7 +10,7 @@ import Alarm from "./Alarm";
10
10
  import TopoGraphView from "./TopoGraphView";
11
11
  import createStore from "../store/createStore";
12
12
  import buildProvider from "../components/buildProvider";
13
- import { getEdgeDatas, getGroupDatas, getNodeData, getNodeDatas, getNodes as _getNodes } from "../../utils/htElementUtils";
13
+ import { getEdgeDatas, getGroupDatas, getNodeData, getNodeDatas, getNodes } from "../../utils/htElementUtils";
14
14
  import Test from "../test/Test";
15
15
  import { formatGroups } from "../../utils/topoData";
16
16
  import DictCache from "./cache/DictCache";
@@ -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 "13.0.0-dev.1" === 'string' ? "13.0.0-dev.1" : null;
27
+ var version = typeof "13.0.0-dev.10" === 'string' ? "13.0.0-dev.10" : null;
28
28
  console.info("\u62D3\u6251\u7248\u672C: " + version);
29
29
  /**
30
30
  * 拓扑显示和编辑
@@ -188,38 +188,29 @@ var Topo = /*#__PURE__*/function () {
188
188
 
189
189
  _proto.getData = function getData() {
190
190
  return {
191
- groups: this.getGroups(),
192
- nodes: this.getNodes(),
193
- lines: this.getLines(),
191
+ groups: getGroupDatas(this.getDataModel()),
192
+ nodes: getNodes(this.getDataModel()).filter(function (node) {
193
+ return !!node.getTag();
194
+ }).map(getNodeData),
194
195
  customNodes: getNodeDatas(this.getDataModel()).filter(function (item) {
195
196
  return !item.id;
196
197
  }),
197
- customLines: this.getEdges().filter(function (item) {
198
+ lines: getEdgeDatas(this.getDataModel()).filter(function (item) {
199
+ return !!item.id;
200
+ }),
201
+ customLines: getEdgeDatas(this.getDataModel()).filter(function (item) {
198
202
  return !item.id;
199
203
  })
200
204
  };
201
- };
202
-
203
- _proto.getGroups = function getGroups() {
204
- return getGroupDatas(this.getDataModel());
205
- };
206
-
207
- _proto.getNodes = function getNodes() {
208
- var nodes = _getNodes(this.getDataModel()).filter(function (node) {
209
- return !!node.getTag();
210
- });
211
-
212
- return nodes.map(getNodeData);
213
- };
205
+ }
206
+ /**
207
+ * @deprecated 待移除。uicbb有使用
208
+ * @returns
209
+ */
210
+ ;
214
211
 
215
212
  _proto.getLines = function getLines() {
216
- return this.getEdges().filter(function (item) {
217
- return !!item.id;
218
- });
219
- };
220
-
221
- _proto.getEdges = function getEdges() {
222
- return getEdgeDatas(this.getDataModel());
213
+ return this.getData().lines;
223
214
  }
224
215
  /**
225
216
  * 全量更新数据
@@ -278,18 +269,19 @@ var Topo = /*#__PURE__*/function () {
278
269
  /*#__PURE__*/
279
270
  function () {
280
271
  var _addElements = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee5(elements) {
281
- var data;
272
+ var prevData, data;
282
273
  return _regeneratorRuntime.wrap(function _callee5$(_context5) {
283
274
  while (1) switch (_context5.prev = _context5.next) {
284
275
  case 0:
276
+ prevData = this.getData();
285
277
  data = {
286
- groups: [].concat(this.getGroups(), elements.groups || []),
287
- nodes: [].concat(this.getNodes(), elements.nodes || []),
288
- lines: [].concat(this.getLines(), elements.lines || [])
278
+ groups: [].concat(prevData.groups, elements.groups || []),
279
+ nodes: [].concat(prevData.nodes, elements.nodes || []),
280
+ lines: [].concat(prevData.lines, elements.lines || [])
289
281
  };
290
282
  this.updateElements(data); // TODO 更新store,触发属性、指标模型加载,更新指标
291
283
 
292
- case 2:
284
+ case 3:
293
285
  case "end":
294
286
  return _context5.stop();
295
287
  }
@@ -516,38 +508,39 @@ var Topo = /*#__PURE__*/function () {
516
508
  while (1) switch (_context12.prev = _context12.next) {
517
509
  case 0:
518
510
  rlog.info('TopoApp.enterEditMode');
511
+ this.historyManager = null;
519
512
 
520
513
  if (!this.options.onSwitchToEditModeBegin) {
521
- _context12.next = 4;
514
+ _context12.next = 5;
522
515
  break;
523
516
  }
524
517
 
525
- _context12.next = 4;
518
+ _context12.next = 5;
526
519
  return this.options.onSwitchToEditModeBegin(this);
527
520
 
528
- case 4:
521
+ case 5:
529
522
  topoDispatchers = this.store.getModelDispatchers('topoMod');
530
- _context12.next = 7;
523
+ _context12.next = 8;
531
524
  return topoDispatchers.update({
532
525
  viewState: 'edit'
533
526
  });
534
527
 
535
- case 7:
536
- _context12.next = 9;
528
+ case 8:
529
+ _context12.next = 10;
537
530
  return this.view.switchToEditMode();
538
531
 
539
- case 9:
532
+ case 10:
540
533
  updateEdgeExpanded(this);
541
534
 
542
535
  if (!this.options.onSwitchToEditMode) {
543
- _context12.next = 13;
536
+ _context12.next = 14;
544
537
  break;
545
538
  }
546
539
 
547
- _context12.next = 13;
540
+ _context12.next = 14;
548
541
  return this.options.onSwitchToEditMode(this);
549
542
 
550
- case 13:
543
+ case 14:
551
544
  if (this.getDataModel()) {
552
545
  // 更新节点名称显示隐藏
553
546
  this.attributeMetricDisplay.updateNodesNameVisible();
@@ -557,7 +550,7 @@ var Topo = /*#__PURE__*/function () {
557
550
  iconManageDispatchers = this.store.getModelDispatchers('customIcon');
558
551
  iconManageDispatchers.loadEditorIcons();
559
552
 
560
- case 16:
553
+ case 17:
561
554
  case "end":
562
555
  return _context12.stop();
563
556
  }
@@ -581,18 +574,19 @@ var Topo = /*#__PURE__*/function () {
581
574
  return this.view.switchToViewMode();
582
575
 
583
576
  case 2:
577
+ this.historyManager = null;
584
578
  editDispatchers = this.store.getModelDispatchers('topoConfig');
585
579
  editDispatchers.switchToViewMode(this.id);
586
580
 
587
581
  if (!this.options.onSwitchToViewMode) {
588
- _context13.next = 7;
582
+ _context13.next = 8;
589
583
  break;
590
584
  }
591
585
 
592
- _context13.next = 7;
586
+ _context13.next = 8;
593
587
  return this.options.onSwitchToViewMode(this);
594
588
 
595
- case 7:
589
+ case 8:
596
590
  case "end":
597
591
  return _context13.stop();
598
592
  }
@@ -41,11 +41,11 @@ export function saveTopo(_x) {
41
41
 
42
42
  function _saveTopo() {
43
43
  _saveTopo = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(data) {
44
- var topoService, topoId, template, layout, backgroundId, globalConfig, serialize, resources, groups, relateTopoIdList, viewGroupId, groupInfo, viewResources, linkIps;
44
+ var topoService, topoId, template, layout, backgroundId, globalConfig, serialize, resources, groups, viewGroupId, groupInfo, viewResources;
45
45
  return _regeneratorRuntime.wrap(function _callee$(_context) {
46
46
  while (1) switch (_context.prev = _context.next) {
47
47
  case 0:
48
- 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;
48
+ 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;
49
49
  rlog.debug("saveTopo", data); // 保存布局
50
50
 
51
51
  if (!(template && layout)) {
@@ -72,7 +72,7 @@ function _saveTopo() {
72
72
 
73
73
  case 8:
74
74
  if (!(resources || groups)) {
75
- _context.next = 16;
75
+ _context.next = 15;
76
76
  break;
77
77
  }
78
78
 
@@ -94,30 +94,22 @@ function _saveTopo() {
94
94
  });
95
95
  }
96
96
 
97
- linkIps = []; // resources?.static.map((nodeId) => {
98
- // if (nodeId.startsWith("ip_")) {
99
- // linkIps.push(nodeId.replace("ip_", ""));
100
- // }
101
- // });
102
-
103
97
  rlog.debug("saveTopo-groupInfo", groupInfo);
104
- _context.next = 16;
98
+ _context.next = 15;
105
99
  return topoService.bindResourceToTopo(topoId, {
106
- groups: groupInfo,
107
- linkIps: linkIps,
108
- relateTopoIdList: relateTopoIdList
100
+ groups: groupInfo
109
101
  });
110
102
 
111
- case 16:
103
+ case 15:
112
104
  if (!serialize) {
113
- _context.next = 19;
105
+ _context.next = 18;
114
106
  break;
115
107
  }
116
108
 
117
- _context.next = 19;
109
+ _context.next = 18;
118
110
  return topoService.saveSerializeData(topoId, serialize);
119
111
 
120
- case 19:
112
+ case 18:
121
113
  case "end":
122
114
  return _context.stop();
123
115
  }
@@ -2,10 +2,9 @@ import _asyncToGenerator from "@babel/runtime/helpers/asyncToGenerator";
2
2
  import _extends from "@babel/runtime/helpers/extends";
3
3
  import _regeneratorRuntime from "@babel/runtime/regenerator";
4
4
  import keyBy from "lodash/keyBy";
5
- import _ from "lodash";
6
- import { queryCisByIds, queryModelAsset } from "../../services"; // 查询所有连线
5
+ import _ from "lodash"; // 查询所有连线
7
6
 
8
- import { getEdges } from "../../../utils/htElementUtils";
7
+ import { getEdges, isEdgeGroupAgent } from "../../../utils/htElementUtils";
9
8
  import CiTypeCache from "../cache/CiTypeCache";
10
9
  import CiCache from "../cache/CiCache"; // const interfaceTypeMap = {
11
10
  // "network.interface": {
@@ -32,42 +31,49 @@ export function isCrucialLink(link) {
32
31
  */
33
32
 
34
33
  export function isExitLink(link) {
35
- return (link === null || link === void 0 ? void 0 : link.attributes) && !(link !== null && link !== void 0 && link.attributes["destination_id"]);
34
+ var _link$attributes;
35
+
36
+ return (link === null || link === void 0 ? void 0 : (_link$attributes = link.attributes) === null || _link$attributes === void 0 ? void 0 : _link$attributes.destination_type) === "ip";
37
+ }
38
+ /**
39
+ * 是否聚合链路
40
+ * @param {*} link
41
+ * @returns
42
+ */
43
+
44
+ export function isAggLink(link) {
45
+ var _link$attributes2, _link$attributes3;
46
+
47
+ 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";
36
48
  }
37
- export function mergeLinksData(links, linkCis, nodes, interfaceCiMap, interfaceDoc) {
49
+ export function mergeLinksData(links, linkCis, nodes, ciMap, interfaceDoc) {
38
50
  var linkCiMap = keyBy(links, "id");
39
51
  return links.map(function (link) {
40
- var _interfaceCiMap$attri, _interfaceCiMap$attri2;
52
+ var _ciMap$attributes$net, _ciMap$attributes$net2, _ciMap$attributes$sou, _ciMap$attributes$des;
41
53
 
42
54
  var linkCi = linkCiMap[link.id];
43
55
 
44
- var attributes = _extends({}, linkCi === null || linkCi === void 0 ? void 0 : linkCi.attributes);
56
+ var attributes = _extends({}, linkCi === null || linkCi === void 0 ? void 0 : linkCi.attributes); // 翻译
45
57
 
46
- var sourceNode = nodes.find(function (node) {
47
- return node.id === attributes["network_link.source_device_id"];
48
- });
49
- var targetNode = nodes.find(function (node) {
50
- return node.id === attributes["network_link.destination_device_id"];
51
- }); // 翻译
52
58
 
53
59
  return _extends({}, link, {
54
60
  attributes: _extends({}, attributes, {
55
61
  // 源/目的设备
56
62
  "network_link.source_device_id_object": {
57
- displayName: sourceNode === null || sourceNode === void 0 ? void 0 : sourceNode.name
63
+ 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"]
58
64
  },
59
65
  "network_link.destination_device_id_object": {
60
- displayName: targetNode === null || targetNode === void 0 ? void 0 : targetNode.name
66
+ 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"]
61
67
  },
62
68
  // 源/目的接口类型
63
69
  source_type_object: interfaceDoc[attributes.source_type],
64
70
  destination_type_object: interfaceDoc[attributes.destination_type],
65
71
  // 源/目的接口
66
72
  source_id_object: {
67
- displayName: (_interfaceCiMap$attri = interfaceCiMap[attributes.source_id]) === null || _interfaceCiMap$attri === void 0 ? void 0 : _interfaceCiMap$attri.attributes["display_name"]
73
+ displayName: (_ciMap$attributes$sou = ciMap[attributes.source_id]) === null || _ciMap$attributes$sou === void 0 ? void 0 : _ciMap$attributes$sou.attributes["display_name"]
68
74
  },
69
75
  destination_id_object: {
70
- displayName: (_interfaceCiMap$attri2 = interfaceCiMap[attributes.destination_id]) === null || _interfaceCiMap$attri2 === void 0 ? void 0 : _interfaceCiMap$attri2.attributes["display_name"]
76
+ displayName: (_ciMap$attributes$des = ciMap[attributes.destination_id]) === null || _ciMap$attributes$des === void 0 ? void 0 : _ciMap$attributes$des.attributes["display_name"]
71
77
  }
72
78
  })
73
79
  });
@@ -79,11 +85,11 @@ export function getLinksDetail(_x, _x2) {
79
85
 
80
86
  function _getLinksDetail() {
81
87
  _getLinksDetail = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(links, nodes) {
82
- var linkCis, interfaceIds, interfaceTypes, interfaceCiMap, interfaceDoc;
88
+ var linkCis, ciMap, ciIds, interfaceTypes, loadCiMap, interfaceDoc;
83
89
  return _regeneratorRuntime.wrap(function _callee$(_context) {
84
90
  while (1) switch (_context.prev = _context.next) {
85
91
  case 0:
86
- if (!(!links || !links.length)) {
92
+ if (links !== null && links !== void 0 && links.length) {
87
93
  _context.next = 2;
88
94
  break;
89
95
  }
@@ -91,15 +97,21 @@ function _getLinksDetail() {
91
97
  return _context.abrupt("return", []);
92
98
 
93
99
  case 2:
94
- // const linkCis = await topoService.relation.batchQueryRelation(
95
- // links.map((link) => link.id)
96
- // );
97
100
  linkCis = links;
98
- interfaceIds = [].concat(linkCis.map(function (item) {
101
+ ciMap = keyBy(nodes, "id");
102
+ ciIds = _.uniq([].concat(linkCis.map(function (item) {
103
+ return item.attributes['network_link.destination_device_id'];
104
+ }), linkCis.map(function (item) {
105
+ return item.attributes['network_link.source_device_id'];
106
+ }), linkCis.map(function (item) {
99
107
  return item.attributes.source_id;
100
108
  }), linkCis.map(function (item) {
101
109
  return item.attributes.destination_id;
102
- }));
110
+ }))).filter(function (item) {
111
+ return !!item;
112
+ }).filter(function (item) {
113
+ return !ciMap[item];
114
+ });
103
115
  interfaceTypes = _.compact(_.uniq([].concat(linkCis.map(function (item) {
104
116
  return item.attributes.source_type;
105
117
  }), linkCis.map(function (item) {
@@ -107,19 +119,21 @@ function _getLinksDetail() {
107
119
  })))).filter(function (item) {
108
120
  return item !== "ip";
109
121
  });
110
- _context.next = 7;
111
- return CiCache.load(interfaceIds);
122
+ _context.next = 8;
123
+ return CiCache.load(ciIds);
112
124
 
113
- case 7:
114
- interfaceCiMap = _context.sent;
115
- _context.next = 10;
125
+ case 8:
126
+ loadCiMap = _context.sent;
127
+ _context.next = 11;
116
128
  return CiTypeCache.load(interfaceTypes);
117
129
 
118
- case 10:
130
+ case 11:
119
131
  interfaceDoc = _context.sent;
120
- return _context.abrupt("return", mergeLinksData(links, linkCis, nodes, interfaceCiMap, interfaceDoc));
132
+ Object.assign(ciMap, loadCiMap); // console.log('getLinksDetail-mergeLinksData', { relations, interfaceIds, interfaceCis, })
121
133
 
122
- case 12:
134
+ return _context.abrupt("return", mergeLinksData(links, linkCis, nodes, ciMap, interfaceDoc));
135
+
136
+ case 14:
123
137
  case "end":
124
138
  return _context.stop();
125
139
  }
@@ -149,7 +163,8 @@ export var plurals = {
149
163
  2: ["phy"],
150
164
  3: ["agg"],
151
165
  4: ["phy", "agg"]
152
- };
166
+ }; // 待办:移到网络拓扑组件
167
+
153
168
  export var showLinkByConfig = function showLinkByConfig(props) {
154
169
  var _plurals$compatibleWi;
155
170
 
@@ -161,31 +176,29 @@ export var showLinkByConfig = function showLinkByConfig(props) {
161
176
 
162
177
  var gv = topo.getGraphView();
163
178
  var dm = gv.getDataModel();
164
- var edges = getEdges(dm); // console.log("edges", edges);
179
+ var edges = getEdges(dm).filter(function (edge) {
180
+ return !isEdgeGroupAgent(edge);
181
+ }); // console.log("edges", edges);
165
182
 
166
183
  var showPhy = types.indexOf("phy") >= 0;
167
184
  var showAgg = types.indexOf("agg") >= 0; // console.log("edges----types",showType, types,showPhy, showAgg);
168
185
 
169
- if (Array.isArray(edges) && edges.length > 0) {
170
- edges.forEach(function (edge) {
171
- if (showType === 1 || showType === true) {
172
- // 单链路全部显示
173
- // console.log("单链路全部显示", edge);
174
- edge.s("2d.visible", true);
175
- } else {
176
- var _d$attributes, _d$attributes2;
177
-
178
- var d = topo.dataModel.getDataById(edge.getTag()); // 判断是否聚合链路
186
+ edges.forEach(function (edge) {
187
+ if (showType === 1 || showType === true) {
188
+ // 单链路全部显示
189
+ // console.log("单链路全部显示", edge);
190
+ edge.s("x.visible", true);
191
+ } else {
192
+ var d = topo.dataModel.getDataById(edge.getTag()); // 判断是否聚合链路
179
193
 
180
- 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") {
181
- edge.s("2d.visible", showAgg);
182
- } else {
183
- // console.log("edge", edge, d, showAgg);
184
- edge.s("2d.visible", showPhy);
185
- }
194
+ if (isAggLink(d)) {
195
+ edge.s("x.visible", showAgg);
196
+ } else {
197
+ // console.log("edge", edge, d, showAgg);
198
+ edge.s("x.visible", showPhy);
186
199
  }
187
- });
188
- }
200
+ }
201
+ });
189
202
  };
190
203
  export var mergeExportLinkData = function mergeExportLinkData(props) {
191
204
  var source = props.source,
@@ -8,13 +8,14 @@ import _regeneratorRuntime from "@babel/runtime/regenerator";
8
8
  import { getUUID, isAvailableArray } from "@riil-frontend/utils";
9
9
  import { transformTopoElements } from "@riil-frontend/component-topology-graph/es/utils";
10
10
  import { TOPO_PARENT_ID } from "@riil-frontend/component-topology-common/es/services/topo";
11
- import rlog from "@riil-frontend/component-topology-utils/es/rlog";
11
+ import Logger from 'loglevel';
12
12
  import { removeFromArray } from "../../../utils/format";
13
13
  import { DEFAULT_GROUP } from "../../../utils/template";
14
14
  import { combTopoData, getCiTypes } from "../../../utils/topoData";
15
15
  import { saveTopo as _saveTopo, resToConditions, getLayoutId } from "../../../core/models/topoData";
16
16
  import networkLinkServer from "../../../networkTopo/services/topo/networkLink";
17
17
  import { addLinkData, buildData as buildTopoData } from "../../../networkTopo/getTopoData";
18
+ var rlog = Logger.getLogger('topo');
18
19
 
19
20
  var newGroupWithUUID = function newGroupWithUUID(group) {
20
21
  if (group === void 0) {
@@ -259,13 +260,7 @@ export default function (topoApp) {
259
260
 
260
261
  case 5:
261
262
  data = _context2.sent;
262
- rlog.debug("按配置查询拓扑数据", {
263
- config: {
264
- resources: resources,
265
- groups: groups
266
- },
267
- data: data
268
- });
263
+ rlog.debug("按配置查询拓扑数据. 参数:", query, ", 返回结果: ", data);
269
264
  return _context2.abrupt("return", data);
270
265
 
271
266
  case 8:
@@ -327,10 +322,11 @@ export default function (topoApp) {
327
322
 
328
323
  case 11:
329
324
  data = _context4.sent;
330
- _context4.next = 14;
325
+ rlog.debug("getTopoByConditions--------", data, groupInfo);
326
+ _context4.next = 15;
331
327
  return Promise.all([addLinkData(data), topoApp.ciTyeCache.load(getCiTypes(data)), dispatch.customIcon.loadCustomIcons()]);
332
328
 
333
- case 14:
329
+ case 15:
334
330
  _yield$Promise$all = _context4.sent;
335
331
  dataWithLinkDetail = _yield$Promise$all[0];
336
332
  _combTopoData = combTopoData({
@@ -357,7 +353,7 @@ export default function (topoApp) {
357
353
  topoDataTrans: topoDataTrans
358
354
  });
359
355
 
360
- case 22:
356
+ case 23:
361
357
  case "end":
362
358
  return _context4.stop();
363
359
  }
@@ -1,12 +1,13 @@
1
1
  import rlog from "@riil-frontend/component-topology-utils/es/rlog";
2
2
  import { showLinkByConfig } from "../models/utils/linkUtils";
3
+ import { isEdgeGroupAgent } from "../../utils/htElementUtils";
3
4
  /**
4
5
  * 是否手工连线
5
6
  * @param {*} edge
6
7
  */
7
8
 
8
9
  export function isCustomEdge(edge) {
9
- return !edge.isEdgeGroupAgent() && (edge.a('type') == 'line' || !edge.a('type'));
10
+ return !isEdgeGroupAgent(edge) && (edge.a('type') == 'line' || !edge.a('type'));
10
11
  }
11
12
  /**
12
13
  * 根据配置更新连线展开折叠状态
@@ -15,7 +16,7 @@ export function isCustomEdge(edge) {
15
16
  */
16
17
 
17
18
  export var updateEdgeExpanded = function updateEdgeExpanded(topo) {
18
- var _topo$historyManager, _topo$historyManager2;
19
+ var _topo$historyManager, _topo$historyManager2, _topo$linkDynamicStyl;
19
20
 
20
21
  var _topo$store$getModelS = topo.store.getModelState("topoMod"),
21
22
  viewState = _topo$store$getModelS.viewState;
@@ -28,8 +29,7 @@ export var updateEdgeExpanded = function updateEdgeExpanded(topo) {
28
29
  }
29
30
 
30
31
  var _topo$store$getModelS2 = topo.store.getModelState("displayConfig"),
31
- expandAllEdges = _topo$store$getModelS2.expandAllEdges; // console.log("expandAllEdges----------", expandAllEdges);
32
-
32
+ expandAllEdges = _topo$store$getModelS2.expandAllEdges;
33
33
 
34
34
  (_topo$historyManager = topo.historyManager) === null || _topo$historyManager === void 0 ? void 0 : _topo$historyManager.setDisabled(true, '连线展开控制');
35
35
 
@@ -38,10 +38,10 @@ export var updateEdgeExpanded = function updateEdgeExpanded(topo) {
38
38
  topo: topo,
39
39
  showType: 1
40
40
  });
41
- htTopo.collapseAllEdgeGroups();
41
+ htTopo.toggleAllEdgeGroups(false);
42
42
  rlog.debug("updateEdgeExpanded 折叠");
43
43
  } else {
44
- htTopo.expandAllEdgeGroups();
44
+ htTopo.toggleAllEdgeGroups(true);
45
45
  showLinkByConfig({
46
46
  topo: topo,
47
47
  showType: expandAllEdges,
@@ -51,8 +51,5 @@ export var updateEdgeExpanded = function updateEdgeExpanded(topo) {
51
51
  }
52
52
 
53
53
  (_topo$historyManager2 = topo.historyManager) === null || _topo$historyManager2 === void 0 ? void 0 : _topo$historyManager2.setDisabled(false, '连线展开控制');
54
-
55
- if (topo.linkDynamicStyleExecutor) {
56
- topo.linkDynamicStyleExecutor.execute();
57
- }
54
+ (_topo$linkDynamicStyl = topo.linkDynamicStyleExecutor) === null || _topo$linkDynamicStyl === void 0 ? void 0 : _topo$linkDynamicStyl.execute();
58
55
  };