@riil-frontend/component-topology 7.0.9 → 8.0.0-a.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.
Files changed (73) hide show
  1. package/build/index.css +1 -1
  2. package/build/index.js +13 -13
  3. package/es/components/BatchAttrMetric/setting.js +0 -2
  4. package/es/core/common/icons/basicIcons.js +57 -0
  5. package/es/core/common/icons/icon.js +4 -6
  6. package/es/core/components/ResourceViewAttributeSetting/Setting.js +5 -11
  7. package/es/core/components/ResourceViewAttributeSetting/nodeCiTypeAttrUtil.js +121 -0
  8. package/es/core/components/TopoView/GraphViewPanel.js +1 -2
  9. package/es/core/components/TopoView/topoView.js +3 -1
  10. package/es/core/editor/components/Toolbar/widgets/EdgeTypeButton/EdgeType.js +42 -24
  11. package/es/core/editor/components/Toolbar/widgets/EdgeTypeButton/LineType.js +7 -2
  12. package/es/core/editor/components/Toolbar/widgets/EdgeTypeButton/LineType.module.scss +4 -0
  13. package/es/core/editor/components/Toolbar/widgets/EdgeTypeButton/index.js +1 -0
  14. package/es/core/editor/utils/edgeTypeStyleUtil.js +2 -3
  15. package/es/core/hooks/useTopoEdit.js +35 -127
  16. package/es/core/models/AttributeMetricDisplay.js +4 -4
  17. package/es/core/models/TopoApp.js +2 -2
  18. package/es/core/models/tagstips/ElementTagTipConfig.js +18 -10
  19. package/es/core/models/topoData.js +9 -1
  20. package/es/core/models/utils/linkUtils.js +53 -91
  21. package/es/core/services/topo/basic.js +34 -0
  22. package/es/core/services/topo/constants.js +1 -0
  23. package/es/core/services/topo/index.js +4 -0
  24. package/es/core/store/models/topoBizMod.js +1 -11
  25. package/es/core/store/models/topoConfig.js +6 -7
  26. package/es/core/store/models/topoMod.js +74 -50
  27. package/es/core/viewer/components/plugins/ResourceDetail/components/ResourceOverview/ResourceOverview.js +1 -1
  28. package/es/core/viewer/components/titlebar/widgets/SearchWidget.js +4 -0
  29. package/es/networkTopo/getTopoData.js +72 -64
  30. package/es/networkTopo/models/TopoCenter.js +14 -94
  31. package/es/networkTopo/services/topo/basic.js +30 -10
  32. package/es/networkTopo/store/linkManager.js +0 -1
  33. package/es/networkTopo/store/topoCenter.js +0 -1
  34. package/es/networkTopo/store/topoLinkMod.js +0 -1
  35. package/es/networkTopo/utils/resourcePermissionUtil.js +2 -2
  36. package/es/utils/topoData.js +4 -169
  37. package/lib/components/BatchAttrMetric/setting.js +0 -4
  38. package/lib/core/common/icons/basicIcons.js +62 -0
  39. package/lib/core/common/icons/icon.js +5 -7
  40. package/lib/core/components/ResourceViewAttributeSetting/Setting.js +6 -11
  41. package/lib/core/components/ResourceViewAttributeSetting/nodeCiTypeAttrUtil.js +127 -0
  42. package/lib/core/components/TopoView/GraphViewPanel.js +1 -2
  43. package/lib/core/components/TopoView/topoView.js +4 -1
  44. package/lib/core/editor/components/Toolbar/widgets/EdgeTypeButton/EdgeType.js +43 -24
  45. package/lib/core/editor/components/Toolbar/widgets/EdgeTypeButton/LineType.js +8 -2
  46. package/lib/core/editor/components/Toolbar/widgets/EdgeTypeButton/LineType.module.scss +4 -0
  47. package/lib/core/editor/components/Toolbar/widgets/EdgeTypeButton/index.js +1 -0
  48. package/lib/core/editor/utils/edgeTypeStyleUtil.js +2 -3
  49. package/lib/core/hooks/useTopoEdit.js +35 -129
  50. package/lib/core/models/AttributeMetricDisplay.js +4 -4
  51. package/lib/core/models/TopoApp.js +3 -3
  52. package/lib/core/models/tagstips/ElementTagTipConfig.js +19 -11
  53. package/lib/core/models/topoData.js +9 -1
  54. package/lib/core/models/utils/linkUtils.js +52 -93
  55. package/lib/core/services/topo/basic.js +46 -0
  56. package/lib/core/services/topo/constants.js +6 -0
  57. package/lib/core/services/topo/index.js +16 -0
  58. package/lib/core/store/models/topoBizMod.js +1 -11
  59. package/lib/core/store/models/topoConfig.js +5 -6
  60. package/lib/core/store/models/topoMod.js +71 -48
  61. package/lib/core/viewer/components/plugins/ResourceDetail/components/ResourceOverview/ResourceOverview.js +1 -1
  62. package/lib/core/viewer/components/titlebar/widgets/SearchWidget.js +4 -0
  63. package/lib/networkTopo/getTopoData.js +73 -65
  64. package/lib/networkTopo/models/TopoCenter.js +14 -94
  65. package/lib/networkTopo/services/topo/basic.js +30 -10
  66. package/lib/networkTopo/store/linkManager.js +0 -2
  67. package/lib/networkTopo/store/topoCenter.js +0 -2
  68. package/lib/networkTopo/store/topoLinkMod.js +0 -2
  69. package/lib/networkTopo/utils/resourcePermissionUtil.js +2 -2
  70. package/lib/utils/topoData.js +6 -172
  71. package/package.json +2 -2
  72. /package/es/core/services/{topo.js → topo/tagtip.js} +0 -0
  73. /package/lib/core/services/{topo.js → topo/tagtip.js} +0 -0
