@riil-frontend/component-topology 11.0.11 → 11.0.13

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.
@@ -11,15 +11,21 @@ var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends")
11
11
 
12
12
  var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
13
13
 
14
+ var _keyBy = _interopRequireDefault(require("lodash/keyBy"));
15
+
16
+ var _rlog = _interopRequireDefault(require("@riil-frontend/component-topology-utils/lib/rlog"));
17
+
14
18
  var _utils = require("./utils");
15
19
 
16
20
  var _tagtip = require("../../services/topo/tagtip");
17
21
 
18
- var _rlog = _interopRequireDefault(require("@riil-frontend/component-topology-utils/lib/rlog"));
19
-
22
+ /**
23
+ * 标注、悬浮框字段模型
24
+ */
20
25
  var ElementTagTipConfig = /*#__PURE__*/function () {
21
26
  function ElementTagTipConfig(topo) {
22
27
  this.topoData = void 0;
28
+ this.modelMap = {};
23
29
  this.mtCodes = void 0;
24
30
  this.mtMetricsMap = {};
25
31
  this.mtCiTypeMap = void 0;
@@ -35,52 +41,214 @@ var ElementTagTipConfig = /*#__PURE__*/function () {
35
41
  switch (_context.prev = _context.next) {
36
42
  case 0:
37
43
  this.topoData = topoData;
38
- this.mtCodes = (0, _utils.getMonitorTemplateCodesFromTopoData)(topoData);
39
- _context.prev = 2;
44
+ _context.next = 3;
45
+ return this.initNetworkLinkModel();
46
+
47
+ case 3:
48
+ this.mtCiTypeMap = (0, _utils.getMtCodeCiTypeMap)(topoData);
49
+
50
+ case 4:
51
+ case "end":
52
+ return _context.stop();
53
+ }
54
+ }
55
+ }, _callee, this);
56
+ }));
57
+
58
+ function init(_x) {
59
+ return _init.apply(this, arguments);
60
+ }
61
+
62
+ return init;
63
+ }();
64
+
65
+ _proto.initNetworkLinkModel = /*#__PURE__*/function () {
66
+ var _initNetworkLinkModel = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee2() {
67
+ var mtCodes;
68
+ return _regenerator["default"].wrap(function _callee2$(_context2) {
69
+ while (1) {
70
+ switch (_context2.prev = _context2.next) {
71
+ case 0:
72
+ _context2.prev = 0;
73
+ mtCodes = ['m.critical_link', 'm.ethernet_link'];
40
74
 
41
- if (!this.mtCodes.length) {
42
- _context.next = 7;
75
+ if (!mtCodes.length) {
76
+ _context2.next = 6;
43
77
  break;
44
78
  }
45
79
 
46
- _context.next = 6;
47
- return (0, _tagtip.getMetricsByMonitorTemplateCodes)(this.mtCodes);
80
+ _context2.next = 5;
81
+ return (0, _tagtip.getMetricsByMonitorTemplateCodes)(mtCodes);
48
82
 
49
- case 6:
50
- this.mtMetricsMap = _context.sent;
83
+ case 5:
84
+ this.mtMetricsMap = _context2.sent;
51
85
 
52
- case 7:
53
- _context.next = 12;
86
+ case 6:
87
+ _context2.next = 11;
54
88
  break;
55
89
 
56
- case 9:
57
- _context.prev = 9;
58
- _context.t0 = _context["catch"](2);
90
+ case 8:
91
+ _context2.prev = 8;
92
+ _context2.t0 = _context2["catch"](0);
59
93
 
60
- _rlog["default"].error('查询监控模板指标失败', _context.t0);
94
+ _rlog["default"].error('查询监控模板指标失败', _context2.t0);
61
95
 
62
- case 12:
63
- this.mtCiTypeMap = (0, _utils.getMtCodeCiTypeMap)(topoData);
64
-
65
- case 13:
96
+ case 11:
66
97
  case "end":
67
- return _context.stop();
98
+ return _context2.stop();
68
99
  }
69
100
  }
70
- }, _callee, this, [[2, 9]]);
101
+ }, _callee2, this, [[0, 8]]);
71
102
  }));
72
103
 
