@riil-frontend/component-topology 13.0.0-dev.1 → 13.0.0-dev.10

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.
Files changed (92) hide show
  1. package/build/1.js +1 -1
  2. package/build/index.css +1 -1
  3. package/build/index.js +29 -29
  4. package/es/components/ColorPanel/index.js +68 -58
  5. package/es/components/ResourceSelectDrawer/ResourceSelectDrawer.js +1 -1
  6. package/es/core/components/TopoView/topoView.js +7 -4
  7. package/es/core/editor/components/Toolbar/widgets/EdgeColorButton/EdgeColorButton.js +2 -2
  8. package/es/core/editor/components/Toolbar/widgets/EdgeTypeButton/LineType.js +5 -15
  9. package/es/core/editor/components/Toolbar/widgets/FontColorButton.js +10 -91
  10. package/es/core/editor/components/Toolbar/widgets/FontFamilyWidget.js +2 -27
  11. package/es/core/editor/components/Toolbar/widgets/FontSizeWidget.js +3 -28
  12. package/es/core/editor/components/Toolbar/widgets/FontStyleButton.js +6 -52
  13. package/es/core/editor/components/Toolbar/widgets/components/FontColorDropdown.js +120 -0
  14. package/es/core/editor/components/Toolbar/widgets/components/FontFamilySelect.js +29 -0
  15. package/es/core/editor/components/Toolbar/widgets/components/FontSizeSelect.js +29 -0
  16. package/es/core/editor/components/Toolbar/widgets/components/FontStyleSelect.js +77 -0
  17. package/es/core/editor/components/settings/core/updateElementProperty.js +3 -2
  18. package/es/core/editor/components/settings/propertyViews/view/GlobalEdgeToggle.js +2 -2
  19. package/es/core/editor/hooks/useKeyboardShortcut.js +4 -0
  20. package/es/core/editor/hooks/useNewElementTheme.js +20 -16
  21. package/es/core/editor/utils/edgeTypeStyleUtil.js +11 -32
  22. package/es/core/hooks/useGraphAlarmDisplay.js +4 -0
  23. package/es/core/hooks/usePolling.js +2 -1
  24. package/es/core/hooks/useResourceConfig.js +1 -2
  25. package/es/core/hooks/useTopoEdit.js +210 -248
  26. package/es/core/models/AttributeMetricDisplay.js +4 -3
  27. package/es/core/models/HistoryManager.js +11 -9
  28. package/es/core/models/TopoApp.js +39 -45
  29. package/es/core/models/topoData.js +9 -17
  30. package/es/core/models/utils/linkUtils.js +65 -52
  31. package/es/core/store/models/topoConfig.js +7 -11
  32. package/es/core/utils/edgeUtil.js +7 -10
  33. package/es/core/viewer/components/plugins/ElementDetailDrawer/hooks/useElementDetailManager.js +2 -2
  34. package/es/core/viewer/components/plugins/ResourceDetail/components/ResourceOverview/EventsCard.js +4 -2
  35. package/es/networkTopo/models/EdgeGroupTagTipBuilder.js +7 -7
  36. package/es/networkTopo/models/LinkDynamicStyleExecutor.js +7 -63
  37. package/es/networkTopo/services/topo/basic.js +27 -17
  38. package/es/networkTopo/utils/__tests__/relateTopoData.js +205 -0
  39. package/es/networkTopo/utils/edgeGroupTagUtil.js +2 -2
  40. package/es/networkTopo/utils/exitLinkUtil.js +25 -13
  41. package/es/networkTopo/utils/relateTopoDataUtil.js +149 -0
  42. package/es/style.js +1 -1
  43. package/es/utils/ResourceConfigUtil.js +1 -16
  44. package/es/utils/clusterUtil.js +3 -3
  45. package/es/utils/htElementUtils.js +19 -85
  46. package/lib/components/ColorPanel/index.js +71 -59
  47. package/lib/components/ResourceSelectDrawer/ResourceSelectDrawer.js +1 -1
  48. package/lib/core/components/TopoView/topoView.js +15 -19
  49. package/lib/core/editor/components/Toolbar/widgets/EdgeColorButton/EdgeColorButton.js +2 -2
  50. package/lib/core/editor/components/Toolbar/widgets/EdgeTypeButton/LineType.js +5 -14
  51. package/lib/core/editor/components/Toolbar/widgets/FontColorButton.js +11 -95
  52. package/lib/core/editor/components/Toolbar/widgets/FontFamilyWidget.js +3 -28
  53. package/lib/core/editor/components/Toolbar/widgets/FontSizeWidget.js +3 -28
  54. package/lib/core/editor/components/Toolbar/widgets/FontStyleButton.js +6 -56
  55. package/lib/core/editor/components/Toolbar/widgets/components/FontColorDropdown.js +136 -0
  56. package/lib/core/editor/components/Toolbar/widgets/components/FontFamilySelect.js +38 -0
  57. package/lib/core/editor/components/Toolbar/widgets/components/FontSizeSelect.js +38 -0
  58. package/lib/core/editor/components/Toolbar/widgets/components/FontStyleSelect.js +89 -0
  59. package/lib/core/editor/components/settings/core/updateElementProperty.js +7 -2
  60. package/lib/core/editor/components/settings/propertyViews/view/GlobalEdgeToggle.js +2 -2
  61. package/lib/core/editor/hooks/useKeyboardShortcut.js +4 -0
  62. package/lib/core/editor/hooks/useNewElementTheme.js +20 -16
  63. package/lib/core/editor/utils/edgeTypeStyleUtil.js +10 -33
  64. package/lib/core/hooks/useGraphAlarmDisplay.js +4 -0
  65. package/lib/core/hooks/usePolling.js +6 -5
  66. package/lib/core/hooks/useResourceConfig.js +1 -2
  67. package/lib/core/hooks/useTopoEdit.js +216 -272
  68. package/lib/core/models/AttributeMetricDisplay.js +6 -6
  69. package/lib/core/models/HistoryManager.js +13 -17
  70. package/lib/core/models/TopoApp.js +39 -43
  71. package/lib/core/models/topoData.js +9 -17
  72. package/lib/core/models/utils/linkUtils.js +65 -51
  73. package/lib/core/store/models/topoConfig.js +13 -25
  74. package/lib/core/utils/edgeUtil.js +8 -10
  75. package/lib/core/viewer/components/plugins/ElementDetailDrawer/hooks/useElementDetailManager.js +3 -2
  76. package/lib/core/viewer/components/plugins/ResourceDetail/components/ResourceOverview/EventsCard.js +6 -2
  77. package/lib/networkTopo/models/EdgeGroupTagTipBuilder.js +6 -6
  78. package/lib/networkTopo/models/LinkDynamicStyleExecutor.js +6 -64
  79. package/lib/networkTopo/services/topo/basic.js +32 -18
  80. package/lib/networkTopo/utils/__tests__/relateTopoData.js +210 -0
  81. package/lib/networkTopo/utils/edgeGroupTagUtil.js +2 -2
  82. package/lib/networkTopo/utils/exitLinkUtil.js +25 -13
  83. package/lib/networkTopo/utils/relateTopoDataUtil.js +164 -0
  84. package/lib/style.js +1 -1
  85. package/lib/utils/ResourceConfigUtil.js +1 -16
  86. package/lib/utils/clusterUtil.js +2 -2
  87. package/lib/utils/htElementUtils.js +22 -94
  88. package/package.json +2 -2
  89. package/es/networkTopo/models/LinkTagsTipsBuilder.js +0 -235
  90. package/lib/networkTopo/models/LinkTagsTipsBuilder.js +0 -245
  91. /package/es/core/editor/components/Toolbar/widgets/{FontColorButton.module.scss → components/FontColorDropdown.module.scss} +0 -0
  92. /package/lib/core/editor/components/Toolbar/widgets/{FontColorButton.module.scss → components/FontColorDropdown.module.scss} +0 -0
