@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.
- package/build/1.js +1 -1
- package/build/index.css +1 -1
- package/build/index.js +29 -29
- package/es/components/ColorPanel/index.js +68 -58
- package/es/components/ResourceSelectDrawer/ResourceSelectDrawer.js +1 -1
- package/es/core/components/TopoView/topoView.js +7 -4
- 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/FontColorButton.js +10 -91
- 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/components/FontColorDropdown.js +120 -0
- 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 +77 -0
- package/es/core/editor/components/settings/core/updateElementProperty.js +3 -2
- package/es/core/editor/components/settings/propertyViews/view/GlobalEdgeToggle.js +2 -2
- package/es/core/editor/hooks/useKeyboardShortcut.js +4 -0
- package/es/core/editor/hooks/useNewElementTheme.js +20 -16
- package/es/core/editor/utils/edgeTypeStyleUtil.js +11 -32
- package/es/core/hooks/useGraphAlarmDisplay.js +4 -0
- package/es/core/hooks/usePolling.js +2 -1
- package/es/core/hooks/useResourceConfig.js +1 -2
- package/es/core/hooks/useTopoEdit.js +210 -248
- package/es/core/models/AttributeMetricDisplay.js +4 -3
- package/es/core/models/HistoryManager.js +11 -9
- package/es/core/models/TopoApp.js +39 -45
- package/es/core/models/topoData.js +9 -17
- package/es/core/models/utils/linkUtils.js +65 -52
- package/es/core/store/models/topoConfig.js +7 -11
- 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 +4 -2
- package/es/networkTopo/models/EdgeGroupTagTipBuilder.js +7 -7
- package/es/networkTopo/models/LinkDynamicStyleExecutor.js +7 -63
- package/es/networkTopo/services/topo/basic.js +27 -17
- package/es/networkTopo/utils/__tests__/relateTopoData.js +205 -0
- package/es/networkTopo/utils/edgeGroupTagUtil.js +2 -2
- package/es/networkTopo/utils/exitLinkUtil.js +25 -13
- package/es/networkTopo/utils/relateTopoDataUtil.js +149 -0
- package/es/style.js +1 -1
- package/es/utils/ResourceConfigUtil.js +1 -16
- package/es/utils/clusterUtil.js +3 -3
- package/es/utils/htElementUtils.js +19 -85
- package/lib/components/ColorPanel/index.js +71 -59
- package/lib/components/ResourceSelectDrawer/ResourceSelectDrawer.js +1 -1
- package/lib/core/components/TopoView/topoView.js +15 -19
- 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/FontColorButton.js +11 -95
- 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/components/FontColorDropdown.js +136 -0
- 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 +89 -0
- package/lib/core/editor/components/settings/core/updateElementProperty.js +7 -2
- package/lib/core/editor/components/settings/propertyViews/view/GlobalEdgeToggle.js +2 -2
- package/lib/core/editor/hooks/useKeyboardShortcut.js +4 -0
- package/lib/core/editor/hooks/useNewElementTheme.js +20 -16
- package/lib/core/editor/utils/edgeTypeStyleUtil.js +10 -33
- package/lib/core/hooks/useGraphAlarmDisplay.js +4 -0
- package/lib/core/hooks/usePolling.js +6 -5
- package/lib/core/hooks/useResourceConfig.js +1 -2
- package/lib/core/hooks/useTopoEdit.js +216 -272
- package/lib/core/models/AttributeMetricDisplay.js +6 -6
- package/lib/core/models/HistoryManager.js +13 -17
- package/lib/core/models/TopoApp.js +39 -43
- package/lib/core/models/topoData.js +9 -17
- package/lib/core/models/utils/linkUtils.js +65 -51
- package/lib/core/store/models/topoConfig.js +13 -25
- 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 +6 -2
- package/lib/networkTopo/models/EdgeGroupTagTipBuilder.js +6 -6
- package/lib/networkTopo/models/LinkDynamicStyleExecutor.js +6 -64
- package/lib/networkTopo/services/topo/basic.js +32 -18
- package/lib/networkTopo/utils/__tests__/relateTopoData.js +210 -0
- package/lib/networkTopo/utils/edgeGroupTagUtil.js +2 -2
- package/lib/networkTopo/utils/exitLinkUtil.js +25 -13
- package/lib/networkTopo/utils/relateTopoDataUtil.js +164 -0
- package/lib/style.js +1 -1
- package/lib/utils/ResourceConfigUtil.js +1 -16
- package/lib/utils/clusterUtil.js +2 -2
- package/lib/utils/htElementUtils.js +22 -94
- package/package.json +2 -2
- package/es/networkTopo/models/LinkTagsTipsBuilder.js +0 -235
- package/lib/networkTopo/models/LinkTagsTipsBuilder.js +0 -245
- /package/es/core/editor/components/Toolbar/widgets/{FontColorButton.module.scss → components/FontColorDropdown.module.scss} +0 -0
- /package/lib/core/editor/components/Toolbar/widgets/{FontColorButton.module.scss → components/FontColorDropdown.module.scss} +0 -0
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@riil-frontend/component-topology",
|
3
|
-
"version": "13.0.0-dev.
|
3
|
+
"version": "13.0.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@13.0.0-dev.
|
126
|
+
"homepage": "https://unpkg.com/@riil-frontend/component-topology@13.0.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
|
-
;
|
@@ -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
|
-
;
|
File without changes
|