@riil-frontend/component-topology 8.0.2 → 8.0.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.
@@ -76,16 +76,21 @@ function getValuesByEdges(topo) {
76
76
  })[0] || 'nil';
77
77
  }
78
78
 
79
- var selectionEdges = getEdgesBySelection(topo);
80
- var edgeValues = [];
81
- loopEdgesAndChildren(topo, selectionEdges, function (edge) {
82
- edgeValues.push({
83
- lineButton: edge.s('edge.type'),
84
- startPoint: getStartPoint(edge),
85
- endPoint: getEndPoint(edge),
86
- lineMold: edge.a('lineMode') || 'solidLine'
79
+ function getEdgesValues(edges) {
80
+ var edgeValues = [];
81
+ edges.forEach(function (edge) {
82
+ edgeValues.push({
83
+ lineButton: edge.s('edge.type'),
84
+ startPoint: getStartPoint(edge),
85
+ endPoint: getEndPoint(edge),
86
+ lineMold: edge.a('lineMode') || 'solidLine'
87
+ });
87
88
  });
88
- });
89
+ return edgeValues;
90
+ }
91
+
92
+ var selectionEdges = getEdgesBySelection(topo);
93
+ var edgeValues = getEdgesValues(selectionEdges);
89
94
  var values = {
90
95
  lineButton: undefined,
91
96
  startPoint: undefined,
@@ -23,7 +23,7 @@ import topoFactory from "./topoFactory";
23
23
  import ElementTagTipConfig from "./tagstips/ElementTagTipConfig";
24
24
  import SelectionModel from "./SelectionModel"; // eslint-disable-next-line no-undef
25
25
 
26
- var version = typeof "8.0.2" === 'string' ? "8.0.2" : null;
26
+ var version = typeof "8.0.4" === 'string' ? "8.0.4" : null;
27
27
  console.info("\u62D3\u6251\u7248\u672C: " + version);
28
28
  /**
29
29
  * 拓扑显示和编辑
@@ -1,6 +1,6 @@
1
1
  import { getEdges } from "../../utils/htElementUtils";
2
2
  /**
3
- * 链路另一端变更后更新另一端,另一端不存在删除线
3
+ * 连线两端节点变更时更新显示。如果两端互相切换,切换两端样式
4
4
  * @param {*} topo
5
5
  */
6
6
 
@@ -10,13 +10,22 @@ export function fixLink(topo) {
10
10
  var edges = getEdges(dm);
11
11
  edges.forEach(function (edge) {
12
12
  var source = edge.getSource();
13
+ var target = edge.getTarget();
13
14
  var linkData = linkDatas.find(function (data) {
14
15
  return data.id === edge.getTag();
15
- });
16
+ }); // TODO 判断两端互相切换
17
+ // const isChange =
16
18
 
17
19
  if (linkData && source.getTag() !== linkData.source) {
18
20
  var node = dm.getDataByTag(linkData.source);
19
21
  edge.setSource(node);
20
22
  }
23
+
24
+ if (linkData && linkData.target && target.getTag() !== linkData.target) {
25
+ var _node = dm.getDataByTag(linkData.target);
26
+
27
+ edge.setTarget(_node);
28
+ } // TODO 两端互相切换,交换两端样式
29
+
21
30
  });
22
31
  }
@@ -16,12 +16,14 @@ export default function useLinkDynamicStyle(props) {
16
16
  var topoModState = topo.store.useModelState('topoMod');
17
17
  var graphLoaded = topoModState.graphLoaded,
18
18
  topoData = topoModState.data;
19
+ var displayConfig = topo.store.useModelState('displayConfig');
20
+ var autoChangeEdgeWidth = displayConfig.autoChangeEdgeWidth !== false;
19
21
  useEffect(function () {
20
22
  // 拓扑图加载完成时刷新
21
23
  if (graphLoaded && topoData) {
22
24
  topo.linkDynamicStyleExecutor.execute();
23
25
  }
24
- }, [topoData, graphLoaded]);
26
+ }, [topoData, graphLoaded, autoChangeEdgeWidth]);
25
27
 
26
28
  var onLoaded = function onLoaded() {};
27
29
 
@@ -165,6 +165,13 @@ var LinkDynamicStyleExecutor = /*#__PURE__*/function () {
165
165
  ;
166
166
 
167
167
  _proto.calcEdgeGroupEdgeWidth = function calcEdgeGroupEdgeWidth(links) {
168
+ var displayConfig = this.topo.store.getModelState('displayConfig');
169
+ var autoChangeEdgeWidth = displayConfig.autoChangeEdgeWidth !== false;
170
+
171
+ if (!autoChangeEdgeWidth) {
172
+ return 2;
173
+ }
174
+
168
175
  if (!links.length) {
169
176
  return 2;
170
177
  }
@@ -181,6 +188,13 @@ var LinkDynamicStyleExecutor = /*#__PURE__*/function () {
181
188
  };
182
189
 
183
190
  _proto.calcLinkEdgeWidth = function calcLinkEdgeWidth(link) {
191
+ var displayConfig = this.topo.store.getModelState('displayConfig');
192
+ var autoChangeEdgeWidth = displayConfig.autoChangeEdgeWidth !== false;
193
+
194
+ if (!autoChangeEdgeWidth) {
195
+ return 2;
196
+ }
197
+
184
198
  return this.calcEdgeWidth(link.attributes['network_link.actual_bandwidth']);
185
199
  } // network_link.actual_bandwidth
186
200
  ;
@@ -94,16 +94,21 @@ function getValuesByEdges(topo) {
94
94
  })[0] || 'nil';
95
95
  }
96
96
 
