@riil-frontend/component-topology 12.1.0-dev.1 → 12.1.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.
- package/build/1.js +1 -1
- package/build/index.css +1 -1
- package/build/index.js +14 -14
- package/es/core/components/AlarmListPanel/components/AlarmListItem.js +2 -2
- package/es/core/editor/components/Toolbar/widgets/EdgeColorButton/EdgeColorButton.js +2 -2
- package/es/core/editor/components/Toolbar/widgets/EdgeTypeButton/LineType.js +5 -15
- package/es/core/editor/components/Toolbar/widgets/FontFamilyWidget.js +2 -27
- package/es/core/editor/components/Toolbar/widgets/FontSizeWidget.js +3 -28
- package/es/core/editor/components/Toolbar/widgets/FontStyleButton.js +6 -52
- package/es/core/editor/components/Toolbar/widgets/Layout/index.js +2 -2
- package/es/core/editor/components/Toolbar/widgets/components/FontFamilySelect.js +29 -0
- package/es/core/editor/components/Toolbar/widgets/components/FontSizeSelect.js +29 -0
- package/es/core/editor/components/Toolbar/widgets/components/FontStyleSelect.js +71 -0
- package/es/core/editor/components/settings/propertyViews/view/GlobalEdgeToggle.js +2 -2
- package/es/core/editor/hooks/useNewElementTheme.js +20 -16
- package/es/core/editor/utils/edgeTypeStyleUtil.js +11 -9
- package/es/core/hooks/usePolling.js +2 -1
- package/es/core/hooks/useTopoEdit.js +169 -231
- package/es/core/models/Alarm.js +14 -15
- package/es/core/models/AttributeMetricDisplay.js +2 -1
- package/es/core/models/HistoryManager.js +11 -9
- package/es/core/models/TopoApp.js +23 -31
- package/es/core/models/utils/linkUtils.js +20 -19
- package/es/core/store/models/topoConfig.js +2 -1
- package/es/core/utils/edgeUtil.js +7 -10
- package/es/core/viewer/components/plugins/ElementDetailDrawer/hooks/useElementDetailManager.js +2 -2
- package/es/core/viewer/components/plugins/ResourceDetail/components/ResourceOverview/EventsCard.js +51 -13
- package/es/core/viewer/components/plugins/ResourceDetail/components/ResourceOverview/index.module.scss +8 -0
- package/es/networkTopo/models/EdgeGroupTagTipBuilder.js +7 -7
- package/es/networkTopo/models/LinkDynamicStyleExecutor.js +7 -63
- package/es/networkTopo/utils/edgeGroupTagUtil.js +2 -2
- package/es/utils/clusterUtil.js +3 -3
- package/es/utils/htElementUtils.js +16 -84
- package/lib/core/components/AlarmListPanel/components/AlarmListItem.js +2 -2
- package/lib/core/editor/components/Toolbar/widgets/EdgeColorButton/EdgeColorButton.js +2 -2
- package/lib/core/editor/components/Toolbar/widgets/EdgeTypeButton/LineType.js +5 -14
- package/lib/core/editor/components/Toolbar/widgets/FontFamilyWidget.js +3 -28
- package/lib/core/editor/components/Toolbar/widgets/FontSizeWidget.js +3 -28
- package/lib/core/editor/components/Toolbar/widgets/FontStyleButton.js +6 -56
- package/lib/core/editor/components/Toolbar/widgets/Layout/index.js +1 -1
- package/lib/core/editor/components/Toolbar/widgets/components/FontFamilySelect.js +38 -0
- package/lib/core/editor/components/Toolbar/widgets/components/FontSizeSelect.js +38 -0
- package/lib/core/editor/components/Toolbar/widgets/components/FontStyleSelect.js +83 -0
- package/lib/core/editor/components/settings/propertyViews/view/GlobalEdgeToggle.js +2 -2
- package/lib/core/editor/hooks/useNewElementTheme.js +20 -16
- package/lib/core/editor/utils/edgeTypeStyleUtil.js +10 -8
- package/lib/core/hooks/usePolling.js +6 -5
- package/lib/core/hooks/useTopoEdit.js +177 -257
- package/lib/core/models/Alarm.js +14 -15
- package/lib/core/models/AttributeMetricDisplay.js +6 -6
- package/lib/core/models/HistoryManager.js +13 -17
- package/lib/core/models/TopoApp.js +22 -29
- package/lib/core/models/utils/linkUtils.js +19 -18
- package/lib/core/store/models/topoConfig.js +9 -16
- package/lib/core/utils/edgeUtil.js +8 -10
- package/lib/core/viewer/components/plugins/ElementDetailDrawer/hooks/useElementDetailManager.js +3 -2
- package/lib/core/viewer/components/plugins/ResourceDetail/components/ResourceOverview/EventsCard.js +52 -13
- package/lib/core/viewer/components/plugins/ResourceDetail/components/ResourceOverview/index.module.scss +8 -0
- package/lib/networkTopo/models/EdgeGroupTagTipBuilder.js +6 -6
- package/lib/networkTopo/models/LinkDynamicStyleExecutor.js +6 -64
- package/lib/networkTopo/utils/edgeGroupTagUtil.js +2 -2
- package/lib/utils/clusterUtil.js +2 -2
- package/lib/utils/htElementUtils.js +19 -93
- package/package.json +2 -2
- package/es/networkTopo/models/LinkTagsTipsBuilder.js +0 -235
- package/lib/networkTopo/models/LinkTagsTipsBuilder.js +0 -245
@@ -3,14 +3,10 @@
|
|
3
3
|
exports.__esModule = true;
|
4
4
|
exports["default"] = void 0;
|
5
5
|
|
6
|
-
var _componentTopologyUtils = require("@riil-frontend/component-topology-utils");
|
7
|
-
|
8
6
|
var _clusterUtil = require("../../utils/clusterUtil");
|
9
7
|
|
10
8
|
var _htElementUtils = require("../../utils/htElementUtils");
|
11
9
|
|
12
|
-
var _linkUtil = require("../utils/linkUtil");
|
13
|
-
|
14
10
|
// network_link.actual_bandwidth
|
15
11
|
function calcEdgeWidth(actualBandwidth) {
|
16
12
|
if (!actualBandwidth) {
|
@@ -61,16 +57,17 @@ var LinkDynamicStyleExecutor = /*#__PURE__*/function () {
|
|
61
57
|
var _proto = LinkDynamicStyleExecutor.prototype;
|
62
58
|
|
63
59
|
_proto.execute = function execute() {
|
64
|
-
var
|
60
|
+
var _topo$historyManager,
|
61
|
+
_this = this,
|
62
|
+
_topo$historyManager2;
|
65
63
|
|
66
64
|
var topo = this.topo;
|
67
65
|
|
68
66
|
var _topo$dataModel$getDa = topo.dataModel.getData(),
|
69
|
-
links = _topo$dataModel$getDa.links
|
70
|
-
linkGroups = _topo$dataModel$getDa.linkGroups;
|
67
|
+
links = _topo$dataModel$getDa.links;
|
71
68
|
|
72
69
|
var dataModel = this.topo.getDataModel();
|
73
|
-
|
70
|
+
(_topo$historyManager = topo.historyManager) === null || _topo$historyManager === void 0 ? void 0 : _topo$historyManager.setDisabled(true, '链路动态样式'); // 1、如果连线可见,设置线宽
|
74
71
|
|
75
72
|
links.forEach(function (link) {
|
76
73
|
var edge = dataModel.getDataByTag(link.id);
|
@@ -78,63 +75,8 @@ var LinkDynamicStyleExecutor = /*#__PURE__*/function () {
|
|
78
75
|
if (edge) {
|
79
76
|
edge.s('edge.width', _this.calcLinkEdgeWidth(link));
|
80
77
|
}
|
81
|
-
}); // 2、如果连线组关联链路并可见,设置线宽
|
82
|
-
|
83
|
-
linkGroups.forEach(function (link) {
|
84
|
-
// 聚合链路是连线/连线组,并可以查询到
|
85
|
-
var edge = topo.getDataModel().getDataByTag(link.id);
|
86
|
-
|
87
|
-
if (edge) {
|
88
|
-
edge.s('edge.width', _this.calcLinkEdgeWidth(link));
|
89
|
-
return;
|
90
|
-
} // 聚合链路是连线组(编辑模式还未关联业务信息)
|
91
|
-
|
92
|
-
|
93
|
-
var edgeGroup = (0, _htElementUtils.getEdgeGroupByNodeTags)(dataModel, link.source, link.target);
|
94
|
-
|
95
|
-
if (edgeGroup) {
|
96
|
-
var edgeGroupAgent = edgeGroup.getEdgeGroupAgent(); // 判断是显示的连线组元素
|
97
|
-
|
98
|
-
if (edgeGroupAgent) {
|
99
|
-
edgeGroup.getEdgeGroupAgent().s('edge.width', _this.calcLinkEdgeWidth(link));
|
100
|
-
}
|
101
|
-
} else {
|
102
|
-
_componentTopologyUtils.rlog.warn('动态链路样式执行:未找到聚合链路的ht元素', link);
|
103
|
-
}
|
104
|
-
}); // 3、如果连线组未关联链路并可见,设置线宽。
|
105
|
-
|
106
|
-
var edges = (0, _htElementUtils.getEdges)(dataModel);
|
107
|
-
edges.forEach(function (edge) {
|
108
|
-
try {
|
109
|
-
// 获取两端代理节点
|
110
|
-
var sourceAgent = edge.getSourceAgent();
|
111
|
-
var targetAgent = edge.getTargetAgent();
|
112
|
-
var sourceId = sourceAgent.getTag();
|
113
|
-
var targetId = targetAgent.getTag(); // 查询是否有聚合链路
|
114
|
-
|
115
|
-
var aggLink = linkGroups.find(function (link) {
|
116
|
-
return link.source === sourceId && link.target === targetId || link.target === sourceId && link.source === targetId;
|
117
|
-
}); // 如果连线组未关联链路并可见
|
118
|
-
|
119
|
-
if (!aggLink && edge.isEdgeGroupAgent()) {
|
120
|
-
// 查询两端代理节点(包含子节点)间的子链路列表
|
121
|
-
var sourceCiIds = getChildrenNodeCiIds([sourceAgent]);
|
122
|
-
var targetCiIds = getChildrenNodeCiIds([targetAgent]);
|
123
|
-
var aggLinks = (0, _linkUtil.getLinksBetweenNodes)(linkGroups, sourceCiIds, targetCiIds);
|
124
|
-
var phyLinks = (0, _linkUtil.getLinksBetweenNodes)(links, sourceCiIds, targetCiIds);
|
125
|
-
var linkBetweenNodes = aggLinks.length ? aggLinks : phyLinks; // 如果有子链路,计算线宽并设置
|
126
|
-
|
127
|
-
if (linkBetweenNodes.length) {
|
128
|
-
var edgeWidth = _this.calcEdgeGroupEdgeWidth(linkBetweenNodes);
|
129
|
-
|
130
|
-
edge.s('edge.width', edgeWidth);
|
131
|
-
}
|
132
|
-
}
|
133
|
-
} catch (error) {
|
134
|
-
_componentTopologyUtils.rlog.error('连线组未关联链路并可见,设置线宽:异常', edge, error);
|
135
|
-
}
|
136
78
|
});
|
137
|
-
topo.historyManager
|
79
|
+
(_topo$historyManager2 = topo.historyManager) === null || _topo$historyManager2 === void 0 ? void 0 : _topo$historyManager2.setDisabled(false, '链路动态样式');
|
138
80
|
}
|
139
81
|
/**
|
140
82
|
* 处理单个连线组切换。有链路时设置
|
@@ -65,8 +65,8 @@ function getEdgeGroupLinkIdConfig(edgeGroup, topo) {
|
|
65
65
|
}
|
66
66
|
|
67
67
|
function getEdgeGroupConfigId(edgeGroup) {
|
68
|
-
var sourceNode = edgeGroup.
|
69
|
-
var targetNode = edgeGroup.
|
68
|
+
var sourceNode = edgeGroup.getSource();
|
69
|
+
var targetNode = edgeGroup.getTarget();
|
70
70
|
var sourceId = sourceNode.a('uuid');
|
71
71
|
var targetId = targetNode.a('uuid');
|
72
72
|
return [sourceId, targetId].sort().join(',');
|
package/lib/utils/clusterUtil.js
CHANGED
@@ -103,7 +103,7 @@ function isClusterHtElement(element) {
|
|
103
103
|
}
|
104
104
|
|
105
105
|
function isClusterMemberHtElement(element) {
|
106
|
-
return element
|
106
|
+
return (element === null || element === void 0 ? void 0 : element.getParent()) && isClusterHtElement(element.getParent());
|
107
107
|
}
|
108
108
|
/**
|
109
109
|
* 集群无权限时收起
|
@@ -140,7 +140,7 @@ function upgradeV103GraphClusterNode(topo, topoData) {
|
|
140
140
|
var topoDataTrans = (0, _utils.transformTopoElements)(topoData);
|
141
141
|
var dm = topo.getDataModel();
|
142
142
|
var unExistedList = topoDataTrans.filter(function (data) {
|
143
|
-
return !(0, _htElementUtils.
|
143
|
+
return !(0, _htElementUtils.containsElement)(dm, data);
|
144
144
|
});
|
145
145
|
|
146
146
|
if (!unExistedList.length) {
|
@@ -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;
|
@@ -27,8 +25,7 @@ exports.getNodes = getNodes;
|
|
27
25
|
exports.getNodesByGroupIdOrTag = getNodesByGroupIdOrTag;
|
28
26
|
exports.isEdge = isEdge;
|
29
27
|
exports.isEdgeGroupAgent = isEdgeGroupAgent;
|
30
|
-
exports.
|
31
|
-
exports.isExistedElement = isExistedElement;
|
28
|
+
exports.isEdgeVisible = isEdgeVisible;
|
32
29
|
exports.isGroup = isGroup;
|
33
30
|
exports.isLayer = isLayer;
|
34
31
|
exports.isNode = isNode;
|
@@ -172,10 +169,6 @@ function getNodeData(element) {
|
|
172
169
|
function getEdges(dataModel) {
|
173
170
|
return getElements(dataModel).filter(isValidEdge);
|
174
171
|
}
|
175
|
-
|
176
|
-
function isEdgeGroupExpanded(edge) {
|
177
|
-
return isEdge(edge) && edge.getEdgeGroup() && !!edge.s("edge.expanded");
|
178
|
-
}
|
179
172
|
/**
|
180
173
|
* 是否连线组代理
|
181
174
|
* @param {*} edge
|
@@ -184,7 +177,11 @@ function isEdgeGroupExpanded(edge) {
|
|
184
177
|
|
185
178
|
|
186
179
|
function isEdgeGroupAgent(edge) {
|
187
|
-
return isEdge(edge) && edge.
|
180
|
+
return isEdge(edge) && edge.a('x.edgegroup.isEdgeGroup');
|
181
|
+
}
|
182
|
+
|
183
|
+
function isEdgeVisible(edge) {
|
184
|
+
return edge.s('2d.visible') || edge.s('2d.visible') === undefined;
|
188
185
|
}
|
189
186
|
/**
|
190
187
|
* 获得两个节点间的连线列表
|
@@ -212,66 +209,20 @@ function getEdgesBetweenNodes(node1, node2) {
|
|
212
209
|
return edges;
|
213
210
|
}
|
214
211
|
/**
|
215
|
-
*
|
216
|
-
* @
|
217
|
-
|
218
|
-
|
219
|
-
|
220
|
-
function getEdgeGroupByNodes(node1, node2) {
|
221
|
-
var htEdgeGroup = null;
|
222
|
-
getEdgesBetweenNodes(node1, node2).forEach(function (edge) {
|
223
|
-
if (!htEdgeGroup) {
|
224
|
-
htEdgeGroup = edge.getEdgeGroup();
|
225
|
-
}
|
226
|
-
});
|
227
|
-
|
228
|
-
if (!htEdgeGroup) {
|
229
|
-
return null;
|
230
|
-
}
|
231
|
-
|
232
|
-
return new _EdgeGroup["default"](htEdgeGroup);
|
233
|
-
}
|
234
|
-
/**
|
235
|
-
* 获得节点间的连线组,连线<=1时返回null
|
236
|
-
* @returns
|
212
|
+
* 获得连线组连线列表
|
213
|
+
* @param {*} dataModel
|
214
|
+
* @returns
|
237
215
|
*/
|
238
216
|
|
239
217
|
|
240
|
-
function getEdgeGroupByNodeTags(dataModel, nodeTag1, nodeTag2) {
|
241
|
-
var node1 = dataModel.getDataByTag(nodeTag1);
|
242
|
-
var node2 = dataModel.getDataByTag(nodeTag2);
|
243
|
-
|
244
|
-
if (!node1 || !node2) {
|
245
|
-
console.warn("getEdgeGroupByNodes 未找到节点", {
|
246
|
-
node1: node1,
|
247
|
-
node2: node2,
|
248
|
-
nodeTag1: nodeTag1,
|
249
|
-
nodeTag2: nodeTag2
|
250
|
-
});
|
251
|
-
return null;
|
252
|
-
}
|
253
|
-
|
254
|
-
return getEdgeGroupByNodes(node1, node2);
|
255
|
-
}
|
256
|
-
|
257
|
-
function getEdgeGroups(dataModel) {
|
258
|
-
var edgeGroups = [];
|
259
|
-
getEdges(dataModel).forEach(function (edge) {
|
260
|
-
var group = edge.getEdgeGroup();
|
261
|
-
|
262
|
-
if (group && !edgeGroups.includes(group)) {
|
263
|
-
edgeGroups.push(group);
|
264
|
-
}
|
265
|
-
});
|
266
|
-
return edgeGroups;
|
267
|
-
}
|
268
|
-
|
269
218
|
function getEdgeGroupAgents(dataModel) {
|
270
219
|
return getEdges(dataModel).filter(isEdgeGroupAgent);
|
271
220
|
}
|
272
221
|
|
273
222
|
function getEdgeDatas(dataModel) {
|
274
|
-
return getEdges(dataModel).
|
223
|
+
return getEdges(dataModel).filter(function (edge) {
|
224
|
+
return !isEdgeGroupAgent(edge);
|
225
|
+
}).map(function (element) {
|
275
226
|
var _element$getSource, _element$getTarget;
|
276
227
|
|
277
228
|
return (0, _extends3["default"])({}, element.getAttrObject(), {
|
@@ -379,10 +330,14 @@ function setElementRuntimeStyle(element, name, value) {
|
|
379
330
|
}
|
380
331
|
/**
|
381
332
|
* 判断拓扑图是否存在元素
|
333
|
+
*
|
334
|
+
* @param {*} dataModel
|
335
|
+
* @param {{id?: string, tag?: string}} data
|
336
|
+
* @returns
|
382
337
|
*/
|
383
338
|
|
384
339
|
|
385
|
-
function
|
340
|
+
function containsElement(dataModel, data) {
|
386
341
|
if (dataModel.getDataByTag(data.id)) {
|
387
342
|
return true;
|
388
343
|
} // 识别区域
|
@@ -391,34 +346,5 @@ function isExistedElement(htTopo, dataModel, data) {
|
|
391
346
|
var element = getElements(dataModel).find(function (item) {
|
392
347
|
return data.tag && item.a("tag") === data.tag;
|
393
348
|
});
|
394
|
-
|
395
|
-
if (element) {
|
396
|
-
return true;
|
397
|
-
} // 连线/连线组
|
398
|
-
|
399
|
-
|
400
|
-
var edges = getEdges(dataModel);
|
401
|
-
|
402
|
-
for (var i = 0; i < edges.length; i++) {
|
403
|
-
var edge = edges[i]; // 如果连线组折叠,判断子连线
|
404
|
-
|
405
|
-
var edgeData = htTopo.getEdgeData(edge);
|
406
|
-
|
407
|
-
if (edgeData) {
|
408
|
-
// eslint-disable-next-line no-underscore-dangle
|
409
|
-
var id = edgeData._attrObject.id;
|
410
|
-
|
411
|
-
if (id === data.id) {
|
412
|
-
return true;
|
413
|
-
}
|
414
|
-
} // 如果连线组展开,判断连线组
|
415
|
-
// eslint-disable-next-line no-underscore-dangle
|
416
|
-
|
417
|
-
|
418
|
-
if (edge.__edgeGroup && edge.__edgeGroup._tag === data.id) {
|
419
|
-
return true;
|
420
|
-
}
|
421
|
-
}
|
422
|
-
|
423
|
-
return false;
|
349
|
+
return !!element;
|
424
350
|
}
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@riil-frontend/component-topology",
|
3
|
-
"version": "12.1.0-dev.
|
3
|
+
"version": "12.1.0-dev.10",
|
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.
|
126
|
+
"homepage": "https://unpkg.com/@riil-frontend/component-topology@12.1.0-dev.10/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
|
-
;
|