@riil-frontend/component-topology 9.0.0-a.38 → 9.0.0-a.39

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.
@@ -13,11 +13,11 @@ var _utils = require("@riil-frontend/utils");
13
13
  var _DictCache = _interopRequireDefault(require("../cache/DictCache"));
14
14
 
15
15
  /**
16
- * 格式化指标
17
- * @param {*} val
18
- * @param {*} metricInfo
19
- * @returns
20
- */
16
+ * 格式化指标
17
+ * @param {*} val
18
+ * @param {*} metricInfo
19
+ * @returns
20
+ */
21
21
  function formatMetric(val, metricInfo) {
22
22
  // rlog.debug('formatMetric', item, metricInfo);
23
23
  if (metricInfo) {
@@ -28,7 +28,7 @@ function formatMetric(val, metricInfo) {
28
28
  unit: metricInfo.unit,
29
29
  code: metricInfo.code
30
30
  });
31
- return result.value + " " + (result.value === '-' ? '' : result.unit);
31
+ return result.value + " " + (result.value === "-" ? "" : result.unit);
32
32
  } else {
33
33
  return "" + val;
34
34
  }
@@ -65,64 +65,33 @@ var AttributeFormatter = /*#__PURE__*/function () {
65
65
 
66
66
  _proto.commonTransform = function commonTransform(item, ciData, attrType) {
67
67
  var fieldCode = item.code;
68
- console.log("commonTransform-item, ciData, attrType", item, ciData, attrType);
69
-
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
- }
78
- }
68
+ var fieldMeta = this.topo.ciTyeCache.getCiType(ciData.ciType)[attrType + "Map"][fieldCode];
69
+ var fieldValue = (ciData[attrType + "Map"] || ciData[attrType + "s"])[fieldCode]; // 引用属性
79
70
 
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
- };
71
+ if (attrType === "attribute") {
72
+ if (ciData[attrType + "Map"][fieldCode + "_object"]) {
73
+ fieldValue = ciData[attrType + "Map"][fieldCode + "_object"].displayName;
116
74
  }
117
75
  }
76
+
77
+ return {
78
+ type: item.type,
79
+ code: item.code,
80
+ // 属性code
81
+ name: (fieldMeta === null || fieldMeta === void 0 ? void 0 : fieldMeta.name) || "",
82
+ // 属性名称
83
+ value: formatMetric(fieldValue, fieldMeta),
84
+ // 属性值
85
+ originValue: fieldValue
86
+ };
118
87
  };
119
88
 
120
89
  _proto.attributeTransform = function attributeTransform(item, ciData) {
121
- return this.commonTransform(item, ciData, 'attribute');
90
+ return this.commonTransform(item, ciData, "attribute");
122
91
  };
123
92
 
124
93
  _proto.metricTransform = function metricTransform(item, ciData) {
125
- return this.commonTransform(item, ciData, 'metric');
94
+ return this.commonTransform(item, ciData, "metric");
126
95
  };
127
96
 