@@ -0,0 +1,210 @@
1
+ "use strict";
2
+
3
+ exports.__esModule = true;
4
+ exports.topoLinks = void 0;
5
+ // 二、子拓扑链路
6
+ // - 资源-子拓扑资源
7
+ // - 资源-子拓扑IP、Ping资源
8
+ // - 子拓扑资源-IP、Ping资源
9
+ // - 子拓扑资源-子拓扑资源
10
+ // - 子拓扑资源-子拓扑IP、Ping资源
11
+ var topoLinks = [// 资源-子拓扑资源
12
+ {
13
+ ciType: 'network_link',
14
+ "id": "00000000010decab",
15
+ "name": '资源、Ping资源-子拓扑资源',
16
+ "source": "00000000010de861",
17
+ 'targetType': 'topo',
18
+ "target": "6",
19
+ "operation": "delete",
20
+ "interfaceSource": "00000000010de8da",
21
+ "interfaceTarget": "00000000010de973",
22
+ "attributes": {
23
+ "network_link.to_if_connect": "r926054146526674944",
24
+ "network_link.source_device_ipv4": "172.17.166.18",
25
+ "network_link.destination_ipv4": "172.17.166.20",
26
+ "network_link.work_mode": "single",
27
+ "support_templates": "m.ethernet_link",
28
+ "destination_id": "00000000010de973",
29
+ "rated_bandwidth": 1000,
30
+ "network_link.actual_bandwidth": 1000,
31
+ "source_type": "network.interface",
32
+ "network_link.connect_type": "phy",
33
+ "display_name": "资源-子拓扑资源",
34
+ "asset_status": "2",
35
+ "destination_type": "network.interface",
36
+ "network_link.network_category": "CAN",
37
+ "network_link.source_ipv4": "172.17.166.18",
38
+ "name": "资源-子拓扑资源",
39
+ "distance_outlet": 2147483647,
40
+ "network_link.is_crucial": false,
41
+ "source_id": "00000000010de8da",
42
+ "network_link.source_device_id": "00000000010de861",
43
+ "network_link.destination_device_id": "00000000010de864",
44
+ "network_link.destination_device_ipv4": "172.17.166.20"
45
+ },
46
+ "sourceCode": null,
47
+ "level": null,
48
+ "customType": null,
49
+ "manageStatus": 3
50
+ }, // 资源-子拓扑IP、Ping资源
51
+ {
52
+ ciType: 'network_link',
53
+ "id": "00000000019990f1",
54
+ "name": "资源-子拓扑IP",
55
+ "source": "00000000010de861",
56
+ 'targetType': 'topo',
57
+ "target": "6",
58
+ "operation": "delete",
59
+ "interfaceSource": "00000000010de8b3",
60
+ "interfaceTarget": "",
61
+ "attributes": {
62
+ "network_link.source_device_ipv4": "172.17.166.18",
63
+ "network_link.destination_ipv4": "1.1.1.1",
64
+ "network_link.work_mode": "AandS",
65
+ "support_templates": "m.ethernet_link",
66
+ "rated_bandwidth": 100,
67
+ "network_link.actual_bandwidth": 100,
68
+ "source_type": "network.interface",
69
+ "network_link.connect_type": "phy",
70
+ "display_name": "资源-子拓扑IP",
71
+ "asset_status": "2",
72
+ "network_link_type": "2",
73
+ "destination_type": "ip",
74
+ "network_link.role": "master",
75
+ "network_link.network_category": "CAN",
76
+ "dcs": "331268969",
77
+ "network_link.source_ipv4": "172.17.166.18",
78
+ "name": "资源-子拓扑IP",
79
+ "distance_outlet": 2147483647,
80
+ "network_link.is_crucial": false,
81
+ "source_id": "00000000010de8b3",
82
+ "network_link.source_device_id": "00000000010de861",
83
+ "network_link.destination_device_ipv4": "1.1.1.1"
84
+ },
85
+ "sourceCode": null,
86
+ "level": null,
87
+ "customType": null,
88
+ "manageStatus": 3
89
+ }, // 子拓扑资源-IP、Ping资源
90
+ {
91
+ ciType: 'network_link',
92
+ "id": "0000000001999538",
93
+ "name": "IP-子拓扑资源",
94
+ 'sourceType': 'topo',
95
+ "source": "6",
96
+ "target": "",
97
+ "operation": "delete",
98
+ "interfaceSource": "00000000010de95e",
99
+ "interfaceTarget": "",
100
+ "attributes": {
101
+ "network_link.source_device_ipv4": "172.17.166.20",
102
+ "network_link.destination_ipv4": "1.5.5.5",
103
+ "network_link.work_mode": "AandS",
104
+ "support_templates": "m.ethernet_link",
105
+ "rated_bandwidth": 1000,
106
+ "network_link.actual_bandwidth": 1000,
107
+ "source_type": "network.interface",
108
+ "network_link.connect_type": "phy",
109
+ "display_name": "IP-子拓扑资源",
110
+ "asset_status": "2",
111
+ "network_link_type": "2",
112
+ "destination_type": "ip",
113
+ "network_link.role": "master",
114
+ "network_link.network_category": "CAN",
115
+ "dcs": "331268969",
116
+ "network_link.source_ipv4": "172.17.166.20",
117
+ "name": "172.17.166.20(Gi 0/1) - 1.5.5.5",
118
+ "distance_outlet": 2147483647,
119
+ "network_link.is_crucial": false,
120
+ "source_id": "00000000010de95e",
121
+ "network_link.source_device_id": "00000000010de864",
122
+ "network_link.destination_device_ipv4": "1.5.5.5"
123
+ },
124
+ "sourceCode": null,
125
+ "level": null,
126
+ "customType": null,
127
+ "manageStatus": 3
128
+ }, // 子拓扑资源-子拓扑资源
129
+ {
130
+ ciType: 'network_link',
131
+ "id": "0000000001899476",
132
+ "name": '子拓扑资源-子拓扑资源',
133
+ 'sourceType': 'topo',
134
+ "source": "3",
135
+ 'targetType': 'topo',
136
+ "target": "6",
137
+ "operation": "delete",
138
+ "interfaceSource": "00000000010de90e",
139
+ "interfaceTarget": "00000000010de973",
140
+ "attributes": {
141
+ "network_link.to_if_connect": "r933757920628178944",
142
+ "network_link.source_device_ipv4": "172.17.166.19",
143
+ "network_link.destination_ipv4": "172.17.166.20",
144
+ "network_link.work_mode": "single",
145
+ "support_templates": "m.ethernet_link",
146
+ "destination_id": "00000000010de973",
147
+ "rated_bandwidth": 1000,
148
+ "network_link.actual_bandwidth": 1000,
149
+ "source_type": "network.interface",
150
+ "network_link.connect_type": "phy",
151
+ "display_name": "子拓扑资源-子拓扑资源",
152
+ "asset_status": "2",
153
+ "network_link_type": "2",
154
+ "destination_type": "network.interface",
155
+ "network_link.network_category": "CAN",
156
+ "network_link.source_ipv4": "172.17.166.19",
157
+ "name": "172.17.166.19(Gi 0/50) - 172.17.166.20(Gi 0/22)",
158
+ "distance_outlet": 2147483647,
159
+ "network_link.is_crucial": false,
160
+ "source_id": "00000000010de90e",
161
+ "network_link.source_device_id": "00000000010de862",
162
+ "network_link.destination_device_id": "00000000010de864",
163
+ "network_link.destination_device_ipv4": "172.17.166.20"
164
+ },
165
+ "sourceCode": null,
166
+ "level": null,
167
+ "customType": null,
168
+ "manageStatus": 3
169
+ }, // 子拓扑资源-子拓扑IP、Ping资源
170
+ {
171
+ ciType: 'network_link',
172
+ "id": "0000000001999c86",
173
+ "name": "子拓扑资源-子拓扑IP",
174
+ 'sourceType': 'topo',
175
+ "source": "3",
176
+ 'targetType': 'topo',
177
+ "target": "6",
178
+ "operation": "delete",
179
+ "interfaceSource": "00000000010de95e",
180
+ "interfaceTarget": "",
181
+ "attributes": {
182
+ "network_link.source_device_ipv4": "172.17.166.20",
183
+ "network_link.destination_ipv4": "2.2.2.2",
184
+ "network_link.work_mode": "AandS",
185
+ "support_templates": "m.ethernet_link",
186
+ "rated_bandwidth": 1000,
187
+ "network_link.actual_bandwidth": 1000,
188
+ "source_type": "network.interface",
189
+ "network_link.connect_type": "phy",
190
+ "display_name": "子拓扑资源-子拓扑IP",
191
+ "asset_status": "2",
192
+ "network_link_type": "2",
193
+ "destination_type": "ip",
194
+ "network_link.role": "master",
195
+ "network_link.network_category": "CAN",
196
+ "dcs": "331268969",
197
+ "network_link.source_ipv4": "172.17.166.20",
198
+ "name": "172.17.166.20(Gi 0/1) - 2.2.2.2",
199
+ "distance_outlet": 2147483647,
200
+ "network_link.is_crucial": false,
201
+ "source_id": "00000000010de95e",
202
+ "network_link.source_device_id": "00000000010de864",
203
+ "network_link.destination_device_ipv4": "2.2.2.2"
204
+ },
205
+ "sourceCode": null,
206
+ "level": null,
207
+ "customType": null,
208
+ "manageStatus": 3
209
+ }];
210
+ exports.topoLinks = topoLinks;
@@ -65,8 +65,8 @@ function getEdgeGroupLinkIdConfig(edgeGroup, topo) {
65
65
  }
