@riil-frontend/component-topology 12.1.0-dev.9 → 12.1.1

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 (54) hide show
  1. package/build/1.js +1 -1
  2. package/build/index.css +1 -1
  3. package/build/index.js +14 -14
  4. package/es/components/ResourceSelectDrawer/ResourceSelectDrawer.js +1 -1
  5. package/es/core/components/TopoView/topoView.js +7 -4
  6. package/es/core/editor/components/Sidebar/views/ImagePanel/ImagePanel.js +11 -3
  7. package/es/core/editor/components/settings/core/updateElementProperty.js +3 -2
  8. package/es/core/editor/components/settings/propertyViews/view/GlobalEdgeToggle.js +2 -2
  9. package/es/core/editor/hooks/useKeyboardShortcut.js +4 -0
  10. package/es/core/editor/hooks/useNewElementTheme.js +20 -16
  11. package/es/core/hooks/useGraphAlarmDisplay.js +4 -0
  12. package/es/core/hooks/usePolling.js +2 -1
  13. package/es/core/hooks/useTopoEdit.js +208 -243
  14. package/es/core/models/AttributeMetricDisplay.js +4 -3
  15. package/es/core/models/HistoryManager.js +11 -9
  16. package/es/core/models/TopoApp.js +17 -15
  17. package/es/core/models/topoData.js +7 -14
  18. package/es/core/models/utils/linkUtils.js +2 -2
  19. package/es/core/store/models/topoConfig.js +7 -11
  20. package/es/core/utils/edgeUtil.js +7 -11
  21. package/es/core/viewer/components/plugins/ResourceDetail/components/ResourceOverview/EventsCard.js +1 -1
  22. package/es/core/viewer/components/plugins/ResourceDetail/components/ResourceOverview/components/LinkTopo/LinkTopo.module.scss +1 -1
  23. package/es/networkTopo/models/LinkDynamicStyleExecutor.js +7 -63
  24. package/es/networkTopo/utils/exitLinkUtil.js +23 -11
  25. package/es/style.js +1 -1
  26. package/es/utils/clusterUtil.js +3 -3
  27. package/es/utils/htElementUtils.js +8 -108
  28. package/lib/components/ResourceSelectDrawer/ResourceSelectDrawer.js +1 -1
  29. package/lib/core/components/TopoView/topoView.js +15 -19
  30. package/lib/core/editor/components/Sidebar/views/ImagePanel/ImagePanel.js +12 -3
  31. package/lib/core/editor/components/settings/core/updateElementProperty.js +7 -2
  32. package/lib/core/editor/components/settings/propertyViews/view/GlobalEdgeToggle.js +2 -2
  33. package/lib/core/editor/hooks/useKeyboardShortcut.js +4 -0
  34. package/lib/core/editor/hooks/useNewElementTheme.js +20 -16
  35. package/lib/core/hooks/useGraphAlarmDisplay.js +4 -0
  36. package/lib/core/hooks/usePolling.js +6 -5
  37. package/lib/core/hooks/useTopoEdit.js +214 -267
  38. package/lib/core/models/AttributeMetricDisplay.js +6 -6
  39. package/lib/core/models/HistoryManager.js +13 -17
  40. package/lib/core/models/TopoApp.js +18 -15
  41. package/lib/core/models/topoData.js +7 -14
  42. package/lib/core/models/utils/linkUtils.js +1 -1
  43. package/lib/core/store/models/topoConfig.js +13 -25
  44. package/lib/core/utils/edgeUtil.js +6 -10
  45. package/lib/core/viewer/components/plugins/ResourceDetail/components/ResourceOverview/EventsCard.js +1 -1
  46. package/lib/core/viewer/components/plugins/ResourceDetail/components/ResourceOverview/components/LinkTopo/LinkTopo.module.scss +1 -1
  47. package/lib/networkTopo/models/LinkDynamicStyleExecutor.js +6 -64
  48. package/lib/networkTopo/utils/exitLinkUtil.js +23 -11
  49. package/lib/style.js +1 -1
  50. package/lib/utils/clusterUtil.js +2 -2
  51. package/lib/utils/htElementUtils.js +9 -119
  52. package/package.json +2 -2
  53. package/es/networkTopo/models/LinkTagsTipsBuilder.js +0 -235
  54. package/lib/networkTopo/models/LinkTagsTipsBuilder.js +0 -245
