@riil-frontend/component-topology 10.0.27 → 10.0.29

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.
@@ -12,13 +12,13 @@ export default function useHtDataPropertyChangeListener(props) {
12
12
  var dm = topo.getDataModel();
13
13
  var inited = false;
14
14
 
15
- if (graphLoaded || graphLoaded2) {
15
+ if (dm) {
16
16
  dm.addDataPropertyChangeListener(onChange);
17
17
  inited = true;
18
18
  }
19
19
 
20
20
  return function () {
21
- if (inited) {
21
+ if (inited && dm) {
22
22
  dm.removeDataPropertyChangeListener(onChange);
23
23
  }
24
24
  };
@@ -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 "10.0.27" === 'string' ? "10.0.27" : null;
27
+ var version = typeof "10.0.29" === 'string' ? "10.0.29" : null;
28
28
  console.info("\u62D3\u6251\u7248\u672C: " + version);
29
29
  /**
30
30
  * 拓扑显示和编辑
@@ -149,7 +149,7 @@ var ElementTagTipConfig = /*#__PURE__*/function () {
149
149
  var ciType = this.mtCiTypeMap[mtCode];
150
150
  var ciTypeModel = this.topo.ciTyeCache.getCiType(ciType);
151
151
  var metrics = ciTypeModel.metrics.filter(function (m) {
152
- return !!_this2.mtMetricsMap[mtCode][m.code];
152
+ return _this2.mtMetricsMap[mtCode] && !!_this2.mtMetricsMap[mtCode][m.code];
153
153
  });
154
154
  return metrics;
155
155
  };
@@ -23,6 +23,13 @@ export default {
23
23
 
24
24
  };
25
25
  },
26
+ open: function open(prevState, id) {
27
+ return {
28
+ visible: true,
29
+ id: id // 资源id
30
+
31
+ };
32
+ },
26
33
  close: function close() {
27
34
  return {
28
35
  visible: false,
@@ -0,0 +1,12 @@
1
+ /**
2
+ *
3
+ * @param {Array} links
4
+ * @param {Array} ids1
5
+ * @param {Array} ids2
6
+ * @returns
7
+ */
8
+ export function getLinksInNodes(links, ids1, ids2) {
9
+ return links.filter(function (link) {
10
+ return ids1.includes(link.source) && ids2.includes(link.target) || ids2.includes(link.source) && ids1.includes(link.target);
11
+ });
12
+ }
@@ -62,8 +62,9 @@ function useElementDetailManager(props) {
62
62
  }
63
63
 
64
64
  function openByHtElement(htElement) {
65
+ var isEdgeGroupAgent = htElement instanceof ht.Edge && htElement.isEdgeGroupAgent() && !htElement.s('edge.expanded');
65
66
  open({
66
- id: htElement.getTag() || "ht:" + htElement.getId(),
67
+ id: isEdgeGroupAgent || !htElement.getTag() ? "ht:" + htElement.getId() : htElement.getTag(),
67
68
  htElement: htElement
68
69
  });
69
70
  }
@@ -42,10 +42,11 @@ function ResourceDetailDrawer(props) {
42
42
  detailManager: detailManager
43
43
  }),
44
44
  onClose: detailManager.close
45
- }, visible && /*#__PURE__*/React.createElement(Content, _extends({}, props, {
45
+ }, visible && Content && /*#__PURE__*/React.createElement(Content, _extends({}, props, {
46
46
  topo: topo,
47
47
  id: id,
48
48
  htElement: htElement,
49
+ detailManager: detailManager,
49
50
  viewerProps: viewerProps,
50
51
  onClose: detailManager.close
51
52
  })));
@@ -1,10 +1,74 @@
1
- // 获得连线组标注配置的链路id。无配置时取默认链路
2
- export function getEdgeGroupLinkIdConfig(edgeGroup, topo) {
3
- var _links$;
1
+ import { getLinksInNodes } from "../../core/utils/linkUtil";
2
+ /**
3
+ * 查询节点/区域及子节点
4
+ * @param {*} nodes
5
+ * @returns
6
+ */
4
7
 
5
- // const { } = options
8
+ var getChildrenNodes = function getChildrenNodes(nodes) {
9
+ var allNodes = [].concat(nodes);
10
+ nodes.forEach(function (node) {
11
+ if (node instanceof ht.Group) {
12
+ var children = node.getChildren().toArray();
13
+ allNodes.push.apply(allNodes, getChildrenNodes(children));
14
+ }
15
+ });
16
+ return allNodes;
17
+ };
18
+ /**
19
+ * 查询连线两端节点间的链路列表
20
+ * @param {*} topo
21
+ * @param {*} edgeGroup
22
+ * @returns
23
+ */
24
+
25
+
26
+ export function getLinksByEdgeGroup(topo, edgeGroup) {
6
27
  var sourceId = edgeGroup.getSource().getTag();
7
28
  var targetId = edgeGroup.getTarget().getTag();
8
- var links = topo.dataModel.getEdgesBetweenTwoNodes(sourceId, targetId);
9
- return (_links$ = links[0]) === null || _links$ === void 0 ? void 0 : _links$.id;
29
+ var links = getLinksInNodes(topo.dataModel.getEdges(), [sourceId], [targetId]);
30
+ return links;
31
+ } // 获得连线组标注配置的链路id。无配置时取默认链路
32
+
33
+ export function getEdgeGroupLinkIdConfig(edgeGroup, topo) {
34
+ // const { } = options
35
+ var links = getLinksByEdgeGroup(topo, edgeGroup);
36
+
37
+ if (!links.length) {
38
+ return null;
39
+ }
40
+
41
+ return getEdgeGroupLinkConfig({
42
+ htElement: edgeGroup,
43
+ topo: topo,
44
+ links: links
45
+ });
46
+ }
47
+ export function getEdgeGroupConfigId(links) {
48
+ var link = links[0];
49
+ var sourceId = link.attributes['network_link.source_device_id'];
50
+ var targetId = link.attributes.destination_type === 'ip' ? link.attributes['network_link.destination_device_ipv4'] : link.attributes['network_link.destination_device_id'];
51
+ return [sourceId, targetId].sort().join(',');
52
+ }
53
+ /**
54
+ * 默认选中/显示标注为按名称排序第一条
55
+ * @param {*} links
56
+ * @returns
57
+ */
58
+
59
+ function getDefaultLinkId(links) {
60
+ var sortedLinks = links.sort(function (a, b) {
61
+ return a.attributes.display_name.localeCompare(b.attributes.display_name);
62
+ });
63
+ return sortedLinks[0].id;
64
+ }
65
+
66
+ export function getEdgeGroupLinkConfig(_ref) {
67
+ var htElement = _ref.htElement,
68
+ topo = _ref.topo,
69
+ links = _ref.links;
70
+ var displayConfig = topo.store.getModelState('displayConfig');
71
+ var edgeGroupShowLinkTag = displayConfig.edgeGroupShowLinkTag || {};
72
+ var edgeGroupId = getEdgeGroupConfigId(links);
73
+ return edgeGroupShowLinkTag[edgeGroupId] || getDefaultLinkId(links);
10
74
  }
@@ -21,13 +21,13 @@ function useHtDataPropertyChangeListener(props) {
21
21
  var dm = topo.getDataModel();
22
22
  var inited = false;
23
23
 
24
- if (graphLoaded || graphLoaded2) {
24
+ if (dm) {
25
25
  dm.addDataPropertyChangeListener(onChange);
26
26
  inited = true;
27
27
  }
28
28
 
29
29
  return function () {
30
- if (inited) {
30
+ if (inited && dm) {
31
31
  dm.removeDataPropertyChangeListener(onChange);
32
32
  }
33
33
  };
@@ -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 "10.0.27" === 'string' ? "10.0.27" : null;
59
+ var version = typeof "10.0.29" === 'string' ? "10.0.29" : null;
60
60
  console.info("\u62D3\u6251\u7248\u672C: " + version);
61
61
  /**
62
62
  * 拓扑显示和编辑
@@ -162,7 +162,7 @@ var ElementTagTipConfig = /*#__PURE__*/function () {
162
162
  var ciType = this.mtCiTypeMap[mtCode];
163
163
  var ciTypeModel = this.topo.ciTyeCache.getCiType(ciType);
164
164
  var metrics = ciTypeModel.metrics.filter(function (m) {
165
- return !!_this2.mtMetricsMap[mtCode][m.code];
165
+ return _this2.mtMetricsMap[mtCode] && !!_this2.mtMetricsMap[mtCode][m.code];
166
166
  });
167
167
  return metrics;
168
168
  };
@@ -31,6 +31,13 @@ var _default = {
31
31
 
32
32
  };
33
33
  },
34
+ open: function open(prevState, id) {
35
+ return {
36
+ visible: true,
37
+ id: id // 资源id
38
+
39
+ };
40
+ },
34
41
  close: function close() {
35
42
  return {
36
43
  visible: false,
@@ -0,0 +1,17 @@
1
+ "use strict";
2
+
3
+ exports.__esModule = true;
4
+ exports.getLinksInNodes = getLinksInNodes;
5
+
6
+ /**
7
+ *
8
+ * @param {Array} links
9
+ * @param {Array} ids1
10
+ * @param {Array} ids2
11
+ * @returns
12
+ */
13
+ function getLinksInNodes(links, ids1, ids2) {
14
+ return links.filter(function (link) {
15
+ return ids1.includes(link.source) && ids2.includes(link.target) || ids2.includes(link.source) && ids1.includes(link.target);
16
+ });
17
+ }
@@ -74,8 +74,9 @@ function useElementDetailManager(props) {
74
74
  }
75
75
 
76
76
  function openByHtElement(htElement) {
77
+ var isEdgeGroupAgent = htElement instanceof ht.Edge && htElement.isEdgeGroupAgent() && !htElement.s('edge.expanded');
77
78
  open({
78
- id: htElement.getTag() || "ht:" + htElement.getId(),
79
+ id: isEdgeGroupAgent || !htElement.getTag() ? "ht:" + htElement.getId() : htElement.getTag(),
79
80
  htElement: htElement
80
81
  });
81
82
  }
@@ -58,10 +58,11 @@ function ResourceDetailDrawer(props) {
58
58
  detailManager: detailManager
59
59
  }),
60
60
  onClose: detailManager.close
61
- }, visible && /*#__PURE__*/_react["default"].createElement(Content, (0, _extends2["default"])({}, props, {
61
+ }, visible && Content && /*#__PURE__*/_react["default"].createElement(Content, (0, _extends2["default"])({}, props, {
62
62
  topo: topo,
63
63
  id: id,
64
64
  htElement: htElement,
65
+ detailManager: detailManager,
65
66
  viewerProps: viewerProps,
66
67
  onClose: detailManager.close
67
68
  })));
@@ -1,15 +1,85 @@
1
1
  "use strict";
2
2
 
3
3
  exports.__esModule = true;
4
+ exports.getEdgeGroupConfigId = getEdgeGroupConfigId;
5
+ exports.getEdgeGroupLinkConfig = getEdgeGroupLinkConfig;
4
6
  exports.getEdgeGroupLinkIdConfig = getEdgeGroupLinkIdConfig;
7
+ exports.getLinksByEdgeGroup = getLinksByEdgeGroup;
5
8
 
6
- // 获得连线组标注配置的链路id。无配置时取默认链路
7
- function getEdgeGroupLinkIdConfig(edgeGroup, topo) {
8
- var _links$;
9
+ var _linkUtil = require("../../core/utils/linkUtil");
9
10
 
10
- // const { } = options
11
+ /**
12
+ * 查询节点/区域及子节点
13
+ * @param {*} nodes
14
+ * @returns
15
+ */
16
+ var getChildrenNodes = function getChildrenNodes(nodes) {
17
+ var allNodes = [].concat(nodes);
18
+ nodes.forEach(function (node) {
19
+ if (node instanceof ht.Group) {
20
+ var children = node.getChildren().toArray();
21
+ allNodes.push.apply(allNodes, getChildrenNodes(children));
22
+ }
23
+ });
24
+ return allNodes;
25
+ };
26
+ /**
27
+ * 查询连线两端节点间的链路列表
28
+ * @param {*} topo
29
+ * @param {*} edgeGroup
30
+ * @returns
31
+ */
32
+
33
+
34
+ function getLinksByEdgeGroup(topo, edgeGroup) {
11
35
  var sourceId = edgeGroup.getSource().getTag();
12
36
  var targetId = edgeGroup.getTarget().getTag();
13
- var links = topo.dataModel.getEdgesBetweenTwoNodes(sourceId, targetId);
14
- return (_links$ = links[0]) === null || _links$ === void 0 ? void 0 : _links$.id;
37
+ var links = (0, _linkUtil.getLinksInNodes)(topo.dataModel.getEdges(), [sourceId], [targetId]);
38
+ return links;
39
+ } // 获得连线组标注配置的链路id。无配置时取默认链路
40
+
41
+
42
+ function getEdgeGroupLinkIdConfig(edgeGroup, topo) {
43
+ // const { } = options
44
+ var links = getLinksByEdgeGroup(topo, edgeGroup);
45
+
46
+ if (!links.length) {
47
+ return null;
48
+ }
49
+
50
+ return getEdgeGroupLinkConfig({
51
+ htElement: edgeGroup,
52
+ topo: topo,
53
+ links: links
54
+ });
55
+ }
56
+
57
+ function getEdgeGroupConfigId(links) {
58
+ var link = links[0];
59
+ var sourceId = link.attributes['network_link.source_device_id'];
60
+ var targetId = link.attributes.destination_type === 'ip' ? link.attributes['network_link.destination_device_ipv4'] : link.attributes['network_link.destination_device_id'];
61
+ return [sourceId, targetId].sort().join(',');
62
+ }
63
+ /**
64
+ * 默认选中/显示标注为按名称排序第一条
65
+ * @param {*} links
66
+ * @returns
67
+ */
68
+
69
+
70
+ function getDefaultLinkId(links) {
71
+ var sortedLinks = links.sort(function (a, b) {
72
+ return a.attributes.display_name.localeCompare(b.attributes.display_name);
73
+ });
74
+ return sortedLinks[0].id;
75
+ }
76
+
77
+ function getEdgeGroupLinkConfig(_ref) {
78
+ var htElement = _ref.htElement,
79
+ topo = _ref.topo,
80
+ links = _ref.links;
81
+ var displayConfig = topo.store.getModelState('displayConfig');
82
+ var edgeGroupShowLinkTag = displayConfig.edgeGroupShowLinkTag || {};
83
+ var edgeGroupId = getEdgeGroupConfigId(links);
84
+ return edgeGroupShowLinkTag[edgeGroupId] || getDefaultLinkId(links);
15
85
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@riil-frontend/component-topology",
3
- "version": "10.0.27",
3
+ "version": "10.0.29",
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@10.0.27/build/index.html",
119
+ "homepage": "https://unpkg.com/@riil-frontend/component-topology@10.0.29/build/index.html",
120
120
  "gitHead": "2da19ffccbb7ca60a8acf396e39f542c68bb33f5"
121
121
  }