@@ -4,7 +4,7 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
4
4
 
5
5
  exports.__esModule = true;
6
6
  exports.buildTopoLinkData = buildTopoLinkData;
7
- exports.getInterfaceObject = exports.compatibleWith = void 0;
7
+ exports.compatibleWith = void 0;
8
8
  exports.getLinksDetail = getLinksDetail;
9
9
  exports.isCrucialLink = isCrucialLink;
10
10
  exports.isExitLink = isExitLink;
@@ -13,11 +13,9 @@ exports.showLinkByConfig = exports.plurals = void 0;
13
13
 
14
14
  var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
15
15
 
16
- var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
17
-
18
16
  var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
19
17
 
20
- var _topo = _interopRequireDefault(require("@riil-frontend/component-topology-common/es/services/topo"));
18
+ var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
21
19
 
22
20
  var _keyBy = _interopRequireDefault(require("lodash/keyBy"));
23
21
 
@@ -27,6 +25,8 @@ var _services = require("../../services");
27
25
 
28
26
  var _htElementUtils = require("../../../utils/htElementUtils");
29
27
 
28
+ var _CiTypeCache = _interopRequireDefault(require("../cache/CiTypeCache"));
29
+
30
30
  // 查询所有连线
31
31
  // const interfaceTypeMap = {
32
32
  // "network.interface": {
@@ -56,67 +56,27 @@ function isExitLink(link) {
56
56
  return (link === null || link === void 0 ? void 0 : link.attributes) && !(link !== null && link !== void 0 && link.attributes['destination_id']);
57
57
  }
58
58
 
