@riil-frontend/component-topology 9.0.0-a.37 → 9.0.0-a.38
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 +2 -2
- package/build/2.js +1 -1
- package/build/index.css +1 -1
- package/build/index.js +18 -18
- package/es/core/editor/components/settings/propertyViews/layer/DataTab/NodeList.js +3 -2
- package/es/core/models/AttributeMetricDisplay.js +115 -79
- package/es/core/models/TopoApp.js +1 -1
- package/es/core/models/attributeFormatter/index.js +47 -16
- package/es/networkTopo/models/IpNodeTagsTipsBuilder.js +235 -0
- package/lib/core/editor/components/settings/propertyViews/layer/DataTab/NodeList.js +3 -1
- package/lib/core/models/AttributeMetricDisplay.js +111 -79
- package/lib/core/models/TopoApp.js +1 -1
- package/lib/core/models/attributeFormatter/index.js +47 -16
- package/lib/networkTopo/models/IpNodeTagsTipsBuilder.js +245 -0
- package/package.json +2 -2
@@ -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.
|
59
|
+
var version = typeof "9.0.0-a.38" === 'string' ? "9.0.0-a.38" : null;
|
60
60
|
console.info("\u62D3\u6251\u7248\u672C: " + version);
|
61
61
|
/**
|
62
62
|
* 拓扑显示和编辑
|
@@ -65,25 +65,56 @@ var AttributeFormatter = /*#__PURE__*/function () {
|
|
65
65
|
|
66
66
|
_proto.commonTransform = function commonTransform(item, ciData, attrType) {
|
67
67
|
var fieldCode = item.code;
|
68
|
-
|
69
|
-
var fieldValue = (ciData[attrType + "Map"] || ciData[attrType + "s"])[fieldCode]; // 引用属性
|
68
|
+
console.log("commonTransform-item, ciData, attrType", item, ciData, attrType);
|
70
69
|
|
71
|
-
if (
|
72
|
-
|
73
|
-
|
70
|
+
if (ciData.ciType) {
|
71
|
+
var fieldMeta = this.topo.ciTyeCache.getCiType(ciData.ciType)[attrType + "Map"][fieldCode];
|
72
|
+
var fieldValue = (ciData[attrType + "Map"] || ciData[attrType + "s"])[fieldCode]; // 引用属性
|
73
|
+
|
74
|
+
if (attrType === "attribute") {
|
75
|
+
if (ciData[attrType + "Map"][fieldCode + "_object"]) {
|
76
|
+
fieldValue = ciData[attrType + "Map"][fieldCode + "_object"].displayName;
|
77
|
+
}
|
74
78
|
}
|
75
|
-
}
|
76
79
|
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
80
|
+
var obj = {
|
81
|
+
type: item.type,
|
82
|
+
code: item.code,
|
83
|
+
// 属性code
|
84
|
+
name: (fieldMeta === null || fieldMeta === void 0 ? void 0 : fieldMeta.name) || "",
|
85
|
+
// 属性名称
|
86
|
+
value: formatMetric(fieldValue, fieldMeta),
|
87
|
+
// 属性值
|
88
|
+
originValue: fieldValue
|
89
|
+
};
|
90
|
+
return obj;
|
91
|
+
} else {
|
92
|
+
if (item.code === "ipv4_address" && ciData.bindType === "ip") {
|
93
|
+
return {
|
94
|
+
type: item.type,
|
95
|
+
code: item.code,
|
96
|
+
// 属性code
|
97
|
+
name: "IPv4地址",
|
98
|
+
// 属性名称
|
99
|
+
value: ciData.bindIp,
|
100
|
+
// 属性值
|
101
|
+
originValue: ciData.bindIp
|
102
|
+
};
|
103
|
+
} else {
|
104
|
+
var _ciData$attributes$di, _ciData$attributes, _ciData$attributes$di2, _ciData$attributes2;
|
105
|
+
|
106
|
+
return {
|
107
|
+
type: item.type,
|
108
|
+
code: item.code,
|
109
|
+
// 属性code
|
110
|
+
name: "显示名称",
|
111
|
+
// 属性名称
|
112
|
+
value: (_ciData$attributes$di = ciData === null || ciData === void 0 ? void 0 : (_ciData$attributes = ciData.attributes) === null || _ciData$attributes === void 0 ? void 0 : _ciData$attributes.display_name) !== null && _ciData$attributes$di !== void 0 ? _ciData$attributes$di : "",
|
113
|
+
// 属性值
|
114
|
+
originValue: (_ciData$attributes$di2 = ciData === null || ciData === void 0 ? void 0 : (_ciData$attributes2 = ciData.attributes) === null || _ciData$attributes2 === void 0 ? void 0 : _ciData$attributes2.display_name) !== null && _ciData$attributes$di2 !== void 0 ? _ciData$attributes$di2 : ""
|
115
|
+
};
|
116
|
+
}
|
117
|
+
}
|
87
118
|
};
|
88
119
|
|
89
120
|
_proto.attributeTransform = function attributeTransform(item, ciData) {
|
@@ -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
|
+
;
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@riil-frontend/component-topology",
|
3
|
-
"version": "9.0.0-a.
|
3
|
+
"version": "9.0.0-a.38",
|
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.
|
119
|
+
"homepage": "https://unpkg.com/@riil-frontend/component-topology@9.0.0-a.38/build/index.html",
|
120
120
|
"gitHead": "2da19ffccbb7ca60a8acf396e39f542c68bb33f5"
|
121
121
|
}
|