66
66
 
67
67
  function getEdgeGroupConfigId(edgeGroup) {
68
- var sourceNode = edgeGroup.getSourceAgent();
69
- var targetNode = edgeGroup.getTargetAgent();
68
+ var sourceNode = edgeGroup.getSource();
69
+ var targetNode = edgeGroup.getTarget();
70
70
  var sourceId = sourceNode.a('uuid');
71
71
  var targetId = targetNode.a('uuid');
72
72
  return [sourceId, targetId].sort().join(',');
@@ -47,11 +47,11 @@ function buildIpNode(ip) {
47
47
  }
48
48
 
49
49
  function getHtSerialize(serialize) {
50
- if (serialize) {
50
+ if (serialize && typeof serialize === 'string') {
51
51
  return JSON.parse(serialize);
52
52
  }
53
53
 
54
- return null;
54
+ return serialize;
55
55
  }
56
56
 
57
57
  function isExitLink(link) {
@@ -251,9 +251,10 @@ function updateLinkTarget(links, nodes) {
251
251
 
252
252
 
253
253
  function processByConditionResult(topoData, groupConfigs) {
254
- var nodes = topoData.nodes,
254
+ var groups = topoData.groups,
255
+ nodes = topoData.nodes,
255
256
  links = topoData.links;
256
- var ipNodes = getIpNodes(groupConfigs, nodes); // 出口链路目的端设置为IP节点或者ping资源节点id
257
+ var ipNodes = getIpNodes(groupConfigs, topoData); // 出口链路目的端设置为IP节点或者ping资源节点id
257
258
 
258
259
  var newLinks = updateLinkTarget(links, nodes);
259
260
  return (0, _extends2["default"])({}, topoData, {
@@ -261,15 +262,26 @@ function processByConditionResult(topoData, groupConfigs) {
261
262
  links: newLinks
262
263
  });
263
264
 
264
- function getIpNodes(groupConfigs, nodes) {
265
- var ips = groupConfigs.map(function (g) {
266
- return g.condition.linkIps;
267
- }).reduce(function (result, groupIps) {
268
- return [].concat(result, groupIps);
269
- }, []) // 过滤ping资源对应的ip节点
270
- .filter(function (ip) {
271
- return !findPingNode(nodes, ip);
265
+ function getIpNodes(groupConfigs, _ref) {
266
+ var groups = _ref.groups,
267
+ nodes = _ref.nodes;
268
+ var ipNodes = [];
269
+ groupConfigs.forEach(function (g) {
270
+ g.condition.linkIps // 过滤ping资源对应的ip节点
271
+ .filter(function (ip) {
272
+ return !findPingNode(nodes, ip);
273
+ }).map(function (ip) {
274
+ var topoGroup = g.topoGroup;
275
+ var group = groups.find(function (item) {
276
+ return item.id === topoGroup.id || item.tag === topoGroup.tag;
277
+ });
278
+ ipNodes.push((0, _extends2["default"])({}, buildIpNode(ip), {
279
+ // 解决区域里有ip添加资源ip消失的问题
280
+ 'groupId': group === null || group === void 0 ? void 0 : group.id,
281
+ 'groupTag': group === null || group === void 0 ? void 0 : group.tag
282
+ }));
283
+ });
272
284
  });
273
- return ips.map(buildIpNode);
285
+ return ipNodes;
274
286
  }
275
287
  }
@@ -0,0 +1,164 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+
5
+ exports.__esModule = true;
6
+ exports.buildTopoNode = buildTopoNode;
7
+ exports.getRelateTopoIdListFromConfig = getRelateTopoIdListFromConfig;
8
+ exports.processBothTopoData = processBothTopoData;
9
+ exports.processByConditionTopoData = processByConditionTopoData;
10
+
11
+ var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
12
+
13
+ var _relateTopoData = require("./__tests__/relateTopoData");
14
+
15
+ // 关联拓扑数据
16
+
17
+ /**
18
+ * 升级历史数据:子拓扑节点序列化数据
19
+ * 构造子拓扑节点
20
+ * 构造子拓扑链路
21
+ * @param {*} ctx
22
+ */
23
+ function processBothTopoData(topoData) {
24
+ var nodes = topoData.nodes,
25
+ links = topoData.links;
26
+ var serialize = upgradeSerializeOldTopoNode(topoData.serialize);
27
+ return (0, _extends2["default"])({}, topoData, {
28
+ nodes: [].concat(nodes, buildTopoNodeDatasFromSerialize(serialize)),
29
+ links: buildTopoLinks(links),
30
+ serialize: serialize
31
+ });
32
+ }
33
+ /**
34
+ * 构造子拓扑节点
35
+ * 构造子拓扑链路
36
+ * @param {*} ctx
37
+ */
38
+
39
+
40
+ function processByConditionTopoData(ctx) {
41
+ var data = ctx.data,
42
+ config = ctx.config;
43
+ var nodes = data.nodes,
44
+ links = data.links;
45
+ return (0, _extends2["default"])({}, data, {
46
+ nodes: [].concat(nodes, buildTopoNodeDatas(config)),
47
+ links: buildTopoLinks(links)
48
+ });
49
+ }
50
+
51
+ function getRelateTopoIdListFromConfig(groups) {
52
+ var relateTopoIdList = [];
53
+ groups.forEach(function (g) {
54
+ g.resources["static"].filter(function (ciId) {
55
+ return ciId.startsWith('topo:');
56
+ }).map(function (ciId) {
57
+ return ciId.replace('topo:', '');
58
+ }).map(function (topoId) {
59
+ if (!relateTopoIdList.includes(topoId)) {
60
+ relateTopoIdList.push(topoId);
61
+ }
62
+ });
63
+ });
64
+ return relateTopoIdList;
65
+ }
66
+
67
+ function buildTopoNode(topoId) {
68
+ return {
69
+ id: "topo:" + topoId,
70
+ // name: ,
71
+ bindType: "topo",
72
+ // 绑定资源类型。关联资源 值为空,关联IP ip
73
+ bindIp: topoId,
74
+ // TODO 所属区域,从序列化拿
75
+ // 'groupId': null,
76
+ // 'groupTag': null,
77
+ // 'attributes': [],
78
+ // 'metrics': [],
79
+ type: "node",
80
+ isbinding: true,
81
+ // 'dtype': 'device'
82
+ operation: "delete"
83
+ };
84
+ }
85
+
86
+ function buildTopoLinks(links) {
87
+ if (process.env.NODE_ENV !== 'production') {
88
+ links.push.apply(links, _relateTopoData.topoLinks);
89
+ }
90
+
91
+ return links.map(function (link) {
92
+ return (0, _extends2["default"])({}, link, {
93
+ "source": link.sourceType ? link.sourceType + ':' + link.source : link.source,
94
+ "target": link.targetType ? link.targetType + ':' + link.target : link.target
95
+ });
96
+ });
97
+ }
98
+ /**
99
+ * 升级历史数据:子拓扑节点序列化数据
100
+ * @param {*} serialize
101
+ */
102
+
103
+
104
+ function upgradeSerializeOldTopoNode(serialize) {
105
+ if (serialize) {
106
+ var isOldTopoNode = function isOldTopoNode(ele) {
107
+ return isTopoNode(ele) && !ele.p.tag;
108
+ };
109
+
110
+ var oldTopoNodes = serialize.d.filter(isOldTopoNode);
111
+ oldTopoNodes.forEach(function (node) {
112
+ var _node$a;
113
+
114
+ var topoId = (_node$a = node.a) === null || _node$a === void 0 ? void 0 : _node$a.bindTopo;
115
+ node.a = (0, _extends2["default"])({}, node.a, buildTopoNode(topoId));
116
+ node.p.tag = "topo:" + topoId;
117
+ });
118
+ }
119
+
120
+ return serialize;
121
+ }
122
+
123
+ function isTopoNode(ele) {
124
+ var _ele$a;
125
+
126
+ return !!((_ele$a = ele.a) !== null && _ele$a !== void 0 && _ele$a.bindTopo);
127
+ }
128
+
129
+ function buildTopoNodeDatasFromSerialize(serialize) {
130
+ if (!serialize) {
131
+ return [];
132
+ }
133
+
134
+ var topoNodes = serialize.d.filter(isTopoNode);
135
+ var topoNodeDatas = topoNodes.map(function (node) {
136
+ var _node$a2;
137
+
138
+ var topoId = (_node$a2 = node.a) === null || _node$a2 === void 0 ? void 0 : _node$a2.bindTopo;
139
+ return buildTopoNode(topoId);
140
+ });
141
+ return topoNodeDatas;
142
+ }
143
+
144
+ function buildTopoNodeDatas(config) {
145
+ var topoNodeDatas = [];
146
+ config.forEach(function (g) {
147
+ g.resources["static"].filter(function (ciId) {
148
+ return ciId.startsWith('topo:');
149
+ }).map(function (ciId) {
150
+ return ciId.replace('topo:', '');
151
+ }).map(function (topoId) {
152
+ topoNodeDatas.push((0, _extends2["default"])({}, buildTopoNode(topoId), {
153
+ // 添加资源拓扑节点消失的问题
154
+ 'groupId': g.id,
155
+ 'groupTag': g.tag
156
+ }));
157
+ });
158
+ });
159
+ return topoNodeDatas;
160
+ }
161
+
162
+ function getRelateTopoIdsFromSerialize(serialize) {
163
+ return serialize;
164
+ }
package/lib/style.js CHANGED
@@ -1,7 +1,7 @@
1
1
  require('@riil-frontend/component-topology-graph/lib/style');
2
2
  require('@alifd/next/lib/box/style');
3
- require('@riil-frontend/component-topology-utils/lib/style');
4
3
  require('@alifd/next/lib/message/style');
4
+ require('@riil-frontend/component-topology-utils/lib/style');
5
5
  require('@riil-frontend/utils/lib/style');
6
6
  require('@riil-frontend/component-riil-event-emitter/lib/style');
7
7
  require('@alifd/next/lib/menu-button/style');
@@ -52,23 +52,8 @@ function getResourceConfigFromHt(topo) {
52
52
  return {
53
53
  layers: (0, _sortBy["default"])(layers, 'order'),
54
54
  groups: groups,
55
- resources: resources,
56
- relateTopoIdList: getRelateTopoIdList(dataModel)
55
+ resources: resources
57
56
  };
58
- } // 查询关联拓扑id列表
59
-
60
-
61
- function getRelateTopoIdList(dataModel) {
62
- return (0, _htElementUtils.getNodes)(dataModel).reduce(function (topoIds, node) {
63
- var bindType = node.a('bindType');
64
- var bindTopo = node.a('bindTopo');
65
-
66
- if (bindType === 'topo' && bindTopo && !topoIds.includes(bindTopo)) {
67
- return [].concat(topoIds, [bindTopo]);
68
- }
69
-
70
- return topoIds;
71
- }, []);
72
57
  }
73
58
 
74
59
  function getLayerDatas(dataModel) {
@@ -103,7 +103,7 @@ function isClusterHtElement(element) {
103
103
  }
104
104
 
105
105
  function isClusterMemberHtElement(element) {
106
- return element && element.getParent() && isClusterHtElement(element.getParent());
106
+ return (element === null || element === void 0 ? void 0 : element.getParent()) && isClusterHtElement(element.getParent());
107
107
  }
108
108
  /**
109
109
  * 集群无权限时收起
@@ -140,7 +140,7 @@ function upgradeV103GraphClusterNode(topo, topoData) {
140
140
  var topoDataTrans = (0, _utils.transformTopoElements)(topoData);
141
141
  var dm = topo.getDataModel();
142
142
  var unExistedList = topoDataTrans.filter(function (data) {
143
- return !(0, _htElementUtils.isExistedElement)(topo.getHtTopo(), dm, data);
143
+ return !(0, _htElementUtils.containsElement)(dm, data);
144
144
  });
145
145
 
146
146
  if (!unExistedList.length) {
@@ -3,11 +3,9 @@
3
3
  var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
4
 
5
5
  exports.__esModule = true;
6
+ exports.containsElement = containsElement;
6
7
  exports.getEdgeDatas = getEdgeDatas;
7
8
  exports.getEdgeGroupAgents = getEdgeGroupAgents;
8
- exports.getEdgeGroupByNodeTags = getEdgeGroupByNodeTags;
9
- exports.getEdgeGroupByNodes = getEdgeGroupByNodes;
10
- exports.getEdgeGroups = getEdgeGroups;
11
9
  exports.getEdges = getEdges;
12
10
  exports.getEdgesBetweenNodes = getEdgesBetweenNodes;
13
11
  exports.getElements = getElements;
@@ -27,8 +25,7 @@ exports.getNodes = getNodes;
27
25
  exports.getNodesByGroupIdOrTag = getNodesByGroupIdOrTag;
28
26
  exports.isEdge = isEdge;
29
27
  exports.isEdgeGroupAgent = isEdgeGroupAgent;
30
- exports.isEdgeGroupExpanded = isEdgeGroupExpanded;
31
- exports.isExistedElement = isExistedElement;
28
+ exports.isEdgeVisible = isEdgeVisible;
32
29
  exports.isGroup = isGroup;
33
30
  exports.isLayer = isLayer;
34
31
  exports.isNode = isNode;
@@ -172,10 +169,6 @@ function getNodeData(element) {
172
169
  function getEdges(dataModel) {
173
170
  return getElements(dataModel).filter(isValidEdge);
174
171
  }
175
-
176
- function isEdgeGroupExpanded(edge) {
177
- return isEdge(edge) && edge.getEdgeGroup() && !!edge.s("edge.expanded");
178
- }
179
172
  /**
180
173
  * 是否连线组代理
181
174
  * @param {*} edge
@@ -184,7 +177,11 @@ function isEdgeGroupExpanded(edge) {
184
177
 
185
178
 
186
179
  function isEdgeGroupAgent(edge) {
187
- return isEdge(edge) && edge.getEdgeGroup() && edge.isEdgeGroupAgent();
180
+ return isEdge(edge) && edge.a('x.edgegroup.isEdgeGroup');
181
+ }
182
+
183
+ function isEdgeVisible(edge) {
184
+ return edge.s('2d.visible') || edge.s('2d.visible') === undefined;
188
185
  }
189
186
  /**
190
187
  * 获得两个节点间的连线列表
@@ -202,7 +199,9 @@ function getEdgesBetweenNodes(node1, node2) {
202
199
  return edges;
203
200
  }
204
201
 
205
- node1Edges.toArray().filter(isValidEdge).forEach(function (edge) {
202
+ node1Edges.toArray().filter(isValidEdge).filter(function (edge) {
203
+ return !isEdgeGroupAgent(edge);
204
+ }).forEach(function (edge) {
206
205
  var isEdgeBetweenNodes = edge.getSource().getTag() === node2.getTag() || edge.getTarget().getTag() === node2.getTag();
207
206
 
208
207
  if (isEdgeBetweenNodes) {
@@ -212,66 +211,20 @@ function getEdgesBetweenNodes(node1, node2) {
212
211
  return edges;
213
212
  }
214
213
  /**
215
- * 获得节点间的连线组,连线<=1时返回null
216
- * @returns
217
- */
218
-
219
-
220
- function getEdgeGroupByNodes(node1, node2) {
221
- var htEdgeGroup = null;
222
- getEdgesBetweenNodes(node1, node2).forEach(function (edge) {
223
- if (!htEdgeGroup) {
224
- htEdgeGroup = edge.getEdgeGroup();
225
- }
226
- });
227
-
228
- if (!htEdgeGroup) {
229
- return null;
230
- }
231
-
232
- return new _EdgeGroup["default"](htEdgeGroup);
233
- }
234
- /**
235
- * 获得节点间的连线组,连线<=1时返回null
236
- * @returns
214
+ * 获得连线组连线列表
215
+ * @param {*} dataModel
216
+ * @returns
237
217
  */
238
218
 
239
219
 
240
- function getEdgeGroupByNodeTags(dataModel, nodeTag1, nodeTag2) {
241
- var node1 = dataModel.getDataByTag(nodeTag1);
242
- var node2 = dataModel.getDataByTag(nodeTag2);
243
-
244
- if (!node1 || !node2) {
245
- console.warn("getEdgeGroupByNodes 未找到节点", {
246
- node1: node1,
247
- node2: node2,
248
- nodeTag1: nodeTag1,
249
- nodeTag2: nodeTag2
250
- });
251
- return null;
252
- }
253
-
254
- return getEdgeGroupByNodes(node1, node2);
255
- }
256
-
257
- function getEdgeGroups(dataModel) {
258
- var edgeGroups = [];
259
- getEdges(dataModel).forEach(function (edge) {
260
- var group = edge.getEdgeGroup();
261
-
262
- if (group && !edgeGroups.includes(group)) {
263
- edgeGroups.push(group);
264
- }
265
- });
266
- return edgeGroups;
267
- }
268
-
269
220
  function getEdgeGroupAgents(dataModel) {
270
221
  return getEdges(dataModel).filter(isEdgeGroupAgent);
271
222
  }
272
223
 
273
224
  function getEdgeDatas(dataModel) {
274
- return getEdges(dataModel).map(function (element) {
225
+ return getEdges(dataModel).filter(function (edge) {
226
+ return !isEdgeGroupAgent(edge);
227
+ }).map(function (element) {
275
228
  var _element$getSource, _element$getTarget;
276
229
 
277
230
  return (0, _extends3["default"])({}, element.getAttrObject(), {
@@ -379,10 +332,14 @@ function setElementRuntimeStyle(element, name, value) {
379
332
  }
380
333
  /**
381
334
  * 判断拓扑图是否存在元素
335
+ *
336
+ * @param {*} dataModel
337
+ * @param {{id?: string, tag?: string}} data
338
+ * @returns
382
339
  */
383
340
 
384
341
 
385
- function isExistedElement(htTopo, dataModel, data) {
342
+ function containsElement(dataModel, data) {
386
343
  if (dataModel.getDataByTag(data.id)) {
387
344
  return true;
388
345
  } // 识别区域
@@ -391,34 +348,5 @@ function isExistedElement(htTopo, dataModel, data) {
391
348
  var element = getElements(dataModel).find(function (item) {
392
349
  return data.tag && item.a("tag") === data.tag;
393
350
  });
394
-
395
- if (element) {
396
- return true;
397
- } // 连线/连线组
398
-
399
-
400
- var edges = getEdges(dataModel);
401
-
402
- for (var i = 0; i < edges.length; i++) {
403
- var edge = edges[i]; // 如果连线组折叠,判断子连线
404
-
405
- var edgeData = htTopo.getEdgeData(edge);
406
-
407
- if (edgeData) {
408
- // eslint-disable-next-line no-underscore-dangle
409
- var id = edgeData._attrObject.id;
410
-
411
- if (id === data.id) {
412
- return true;
413
- }
414
- } // 如果连线组展开,判断连线组
415
- // eslint-disable-next-line no-underscore-dangle
416
-
417
-
418
- if (edge.__edgeGroup && edge.__edgeGroup._tag === data.id) {
419
- return true;
420
- }
421
- }
422
-
423
- return false;
351
+ return !!element;
424
352
  }