97
- var selectionEdges = (0, _edgeTypeStyleUtil.getEdgesBySelection)(topo);
98
- var edgeValues = [];
99
- (0, _edgeTypeStyleUtil.loopEdgesAndChildren)(topo, selectionEdges, function (edge) {
100
- edgeValues.push({
101
- lineButton: edge.s('edge.type'),
102
- startPoint: getStartPoint(edge),
103
- endPoint: getEndPoint(edge),
104
- lineMold: edge.a('lineMode') || 'solidLine'
97
+ function getEdgesValues(edges) {
98
+ var edgeValues = [];
99
+ edges.forEach(function (edge) {
100
+ edgeValues.push({
101
+ lineButton: edge.s('edge.type'),
102
+ startPoint: getStartPoint(edge),
103
+ endPoint: getEndPoint(edge),
104
+ lineMold: edge.a('lineMode') || 'solidLine'
105
+ });
105
106
  });
106
- });
107
+ return edgeValues;
108
+ }
109
+
110
+ var selectionEdges = (0, _edgeTypeStyleUtil.getEdgesBySelection)(topo);
111
+ var edgeValues = getEdgesValues(selectionEdges);
107
112
  var values = {
108
113
  lineButton: undefined,
109
114
  startPoint: undefined,
@@ -54,7 +54,7 @@ var _ElementTagTipConfig = _interopRequireDefault(require("./tagstips/ElementTag
54
54
  var _SelectionModel = _interopRequireDefault(require("./SelectionModel"));
55
55
 
56
56
  // eslint-disable-next-line no-undef
57
- var version = typeof "8.0.2" === 'string' ? "8.0.2" : null;
57
+ var version = typeof "8.0.4" === 'string' ? "8.0.4" : null;
58
58
  console.info("\u62D3\u6251\u7248\u672C: " + version);
59
59
  /**
60
60
  * 拓扑显示和编辑
@@ -6,7 +6,7 @@ exports.fixLink = fixLink;
6
6
  var _htElementUtils = require("../../utils/htElementUtils");
7
7
 
8
8
  /**
9
- * 链路另一端变更后更新另一端,另一端不存在删除线
9
+ * 连线两端节点变更时更新显示。如果两端互相切换,切换两端样式
10
10
  * @param {*} topo
11
11
  */
12
12
  function fixLink(topo) {
@@ -15,13 +15,22 @@ function fixLink(topo) {
15
15
  var edges = (0, _htElementUtils.getEdges)(dm);
16
16
  edges.forEach(function (edge) {
17
17
  var source = edge.getSource();
18
+ var target = edge.getTarget();
18
19
  var linkData = linkDatas.find(function (data) {
19
20
  return data.id === edge.getTag();
20
- });
21
+ }); // TODO 判断两端互相切换
22
+ // const isChange =
21
23
 
22
24
  if (linkData && source.getTag() !== linkData.source) {
23
25
  var node = dm.getDataByTag(linkData.source);
24
26
  edge.setSource(node);
25
27
  }
28
+
29
+ if (linkData && linkData.target && target.getTag() !== linkData.target) {
30
+ var _node = dm.getDataByTag(linkData.target);
31
+
32
+ edge.setTarget(_node);
33
+ } // TODO 两端互相切换,交换两端样式
34
+
26
35
  });
27
36
  }
@@ -24,12 +24,14 @@ function useLinkDynamicStyle(props) {
24
24
  var topoModState = topo.store.useModelState('topoMod');
25
25
  var graphLoaded = topoModState.graphLoaded,
26
26
  topoData = topoModState.data;
27
+ var displayConfig = topo.store.useModelState('displayConfig');
28
+ var autoChangeEdgeWidth = displayConfig.autoChangeEdgeWidth !== false;
27
29
  (0, _react.useEffect)(function () {
28
30
  // 拓扑图加载完成时刷新
29
31
  if (graphLoaded && topoData) {
30
32
  topo.linkDynamicStyleExecutor.execute();
31
33
  }
32
- }, [topoData, graphLoaded]);
34
+ }, [topoData, graphLoaded, autoChangeEdgeWidth]);
33
35
 
34
36
  var onLoaded = function onLoaded() {};
35
37
 
@@ -176,6 +176,13 @@ var LinkDynamicStyleExecutor = /*#__PURE__*/function () {
176
176
  ;
177
177
 
178
178
  _proto.calcEdgeGroupEdgeWidth = function calcEdgeGroupEdgeWidth(links) {
179
+ var displayConfig = this.topo.store.getModelState('displayConfig');
180
+ var autoChangeEdgeWidth = displayConfig.autoChangeEdgeWidth !== false;
181
+
182
+ if (!autoChangeEdgeWidth) {
183
+ return 2;
184
+ }
185
+
179
186
  if (!links.length) {
180
187
  return 2;
181
188
  }
@@ -192,6 +199,13 @@ var LinkDynamicStyleExecutor = /*#__PURE__*/function () {
192
199
  };
193
200
 
194
201
  _proto.calcLinkEdgeWidth = function calcLinkEdgeWidth(link) {
202
+ var displayConfig = this.topo.store.getModelState('displayConfig');
203
+ var autoChangeEdgeWidth = displayConfig.autoChangeEdgeWidth !== false;
204
+
205
+ if (!autoChangeEdgeWidth) {
206
+ return 2;
207
+ }
208
+
195
209
  return this.calcEdgeWidth(link.attributes['network_link.actual_bandwidth']);
196
210
  } // network_link.actual_bandwidth
197
211
  ;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@riil-frontend/component-topology",
3
- "version": "8.0.2",
3
+ "version": "8.0.4",
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@8.0.2/build/index.html",
119
+ "homepage": "https://unpkg.com/@riil-frontend/component-topology@8.0.4/build/index.html",
120
120
  "gitHead": "2da19ffccbb7ca60a8acf396e39f542c68bb33f5"
121
121
  }