59
- var getInterfaceObject = /*#__PURE__*/function () {
60
- var _ref = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee(codes) {
61
- var query, promises, result, ifDoc;
62
- return _regenerator["default"].wrap(function _callee$(_context) {
63
- while (1) {
64
- switch (_context.prev = _context.next) {
65
- case 0:
66
- query = _lodash["default"].compact(_lodash["default"].uniq(codes));
67
- promises = query.map(_services.queryModelAsset);
68
- _context.next = 4;
69
- return Promise.all(promises);
70
-
71
- case 4:
72
- result = _context.sent;
73
- ifDoc = {};
74
- result.map(function (ifItem) {
75
- ifDoc[ifItem.code] = {
76
- displayName: ifItem.displayName
77
- };
78
- });
79
- return _context.abrupt("return", ifDoc);
80
-
81
- case 8:
82
- case "end":
83
- return _context.stop();
84
- }
85
- }
86
- }, _callee);
87
- }));
88
-
89
- return function getInterfaceObject(_x) {
90
- return _ref.apply(this, arguments);
91
- };
92
- }();
93
-
94
- exports.getInterfaceObject = getInterfaceObject;
95
-
96
59
  function mergeLinksData(links, linkCis, nodes, interfaceCis, interfaceDoc) {
97
- var linkCiMap = (0, _keyBy["default"])(linkCis, "id");
60
+ var linkCiMap = (0, _keyBy["default"])(links, 'id');
98
61
  return links.map(function (link) {
99
62
  var _interfaceCis$find, _interfaceCis$find2;
100
63
 
101
64
  var linkCi = linkCiMap[link.id];
102
65
  var attributes = (0, _extends2["default"])({}, linkCi === null || linkCi === void 0 ? void 0 : linkCi.attributes);
103
66
  var sourceNode = nodes.find(function (node) {
104
- return node.id === attributes["network_link.source_device_id"];
67
+ return node.id === attributes['network_link.source_device_id'];
105
68
  });
106
69
  var targetNode = nodes.find(function (node) {
107
- return node.id === attributes["network_link.destination_device_id"];
70
+ return node.id === attributes['network_link.destination_device_id'];
108
71
  }); // 翻译
109
72
 
110
73
  return (0, _extends2["default"])({}, link, {
111
- id: linkCi.id,
112
- ciType: linkCi === null || linkCi === void 0 ? void 0 : linkCi.typeCode,
113
- name: linkCi === null || linkCi === void 0 ? void 0 : linkCi.attributes.name,
114
74
  attributes: (0, _extends2["default"])({}, attributes, {
115
75
  // 源/目的设备
116
- "network_link.source_device_id_object": {
76
+ 'network_link.source_device_id_object': {
117
77
  displayName: sourceNode === null || sourceNode === void 0 ? void 0 : sourceNode.name
118
78
  },
119
- "network_link.destination_device_id_object": {
79
+ 'network_link.destination_device_id_object': {
120
80
  displayName: targetNode === null || targetNode === void 0 ? void 0 : targetNode.name
121
81
  },
122
82
  // 源/目的接口类型
@@ -126,72 +86,71 @@ function mergeLinksData(links, linkCis, nodes, interfaceCis, interfaceDoc) {
126
86
  source_id_object: {
127
87
  displayName: (_interfaceCis$find = interfaceCis.find(function (node) {
128
88
  return node.id === attributes.source_id;
129
- })) === null || _interfaceCis$find === void 0 ? void 0 : _interfaceCis$find.attributes["display_name"]
89
+ })) === null || _interfaceCis$find === void 0 ? void 0 : _interfaceCis$find.attributes['display_name']
130
90
  },
131
91
  destination_id_object: {
132
92
  displayName: (_interfaceCis$find2 = interfaceCis.find(function (node) {
133
93
  return node.id === attributes.destination_id;
134
- })) === null || _interfaceCis$find2 === void 0 ? void 0 : _interfaceCis$find2.attributes["display_name"]
94
+ })) === null || _interfaceCis$find2 === void 0 ? void 0 : _interfaceCis$find2.attributes['display_name']
135
95
  }
136
96
  })
137
97
  });
138
98
  });
139
99
  }
140
100
 