@@ -3,11 +3,9 @@
3
3
  var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
4
 
5
5
  exports.__esModule = true;
6
+ exports.containsElement = containsElement;
6
7
  exports.getEdgeDatas = getEdgeDatas;
7
8
  exports.getEdgeGroupAgents = getEdgeGroupAgents;
8
- exports.getEdgeGroupByNodeTags = getEdgeGroupByNodeTags;
9
- exports.getEdgeGroupByNodes = getEdgeGroupByNodes;
10
- exports.getEdgeGroups = getEdgeGroups;
11
9
  exports.getEdges = getEdges;
12
10
  exports.getEdgesBetweenNodes = getEdgesBetweenNodes;
13
11
  exports.getElements = getElements;
@@ -26,11 +24,8 @@ exports.getNodeDatas = getNodeDatas;
26
24
  exports.getNodes = getNodes;
27
25
  exports.getNodesByGroupIdOrTag = getNodesByGroupIdOrTag;
28
26
  exports.isEdge = isEdge;
29
- exports.isEdgeGroup = isEdgeGroup;
30
27
  exports.isEdgeGroupAgent = isEdgeGroupAgent;
31
- exports.isEdgeGroupExpanded = isEdgeGroupExpanded;
32
28
  exports.isEdgeVisible = isEdgeVisible;
33
- exports.isExistedElement = isExistedElement;
34
29
  exports.isGroup = isGroup;
35
30
  exports.isLayer = isLayer;
36
31
  exports.isNode = isNode;
@@ -174,16 +169,6 @@ function getNodeData(element) {
174
169
  function getEdges(dataModel) {
175
170
  return getElements(dataModel).filter(isValidEdge);
176
171
  }
177
- /**
178
- * 是否连线组
179
- * @param {ht.Edge} edge
180
- * @returns
181
- */
182
-
183
-
184
- function isEdgeGroup(edge) {
185
- return isEdge(edge) && edge.a('x.edgegroup.isEdgeGroup');
186
- }
187
172
  /**
188
173
  * 是否连线组代理
189
174
  * @param {*} edge
@@ -192,17 +177,7 @@ function isEdgeGroup(edge) {
192
177
 
193
178
 
194
179
  function isEdgeGroupAgent(edge) {
195
- return isEdgeGroup(edge);
196
- }
197
- /**
198
- * TODO
199
- * @param {*} edge
200
- * @returns
201
- */
202
-
203
-
204
- function isEdgeGroupExpanded(edge) {
205
- return isEdge(edge) && edge.getEdgeGroup() && !!edge.s("edge.expanded");
180
+ return isEdge(edge) && edge.a('x.edgegroup.isEdgeGroup');
206
181
  }
207
182
 
208
183
  function isEdgeVisible(edge) {
@@ -233,66 +208,6 @@ function getEdgesBetweenNodes(node1, node2) {
233
208
  });
234
209
  return edges;
235
210
  }