128
97
  _proto.ciTypeAttrTransform = function ciTypeAttrTransform(item, ciData) {
@@ -131,7 +100,7 @@ var AttributeFormatter = /*#__PURE__*/function () {
131
100
  type: item.type,
132
101
  code: item.code,
133
102
  // 属性code
134
- name: '资源类型',
103
+ name: "资源类型",
135
104
  // 属性名称
136
105
  value: ciTypeMeta.name // 属性数值
137
106
 
@@ -139,11 +108,11 @@ var AttributeFormatter = /*#__PURE__*/function () {
139
108
  };
140
109
 
141
110
  _proto.graphTransform = function graphTransform(item, ciData) {
142
- var value = '-';
111
+ var value = "-";
143
112
 
144
113
  try {
145
114
  var node = this.topo.getDataModel().getDataByTag(ciData.id);
146
- value = (node === null || node === void 0 ? void 0 : node.a('customName')) || (node === null || node === void 0 ? void 0 : node.a('name')) || '-';
115
+ value = (node === null || node === void 0 ? void 0 : node.a("customName")) || (node === null || node === void 0 ? void 0 : node.a("name")) || "-";
147
116
  } catch (error) {
148
117
  _rlog["default"].error(error);
149
118
  }
@@ -152,7 +121,7 @@ var AttributeFormatter = /*#__PURE__*/function () {
152
121
  type: item.type,
153
122
  code: item.code,
154
123
  // 属性code
155
- name: '图片名称',
124
+ name: "图片名称",
156
125
  // 属性名称
157
126
  value: value // 属性值
158
127
 
@@ -5,8 +5,6 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
5
5
  exports.__esModule = true;
6
6
  exports["default"] = void 0;
7
7
 
8
- var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
9
-
10
8
  var _rlog = _interopRequireDefault(require("@riil-frontend/component-topology-utils/es/rlog"));
11
9
 
12
10
  var _htElementUtils = require("../../utils/htElementUtils");
@@ -19,29 +17,29 @@ var _attributeFormatter = _interopRequireDefault(require("../../core/models/attr
19
17
  // 参与计算的链路指标
20
18
  var metrics = [// 总流速
21
19
  {
22
- code: 'interface_totalbps',
23
- calcType: 'sum'
20
+ code: "interface_totalbps",
21
+ calcType: "sum"
24
22
  }, // 带宽利用率
25
23
  {
26
- code: 'bandwidth_utilization',
27
- calcType: 'avg'
24
+ code: "bandwidth_utilization",
25
+ calcType: "avg"
28
26
  }, // 发送带宽利用率
29
27
  {
30
- code: 'out_bandwidth_utilization',
31
- calcType: 'avg',
28
+ code: "out_bandwidth_utilization",
29
+ calcType: "avg",
32
30
  showWhenSameSource: true
33
31
  }, // 接收带宽利用率
34
32
  {
35
- code: 'in_bandwidth_utilization',
36
- calcType: 'avg',
33
+ code: "in_bandwidth_utilization",
34
+ calcType: "avg",
37
35
  showWhenSameSource: true
38
36
  }, {
39
- code: 'out_rate',
40
- calcType: 'sum',
37
+ code: "out_rate",
38
+ calcType: "sum",
41
39
  showWhenSameSource: true
42
40
  }, {
43
- code: 'in_rate',
44
- calcType: 'sum',
41
+ code: "in_rate",
42
+ calcType: "sum",
45
43
  showWhenSameSource: true
46
44
  }];
47
45
  var calcFnMap = {
@@ -68,178 +66,58 @@ var IpNodeTagsTipsBuilder = /*#__PURE__*/function () {
68
66
  var _proto = IpNodeTagsTipsBuilder.prototype;
69
67
 
70
68
  _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;
69
+ return this.getIpNodeTagsAndTips();
149
70
  };
150
71
 
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;
72
+ _proto.getIpNodeTagsAndTips = function getIpNodeTagsAndTips() {
73
+ // const ciConfigs = this.amDisplay.getResourceTagTipConfig();
74
+ var tts = [];
75
+ var data = this.amDisplay.getData();
76
+ var ipNodes = data.filter(function (item) {
77
+ return item.bindType === "ip";
193
78
  });
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);
79
+ var topo = this.topo;
80
+ var dm = this.topo.getDataModel();
81
+ var config = topo.attributeMetricDisplay.getConfig();
82
+ console.log("getIpNodeTagsAndTips", config, ipNodes);
83
+
84
+ if (config.nodeTag && !config.nodeTag.isCustom) {
85
+ var tagDatas = config.nodeTag.data;
86
+ var hasIpv4 = tagDatas.filter(function (item) {
87
+ return item.code === "ipv4_address";
88
+ }).length > 0;
89
+ ipNodes.map(function (node) {
90
+ if (hasIpv4) {
91
+ tts.push({
92
+ type: node,
93
+ id: node.id,
94
+ tags: [{
95
+ type: "attribute",
96
+ code: "ipv4_address",
97
+ // 属性code
98
+ name: "IPv4地址",
99
+ // 属性名称
100
+ value: node.bindIp,
101
+ // 属性值
102
+ originValue: node.bindIp
103
+ }],
104
+ tips: []
105
+ });
106
+ } else {
107
+ tts.push({
108
+ type: node,
109
+ id: node.id,
110
+ tags: [],
111
+ tips: []
112
+ });
205
113
  }
206
114
  });
207
-
208
- if (sources.length > 1) {
209
- return false;
210
- }
211
115
  }
212
116
 
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;
117
+ return tts;
239
118
  };
240
119
 
241
120
  return IpNodeTagsTipsBuilder;
242
121
  }();
243
122
 
244
- exports["default"] = IpNodeTagsTipsBuilder;
245
- ;
123
+ exports["default"] = IpNodeTagsTipsBuilder;
@@ -27,7 +27,8 @@ var _store = _interopRequireDefault(require("../store"));
27
27
 
28
28
  var _ResourceInfoDisplay = require("../../constants/ResourceInfoDisplay");
29
29
 
30
- // import LinkTagsTipsBuilder from './LinkTagsTipsBuilder';
30
+ var _IpNodeTagsTipsBuilder = _interopRequireDefault(require("./IpNodeTagsTipsBuilder"));
31
+
31
32
  var TopoCenter = /*#__PURE__*/function (_TopoApp) {
32
33
  (0, _inheritsLoose2["default"])(TopoCenter, _TopoApp);
33
34
 
@@ -46,8 +47,8 @@ var TopoCenter = /*#__PURE__*/function (_TopoApp) {
46
47
  },
47
48
  getDefaultLinkTipConfig: function getDefaultLinkTipConfig() {
48
49
  return _ResourceInfoDisplay.DEFAULT_TIP_COMMON_CONFIG;
49
- } // ExtElementTagTipBuilder: LinkTagsTipsBuilder,
50
-
50
+ },
51
+ ExtElementTagTipBuilder: _IpNodeTagsTipsBuilder["default"]
51
52
  }
52
53
  })) || this;
53
54
  _this.resourceConfig = null;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@riil-frontend/component-topology",
3
- "version": "9.0.0-a.38",
3
+ "version": "9.0.0-a.39",
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.38/build/index.html",
119
+ "homepage": "https://unpkg.com/@riil-frontend/component-topology@9.0.0-a.39/build/index.html",
120
120
  "gitHead": "2da19ffccbb7ca60a8acf396e39f542c68bb33f5"
121
121
  }