@riil-frontend/component-topology 9.0.0-a.33 → 9.0.0-a.36

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.
@@ -21,7 +21,7 @@ var LINE_TYPE_OPTIONS = [{
21
21
  label: '双折线',
22
22
  icon: 'topo_linear_icon_bilinear'
23
23
  }, {
24
- value: 'arc',
24
+ value: 'ripple',
25
25
  label: '单弧线',
26
26
  icon: 'topo_linear_icon_arc_line'
27
27
  }, {
@@ -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 "9.0.0-a.33" === 'string' ? "9.0.0-a.33" : null;
27
+ var version = typeof "9.0.0-a.36" === 'string' ? "9.0.0-a.36" : null;
28
28
  console.info("\u62D3\u6251\u7248\u672C: " + version);
29
29
  /**
30
30
  * 拓扑显示和编辑
@@ -0,0 +1,235 @@
1
+ import _extends from "@babel/runtime/helpers/extends";
2
+
3
+ /**
4
+ * 连线组标注、悬浮框数据构建
5
+ */
6
+ import rlog from '@riil-frontend/component-topology-utils/es/rlog';
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 IpNodeTagsTipsBuilder = /*#__PURE__*/function () {
51
+ function IpNodeTagsTipsBuilder(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 = IpNodeTagsTipsBuilder.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 IpNodeTagsTipsBuilder;
232
+ }();
233
+
234
+ export { IpNodeTagsTipsBuilder as default };
235
+ ;
@@ -169,11 +169,11 @@ var LinkDynamicStyleExecutor = /*#__PURE__*/function () {
169
169
  var autoChangeEdgeWidth = displayConfig.autoChangeEdgeWidth !== false;
170
170
 
171
171
  if (!autoChangeEdgeWidth) {
172
- return 2;
172
+ return 3;
173
173
  }
174
174
 
175
175
  if (!links.length) {
176
- return 2;
176
+ return 3;
177
177
  }
178
178
 
179
179
  var total = 0;
@@ -192,7 +192,7 @@ var LinkDynamicStyleExecutor = /*#__PURE__*/function () {
192
192
  var autoChangeEdgeWidth = displayConfig.autoChangeEdgeWidth !== false;
193
193
 
194
194
  if (!autoChangeEdgeWidth) {
195
- return 2;
195
+ return 3;
196
196
  }
197
197
 
198
198
  return this.calcEdgeWidth(link.attributes['network_link.actual_bandwidth']);
@@ -37,7 +37,7 @@ var LINE_TYPE_OPTIONS = [{
37
37
  label: '双折线',
38
38
  icon: 'topo_linear_icon_bilinear'
39
39
  }, {
40
- value: 'arc',
40
+ value: 'ripple',
41
41
  label: '单弧线',
42
42
  icon: 'topo_linear_icon_arc_line'
43
43
  }, {
@@ -56,7 +56,7 @@ var _SelectionModel = _interopRequireDefault(require("./SelectionModel"));
56
56
  var _CiCache = _interopRequireDefault(require("./cache/CiCache"));
57
57
 
58
58
  // eslint-disable-next-line no-undef
59
- var version = typeof "9.0.0-a.33" === 'string' ? "9.0.0-a.33" : null;
59
+ var version = typeof "9.0.0-a.36" === 'string' ? "9.0.0-a.36" : null;
60
60
  console.info("\u62D3\u6251\u7248\u672C: " + version);
61
61
  /**
62
62
  * 拓扑显示和编辑
@@ -0,0 +1,245 @@
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 _rlog = _interopRequireDefault(require("@riil-frontend/component-topology-utils/es/rlog"));
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 IpNodeTagsTipsBuilder = /*#__PURE__*/function () {
61
+ function IpNodeTagsTipsBuilder(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 = IpNodeTagsTipsBuilder.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
+ _rlog["default"].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
+ _rlog["default"].warn('连线组指标计算异常', error);
235
+ }
236
+ }); // console.error(groupId, {config, linkChildrenData, mergeData})
237
+
238
+ return mergeData;
239
+ };
240
+
241
+ return IpNodeTagsTipsBuilder;
242
+ }();
243
+
244
+ exports["default"] = IpNodeTagsTipsBuilder;
245
+ ;
@@ -180,11 +180,11 @@ var LinkDynamicStyleExecutor = /*#__PURE__*/function () {
180
180
  var autoChangeEdgeWidth = displayConfig.autoChangeEdgeWidth !== false;
181
181
 
182
182
  if (!autoChangeEdgeWidth) {
183
- return 2;
183
+ return 3;
184
184
  }
185
185
 
186
186
  if (!links.length) {
187
- return 2;
187
+ return 3;
188
188
  }
189
189
 
190
190
  var total = 0;
@@ -203,7 +203,7 @@ var LinkDynamicStyleExecutor = /*#__PURE__*/function () {
203
203
  var autoChangeEdgeWidth = displayConfig.autoChangeEdgeWidth !== false;
204
204
 
205
205
  if (!autoChangeEdgeWidth) {
206
- return 2;
206
+ return 3;
207
207
  }
208
208
 
209
209
  return this.calcEdgeWidth(link.attributes['network_link.actual_bandwidth']);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@riil-frontend/component-topology",
3
- "version": "9.0.0-a.33",
3
+ "version": "9.0.0-a.36",
4
4
  "description": "拓扑",
5
5
  "scripts": {
6
6
  "start": "build-scripts start",
@@ -116,6 +116,6 @@
116
116
  "access": "public"
117
117
  },
118
118
  "license": "MIT",
119
- "homepage": "https://unpkg.com/@riil-frontend/component-topology@9.0.0-a.33/build/index.html",
119
+ "homepage": "https://unpkg.com/@riil-frontend/component-topology@9.0.0-a.36/build/index.html",
120
120
  "gitHead": "2da19ffccbb7ca60a8acf396e39f542c68bb33f5"
121
121
  }