236
- /**
237
- * 获得节点间的连线组,连线<=1时返回null
238
- * @returns
239
- */
240
-
241
-
242
- function getEdgeGroupByNodes(node1, node2) {
243
- var htEdgeGroup = null;
244
- getEdgesBetweenNodes(node1, node2).forEach(function (edge) {
245
- if (!htEdgeGroup) {
246
- htEdgeGroup = edge.getEdgeGroup();
247
- }
248
- });
249
-
250
- if (!htEdgeGroup) {
251
- return null;
252
- }
253
-
254
- return new _EdgeGroup["default"](htEdgeGroup);
255
- }
256
- /**
257
- * 获得节点间的连线组,连线<=1时返回null
258
- * @returns
259
- */
260
-
261
-
262
- function getEdgeGroupByNodeTags(dataModel, nodeTag1, nodeTag2) {
263
- var node1 = dataModel.getDataByTag(nodeTag1);
264
- var node2 = dataModel.getDataByTag(nodeTag2);
265
-
266
- if (!node1 || !node2) {
267
- console.warn("getEdgeGroupByNodes 未找到节点", {
268
- node1: node1,
269
- node2: node2,
270
- nodeTag1: nodeTag1,
271
- nodeTag2: nodeTag2
272
- });
273
- return null;
274
- }
275
-
276
- return getEdgeGroupByNodes(node1, node2);
277
- }
278
- /**
279
- * 获得连线组连线列表
280
- * @param {*} dataModel
281
- * @returns
282
- */
283
-
284
-
285
- function getEdgeGroups(dataModel) {
286
- var edgeGroups = [];
287
- getEdges(dataModel).forEach(function (edge) {
288
- var group = edge.getEdgeGroup();
289
-
290
- if (group && !edgeGroups.includes(group)) {
291
- edgeGroups.push(group);
292
- }
293
- });
294
- return edgeGroups;
295
- }
296
211
  /**
297
212
  * 获得连线组连线列表
298
213
  * @param {*} dataModel
@@ -306,7 +221,7 @@ function getEdgeGroupAgents(dataModel) {
306
221
 
307
222
  function getEdgeDatas(dataModel) {
308
223
  return getEdges(dataModel).filter(function (edge) {
309
- return !isEdgeGroup(edge);
224
+ return !isEdgeGroupAgent(edge);
310
225
  }).map(function (element) {
311
226
  var _element$getSource, _element$getTarget;
312
227
 
@@ -415,10 +330,14 @@ function setElementRuntimeStyle(element, name, value) {
415
330
  }
416
331
  /**
417
332
  * 判断拓扑图是否存在元素
333
+ *
334
+ * @param {*} dataModel
335
+ * @param {{id?: string, tag?: string}} data
336
+ * @returns
418
337
  */
419
338
 
420
339
 
