@riil-frontend/component-topology 13.0.0-dev.2 → 13.0.0-dev.4

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.
@@ -25,6 +25,10 @@ function initKeyboardShortcuts(props) {
25
25
 
26
26
  hotkeys('ctrl+v, command+v', function (event) {
27
27
  return handlePasteHotkey(event, props);
28
+ }); // 删除
29
+
30
+ hotkeys('delete', function (event) {
31
+ topoEdit.batchDeleteSelectedElement();
28
32
  });
29
33
  }
30
34
 
@@ -307,6 +307,8 @@ var useTopoEdit = function useTopoEdit(params) {
307
307
  }
308
308
  };
309
309
 
310
+ var batchDeleteSelectedElement = function batchDeleteSelectedElement() {};
311
+
310
312
  var onDeleteElement = function onDeleteElement(data) {
311
313
  var dtype = data.dtype;
312
314
  rlog.info("onDeleteElement", data);
@@ -1123,6 +1125,7 @@ var useTopoEdit = function useTopoEdit(params) {
1123
1125
  onCloseComboResDrawer: function onCloseComboResDrawer() {
1124
1126
  return setShowComboResDrawer(false);
1125
1127
  },
1128
+ batchDeleteSelectedElement: batchDeleteSelectedElement,
1126
1129
 
1127
1130
  /**
1128
1131
  * 拓扑图元素(节点、连线、容器)删除回调
@@ -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 "13.0.0-dev.2" === 'string' ? "13.0.0-dev.2" : null;
27
+ var version = typeof "13.0.0-dev.4" === 'string' ? "13.0.0-dev.4" : null;
28
28
  console.info("\u62D3\u6251\u7248\u672C: " + version);
29
29
  /**
30
30
  * 拓扑显示和编辑
@@ -9,6 +9,7 @@ import blackList from "./blacklist";
9
9
  import { TOPO_API_ROOT } from "./constants";
10
10
  import { getBatchCi as _getBatchCi, getBatchCiMetric as _getBatchCiMetric } from "../model";
11
11
  import { processByConditionResult, processExitLink } from "../../utils/exitLinkUtil";
12
+ import * as processBothTopoDataUtil from "../../utils/relateTopoDataUtil";
12
13
  var API_ROOT = TOPO_API_ROOT;
13
14
  /**
14
15
  * 拓扑图(看做一个容器)的“父容器”ID
@@ -49,7 +50,7 @@ function prepareResourceParams(conditions, query) {
49
50
  return {
50
51
  dynamicCondition: dynamicCondition,
51
52
  fixedConditionIdList: (staticRes || []).filter(function (ciId) {
52
- return !ciId.startsWith('ip:');
53
+ return !ciId.includes(':');
53
54
  }),
54
55
  linkIps: (staticRes || []).filter(function (ciId) {
55
56
  return ciId.startsWith('ip:');
@@ -389,16 +390,19 @@ export default _extends({
389
390
 
390
391
  case 2:
391
392
  result = _context12.sent;
392
- return _context12.abrupt("return", processExitLink(_extends({}, result, {
393
+ result = _extends({}, result, {
393
394
  nodes: (_result$nodes = result.nodes) !== null && _result$nodes !== void 0 ? _result$nodes : [],
394
395
  links: ((_result$links = result.links) !== null && _result$links !== void 0 ? _result$links : []).map(function (item) {
395
396
  return _extends({}, item, {
396
397
  ciType: 'network_link'
397
398
  });
398
399
  })
399
- })));
400
+ });
401
+ result = processExitLink(result);
402
+ result = processBothTopoDataUtil.processBothTopoData(result);
403
+ return _context12.abrupt("return", result);
400
404
 
401
- case 4:
405
+ case 7:
402
406
  case "end":
403
407
  return _context12.stop();
404
408
  }
@@ -439,16 +443,17 @@ export default _extends({
439
443
 
440
444
  case 5:
441
445
  result = _context13.sent;
442
- return _context13.abrupt("return", processByConditionResult(_extends({}, result, {
446
+ result = _extends({}, result, {
443
447
  nodes: (_result$nodes2 = result.nodes) !== null && _result$nodes2 !== void 0 ? _result$nodes2 : [],
444
448
  links: ((_result$links2 = result.links) !== null && _result$links2 !== void 0 ? _result$links2 : []).map(function (item) {
445
449
  return _extends({}, item, {
446
450
  ciType: 'network_link'
447
451
  });
448
452
  })
449
- }), obj.groups));
453
+ });
454
+ return _context13.abrupt("return", processByConditionResult(result, obj.groups));
450
455
 
451
- case 7:
456
+ case 8:
452
457
  case "end":
453
458
  return _context13.stop();
454
459
  }
@@ -0,0 +1,38 @@
1
+ export var topoLinks = [// 子拓扑之间
2
+ {
3
+ "id": "2-2",
4
+ "name": "子拓扑链路",
5
+ 'sourceType': 'topo',
6
+ "source": "3",
7
+ 'targetType': 'topo',
8
+ "target": "6",
9
+ "operation": "delete",
10
+ "ciType": "network_link",
11
+ "attributes": {
12
+ "network_link.source_device_ipv4": "172.17.166.18",
13
+ "network_link.destination_ipv4": "1.5.5.5",
14
+ "network_link.work_mode": "AandS",
15
+ "support_templates": "m.ethernet_link",
16
+ "rated_bandwidth": 100,
17
+ "network_link.actual_bandwidth": 100,
18
+ "source_type": "network.interface",
19
+ "network_link.connect_type": "phy",
20
+ "display_name": "172.17.166.18(Fa 0/10) - 1.5.5.5",
21
+ "asset_status": "2",
22
+ "network_link_type": "2",
23
+ "destination_type": "ip",
24
+ "network_link.role": "master",
25
+ "network_link.network_category": "CAN",
26
+ "dcs": "331268969",
27
+ "network_link.source_ipv4": "172.17.166.18",
28
+ "name": "172.17.166.18(Fa 0/10) - 1.5.5.5",
29
+ "distance_outlet": 2147483647,
30
+ "network_link.is_crucial": false,
31
+ "source_id": "00000000010de8b2",
32
+ "network_link.source_device_id": "00000000010de861"
33
+ },
34
+ "sourceCode": null,
35
+ "level": null,
36
+ "customType": null,
37
+ "manageStatus": 3
38
+ }];
@@ -1,16 +1,20 @@
1
1
  import _extends from "@babel/runtime/helpers/extends";
2
2
  // 关联拓扑数据
3
-
3
+ import { topoLinks } from "./__tests__/relateTopoData";
4
4
  /**
5
5
  * 升级历史数据:子拓扑节点序列化数据
6
6
  * 构造子拓扑节点
7
7
  * 构造子拓扑链路
8
8
  * @param {*} ctx
9
9
  */
10
- export function processBothTopoData(ctx) {
11
- var topoData = ctx.topoData;
12
- var serialize = upgradeSerializeRelateTopoNode(topoData.serialize);
10
+
11
+ export function processBothTopoData(topoData) {
12
+ var nodes = topoData.nodes,
13
+ links = topoData.links;
14
+ var serialize = upgradeSerializeOldTopoNode(topoData.serialize);
13
15
  return _extends({}, topoData, {
16
+ nodes: [].concat(nodes, buildTopoNodeDatasFromSerialize(serialize)),
17
+ links: buildTopoLinks(links),
14
18
  serialize: serialize
15
19
  });
16
20
  }
@@ -22,17 +26,84 @@ export function processBothTopoData(ctx) {
22
26
 
23
27
  export function processByConditionTopoData(ctx) {
24
28
  var topoData = ctx.topoData;
29
+ var nodes = topoData.nodes,
30
+ links = topoData.links;
25
31
  return _extends({}, topoData);
26
32
  }
33
+ export function buildTopoNode(topoId) {
34
+ return {
35
+ id: "topo:" + topoId,
36
+ // name: ,
37
+ bindType: "topo",
38
+ // 绑定资源类型。关联资源 值为空,关联IP ip
39
+ bindIp: topoId,
40
+ // TODO 所属区域,从序列化拿
41
+ // 'groupId': null,
42
+ // 'groupTag': null,
43
+ // 'attributes': [],
44
+ // 'metrics': [],
45
+ type: "node",
46
+ isbinding: true,
47
+ // 'dtype': 'device'
48
+ operation: "delete"
49
+ };
50
+ }
51
+
52
+ function buildTopoLinks(links) {
53
+ links.push.apply(links, topoLinks);
54
+ return links.map(function (link) {
55
+ return _extends({}, link, {
56
+ "source": link.sourceType ? link.sourceType + ':' + link.source : link.source,
57
+ "target": link.targetType ? link.targetType + ':' + link.target : link.target
58
+ });
59
+ });
60
+ }
27
61
  /**
28
62
  * 升级历史数据:子拓扑节点序列化数据
29
63
  * @param {*} serialize
30
64
  */
31
65
 
32
- function upgradeSerializeRelateTopoNode(serialize) {
66
+
67
+ function upgradeSerializeOldTopoNode(serialize) {
68
+ if (serialize) {
69
+ var isOldTopoNode = function isOldTopoNode(ele) {
70
+ return isTopoNode(ele) && !ele.p.tag;
71
+ };
72
+
73
+ var oldTopoNodes = serialize.d.filter(isOldTopoNode);
74
+ oldTopoNodes.forEach(function (node) {
75
+ var _node$a;
76
+
77
+ var topoId = (_node$a = node.a) === null || _node$a === void 0 ? void 0 : _node$a.bindTopo;
78
+ node.a = _extends({}, node.a, buildTopoNode(topoId));
79
+ node.p.tag = "topo:" + topoId;
80
+ });
81
+ }
82
+
33
83
  return serialize;
34
84
  }
35
85
 
86
+ function isTopoNode(ele) {
87
+ var _ele$a;
88
+
89
+ return !!((_ele$a = ele.a) !== null && _ele$a !== void 0 && _ele$a.bindTopo);
90
+ }
91
+
92
+ function buildTopoNodeDatasFromSerialize(serialize) {
93
+ if (!serialize) {
94
+ return [];
95
+ }
96
+
97
+ var topoNodes = serialize.d.filter(isTopoNode);
98
+ var topoNodeDatas = topoNodes.map(function (node) {
99
+ var _node$a2;
100
+
101
+ var topoId = (_node$a2 = node.a) === null || _node$a2 === void 0 ? void 0 : _node$a2.bindTopo;
102
+ return buildTopoNode(topoId);
103
+ });
104
+ return topoNodeDatas;
105
+ }
106
+
36
107
  function getRelateTopoIdsFromSerialize(serialize) {
37
108
  return serialize;
38
109
  }
@@ -34,6 +34,10 @@ function initKeyboardShortcuts(props) {
34
34
 
35
35
  (0, _hotkeysJs["default"])('ctrl+v, command+v', function (event) {
36
36
  return (0, _copyElementUtil.handlePasteHotkey)(event, props);
37
+ }); // 删除
38
+
39
+ (0, _hotkeysJs["default"])('delete', function (event) {
40
+ topoEdit.batchDeleteSelectedElement();
37
41
  });
38
42
  }
39
43
 
@@ -336,6 +336,8 @@ var useTopoEdit = function useTopoEdit(params) {
336
336
  }
337
337
  };
338
338
 
339
+ var batchDeleteSelectedElement = function batchDeleteSelectedElement() {};
340
+
339
341
  var onDeleteElement = function onDeleteElement(data) {
340
342
  var dtype = data.dtype;
341
343
  rlog.info("onDeleteElement", data);
@@ -1152,6 +1154,7 @@ var useTopoEdit = function useTopoEdit(params) {
1152
1154
  onCloseComboResDrawer: function onCloseComboResDrawer() {
1153
1155
  return setShowComboResDrawer(false);
1154
1156
  },
1157
+ batchDeleteSelectedElement: batchDeleteSelectedElement,
1155
1158
 
1156
1159
  /**
1157
1160
  * 拓扑图元素(节点、连线、容器)删除回调
@@ -54,7 +54,7 @@ var _SelectionModel = _interopRequireDefault(require("./SelectionModel"));
54
54
  var _CiCache = _interopRequireDefault(require("./cache/CiCache"));
55
55
 
56
56
  // eslint-disable-next-line no-undef
57
- var version = typeof "13.0.0-dev.2" === 'string' ? "13.0.0-dev.2" : null;
57
+ var version = typeof "13.0.0-dev.4" === 'string' ? "13.0.0-dev.4" : null;
58
58
  console.info("\u62D3\u6251\u7248\u672C: " + version);
59
59
  /**
60
60
  * 拓扑显示和编辑
@@ -23,7 +23,14 @@ var _model = require("../model");
23
23
 
24
24
  var _exitLinkUtil = require("../../utils/exitLinkUtil");
25
25
 
26
+ var processBothTopoDataUtil = _interopRequireWildcard(require("../../utils/relateTopoDataUtil"));
27
+
26
28
  var _excluded = ["groups", "resources"];
29
+
30
+ function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
31
+
32
+ function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { "default": obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj["default"] = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
33
+
27
34
  var API_ROOT = _constants.TOPO_API_ROOT;
28
35
  /**
29
36
  * 拓扑图(看做一个容器)的“父容器”ID
@@ -66,7 +73,7 @@ function prepareResourceParams(conditions, query) {
66
73
  return {
67
74
  dynamicCondition: dynamicCondition,
68
75
  fixedConditionIdList: (staticRes || []).filter(function (ciId) {
69
- return !ciId.startsWith('ip:');
76
+ return !ciId.includes(':');
70
77
  }),
71
78
  linkIps: (staticRes || []).filter(function (ciId) {
72
79
  return ciId.startsWith('ip:');
@@ -406,16 +413,19 @@ var _default = (0, _extends2["default"])({
406
413
 
407
414
  case 2:
408
415
  result = _context12.sent;
409
- return _context12.abrupt("return", (0, _exitLinkUtil.processExitLink)((0, _extends2["default"])({}, result, {
416
+ result = (0, _extends2["default"])({}, result, {
410
417
  nodes: (_result$nodes = result.nodes) !== null && _result$nodes !== void 0 ? _result$nodes : [],
411
418
  links: ((_result$links = result.links) !== null && _result$links !== void 0 ? _result$links : []).map(function (item) {
412
419
  return (0, _extends2["default"])({}, item, {
413
420
  ciType: 'network_link'
414
421
  });
415
422
  })
416
- })));
423
+ });
424
+ result = (0, _exitLinkUtil.processExitLink)(result);
425
+ result = processBothTopoDataUtil.processBothTopoData(result);
426
+ return _context12.abrupt("return", result);
417
427
 
418
- case 4:
428
+ case 7:
419
429
  case "end":
420
430
  return _context12.stop();
421
431
  }
@@ -456,16 +466,17 @@ var _default = (0, _extends2["default"])({
456
466
 
457
467
  case 5:
458
468
  result = _context13.sent;
459
- return _context13.abrupt("return", (0, _exitLinkUtil.processByConditionResult)((0, _extends2["default"])({}, result, {
469
+ result = (0, _extends2["default"])({}, result, {
460
470
  nodes: (_result$nodes2 = result.nodes) !== null && _result$nodes2 !== void 0 ? _result$nodes2 : [],
461
471
  links: ((_result$links2 = result.links) !== null && _result$links2 !== void 0 ? _result$links2 : []).map(function (item) {
462
472
  return (0, _extends2["default"])({}, item, {
463
473
  ciType: 'network_link'
464
474
  });
465
475
  })
466
- }), obj.groups));
476
+ });
477
+ return _context13.abrupt("return", (0, _exitLinkUtil.processByConditionResult)(result, obj.groups));
467
478
 
468
- case 7:
479
+ case 8:
469
480
  case "end":
470
481
  return _context13.stop();
471
482
  }
@@ -0,0 +1,43 @@
1
+ "use strict";
2
+
3
+ exports.__esModule = true;
4
+ exports.topoLinks = void 0;
5
+ var topoLinks = [// 子拓扑之间
6
+ {
7
+ "id": "2-2",
8
+ "name": "子拓扑链路",
9
+ 'sourceType': 'topo',
10
+ "source": "3",
11
+ 'targetType': 'topo',
12
+ "target": "6",
13
+ "operation": "delete",
14
+ "ciType": "network_link",
15
+ "attributes": {
16
+ "network_link.source_device_ipv4": "172.17.166.18",
17
+ "network_link.destination_ipv4": "1.5.5.5",
18
+ "network_link.work_mode": "AandS",
19
+ "support_templates": "m.ethernet_link",
20
+ "rated_bandwidth": 100,
21
+ "network_link.actual_bandwidth": 100,
22
+ "source_type": "network.interface",
23
+ "network_link.connect_type": "phy",
24
+ "display_name": "172.17.166.18(Fa 0/10) - 1.5.5.5",
25
+ "asset_status": "2",
26
+ "network_link_type": "2",
27
+ "destination_type": "ip",
28
+ "network_link.role": "master",
29
+ "network_link.network_category": "CAN",
30
+ "dcs": "331268969",
31
+ "network_link.source_ipv4": "172.17.166.18",
32
+ "name": "172.17.166.18(Fa 0/10) - 1.5.5.5",
33
+ "distance_outlet": 2147483647,
34
+ "network_link.is_crucial": false,
35
+ "source_id": "00000000010de8b2",
36
+ "network_link.source_device_id": "00000000010de861"
37
+ },
38
+ "sourceCode": null,
39
+ "level": null,
40
+ "customType": null,
41
+ "manageStatus": 3
42
+ }];
43
+ exports.topoLinks = topoLinks;
@@ -3,11 +3,14 @@
3
3
  var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
4
 
5
5
  exports.__esModule = true;
6
+ exports.buildTopoNode = buildTopoNode;
6
7
  exports.processBothTopoData = processBothTopoData;
7
8
  exports.processByConditionTopoData = processByConditionTopoData;
8
9
 
9
10
  var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
10
11
 
12
+ var _relateTopoData = require("./__tests__/relateTopoData");
13
+
11
14
  // 关联拓扑数据
12
15
 
13
16
  /**
@@ -16,10 +19,13 @@ var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends")
16
19
  * 构造子拓扑链路
17
20
  * @param {*} ctx
18
21
  */
19
- function processBothTopoData(ctx) {
20
- var topoData = ctx.topoData;
21
- var serialize = upgradeSerializeRelateTopoNode(topoData.serialize);
22
+ function processBothTopoData(topoData) {
23
+ var nodes = topoData.nodes,
24
+ links = topoData.links;
25
+ var serialize = upgradeSerializeOldTopoNode(topoData.serialize);
22
26
  return (0, _extends2["default"])({}, topoData, {
27
+ nodes: [].concat(nodes, buildTopoNodeDatasFromSerialize(serialize)),
28
+ links: buildTopoLinks(links),
23
29
  serialize: serialize
24
30
  });
25
31
  }
@@ -32,18 +38,85 @@ function processBothTopoData(ctx) {
32
38
 
33
39
  function processByConditionTopoData(ctx) {
34
40
  var topoData = ctx.topoData;
41
+ var nodes = topoData.nodes,
42
+ links = topoData.links;
35
43
  return (0, _extends2["default"])({}, topoData);
36
44
  }
45
+
46
+ function buildTopoNode(topoId) {
47
+ return {
48
+ id: "topo:" + topoId,
49
+ // name: ,
50
+ bindType: "topo",
51
+ // 绑定资源类型。关联资源 值为空,关联IP ip
52
+ bindIp: topoId,
53
+ // TODO 所属区域,从序列化拿
54
+ // 'groupId': null,
55
+ // 'groupTag': null,
56
+ // 'attributes': [],
57
+ // 'metrics': [],
58
+ type: "node",
59
+ isbinding: true,
60
+ // 'dtype': 'device'
61
+ operation: "delete"
62
+ };
63
+ }
64
+
65
+ function buildTopoLinks(links) {
66
+ links.push.apply(links, _relateTopoData.topoLinks);
67
+ return links.map(function (link) {
68
+ return (0, _extends2["default"])({}, link, {
69
+ "source": link.sourceType ? link.sourceType + ':' + link.source : link.source,
70
+ "target": link.targetType ? link.targetType + ':' + link.target : link.target
71
+ });
72
+ });
73
+ }
37
74
  /**
38
75
  * 升级历史数据:子拓扑节点序列化数据
39
76
  * @param {*} serialize
40
77
  */
41
78
 
42
79
 
43
- function upgradeSerializeRelateTopoNode(serialize) {
80
+ function upgradeSerializeOldTopoNode(serialize) {
81
+ if (serialize) {
82
+ var isOldTopoNode = function isOldTopoNode(ele) {
83
+ return isTopoNode(ele) && !ele.p.tag;
84
+ };
85
+
86
+ var oldTopoNodes = serialize.d.filter(isOldTopoNode);
87
+ oldTopoNodes.forEach(function (node) {
88
+ var _node$a;
89
+
90
+ var topoId = (_node$a = node.a) === null || _node$a === void 0 ? void 0 : _node$a.bindTopo;
91
+ node.a = (0, _extends2["default"])({}, node.a, buildTopoNode(topoId));
92
+ node.p.tag = "topo:" + topoId;
93
+ });
94
+ }
95
+
44
96
  return serialize;
45
97
  }
46
98
 
99
+ function isTopoNode(ele) {
100
+ var _ele$a;
101
+
102
+ return !!((_ele$a = ele.a) !== null && _ele$a !== void 0 && _ele$a.bindTopo);
103
+ }
104
+
105
+ function buildTopoNodeDatasFromSerialize(serialize) {
106
+ if (!serialize) {
107
+ return [];
108
+ }
109
+
110
+ var topoNodes = serialize.d.filter(isTopoNode);
111
+ var topoNodeDatas = topoNodes.map(function (node) {
112
+ var _node$a2;
113
+
114
+ var topoId = (_node$a2 = node.a) === null || _node$a2 === void 0 ? void 0 : _node$a2.bindTopo;
115
+ return buildTopoNode(topoId);
116
+ });
117
+ return topoNodeDatas;
118
+ }
119
+
47
120
  function getRelateTopoIdsFromSerialize(serialize) {
48
121
  return serialize;
49
122
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@riil-frontend/component-topology",
3
- "version": "13.0.0-dev.2",
3
+ "version": "13.0.0-dev.4",
4
4
  "description": "拓扑",
5
5
  "scripts": {
6
6
  "start": "build-scripts start",
@@ -123,6 +123,6 @@
123
123
  "access": "public"
124
124
  },
125
125
  "license": "MIT",
126
- "homepage": "https://unpkg.com/@riil-frontend/component-topology@13.0.0-dev.2/build/index.html",
126
+ "homepage": "https://unpkg.com/@riil-frontend/component-topology@13.0.0-dev.4/build/index.html",
127
127
  "gitHead": "2da19ffccbb7ca60a8acf396e39f542c68bb33f5"
128
128
  }