@riil-frontend/component-topology 9.0.0-a.21 → 9.0.0-a.23

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.
@@ -15,7 +15,7 @@ function FontSizeSelect(props) {
15
15
  style: {
16
16
  width: 18
17
17
  }
18
- }, val || 12);
18
+ }, val || 20);
19
19
  },
20
20
  disabled: disabled,
21
21
  onSelect: function onSelect(val) {
@@ -15,7 +15,7 @@ export function getTextStyle(element) {
15
15
  color: parseColor(element.s('group.title.color')),
16
16
  underline: underline
17
17
  }, fontStyleUtil.toMap(element.s('group.title.font')), {
18
- fontSize: font.fontSize || 12,
18
+ fontSize: font.fontSize || 24,
19
19
  fontFamily: font.fontFamily || '微软雅黑'
20
20
  }, parseBackground(element.s('group.title.background')));
21
21
  }
@@ -4,7 +4,7 @@ var themeMap = [{
4
4
  name: 'white',
5
5
  label: '白色',
6
6
  color: null,
7
- toolsTheme: 'lightgrayblue'
7
+ toolsTheme: 'white'
8
8
  }, {
9
9
  name: 'lightblue',
10
10
  label: '蓝色',
@@ -22,11 +22,11 @@ var themeMap = [{
22
22
  name: 'dark',
23
23
  label: '深色',
24
24
  color: '#031425',
25
- toolsTheme: 'black'
25
+ toolsTheme: 'dark'
26
26
  }, {
27
27
  name: 'poly',
28
28
  label: 'Poly',
29
- toolsTheme: 'black',
29
+ toolsTheme: 'dark',
30
30
  backgroundImage: '/img/topo/themes/poly.png'
31
31
  }].reduce(function (map, item) {
32
32
  var _extends2;
@@ -49,7 +49,7 @@ export default function useCanvasTheme(props) {
49
49
  if (graphLoaded && themeConfig) {
50
50
  try {
51
51
  topo.getHtTopo().setTheme(themeName);
52
- topo.getHtTopo().setToolsTheme(themeName);
52
+ topo.getHtTopo().setToolsTheme(themeConfig.toolsTheme);
53
53
  } catch (error) {
54
54
  console.error('切换主题失败', error);
55
55
  }
@@ -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.21" === 'string' ? "9.0.0-a.21" : null;
27
+ var version = typeof "9.0.0-a.23" === 'string' ? "9.0.0-a.23" : null;
28
28
  console.info("\u62D3\u6251\u7248\u672C: " + version);
29
29
  /**
30
30
  * 拓扑显示和编辑
@@ -408,17 +408,17 @@ export default _extends({
408
408
  */
409
409
  getTopoData: function getTopoData(id) {
410
410
  return _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee12() {
411
- var _result$nodes, _result$links, result;
411
+ var _result$nodes, _result$links;
412
412
 
413
+ var result;
413
414
  return _regeneratorRuntime.wrap(function _callee12$(_context12) {
414
415
  while (1) {
415
416
  switch (_context12.prev = _context12.next) {
416
417
  case 0:
417
- _context12.prev = 0;
418
- _context12.next = 3;
418
+ _context12.next = 2;
419
419
  return request.get(API_ROOT + "/structure/both/" + id);
420
420
 
421
- case 3:
421
+ case 2:
422
422
  result = _context12.sent;
423
423
  return _context12.abrupt("return", processExitLink(_extends({}, result, {
424
424
  nodes: (_result$nodes = result.nodes) !== null && _result$nodes !== void 0 ? _result$nodes : [],
@@ -429,18 +429,12 @@ export default _extends({
429
429
  })
430
430
  })));
431
431
 
432
- case 7:
433
- _context12.prev = 7;
434
- _context12.t0 = _context12["catch"](0);
435
- rlog.debug('getTopoData-error', _context12.t0);
436
- return _context12.abrupt("return", null);
437
-
438
- case 11:
432
+ case 4:
439
433
  case "end":
440
434
  return _context12.stop();
441
435
  }
442
436
  }
443
- }, _callee12, null, [[0, 7]]);
437
+ }, _callee12);
444
438
  }))();
445
439
  },
446
440
 
@@ -64,56 +64,70 @@ export function isUniqueIp(dataModel, ip, nodeElement) {
64
64
 
65
65
  export function processExitLink(topoData) {
66
66
  var nodes = topoData.nodes,
67
- links = topoData.links;
67
+ links = topoData.links; // 出口链路目的端设置为IP节点或者ping资源节点id
68
68
 
69
- var serialize = _extends({}, getHtSerialize(topoData.serialize));
69
+ var newLinks = updateLinkTarget(links, nodes);
70
70
 
71
- if (!serialize) {
72
- return topoData;
73
- } // 历史数据升级
71
+ if (!topoData.serialize) {
72
+ return _extends({}, topoData, {
73
+ links: newLinks
74
+ });
75
+ }
76
+
77
+ var serialize = _extends({}, getHtSerialize(topoData.serialize)); // 历史数据升级
74
78
 
75
79
 
76
80
  links.filter(isExitLink) // 升级V1.4前配置的出口链路目的端节点为IP节点
77
81
  .forEach(function (link) {
78
82
  return upgradeExitLinkTarget(link);
79
- }); // 出口链路目的端设置为IP节点或者ping资源节点id
83
+ }); // 历史数据适配:同IP节点关联多个不同IP的链路、分级拓扑。target匹配不到元素时,根据序列化匹配
80
84
 
81
- var newLinks = links.map(function (link) {
82
- if (!isExitLink(link) || link.target && nodes.find(function (node) {
83
- return node.id === link.target;
84
- })) {
85
- return link;
86
- }
85
+ newLinks = upgradeLinkTargetNotExisted(links); // IP节点构造为node。如果有相同ip的ping资源和图片节点,图片节点消失(不构造)
87
86
 
88
- var destinationIp = link.attributes['network_link.destination_ipv4'];
89
- var pingNode = findPingNode(nodes, destinationIp); // 出口链路目的端设置为IP节点或者ping资源节点id
87
+ var ipNodes = getIpNodes();
88
+ return _extends({}, topoData, {
89
+ nodes: [].concat(nodes, ipNodes),
90
+ links: newLinks,
91
+ serialize: serialize
92
+ }); // 历史数据适配:同IP节点关联多个不同IP的链路、分级拓扑。target匹配不到元素时,根据序列化匹配
93
+
94
+ function upgradeLinkTargetNotExisted(links) {
95
+ newLinks = links.map(function (link) {
96
+ if (!isExitLink(link) || link.target && nodes.find(function (node) {
97
+ return node.id === link.target;
98
+ })) {
99
+ return link;
100
+ }
90
101
 
91
- var target = pingNode ? pingNode.id : "ip:" + destinationIp; // 历史数据适配:同IP节点关联多个不同IP的链路、分级拓扑。target匹配不到元素时,根据序列化匹配
102
+ var destinationIp = link.attributes['network_link.destination_ipv4'];
103
+ var pingNode = findPingNode(nodes, destinationIp); // 出口链路目的端设置为IP节点或者ping资源节点id
92
104
 
93
- var targetSerialize = findElementSerializeById(serialize, target);
105
+ var target = link.target; // 历史数据适配:同IP节点关联多个不同IP的链路、分级拓扑。target匹配不到元素时,根据序列化匹配
94
106
 
95
- if (!targetSerialize) {
96
- var linkSerialize = findElementSerializeById(serialize, link.id);
107
+ var targetSerialize = findElementSerializeById(serialize, target);
97
108
 
98
- if (linkSerialize) {
99
- // 根据链路序列化数据找目的端节点
100
- // eslint-disable-next-line no-underscore-dangle
101
- var targetNodeSerialize = serialize.d.find(function (item) {
102
- return item.i === linkSerialize.p.target.__i;
103
- });
109
+ if (!targetSerialize) {
110
+ var linkSerialize = findElementSerializeById(serialize, link.id);
104
111
 
105
- if (targetNodeSerialize) {
106
- target = targetNodeSerialize.p.tag;
112
+ if (linkSerialize) {
113
+ // 根据链路序列化数据找目的端节点
114
+ // eslint-disable-next-line no-underscore-dangle
115
+ var targetNodeSerialize = serialize.d.find(function (item) {
116
+ return item.i === linkSerialize.p.target.__i;
117
+ });
118
+
119
+ if (targetNodeSerialize) {
120
+ target = targetNodeSerialize.p.tag;
121
+ }
107
122
  }
108
123
  }
109
- }
110
124
 
111
- return _extends({}, link, {
112
- target: target
125
+ return _extends({}, link, {
126
+ target: target
127
+ });
113
128
  });
114
- }); // IP节点构造为node。如果有相同ip的ping资源和图片节点,图片节点消失(不构造)
115
-
116
- var ipNodes = getIpNodes();
129
+ return newLinks;
130
+ }
117
131
 
118
132
  function getIpNodes() {
119
133
  // 从序列化获取关联的IP
@@ -166,18 +180,32 @@ export function processExitLink(topoData) {
166
180
  }
167
181
  }
168
182
  }
169
-
170
- return _extends({}, topoData, {
171
- nodes: [].concat(nodes, ipNodes),
172
- links: newLinks,
173
- serialize: serialize
174
- });
175
183
  } // 从拓扑数据查找
176
184
 
177
185
  function findPingNode(nodes, ip) {
178
186
  return nodes.find(function (node) {
179
187
  return node.ciType === "ping" && (node.ipAddress || node.attributes.ipv4_address) === ip;
180
188
  });
189
+ } // 出口链路目的端设置为IP节点或者ping资源节点id
190
+
191
+
192
+ function updateLinkTarget(links, nodes) {
193
+ var newLinks = links.map(function (link) {
194
+ if (!isExitLink(link) || link.target && nodes.find(function (node) {
195
+ return node.id === link.target;
196
+ })) {
197
+ return link;
198
+ }
199
+
200
+ var destinationIp = link.attributes['network_link.destination_ipv4'];
201
+ var pingNode = findPingNode(nodes, destinationIp); // 出口链路目的端设置为IP节点或者ping资源节点id
202
+
203
+ var target = pingNode ? pingNode.id : "ip:" + destinationIp;
204
+ return _extends({}, link, {
205
+ target: target
206
+ });
207
+ });
208
+ return newLinks;
181
209
  }
182
210
  /**
183
211
  * 编辑模式按资源查询拓扑数据处理出口链路target
@@ -202,21 +230,7 @@ export function processByConditionResult(topoData) {
202
230
  } // 出口链路目的端设置为IP节点或者ping资源节点id
203
231
 
204
232
 
205
- var newLinks = links.map(function (link) {
206
- if (!isExitLink(link) || link.target && nodes.find(function (node) {
207
- return node.id === link.target;
208
- })) {
209
- return link;
210
- }
211
-
212
- var destinationIp = link.attributes['network_link.destination_ipv4'];
213
- var pingNode = findPingNode(nodes, destinationIp); // 出口链路目的端设置为IP节点或者ping资源节点id
214
-
215
- var target = pingNode ? pingNode.id : "ip:" + destinationIp;
216
- return _extends({}, link, {
217
- target: target
218
- });
219
- });
233
+ var newLinks = updateLinkTarget(links, nodes);
220
234
  return _extends({}, topoData, {
221
235
  nodes: [].concat(nodes, ipNodes),
222
236
  links: newLinks
@@ -29,7 +29,7 @@ function FontSizeSelect(props) {
29
29
  style: {
30
30
  width: 18
31
31
  }
32
- }, val || 12);
32
+ }, val || 20);
33
33
  },
34
34
  disabled: disabled,
35
35
  onSelect: function onSelect(val) {
@@ -33,7 +33,7 @@ function getTextStyle(element) {
33
33
  color: (0, _colorUtil.parseColor)(element.s('group.title.color')),
34
34
  underline: underline
35
35
  }, _fontStyleUtil["default"].toMap(element.s('group.title.font')), {
36
- fontSize: font.fontSize || 12,
36
+ fontSize: font.fontSize || 24,
37
37
  fontFamily: font.fontFamily || '微软雅黑'
38
38
  }, (0, _colorUtil.parseBackground)(element.s('group.title.background')));
39
39
  }
@@ -17,7 +17,7 @@ var themeMap = [{
17
17
  name: 'white',
18
18
  label: '白色',
19
19
  color: null,
20
- toolsTheme: 'lightgrayblue'
20
+ toolsTheme: 'white'
21
21
  }, {
22
22
  name: 'lightblue',
23
23
  label: '蓝色',
@@ -35,11 +35,11 @@ var themeMap = [{
35
35
  name: 'dark',
36
36
  label: '深色',
37
37
  color: '#031425',
38
- toolsTheme: 'black'
38
+ toolsTheme: 'dark'
39
39
  }, {
40
40
  name: 'poly',
41
41
  label: 'Poly',
42
- toolsTheme: 'black',
42
+ toolsTheme: 'dark',
43
43
  backgroundImage: '/img/topo/themes/poly.png'
44
44
  }].reduce(function (map, item) {
45
45
  var _extends2;
@@ -63,7 +63,7 @@ function useCanvasTheme(props) {
63
63
  if (graphLoaded && themeConfig) {
64
64
  try {
65
65
  topo.getHtTopo().setTheme(themeName);
66
- topo.getHtTopo().setToolsTheme(themeName);
66
+ topo.getHtTopo().setToolsTheme(themeConfig.toolsTheme);
67
67
  } catch (error) {
68
68
  console.error('切换主题失败', error);
69
69
  }
@@ -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.21" === 'string' ? "9.0.0-a.21" : null;
59
+ var version = typeof "9.0.0-a.23" === 'string' ? "9.0.0-a.23" : null;
60
60
  console.info("\u62D3\u6251\u7248\u672C: " + version);
61
61
  /**
62
62
  * 拓扑显示和编辑
@@ -428,17 +428,17 @@ var _default = (0, _extends2["default"])({
428
428
  */
429
429
  getTopoData: function getTopoData(id) {
430
430
  return (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee12() {
431
- var _result$nodes, _result$links, result;
431
+ var _result$nodes, _result$links;
432
432
 
433
+ var result;
433
434
  return _regenerator["default"].wrap(function _callee12$(_context12) {
434
435
  while (1) {
435
436
  switch (_context12.prev = _context12.next) {
436
437
  case 0:
437
- _context12.prev = 0;
438
- _context12.next = 3;
438
+ _context12.next = 2;
439
439
  return _componentTopologyUtils.request.get(API_ROOT + "/structure/both/" + id);
440
440
 
441
- case 3:
441
+ case 2:
442
442
  result = _context12.sent;
443
443
  return _context12.abrupt("return", (0, _exitLinkUtil.processExitLink)((0, _extends2["default"])({}, result, {
444
444
  nodes: (_result$nodes = result.nodes) !== null && _result$nodes !== void 0 ? _result$nodes : [],
@@ -449,20 +449,12 @@ var _default = (0, _extends2["default"])({
449
449
  })
450
450
  })));
451
451
 
452
- case 7:
453
- _context12.prev = 7;
454
- _context12.t0 = _context12["catch"](0);
455
-
456
- _rlog["default"].debug('getTopoData-error', _context12.t0);
457
-
458
- return _context12.abrupt("return", null);
459
-
460
- case 11:
452
+ case 4:
461
453
  case "end":
462
454
  return _context12.stop();
463
455
  }
464
456
  }
465
- }, _callee12, null, [[0, 7]]);
457
+ }, _callee12);
466
458
  }))();
467
459
  },
468
460
 
@@ -75,55 +75,69 @@ function isUniqueIp(dataModel, ip, nodeElement) {
75
75
 
76
76
  function processExitLink(topoData) {
77
77
  var nodes = topoData.nodes,
78
- links = topoData.links;
79
- var serialize = (0, _extends2["default"])({}, getHtSerialize(topoData.serialize));
78
+ links = topoData.links; // 出口链路目的端设置为IP节点或者ping资源节点id
80
79
 
81
- if (!serialize) {
82
- return topoData;
83
- } // 历史数据升级
80
+ var newLinks = updateLinkTarget(links, nodes);
84
81
 
82
+ if (!topoData.serialize) {
83
+ return (0, _extends2["default"])({}, topoData, {
84
+ links: newLinks
85
+ });
86
+ }
87
+
88
+ var serialize = (0, _extends2["default"])({}, getHtSerialize(topoData.serialize)); // 历史数据升级
85
89
 
86
90
  links.filter(isExitLink) // 升级V1.4前配置的出口链路目的端节点为IP节点
87
91
  .forEach(function (link) {
88
92
  return upgradeExitLinkTarget(link);
89
- }); // 出口链路目的端设置为IP节点或者ping资源节点id
93
+ }); // 历史数据适配:同IP节点关联多个不同IP的链路、分级拓扑。target匹配不到元素时,根据序列化匹配
90
94
 
91
- var newLinks = links.map(function (link) {
92
- if (!isExitLink(link) || link.target && nodes.find(function (node) {
93
- return node.id === link.target;
94
- })) {
95
- return link;
96
- }
95
+ newLinks = upgradeLinkTargetNotExisted(links); // IP节点构造为node。如果有相同ip的ping资源和图片节点,图片节点消失(不构造)
97
96
 
98
- var destinationIp = link.attributes['network_link.destination_ipv4'];
99
- var pingNode = findPingNode(nodes, destinationIp); // 出口链路目的端设置为IP节点或者ping资源节点id
97
+ var ipNodes = getIpNodes();
98
+ return (0, _extends2["default"])({}, topoData, {
99
+ nodes: [].concat(nodes, ipNodes),
100
+ links: newLinks,
101
+ serialize: serialize
102
+ }); // 历史数据适配:同IP节点关联多个不同IP的链路、分级拓扑。target匹配不到元素时,根据序列化匹配
103
+
104
+ function upgradeLinkTargetNotExisted(links) {
105
+ newLinks = links.map(function (link) {
106
+ if (!isExitLink(link) || link.target && nodes.find(function (node) {
107
+ return node.id === link.target;
108
+ })) {
109
+ return link;
110
+ }
100
111
 
101
- var target = pingNode ? pingNode.id : "ip:" + destinationIp; // 历史数据适配:同IP节点关联多个不同IP的链路、分级拓扑。target匹配不到元素时,根据序列化匹配
112
+ var destinationIp = link.attributes['network_link.destination_ipv4'];
113
+ var pingNode = findPingNode(nodes, destinationIp); // 出口链路目的端设置为IP节点或者ping资源节点id
102
114
 
103
- var targetSerialize = findElementSerializeById(serialize, target);
115
+ var target = link.target; // 历史数据适配:同IP节点关联多个不同IP的链路、分级拓扑。target匹配不到元素时,根据序列化匹配
104
116
 
105
- if (!targetSerialize) {
106
- var linkSerialize = findElementSerializeById(serialize, link.id);
117
+ var targetSerialize = findElementSerializeById(serialize, target);
107
118
 
108
- if (linkSerialize) {
109
- // 根据链路序列化数据找目的端节点
110
- // eslint-disable-next-line no-underscore-dangle
111
- var targetNodeSerialize = serialize.d.find(function (item) {
112
- return item.i === linkSerialize.p.target.__i;
113
- });
119
+ if (!targetSerialize) {
120
+ var linkSerialize = findElementSerializeById(serialize, link.id);
114
121
 
115
- if (targetNodeSerialize) {
116
- target = targetNodeSerialize.p.tag;
122
+ if (linkSerialize) {
123
+ // 根据链路序列化数据找目的端节点
124
+ // eslint-disable-next-line no-underscore-dangle
125
+ var targetNodeSerialize = serialize.d.find(function (item) {
126
+ return item.i === linkSerialize.p.target.__i;
127
+ });
128
+
129
+ if (targetNodeSerialize) {
130
+ target = targetNodeSerialize.p.tag;
131
+ }
117
132
  }
118
133
  }
119
- }
120
134
 
121
- return (0, _extends2["default"])({}, link, {
122
- target: target
135
+ return (0, _extends2["default"])({}, link, {
136
+ target: target
137
+ });
123
138
  });
124
- }); // IP节点构造为node。如果有相同ip的ping资源和图片节点,图片节点消失(不构造)
125
-
126
- var ipNodes = getIpNodes();
139
+ return newLinks;
140
+ }
127
141
 
128
142
  function getIpNodes() {
129
143
  // 从序列化获取关联的IP
@@ -176,12 +190,6 @@ function processExitLink(topoData) {
176
190
  }
177
191
  }
178
192
  }
179
-
180
- return (0, _extends2["default"])({}, topoData, {
181
- nodes: [].concat(nodes, ipNodes),
182
- links: newLinks,
183
- serialize: serialize
184
- });
185
193
  } // 从拓扑数据查找
186
194
 
187
195
 
@@ -189,6 +197,26 @@ function findPingNode(nodes, ip) {
189
197
  return nodes.find(function (node) {
190
198
  return node.ciType === "ping" && (node.ipAddress || node.attributes.ipv4_address) === ip;
191
199
  });
200
+ } // 出口链路目的端设置为IP节点或者ping资源节点id
201
+
202
+
203
+ function updateLinkTarget(links, nodes) {
204
+ var newLinks = links.map(function (link) {
205
+ if (!isExitLink(link) || link.target && nodes.find(function (node) {
206
+ return node.id === link.target;
207
+ })) {
208
+ return link;
209
+ }
210
+
211
+ var destinationIp = link.attributes['network_link.destination_ipv4'];
212
+ var pingNode = findPingNode(nodes, destinationIp); // 出口链路目的端设置为IP节点或者ping资源节点id
213
+
214
+ var target = pingNode ? pingNode.id : "ip:" + destinationIp;
215
+ return (0, _extends2["default"])({}, link, {
216
+ target: target
217
+ });
218
+ });
219
+ return newLinks;
192
220
  }
193
221
  /**
194
222
  * 编辑模式按资源查询拓扑数据处理出口链路target
@@ -213,21 +241,7 @@ function processByConditionResult(topoData) {
213
241
  } // 出口链路目的端设置为IP节点或者ping资源节点id
214
242
 
215
243
 
216
- var newLinks = links.map(function (link) {
217
- if (!isExitLink(link) || link.target && nodes.find(function (node) {
218
- return node.id === link.target;
219
- })) {
220
- return link;
221
- }
222
-
223
- var destinationIp = link.attributes['network_link.destination_ipv4'];
224
- var pingNode = findPingNode(nodes, destinationIp); // 出口链路目的端设置为IP节点或者ping资源节点id
225
-
226
- var target = pingNode ? pingNode.id : "ip:" + destinationIp;
227
- return (0, _extends2["default"])({}, link, {
228
- target: target
229
- });
230
- });
244
+ var newLinks = updateLinkTarget(links, nodes);
231
245
  return (0, _extends2["default"])({}, topoData, {
232
246
  nodes: [].concat(nodes, ipNodes),
233
247
  links: newLinks
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@riil-frontend/component-topology",
3
- "version": "9.0.0-a.21",
3
+ "version": "9.0.0-a.23",
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.21/build/index.html",
119
+ "homepage": "https://unpkg.com/@riil-frontend/component-topology@9.0.0-a.23/build/index.html",
120
120
  "gitHead": "2da19ffccbb7ca60a8acf396e39f542c68bb33f5"
121
121
  }