421
- function isExistedElement(htTopo, dataModel, data) {
340
+ function containsElement(dataModel, data) {
422
341
  if (dataModel.getDataByTag(data.id)) {
423
342
  return true;
424
343
  } // 识别区域
@@ -427,34 +346,5 @@ function isExistedElement(htTopo, dataModel, data) {
427
346
  var element = getElements(dataModel).find(function (item) {
428
347
  return data.tag && item.a("tag") === data.tag;
429
348
  });
430
-
431
- if (element) {
432
- return true;
433
- } // 连线/连线组
434
-
435
-
436
- var edges = getEdges(dataModel);
437
-
438
- for (var i = 0; i < edges.length; i++) {
439
- var edge = edges[i]; // 如果连线组折叠,判断子连线
440
-
441
- var edgeData = htTopo.getEdgeData(edge);
442
-
443
- if (edgeData) {
444
- // eslint-disable-next-line no-underscore-dangle
445
- var id = edgeData._attrObject.id;
446
-
447
- if (id === data.id) {
448
- return true;
449
- }
450
- } // 如果连线组展开,判断连线组
451
- // eslint-disable-next-line no-underscore-dangle
452
-
453
-
454
- if (edge.__edgeGroup && edge.__edgeGroup._tag === data.id) {
455
- return true;
456
- }
457
- }
458
-
459
- return false;
349
+ return !!element;
460
350
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@riil-frontend/component-topology",
3
- "version": "12.1.0-dev.9",
3
+ "version": "12.1.1",
4
4
  "description": "拓扑",
5
5
  "scripts": {
6
6
  "start": "build-scripts start",
@@ -123,6 +123,6 @@
123
123
  "access": "public"
124
124
  },
125
125
  "license": "MIT",
126
- "homepage": "https://unpkg.com/@riil-frontend/component-topology@12.1.0-dev.9/build/index.html",
126
+ "homepage": "https://unpkg.com/@riil-frontend/component-topology@12.1.1/build/index.html",
127
127
  "gitHead": "2da19ffccbb7ca60a8acf396e39f542c68bb33f5"
128
128
  }
@@ -1,235 +0,0 @@
1
- import _extends from "@babel/runtime/helpers/extends";
2
-
3
- /**
4
- * 连线组标注、悬浮框数据构建
5
- */
6
- import { rlog } from '@riil-frontend/component-topology-utils';
7
- import { getEdgeGroups } from "../../utils/htElementUtils";
8
- import AttributeFormatter from "../../core/models/attributeFormatter"; // 参与计算的链路指标
9
-
10
- var metrics = [// 总流速
11
- {
12
- code: 'interface_totalbps',
13
- calcType: 'sum'
14
- }, // 带宽利用率
15
- {
16
- code: 'bandwidth_utilization',
17
- calcType: 'avg'
18
- }, // 发送带宽利用率
19
- {
20
- code: 'out_bandwidth_utilization',
21
- calcType: 'avg',
22
- showWhenSameSource: true
23
- }, // 接收带宽利用率
24
- {
25
- code: 'in_bandwidth_utilization',
26
- calcType: 'avg',
27
- showWhenSameSource: true
28
- }, {
29
- code: 'out_rate',
30
- calcType: 'sum',
31
- showWhenSameSource: true
32
- }, {
33
- code: 'in_rate',
34
- calcType: 'sum',
35
- showWhenSameSource: true
36
- }];
37
- var calcFnMap = {
38
- sum: function sum(values) {
39
- return values.reduce(function (total, val) {
40
- return total + parseInt(val || 0, 10);
41
- }, 0);
42
- },
43
- avg: function avg(values) {
44
- return values.reduce(function (total, val) {
45
- return total + parseFloat(val || 0, 10);
46
- }, 0) / values.length;
47
- }
48
- };
49
-
50
- var LinkTagsTipsBuilder = /*#__PURE__*/function () {
51
- function LinkTagsTipsBuilder(amDisplay) {
52
- this.amDisplay = void 0;
53
- this.topo = void 0;
54
- this.amDisplay = amDisplay;
55
- this.topo = amDisplay.topo;
56
- }
57
-
58
- var _proto = LinkTagsTipsBuilder.prototype;
59
-
60
- _proto.getExtElementTagsAndTips = function getExtElementTagsAndTips() {
61
- return this.getEdgeGroupTagsAndTips();
62
- }
63
- /**
64
- * 获得未关联聚合链路的连线组标注和悬浮框数据
65
- * @param {*} ciTagsAndTips
66
- * @returns
67
- */
68
- ;
69
-
70
- _proto.getEdgeGroupTagsAndTips = function getEdgeGroupTagsAndTips() {
71
- var _this = this;
72
-
73
- var ciConfigs = this.amDisplay.getResourceTagTipConfig();
74
- var data = this.amDisplay.getData();
75
- var topo = this.topo;
76
- var dm = this.topo.getDataModel(); // 获取所有连线组,排除关联聚合链路,排除无子链路
77
-
78
- var groups = getEdgeGroups(dm).map(getGroupInfo).filter(function (item) {
79
- return !!item;
80
- }); // 计算标注和指标
81
-
82
- var edgeGroupsTagsTips = groups.map(function (_ref) {
83
- var groupId = _ref.groupId,
84
- linkChildren = _ref.children;
85
- var config = ciConfigs.find(function (item) {
86
- return item.id === linkChildren[0].id;
87
- });
88
- return _this.buildEdgeGroupTagTagsAndTips({
89
- groupId: groupId,
90
- config: config,
91
- linkChildren: linkChildren,
92
- data: data
93
- });
94
- }); // 获得连线组及子链路
95
- // 关联聚合链路、无子链路 时返回null
96
-
97
- function getGroupInfo(group) {
98
- var edges = group.getEdges().toArray();
99
- var edge = edges[0];
100
- var edgeGroupData = topo.getHtTopo().getEdgeGroupData(edge.getSource(), edge.getTarget()); // eslint-disable-next-line no-underscore-dangle
101
-
102
- var linkId = edgeGroupData.data._attrObject.id;
103
-
104
- if (linkId) {
105
- return null;
106
- }
107
-
108
- var linkChildren = getLinkChildren(edges);
109
-
110
- if (!linkChildren.length) {
111
- return null;
112
- }
113
-
114
- return {
115
- groupId: [edge.getSource().getId(), edge.getTarget().getId()].sort().join('-'),
116
- children: linkChildren
117
- };
118
- }
119
-
120
- function getLinkChildren(edges) {
121
- return edges.map(function (edge) {
122
- var edgeData = topo.getHtTopo().getEdgeData(edge); // eslint-disable-next-line no-underscore-dangle
123
-
124
- var childLinkId = edgeData._tag;
125
-
126
- if (childLinkId) {
127
- return topo.dataModel.getDataById(childLinkId);
128
- }
129
-
130
- return null;
131
- }).filter(function (item) {
132
- return !!item;
133
- }).filter(function (link) {
134
- return link.ciType === 'network_link';
135
- });
136
- }
137
-
138
- return edgeGroupsTagsTips;
139
- };
140
-
141
- _proto.buildEdgeGroupTagTagsAndTips = function buildEdgeGroupTagTagsAndTips(_ref2) {
142
- var _this2 = this;
143
-
144
- var groupId = _ref2.groupId,
145
- config = _ref2.config,
146
- linkChildren = _ref2.linkChildren,
147
- data = _ref2.data;
148
-
149
- // 查询配置,过滤不在范围内的属性
150
- var finalConfig = _extends({}, config, {
151
- tags: config.tags.filter(function (item) {
152
- return _this2.filterField(item, linkChildren);
153
- }),
154
- tips: config.tips.filter(function (item) {
155
- return _this2.filterField(item, linkChildren);
156
- })
157
- }); // 构造数据,计算指标值
158
-
159
-
160
- var mergeData = this.buildData(data, linkChildren);
161
- rlog.debug('buildEdgeGroupTagTagsAndTips', {
162
- groupId: groupId,
163
- config: config,
164
- linkChildren: linkChildren,
165
- data: data,
166
- finalConfig: finalConfig,
167
- mergeData: mergeData
168
- }); // 构造标注、悬浮框数据
169
-
170
- var formatter = new AttributeFormatter(this.topo);
171
- return {
172
- type: 'edgeGroup',
173
- edgeGroupId: groupId,
174
- tags: formatter.formatAttrs(finalConfig.tags, mergeData),
175
- tips: formatter.formatAttrs(finalConfig.tips, mergeData)
176
- };
177
- } // eslint-disable-next-line class-methods-use-this
178
- ;
179
-
180
- _proto.filterField = function filterField(item, linkChildren) {
181
- var fieldConfig = metrics.find(function (m) {
182
- return item.code === m.code;
183
- });
184
-
185
- if (item.type !== 'metric' || !fieldConfig) {
186
- return false;
187
- } // 如果需要校验取值接口,如果取值接口为不同设备的接口,则不显示这四个指标
188
-
189
-
190
- if (fieldConfig.showWhenSameSource) {
191
- var sources = [];
192
- linkChildren.forEach(function (link) {
193
- if (sources.indexOf(link.source) === -1) {
194
- sources.push(link.source);
195
- }
196
- });
197
-
198
- if (sources.length > 1) {
199
- return false;
200
- }
201
- }
202
-
203
- return true;
204
- } // eslint-disable-next-line class-methods-use-this
205
- ;
206
-
207
- _proto.buildData = function buildData(data, linkChildren) {
208
- var linkChildrenData = linkChildren.map(function (link) {
209
- return data.find(function (item) {
210
- return item.id === link.id;
211
- });
212
- });
213
- var mergeData = {
214
- ciType: 'network_link',
215
- metricMap: {}
216
- };
217
- metrics.forEach(function (m) {
218
- try {
219
- var values = linkChildrenData.map(function (linkData) {
220
- return linkData.metricMap[m.code];
221
- });
222
- mergeData.metricMap[m.code] = calcFnMap[m.calcType](values);
223
- } catch (error) {
224
- rlog.warn('连线组指标计算异常', error);
225
- }
226
- }); // console.error(groupId, {config, linkChildrenData, mergeData})
227
-
228
- return mergeData;
229
- };
230
-
231
- return LinkTagsTipsBuilder;
232
- }();
233
-
234
- export { LinkTagsTipsBuilder as default };
235
- ;
@@ -1,245 +0,0 @@
1
- "use strict";
2
-
3
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
-
5
- exports.__esModule = true;
6
- exports["default"] = void 0;
7
-
8
- var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
9
-
10
- var _componentTopologyUtils = require("@riil-frontend/component-topology-utils");
11
-
12
- var _htElementUtils = require("../../utils/htElementUtils");
13
-
14
- var _attributeFormatter = _interopRequireDefault(require("../../core/models/attributeFormatter"));
15
-
16
- /**
17
- * 连线组标注、悬浮框数据构建
18
- */
19
- // 参与计算的链路指标
20
- var metrics = [// 总流速
21
- {
22
- code: 'interface_totalbps',
23
- calcType: 'sum'
24
- }, // 带宽利用率
25
- {
26
- code: 'bandwidth_utilization',
27
- calcType: 'avg'
28
- }, // 发送带宽利用率
29
- {
30
- code: 'out_bandwidth_utilization',
31
- calcType: 'avg',
32
- showWhenSameSource: true
33
- }, // 接收带宽利用率
34
- {
35
- code: 'in_bandwidth_utilization',
36
- calcType: 'avg',
37
- showWhenSameSource: true
38
- }, {
39
- code: 'out_rate',
40
- calcType: 'sum',
41
- showWhenSameSource: true
42
- }, {
43
- code: 'in_rate',
44
- calcType: 'sum',
45
- showWhenSameSource: true
46
- }];
47
- var calcFnMap = {
48
- sum: function sum(values) {
49
- return values.reduce(function (total, val) {
50
- return total + parseInt(val || 0, 10);
51
- }, 0);
52
- },
53
- avg: function avg(values) {
54
- return values.reduce(function (total, val) {
55
- return total + parseFloat(val || 0, 10);
56
- }, 0) / values.length;
57
- }
58
- };
59
-
60
- var LinkTagsTipsBuilder = /*#__PURE__*/function () {
61
- function LinkTagsTipsBuilder(amDisplay) {
62
- this.amDisplay = void 0;
63
- this.topo = void 0;
64
- this.amDisplay = amDisplay;
65
- this.topo = amDisplay.topo;
66
- }
67
-
68
- var _proto = LinkTagsTipsBuilder.prototype;
69
-
70
- _proto.getExtElementTagsAndTips = function getExtElementTagsAndTips() {
71
- return this.getEdgeGroupTagsAndTips();
72
- }
73
- /**
74
- * 获得未关联聚合链路的连线组标注和悬浮框数据
75
- * @param {*} ciTagsAndTips
76
- * @returns
77
- */
78
- ;
79
-
80
- _proto.getEdgeGroupTagsAndTips = function getEdgeGroupTagsAndTips() {
81
- var _this = this;
82
-
83
- var ciConfigs = this.amDisplay.getResourceTagTipConfig();
84
- var data = this.amDisplay.getData();
85
- var topo = this.topo;
86
- var dm = this.topo.getDataModel(); // 获取所有连线组,排除关联聚合链路,排除无子链路
87
-
88
- var groups = (0, _htElementUtils.getEdgeGroups)(dm).map(getGroupInfo).filter(function (item) {
89
- return !!item;
90
- }); // 计算标注和指标
91
-
92
- var edgeGroupsTagsTips = groups.map(function (_ref) {
93
- var groupId = _ref.groupId,
94
- linkChildren = _ref.children;
95
- var config = ciConfigs.find(function (item) {
96
- return item.id === linkChildren[0].id;
97
- });
98
- return _this.buildEdgeGroupTagTagsAndTips({
99
- groupId: groupId,
100
- config: config,
101
- linkChildren: linkChildren,
102
- data: data
103
- });
104
- }); // 获得连线组及子链路
105
- // 关联聚合链路、无子链路 时返回null
106
-
107
- function getGroupInfo(group) {
108
- var edges = group.getEdges().toArray();
109
- var edge = edges[0];
110
- var edgeGroupData = topo.getHtTopo().getEdgeGroupData(edge.getSource(), edge.getTarget()); // eslint-disable-next-line no-underscore-dangle
111
-
112
- var linkId = edgeGroupData.data._attrObject.id;
113
-
114
- if (linkId) {
115
- return null;
116
- }
117
-
118
- var linkChildren = getLinkChildren(edges);
119
-
120
- if (!linkChildren.length) {
121
- return null;
122
- }
123
-
124
- return {
125
- groupId: [edge.getSource().getId(), edge.getTarget().getId()].sort().join('-'),
126
- children: linkChildren
127
- };
128
- }
129
-
130
- function getLinkChildren(edges) {
131
- return edges.map(function (edge) {
132
- var edgeData = topo.getHtTopo().getEdgeData(edge); // eslint-disable-next-line no-underscore-dangle
133
-
134
- var childLinkId = edgeData._tag;
135
-
136
- if (childLinkId) {
137
- return topo.dataModel.getDataById(childLinkId);
138
- }
139
-
140
- return null;
141
- }).filter(function (item) {
142
- return !!item;
143
- }).filter(function (link) {
144
- return link.ciType === 'network_link';
145
- });
146
- }
147
-
148
- return edgeGroupsTagsTips;
149
- };
150
-
151
- _proto.buildEdgeGroupTagTagsAndTips = function buildEdgeGroupTagTagsAndTips(_ref2) {
152
- var _this2 = this;
153
-
154
- var groupId = _ref2.groupId,
155
- config = _ref2.config,
156
- linkChildren = _ref2.linkChildren,
157
- data = _ref2.data;
158
- // 查询配置,过滤不在范围内的属性
159
- var finalConfig = (0, _extends2["default"])({}, config, {
160
- tags: config.tags.filter(function (item) {
161
- return _this2.filterField(item, linkChildren);
162
- }),
163
- tips: config.tips.filter(function (item) {
164
- return _this2.filterField(item, linkChildren);
165
- })
166
- }); // 构造数据,计算指标值
167
-
168
- var mergeData = this.buildData(data, linkChildren);
169
-
170
- _componentTopologyUtils.rlog.debug('buildEdgeGroupTagTagsAndTips', {
171
- groupId: groupId,
172
- config: config,
173
- linkChildren: linkChildren,
174
- data: data,
175
- finalConfig: finalConfig,
176
- mergeData: mergeData
177
- }); // 构造标注、悬浮框数据
178
-
179
-
180
- var formatter = new _attributeFormatter["default"](this.topo);
181
- return {
182
- type: 'edgeGroup',
183
- edgeGroupId: groupId,
184
- tags: formatter.formatAttrs(finalConfig.tags, mergeData),
185
- tips: formatter.formatAttrs(finalConfig.tips, mergeData)
186
- };
187
- } // eslint-disable-next-line class-methods-use-this
188
- ;
189
-
190
- _proto.filterField = function filterField(item, linkChildren) {
191
- var fieldConfig = metrics.find(function (m) {
192
- return item.code === m.code;
193
- });
194
-
195
- if (item.type !== 'metric' || !fieldConfig) {
196
- return false;
197
- } // 如果需要校验取值接口,如果取值接口为不同设备的接口,则不显示这四个指标
198
-
199
-
200
- if (fieldConfig.showWhenSameSource) {
201
- var sources = [];
202
- linkChildren.forEach(function (link) {
203
- if (sources.indexOf(link.source) === -1) {
204
- sources.push(link.source);
205
- }
206
- });
207
-
208
- if (sources.length > 1) {
209
- return false;
210
- }
211
- }
212
-
213
- return true;
214
- } // eslint-disable-next-line class-methods-use-this
215
- ;
216
-
217
- _proto.buildData = function buildData(data, linkChildren) {
218
- var linkChildrenData = linkChildren.map(function (link) {
219
- return data.find(function (item) {
220
- return item.id === link.id;
221
- });
222
- });
223
- var mergeData = {
224
- ciType: 'network_link',
225
- metricMap: {}
226
- };
227
- metrics.forEach(function (m) {
228
- try {
229
- var values = linkChildrenData.map(function (linkData) {
230
- return linkData.metricMap[m.code];
231
- });
232
- mergeData.metricMap[m.code] = calcFnMap[m.calcType](values);
233
- } catch (error) {
234
- _componentTopologyUtils.rlog.warn('连线组指标计算异常', error);
235
- }
236
- }); // console.error(groupId, {config, linkChildrenData, mergeData})
237
-
238
- return mergeData;
239
- };
240
-
241
- return LinkTagsTipsBuilder;
242
- }();
243
-
244
- exports["default"] = LinkTagsTipsBuilder;
245
- ;