73
- function init(_x) {
74
- return _init.apply(this, arguments);
104
+ function initNetworkLinkModel() {
105
+ return _initNetworkLinkModel.apply(this, arguments);
75
106
  }
76
107
 
77
- return init;
78
- }()
108
+ return initNetworkLinkModel;
109
+ }();
110
+
111
+ _proto.getModelTypes = function getModelTypes(cis) {
112
+ var _this = this;
113
+
114
+ var modelTypes = [];
115
+ cis.forEach(function (ci) {
116
+ var modelType = _this.getModelType(ci);
117
+
118
+ if (modelType && modelTypes.indexOf(modelType) < 0) {
119
+ modelTypes.push(modelType);
120
+ }
121
+ });
122
+ return modelTypes;
123
+ }
79
124
  /**
80
- * 获得节点字段配置项map
125
+ * 查询模型
126
+ * @param {*} ci
127
+ * @returns
81
128
  */
129
+ // eslint-disable-next-line class-methods-use-this
82
130
  ;
83
131
 
132
+ _proto.getModelType = function getModelType(ci) {
133
+ if (ci.ciType === 'network_link') {
134
+ return ci.attributes.support_templates;
135
+ }
136
+
137
+ return ci.ciType;
138
+ };
139
+
140
+ _proto.getModelByType = function getModelByType(type) {
141
+ return this.getNetworkLinkModel(type) || this.topo.ciTyeCache.getCiType(type);
142
+ };
143
+
144
+ _proto.getNetworkLinkModel = function getNetworkLinkModel(type) {
145
+ var _this2 = this;
146
+
147
+ var baseInfo = [{
148
+ code: 'm.critical_link',
149
+ displayName: '关键链路',
150
+ typeCode: 'network_link'
151
+ }, {
152
+ code: 'm.ethernet_link',
153
+ displayName: '网络链路',
154
+ typeCode: 'network_link'
155
+ }].find(function (item) {
156
+ return item.code === type;
157
+ });
158
+
159
+ if (!baseInfo) {
160
+ return null;
161
+ }
162
+
163
+ var ciTypeModel = this.topo.ciTyeCache.getCiType('network_link');
164
+ var metrics = ciTypeModel.metrics.filter(function (m) {
165
+ return _this2.mtMetricsMap[type] && !!_this2.mtMetricsMap[type][m.code];
166
+ });
167
+ return (0, _extends2["default"])({}, ciTypeModel, baseInfo, {
168
+ metrics: metrics,
169
+ metricMap: (0, _keyBy["default"])(metrics, 'code')
170
+ });
171
+ }
172
+ /**
173
+ * 获取链路标注悬浮框属性配置数据
174
+ * @returns
175
+ */
176
+ ;
177
+
178
+ _proto.getLinkConfigItems = function getLinkConfigItems() {
179
+ var _this3 = this;
180
+
181
+ var _this$topo$dataModel$ = this.topo.dataModel.getData(),
182
+ links = _this$topo$dataModel$.links;
183
+
184
+ var modelTypes = this.getModelTypes(links);
185
+ var list = modelTypes.map(this.getModelByType.bind(this)).map(function (item) {
186
+ return _this3.buildModels(item, 'link');
187
+ });
188
+ return list;
189
+ } // eslint-disable-next-line
190
+ ;
191
+
192
+ _proto.buildModels = function buildModels(ciTypeObj, type) {
193
+ return {
194
+ id: ciTypeObj.code,
195
+ label: ciTypeObj.displayName,
196
+ typeCode: ciTypeObj.typeCode,
197
+ icon: "/img/model/" + ciTypeObj.icon + ".svg",
198
+ list: this.buildModelFields(ciTypeObj, type)
199
+ };
200
+ }
201
+ /**
202
+ * 过滤ci元数据中的属性和指标,用于属性和指标显示设置
203
+ * @param {} ciTypeObj
204
+ * @returns
205
+ */
206
+ // eslint-disable-next-line
207
+ ;
208
+
209
+ _proto.buildModelFields = function buildModelFields(ciTypeObj, type) {
210
+ var custom = [];
211
+
212
+ if (type === 'node') {
213
+ custom.push.apply(custom, [{
214
+ id: 'graph:name',
215
+ code: 'name',
216
+ name: '图片名称',
217
+ type: 'custom'
218
+ }, {
219
+ id: 'ciType:display_name',
220
+ code: 'ciType',
221
+ name: '资源类型',
222
+ type: 'custom'
223
+ }]);
224
+ }
225
+
226
+ var attributes = ciTypeObj.attributes.filter(function (attr) {
227
+ return !!attr.userVisible;
228
+ }).map(function (item) {
229
+ return {
230
+ type: 'attribute',
231
+ id: "attribute:" + item.code,
232
+ code: "attribute:" + item.code,
233
+ name: item.name,
234
+ typeName: '属性'
235
+ };
236
+ });
237
+ var metrics = ciTypeObj.metrics.map(function (item) {
238
+ return {
239
+ type: 'metric',
240
+ id: "metric:" + item.code,
241
+ code: "metric:" + item.code,
242
+ name: item.name,
243
+ typeName: '指标'
244
+ };
245
+ });
246
+ return [].concat(custom, attributes, metrics);
247
+ };
248
+
249
+ /**
250
+ * 获得节点字段配置项map
251
+ */
84
252
  _proto.getNodeFiedldMap = function getNodeFiedldMap() {
85
253
  var mtCodes = (0, _utils.getNodeMtCodes)(this.topoData);
86
254
  return this.getFiedldMapByMtCodes(mtCodes, 'node');
@@ -93,48 +261,15 @@ var ElementTagTipConfig = /*#__PURE__*/function () {
93
261
  _proto.getLinkFidldMap = function getLinkFidldMap() {
94
262
  var mtCodes = (0, _utils.getLinkMtCodes)(this.topoData);
95
263
  return this.getFiedldMapByMtCodes(mtCodes, 'link');
96
- }
97
- /**
98
- * 获取链路标注悬浮框属性配置数据
99
- * @returns
100
- */
101
- ;
102
-
103
- _proto.getLinkConfigItems = function getLinkConfigItems() {
104
- var mtCodes = (0, _utils.getLinkMtCodes)(this.topoData);
105
- var linkFidldMap = this.getLinkFidldMap();
106
- var list = [{
107
- id: 'm.critical_link',
108
- label: '关键链路'
109
- }, {
110
- id: 'm.ethernet_link',
111
- label: '网络链路'
112
- }] // 只拓扑图上已有资源的监控模板
113
- .filter(function (item) {
114
- return mtCodes.includes(item.id);
115
- }).map(function (t) {
116
- return (0, _extends2["default"])({}, t, {
117
- icon: '/img/model/networkLink.svg',
118
- list: linkFidldMap[t.id] || []
119
- });
120
- });
121
- return list; // return [
122
- // { id: 'ax1', label: '本级平台', children: list, type: 'folder', disabled: true },
123
- // {
124
- // id: 'bb22', label: '下级平台', type: 'folder', children: [
125
- // { id: 'xvdafa', label: '关键链路', icon: '/img/model/networkLink.svg' },
126
- // ]
127
- // },
128
- // ]
129
264
  };
130
265
 
131
266
  _proto.getFiedldMapByMtCodes = function getFiedldMapByMtCodes(mtCodes, type) {
132
- var _this = this;
267
+ var _this4 = this;
133
268
 
134
269
  var map = {};
135
270
  mtCodes.forEach(function (mtCode) {
136
- var ciType = _this.mtCiTypeMap[mtCode];
137
- map[mtCode] = _this.getFiedldMapByType(ciType, type, mtCode);
271
+ var ciType = _this4.mtCiTypeMap[mtCode];
272
+ map[mtCode] = _this4.getFiedldMapByType(ciType, type, mtCode);
138
273
  });
139
274
  return map;
140
275
  };
@@ -173,12 +308,12 @@ var ElementTagTipConfig = /*#__PURE__*/function () {
173
308
  };
174
309
 
175
310
  _proto.getMtMetricModels = function getMtMetricModels(mtCode) {
176
- var _this2 = this;
311
+ var _this5 = this;
177
312
 
178
313
  var ciType = this.mtCiTypeMap[mtCode];
179
314
  var ciTypeModel = this.topo.ciTyeCache.getCiType(ciType);
180
315
  var metrics = ciTypeModel.metrics.filter(function (m) {
181
- return _this2.mtMetricsMap[mtCode] && !!_this2.mtMetricsMap[mtCode][m.code];
316
+ return _this5.mtMetricsMap[mtCode] && !!_this5.mtMetricsMap[mtCode][m.code];
182
317
  });
183
318
  return metrics;
184
319
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@riil-frontend/component-topology",
3
- "version": "11.0.11",
3
+ "version": "11.0.13",
4
4
  "description": "拓扑",
5
5
  "scripts": {
6
6
  "start": "build-scripts start",
@@ -118,6 +118,6 @@
118
118
  "access": "public"
119
119
  },
120
120
  "license": "MIT",
121
- "homepage": "https://unpkg.com/@riil-frontend/component-topology@11.0.11/build/index.html",
121
+ "homepage": "https://unpkg.com/@riil-frontend/component-topology@11.0.13/build/index.html",
122
122
  "gitHead": "2da19ffccbb7ca60a8acf396e39f542c68bb33f5"
123
123
  }