141
- function getLinksDetail(_x2, _x3) {
101
+ function getLinksDetail(_x, _x2) {
142
102
  return _getLinksDetail.apply(this, arguments);
143
103
  }
144
104
 
145
105
  function _getLinksDetail() {
146
- _getLinksDetail = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee2(links, nodes) {
106
+ _getLinksDetail = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee(links, nodes) {
147
107
  var linkCis, interfaceIds, interfaceTypes, interfaceCis, interfaceDoc;
148
- return _regenerator["default"].wrap(function _callee2$(_context2) {
108
+ return _regenerator["default"].wrap(function _callee$(_context) {
149
109
  while (1) {
150
- switch (_context2.prev = _context2.next) {
110
+ switch (_context.prev = _context.next) {
151
111
  case 0:
152
112
  if (!(!links || !links.length)) {
153
- _context2.next = 2;
113
+ _context.next = 2;
154
114
  break;
155
115
  }
156
116
 
157
- return _context2.abrupt("return", []);
117
+ return _context.abrupt("return", []);
158
118
 
159
119
  case 2:
160
- _context2.next = 4;
161
- return _topo["default"].relation.batchQueryRelation(links.map(function (link) {
162
- return link.id;
120
+ // const linkCis = await topoService.relation.batchQueryRelation(
121
+ // links.map((link) => link.id)
122
+ // );
123
+ linkCis = links;
124
+ interfaceIds = [].concat(linkCis.map(function (item) {
125
+ return item.attributes.source_id;
126
+ }), linkCis.map(function (item) {
127
+ return item.attributes.destination_id;
163
128
  }));
164
-
165
- case 4:
166
- linkCis = _context2.sent;
167
- interfaceIds = [];
168
- interfaceTypes = [];
169
- linkCis.map(function (item) {
170
- interfaceIds.push(item.attributes.source_id);
171
- interfaceIds.push(item.attributes.destination_id);
172
- interfaceTypes.push(item.attributes.source_type);
173
- interfaceTypes.push(item.attributes.destination_type);
129
+ interfaceTypes = _lodash["default"].compact(_lodash["default"].uniq([].concat(linkCis.map(function (item) {
130
+ return item.attributes.source_type;
131
+ }), linkCis.map(function (item) {
132
+ return item.attributes.destination_type;
133
+ })))).filter(function (item) {
134
+ return item !== 'ip';
174
135
  });
175
- _context2.next = 10;
136
+ _context.next = 7;
176
137
  return (0, _services.queryCisByIds)(interfaceIds);
177
138
 
178
- case 10:
179
- interfaceCis = _context2.sent;
180
- _context2.next = 13;
181
- return getInterfaceObject(interfaceTypes.filter(function (item) {
182
- return item !== 'ip';
183
- }));
139
+ case 7:
140
+ interfaceCis = _context.sent;
141
+ _context.next = 10;
142
+ return _CiTypeCache["default"].getCiTypeMap(interfaceTypes);
184
143
 
185
- case 13:
186
- interfaceDoc = _context2.sent;
187
- return _context2.abrupt("return", mergeLinksData(links, linkCis, nodes, interfaceCis, interfaceDoc));
144
+ case 10:
145
+ interfaceDoc = _context.sent;
146
+ return _context.abrupt("return", mergeLinksData(links, linkCis, nodes, interfaceCis, interfaceDoc));
188
147
 
189
- case 15:
148
+ case 12:
190
149
  case "end":
191
- return _context2.stop();
150
+ return _context.stop();
192
151
  }
193
152
  }
194
- }, _callee2);
153
+ }, _callee);
195
154
  }));
196
155
  return _getLinksDetail.apply(this, arguments);
197
156
  }
@@ -216,10 +175,10 @@ var compatibleWith = function compatibleWith(value) {
216
175
  exports.compatibleWith = compatibleWith;
217
176
  var plurals = {
218
177
  0: [],
219
- 1: ["phy"],
220
- 2: ["phy"],
221
- 3: ["agg"],
222
- 4: ["phy", "agg"]
178
+ 1: ['phy'],
179
+ 2: ['phy'],
180
+ 3: ['agg'],
181
+ 4: ['phy', 'agg']
223
182
  };
224
183
  exports.plurals = plurals;
225
184
 
@@ -236,25 +195,25 @@ var showLinkByConfig = function showLinkByConfig(props) {
236
195
  var dm = gv.getDataModel();
237
196
  var edges = (0, _htElementUtils.getEdges)(dm); // console.log("edges", edges);
238
197
 
239
- var showPhy = types.indexOf("phy") >= 0;
240
- var showAgg = types.indexOf("agg") >= 0; // console.log("edges----types",showType, types,showPhy, showAgg);
198
+ var showPhy = types.indexOf('phy') >= 0;
199
+ var showAgg = types.indexOf('agg') >= 0; // console.log("edges----types",showType, types,showPhy, showAgg);
241
200
 
242
201
  if (Array.isArray(edges) && edges.length > 0) {
243
202
  edges.map(function (edge) {
244
203
  if (showType === 1 || showType === true) {
245
204
  // 单链路全部显示
246
205
  // console.log("单链路全部显示", edge);
247
- edge.s("2d.visible", true);
206
+ edge.s('2d.visible', true);
248
207
  } else {
249
208
  var _d$attributes, _d$attributes2;
250
209
 
251
210
  var d = topo.dataModel.getDataById(edge.getTag()); // 判断是否聚合链路
252
211
 
253
- if ((d === null || d === void 0 ? void 0 : (_d$attributes = d.attributes) === null || _d$attributes === void 0 ? void 0 : _d$attributes.destination_type) === "network.agg_interface" && (d === null || d === void 0 ? void 0 : (_d$attributes2 = d.attributes) === null || _d$attributes2 === void 0 ? void 0 : _d$attributes2.source_type) === "network.agg_interface") {
254
- edge.s("2d.visible", showAgg);
212
+ if ((d === null || d === void 0 ? void 0 : (_d$attributes = d.attributes) === null || _d$attributes === void 0 ? void 0 : _d$attributes.destination_type) === 'network.agg_interface' && (d === null || d === void 0 ? void 0 : (_d$attributes2 = d.attributes) === null || _d$attributes2 === void 0 ? void 0 : _d$attributes2.source_type) === 'network.agg_interface') {
213
+ edge.s('2d.visible', showAgg);
255
214
  } else {
256
215
  // console.log("edge", edge, d, showAgg);
257
- edge.s("2d.visible", showPhy);
216
+ edge.s('2d.visible', showPhy);
258
217
  }
259
218
  }
260
219
  });
@@ -0,0 +1,46 @@
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 _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
9
+
10
+ var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
11
+
12
+ var _componentTopologyUtils = require("@riil-frontend/component-topology-utils");
13
+
14
+ var _constants = require("./constants");
15
+
16
+ var _default = {
17
+ /**
18
+ * 保存拓扑绘制数据(第三方库内部结构,无需关心含义)
19
+ * @param {Number} id Topo ID
20
+ * @param {String} data ht拓扑序列化数据
21
+ * @returns
22
+ */
23
+ saveSerializeData: function saveSerializeData(id, data) {
24
+ return (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee() {
25
+ return _regenerator["default"].wrap(function _callee$(_context) {
26
+ while (1) {
27
+ switch (_context.prev = _context.next) {
28
+ case 0:
29
+ _context.next = 2;
30
+ return _componentTopologyUtils.request.post(_constants.TOPO_API_ROOT + "/structure/" + id, {
31
+ data: data
32
+ });
33
+
34
+ case 2:
35
+ return _context.abrupt("return", _context.sent);
36
+
37
+ case 3:
38
+ case "end":
39
+ return _context.stop();
40
+ }
41
+ }
42
+ }, _callee);
43
+ }))();
44
+ }
45
+ };
46
+ exports["default"] = _default;
@@ -0,0 +1,6 @@
1
+ "use strict";
2
+
3
+ exports.__esModule = true;
4
+ exports.TOPO_API_ROOT = void 0;
5
+ var TOPO_API_ROOT = '/topo/v1/api';
6
+ exports.TOPO_API_ROOT = TOPO_API_ROOT;
@@ -0,0 +1,16 @@
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 _topo = _interopRequireDefault(require("@riil-frontend/component-topology-common/es/services/topo"));
11
+
12
+ var _basic = _interopRequireDefault(require("./basic"));
13
+
14
+ var _default = (0, _extends2["default"])({}, _topo["default"], _basic["default"]);
15
+
16
+ exports["default"] = _default;
@@ -23,7 +23,6 @@ function _default(engine) {
23
23
  metricDoc: {},
24
24
  attrDoc: {},
25
25
  allCiSet: {},
26
- ciSetDoc: {},
27
26
  pollingSwitch: false,
28
27
 
29
28
  /**
@@ -44,7 +43,6 @@ function _default(engine) {
44
43
  var _this = this;
45
44
 
46
45
  return (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee() {
47
- var ciDoc, newCiDoc;
48
46
  return _regenerator["default"].wrap(function _callee$(_context) {
49
47
  while (1) {
50
48
  switch (_context.prev = _context.next) {
@@ -53,17 +51,9 @@ function _default(engine) {
53
51
  resAndMetrics: conditions
54
52
  });
55
53
 
56
- ciDoc = conditions.ciDoc;
57
- newCiDoc = (0, _extends2["default"])({}, ciDoc); // rlog.debug('topoBizMod.combBatchCiInfo getBatchCiInfo', conditions);
58
-
59
- _this.update({
60
- ciSetDoc: newCiDoc,
61
- pollingSwitch: true
62
- });
63
-
64
54
  return _context.abrupt("return", {});
65
55
 
66
- case 5:
56
+ case 2:
67
57
  case "end":
68
58
  return _context.stop();
69
59
  }
@@ -330,7 +330,7 @@ function _default(topoApp) {
330
330
  var _this4 = this;
331
331
 
332
332
  return (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee4() {
333
- var topoId, resources, groups, exportLinkIdList, viewConditions, groupInfo, data, _yield$Promise$all, ciTypeMap, _combTopoData, topoData, resAndMetrics, topoDataTrans;
333
+ var topoId, resources, groups, exportLinkIdList, viewConditions, groupInfo, data, _yield$Promise$all, dataWithLinkDetail, _combTopoData, topoData, resAndMetrics, topoDataTrans;
334
334
 
335
335
  return _regenerator["default"].wrap(function _callee4$(_context4) {
336
336
  while (1) {
@@ -357,20 +357,19 @@ function _default(topoApp) {
357
357
  case 8:
358
358
  data = _context4.sent;
359
359
  _context4.next = 11;
360
- return Promise.all([topoApp.ciTyeCache.getCiTypeMap((0, _topoData.getCiTypes)(data)), dispatch.customIcon.loadCustomIcons()]);
360
+ return Promise.all([(0, _getTopoData.addLinkData)(data), topoApp.ciTyeCache.getCiTypeMap((0, _topoData.getCiTypes)(data)), dispatch.customIcon.loadCustomIcons()]);
361
361
 
362
362
  case 11:
363
363
  _yield$Promise$all = _context4.sent;
364
- ciTypeMap = _yield$Promise$all[0];
364
+ dataWithLinkDetail = _yield$Promise$all[0];
365
365
  _combTopoData = (0, _topoData.combTopoData)({
366
366
  engine: topoApp,
367
367
  data: data,
368
368
  linkTo: null,
369
- globalConfig: state.topoMod.globalConfig,
370
- ciTypeMap: ciTypeMap
369
+ globalConfig: state.topoMod.globalConfig
371
370
  }), topoData = _combTopoData.topoData, resAndMetrics = _combTopoData.resAndMetrics;
372
371
  dispatch.topoMod.update({
373
- data: data
372
+ data: dataWithLinkDetail
374
373
  });
375
374
  topoDataTrans = (0, _utils2.transformTopoElements)(topoData);
376
375