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

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.
@@ -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.3" === 'string' ? "13.0.0-dev.3" : 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
@@ -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
  }
@@ -7,10 +7,12 @@ import _extends from "@babel/runtime/helpers/extends";
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
+ export function processBothTopoData(topoData) {
11
+ var nodes = topoData.nodes,
12
+ links = topoData.links;
13
+ var serialize = upgradeSerializeOldTopoNode(topoData.serialize);
13
14
  return _extends({}, topoData, {
15
+ nodes: [].concat(nodes, buildTopoNodeDatasFromSerialize(serialize)),
14
16
  serialize: serialize
15
17
  });
16
18
  }
@@ -22,17 +24,73 @@ export function processBothTopoData(ctx) {
22
24
 
23
25
  export function processByConditionTopoData(ctx) {
24
26
  var topoData = ctx.topoData;
27
+ var nodes = topoData.nodes,
28
+ links = topoData.links;
25
29
  return _extends({}, topoData);
26
30
  }
31
+ export function buildTopoNode(topoId) {
32
+ return {
33
+ id: "topo:" + topoId,
34
+ // name: ,
35
+ bindType: "topo",
36
+ // 绑定资源类型。关联资源 值为空,关联IP ip
37
+ bindIp: topoId,
38
+ // TODO 所属区域,从序列化拿
39
+ // 'groupId': null,
40
+ // 'groupTag': null,
41
+ // 'attributes': [],
42
+ // 'metrics': [],
43
+ type: "node",
44
+ isbinding: true,
45
+ // 'dtype': 'device'
46
+ operation: "delete"
47
+ };
48
+ }
27
49
  /**
28
50
  * 升级历史数据:子拓扑节点序列化数据
29
51
  * @param {*} serialize
30
52
  */
31
53
 
32
- function upgradeSerializeRelateTopoNode(serialize) {
54
+ function upgradeSerializeOldTopoNode(serialize) {
55
+ if (serialize) {
56
+ var isOldTopoNode = function isOldTopoNode(ele) {
57
+ return isTopoNode(ele) && !ele.p.tag;
58
+ };
59
+
60
+ var oldTopoNodes = serialize.d.filter(isOldTopoNode);
61
+ oldTopoNodes.forEach(function (node) {
62
+ var _node$a;
63
+
64
+ var topoId = (_node$a = node.a) === null || _node$a === void 0 ? void 0 : _node$a.bindTopo;
65
+ node.a = _extends({}, node.a, buildTopoNode(topoId));
66
+ node.p.tag = "topo:" + topoId;
67
+ });
68
+ }
69
+
33
70
  return serialize;
34
71
  }
35
72
 
73
+ function isTopoNode(ele) {
74
+ var _ele$a;
75
+
76
+ return !!((_ele$a = ele.a) !== null && _ele$a !== void 0 && _ele$a.bindTopo);
77
+ }
78
+
79
+ function buildTopoNodeDatasFromSerialize(serialize) {
80
+ if (!serialize) {
81
+ return [];
82
+ }
83
+
84
+ var topoNodes = serialize.d.filter(isTopoNode);
85
+ var topoNodeDatas = topoNodes.map(function (node) {
86
+ var _node$a2;
87
+
88
+ var topoId = (_node$a2 = node.a) === null || _node$a2 === void 0 ? void 0 : _node$a2.bindTopo;
89
+ return buildTopoNode(topoId);
90
+ });
91
+ return topoNodeDatas;
92
+ }
93
+
36
94
  function getRelateTopoIdsFromSerialize(serialize) {
37
95
  return serialize;
38
96
  }
@@ -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.3" === 'string' ? "13.0.0-dev.3" : 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
@@ -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
  }
@@ -3,6 +3,7 @@
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
 
@@ -16,10 +17,12 @@ var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends")
16
17
  * 构造子拓扑链路
17
18
  * @param {*} ctx
18
19
  */
19
- function processBothTopoData(ctx) {
20
- var topoData = ctx.topoData;
21
- var serialize = upgradeSerializeRelateTopoNode(topoData.serialize);
20
+ function processBothTopoData(topoData) {
21
+ var nodes = topoData.nodes,
22
+ links = topoData.links;
23
+ var serialize = upgradeSerializeOldTopoNode(topoData.serialize);
22
24
  return (0, _extends2["default"])({}, topoData, {
25
+ nodes: [].concat(nodes, buildTopoNodeDatasFromSerialize(serialize)),
23
26
  serialize: serialize
24
27
  });
25
28
  }
@@ -32,18 +35,75 @@ function processBothTopoData(ctx) {
32
35
 
33
36
  function processByConditionTopoData(ctx) {
34
37
  var topoData = ctx.topoData;
38
+ var nodes = topoData.nodes,
39
+ links = topoData.links;
35
40
  return (0, _extends2["default"])({}, topoData);
36
41
  }
42
+
43
+ function buildTopoNode(topoId) {
44
+ return {
45
+ id: "topo:" + topoId,
46
+ // name: ,
47
+ bindType: "topo",
48
+ // 绑定资源类型。关联资源 值为空,关联IP ip
49
+ bindIp: topoId,
50
+ // TODO 所属区域,从序列化拿
51
+ // 'groupId': null,
52
+ // 'groupTag': null,
53
+ // 'attributes': [],
54
+ // 'metrics': [],
55
+ type: "node",
56
+ isbinding: true,
57
+ // 'dtype': 'device'
58
+ operation: "delete"
59
+ };
60
+ }
37
61
  /**
38
62
  * 升级历史数据:子拓扑节点序列化数据
39
63
  * @param {*} serialize
40
64
  */
41
65
 
42
66
 
43
- function upgradeSerializeRelateTopoNode(serialize) {
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 = (0, _extends2["default"])({}, node.a, buildTopoNode(topoId));
79
+ node.p.tag = "topo:" + topoId;
80
+ });
81
+ }
82
+
44
83
  return serialize;
45
84
  }
46
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
+
47
107
  function getRelateTopoIdsFromSerialize(serialize) {
48
108
  return serialize;
49
109
  }
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.3",
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.3/build/index.html",
127
127
  "gitHead": "2da19ffccbb7ca60a8acf396e39f542c68bb33f5"
128
128
  }