@riil-frontend/component-topology 3.2.0 → 3.4.1
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.
- package/build/1.js +2 -2
- package/build/2.js +1 -1
- package/build/index.js +18 -18
- package/demo/CHANGELOG/CHANGELOG.md +5 -0
- package/es/components/MultiResourceDrawer/index.js +2 -2
- package/es/components/NetworkTopoResourceSelectDrawer/NetworkTopoResourceSelectDrawer.js +9 -0
- package/es/components/NetworkTopoResourceSelectDrawer/index.js +2 -0
- package/es/components/ResourceSelectDrawer/ResourceSelectDrawer.js +8 -3
- package/es/components/ResourceSelectDrawer/ResourceSelectList.js +9 -6
- package/es/components/SingleResourceDrawer/SelectDrawer.js +1 -1
- package/es/constants/ResourceTypeLimit.js +38 -1
- package/es/core/common/icons/icon.js +3 -29
- package/es/core/editor/components/GroupAddResourceDrawerPlugin/GroupAddResourceDrawer.js +1 -1
- package/es/core/editor/components/settings/propertyViews/edge/CommonEdgePropertyView.js +148 -10
- package/es/core/editor/components/settings/propertyViews/edge/EdgePropertyView.js +4 -5
- package/es/core/editor/components/settings/propertyViews/index.js +1 -5
- package/es/core/editor/components/settings/propertyViews/layer/DataTab/LayerAddResourceDrawer.js +1 -1
- package/es/core/editor/components/settings/propertyViews/node/data/BindResourceDrawer.js +2 -1
- package/es/core/editor/components/titlebar/TopoEditorTitleBar.js +29 -1
- package/es/core/models/TopoApp.js +1 -1
- package/es/core/models/topoData.js +21 -18
- package/es/core/models/utils/linkUtils.js +14 -14
- package/es/hooks/useResourceConfig.js +3 -2
- package/es/hooks/useSelection.js +16 -14
- package/es/hooks/useTopoEdit.js +0 -5
- package/es/models/topoConfig.js +20 -16
- package/es/topoCenter/components/editor/propertyViews/edge/LinkPropertyView/Data/index.js +11 -7
- package/es/topoCenter/components/editor/propertyViews/edge/LinkPropertyView/LinkPropertyView.js +14 -3
- package/es/topoCenter/components/editor/propertyViews/edge/LinkPropertyView/Setting/index.js +3 -3
- package/es/topoCenter/components/editor/propertyViews/edge/addLinkDrawer/AddLinkDrawer.js +185 -105
- package/es/topoCenter/components/editor/propertyViews/edge/addLinkDrawer/components/editLinkInfo.js +61 -21
- package/es/topoCenter/components/editor/propertyViews/edge/link/LinkInfoPreview.js +26 -7
- package/es/topoCenter/event/index.js +1 -0
- package/es/topoCenter/hooks/editor/useDeleteEdges.js +48 -24
- package/es/topoCenter/services/link.js +51 -0
- package/es/topoCenter/utils/linPermissionUtil.js +24 -13
- package/es/utils/ResourceConfigUtil.js +38 -16
- package/es/utils/topoData.js +0 -1
- package/lib/components/MultiResourceDrawer/index.js +2 -2
- package/lib/components/NetworkTopoResourceSelectDrawer/NetworkTopoResourceSelectDrawer.js +20 -0
- package/lib/components/NetworkTopoResourceSelectDrawer/index.js +11 -0
- package/lib/components/ResourceSelectDrawer/ResourceSelectDrawer.js +8 -3
- package/lib/components/ResourceSelectDrawer/ResourceSelectList.js +10 -5
- package/lib/components/SingleResourceDrawer/SelectDrawer.js +2 -2
- package/lib/constants/ResourceTypeLimit.js +53 -2
- package/lib/core/common/icons/icon.js +3 -37
- package/lib/core/editor/components/GroupAddResourceDrawerPlugin/GroupAddResourceDrawer.js +2 -2
- package/lib/core/editor/components/settings/propertyViews/edge/CommonEdgePropertyView.js +160 -9
- package/lib/core/editor/components/settings/propertyViews/edge/EdgePropertyView.js +3 -5
- package/lib/core/editor/components/settings/propertyViews/index.js +1 -5
- package/lib/core/editor/components/settings/propertyViews/layer/DataTab/LayerAddResourceDrawer.js +2 -2
- package/lib/core/editor/components/settings/propertyViews/node/data/BindResourceDrawer.js +3 -2
- package/lib/core/editor/components/titlebar/TopoEditorTitleBar.js +32 -1
- package/lib/core/models/TopoApp.js +1 -1
- package/lib/core/models/topoData.js +24 -17
- package/lib/core/models/utils/linkUtils.js +12 -12
- package/lib/hooks/useResourceConfig.js +3 -2
- package/lib/hooks/useSelection.js +15 -11
- package/lib/hooks/useTopoEdit.js +0 -5
- package/lib/models/topoConfig.js +24 -16
- package/lib/topoCenter/components/editor/propertyViews/edge/LinkPropertyView/Data/index.js +15 -8
- package/lib/topoCenter/components/editor/propertyViews/edge/LinkPropertyView/LinkPropertyView.js +15 -2
- package/lib/topoCenter/components/editor/propertyViews/edge/LinkPropertyView/Setting/index.js +2 -2
- package/lib/topoCenter/components/editor/propertyViews/edge/addLinkDrawer/AddLinkDrawer.js +185 -121
- package/lib/topoCenter/components/editor/propertyViews/edge/addLinkDrawer/components/editLinkInfo.js +60 -22
- package/lib/topoCenter/components/editor/propertyViews/edge/link/LinkInfoPreview.js +27 -7
- package/lib/topoCenter/event/index.js +2 -1
- package/lib/topoCenter/hooks/editor/useDeleteEdges.js +48 -24
- package/lib/topoCenter/services/link.js +52 -0
- package/lib/topoCenter/utils/linPermissionUtil.js +24 -13
- package/lib/utils/ResourceConfigUtil.js +36 -14
- package/lib/utils/topoData.js +0 -1
- package/package.json +3 -3
- package/es/core/common/icons/defaultIcons.js +0 -44
- package/es/core/common/icons/networkTopoCiTypeIcons.js +0 -9
- package/lib/core/common/icons/defaultIcons.js +0 -53
- package/lib/core/common/icons/networkTopoCiTypeIcons.js +0 -22
|
@@ -11,6 +11,8 @@ var _drawer = _interopRequireDefault(require("@alifd/next/lib/drawer"));
|
|
|
11
11
|
|
|
12
12
|
var _message = _interopRequireDefault(require("@alifd/next/lib/message"));
|
|
13
13
|
|
|
14
|
+
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
|
|
15
|
+
|
|
14
16
|
var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
|
|
15
17
|
|
|
16
18
|
var _collapse = _interopRequireDefault(require("@alifd/next/lib/collapse"));
|
|
@@ -49,6 +51,10 @@ function AddLinkDrawer(props) {
|
|
|
49
51
|
lineData = props.lineData;
|
|
50
52
|
var store = topo.store;
|
|
51
53
|
|
|
54
|
+
var _topo$store$useModel = topo.store.useModel("topoMod"),
|
|
55
|
+
topoState = _topo$store$useModel[0],
|
|
56
|
+
topoDispatchers = _topo$store$useModel[1];
|
|
57
|
+
|
|
52
58
|
var _store$useModel = store.useModel("topoConfig"),
|
|
53
59
|
editState = _store$useModel[0],
|
|
54
60
|
editDispatchers = _store$useModel[1];
|
|
@@ -59,8 +65,6 @@ function AddLinkDrawer(props) {
|
|
|
59
65
|
|
|
60
66
|
var addLinkIsOpen = editState.addLinkIsOpen,
|
|
61
67
|
currentLink = editState.currentLink;
|
|
62
|
-
var ciConnectable = linkState.ciConnectable; // rlog.debug("addLinkDrawer--init-addLinkIsOpen", addLinkIsOpen, currentLink);
|
|
63
|
-
// const [visible, { setTrue, setFalse }] = useBoolean();
|
|
64
68
|
|
|
65
69
|
var _useState = (0, _react.useState)(),
|
|
66
70
|
link = _useState[0],
|
|
@@ -72,12 +76,16 @@ function AddLinkDrawer(props) {
|
|
|
72
76
|
|
|
73
77
|
var _useState3 = (0, _react.useState)(false),
|
|
74
78
|
loading = _useState3[0],
|
|
75
|
-
setLoading = _useState3[1];
|
|
79
|
+
setLoading = _useState3[1];
|
|
80
|
+
|
|
81
|
+
var _useState4 = (0, _react.useState)(),
|
|
82
|
+
sourceIFDoc = _useState4[0],
|
|
83
|
+
setSourceIFDoc = _useState4[1]; // 保存后更新拓扑图状态
|
|
76
84
|
|
|
77
85
|
|
|
78
|
-
var
|
|
79
|
-
ciIdsConnectable =
|
|
80
|
-
setCiIdsConnectable =
|
|
86
|
+
var _useState5 = (0, _react.useState)([]),
|
|
87
|
+
ciIdsConnectable = _useState5[0],
|
|
88
|
+
setCiIdsConnectable = _useState5[1];
|
|
81
89
|
|
|
82
90
|
var linkNodesRef = (0, _react.useRef)();
|
|
83
91
|
|
|
@@ -93,10 +101,8 @@ function AddLinkDrawer(props) {
|
|
|
93
101
|
|
|
94
102
|
case 2:
|
|
95
103
|
result = _context.sent;
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
104
|
+
// rlog.debug("端口列表", result);
|
|
105
|
+
//const list = result[id];
|
|
100
106
|
portsDoc = {};
|
|
101
107
|
ports = result.map(function (item) {
|
|
102
108
|
var obj = {
|
|
@@ -113,7 +119,7 @@ function AddLinkDrawer(props) {
|
|
|
113
119
|
portsDoc: portsDoc
|
|
114
120
|
});
|
|
115
121
|
|
|
116
|
-
case
|
|
122
|
+
case 6:
|
|
117
123
|
case "end":
|
|
118
124
|
return _context.stop();
|
|
119
125
|
}
|
|
@@ -134,21 +140,20 @@ function AddLinkDrawer(props) {
|
|
|
134
140
|
switch (_context2.prev = _context2.next) {
|
|
135
141
|
case 0:
|
|
136
142
|
linkNodesRef.current = e; // const { type, data } = e;
|
|
137
|
-
|
|
138
|
-
_rlog["default"].debug("接到打开创建链路抽屉信息", e);
|
|
143
|
+
// rlog.debug("接到打开创建链路抽屉信息", e);
|
|
139
144
|
|
|
140
145
|
setIsAddMode(true); // setTrue();
|
|
141
146
|
|
|
142
|
-
_context2.prev =
|
|
143
|
-
_context2.next =
|
|
147
|
+
_context2.prev = 2;
|
|
148
|
+
_context2.next = 5;
|
|
144
149
|
return getPortsById(e.source._attrObject.id);
|
|
145
150
|
|
|
146
|
-
case
|
|
151
|
+
case 5:
|
|
147
152
|
sourcePorts = _context2.sent;
|
|
148
|
-
_context2.next =
|
|
153
|
+
_context2.next = 8;
|
|
149
154
|
return getPortsById(e.target._attrObject.id);
|
|
150
155
|
|
|
151
|
-
case
|
|
156
|
+
case 8:
|
|
152
157
|
targetPorts = _context2.sent;
|
|
153
158
|
source = translationNode(e.source, sourcePorts);
|
|
154
159
|
target = translationNode(e.target, targetPorts);
|
|
@@ -170,24 +175,25 @@ function AddLinkDrawer(props) {
|
|
|
170
175
|
source_id: "",
|
|
171
176
|
"network_link.source_device_id": source.id,
|
|
172
177
|
"network_link.destination_device_id": target.id,
|
|
173
|
-
"network_link.actual_bandwidth": null
|
|
178
|
+
"network_link.actual_bandwidth": null,
|
|
179
|
+
connect_type: target.ciType !== "customNode" ? "phy" : "exit"
|
|
174
180
|
}
|
|
175
181
|
});
|
|
176
|
-
_context2.next =
|
|
182
|
+
_context2.next = 18;
|
|
177
183
|
break;
|
|
178
184
|
|
|
179
|
-
case
|
|
180
|
-
_context2.prev =
|
|
181
|
-
_context2.t0 = _context2["catch"](
|
|
185
|
+
case 15:
|
|
186
|
+
_context2.prev = 15;
|
|
187
|
+
_context2.t0 = _context2["catch"](2);
|
|
182
188
|
|
|
183
189
|
_rlog["default"].error("出现异常", _context2.t0);
|
|
184
190
|
|
|
185
|
-
case
|
|
191
|
+
case 18:
|
|
186
192
|
case "end":
|
|
187
193
|
return _context2.stop();
|
|
188
194
|
}
|
|
189
195
|
}
|
|
190
|
-
}, _callee2, null, [[
|
|
196
|
+
}, _callee2, null, [[2, 15]]);
|
|
191
197
|
}));
|
|
192
198
|
|
|
193
199
|
return function handleEvent(_x2) {
|
|
@@ -195,17 +201,23 @@ function AddLinkDrawer(props) {
|
|
|
195
201
|
};
|
|
196
202
|
}();
|
|
197
203
|
|
|
204
|
+
var selectedSourceNodeHandleEvent = function selectedSourceNodeHandleEvent(e) {
|
|
205
|
+
// rlog.debug("设置了起始节点", e);
|
|
206
|
+
//const allData = topo.getData();
|
|
207
|
+
var enableNodes = (0, _htElementUtils.getNodes)(topo.getDataModel());
|
|
208
|
+
topo.view.topoClient.emitEvent("topo_link_set_connectable_nodes", enableNodes);
|
|
209
|
+
};
|
|
210
|
+
|
|
198
211
|
var initEditLineData = /*#__PURE__*/function () {
|
|
199
212
|
var _ref3 = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee3() {
|
|
200
213
|
var _currentLink$attribut, _sourcePorts$ports, _currentLink$attribut2, _targetPorts$ports;
|
|
201
214
|
|
|
202
|
-
var sourcePorts, targetPorts;
|
|
215
|
+
var sourcePorts, targetPorts, connect_type;
|
|
203
216
|
return _regenerator["default"].wrap(function _callee3$(_context3) {
|
|
204
217
|
while (1) {
|
|
205
218
|
switch (_context3.prev = _context3.next) {
|
|
206
219
|
case 0:
|
|
207
|
-
|
|
208
|
-
|
|
220
|
+
console.log("编辑链路--当前链路", currentLink);
|
|
209
221
|
_context3.next = 3;
|
|
210
222
|
return getPortsById(currentLink.source);
|
|
211
223
|
|
|
@@ -216,6 +228,8 @@ function AddLinkDrawer(props) {
|
|
|
216
228
|
|
|
217
229
|
case 6:
|
|
218
230
|
targetPorts = _context3.sent;
|
|
231
|
+
setSourceIFDoc(sourcePorts.portsDoc);
|
|
232
|
+
connect_type = currentLink.attributes["network_link.connect_type"] === "exit" ? "exit" : "phy";
|
|
219
233
|
setLink({
|
|
220
234
|
source: {
|
|
221
235
|
id: currentLink.source,
|
|
@@ -232,15 +246,17 @@ function AddLinkDrawer(props) {
|
|
|
232
246
|
name: currentLink.attributes["network_link.destination_device_id_object"].displayName,
|
|
233
247
|
ipAddress: currentLink.attributes["network_link.destination_ipv4"],
|
|
234
248
|
ciName: (_currentLink$attribut2 = currentLink.attributes.destination_type_object) === null || _currentLink$attribut2 === void 0 ? void 0 : _currentLink$attribut2.displayName,
|
|
235
|
-
ciType: currentLink.attributes.destination_type,
|
|
249
|
+
ciType: currentLink.attributes.destination_type !== "" ? currentLink.attributes.destination_type : "customNode",
|
|
236
250
|
interfaceTarget: currentLink.interfaceTarget,
|
|
237
251
|
ports: (_targetPorts$ports = targetPorts.ports) !== null && _targetPorts$ports !== void 0 ? _targetPorts$ports : [],
|
|
238
252
|
portsDoc: targetPorts.portsDoc
|
|
239
253
|
},
|
|
240
|
-
attributes: currentLink.attributes
|
|
254
|
+
attributes: (0, _extends2["default"])({}, currentLink.attributes, {
|
|
255
|
+
connect_type: connect_type
|
|
256
|
+
})
|
|
241
257
|
});
|
|
242
258
|
|
|
243
|
-
case
|
|
259
|
+
case 10:
|
|
244
260
|
case "end":
|
|
245
261
|
return _context3.stop();
|
|
246
262
|
}
|
|
@@ -254,8 +270,7 @@ function AddLinkDrawer(props) {
|
|
|
254
270
|
}();
|
|
255
271
|
|
|
256
272
|
(0, _react.useEffect)(function () {
|
|
257
|
-
|
|
258
|
-
|
|
273
|
+
// rlog.debug("useEffect-----currentLink", currentLink);
|
|
259
274
|
if (currentLink) {
|
|
260
275
|
setIsAddMode(false);
|
|
261
276
|
initEditLineData();
|
|
@@ -264,38 +279,33 @@ function AddLinkDrawer(props) {
|
|
|
264
279
|
|
|
265
280
|
var getCiTypesConnectable = /*#__PURE__*/function () {
|
|
266
281
|
var _ref4 = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee4() {
|
|
267
|
-
var
|
|
282
|
+
var ciTypesConnectable, nodes, ciIds, ciNodes;
|
|
268
283
|
return _regenerator["default"].wrap(function _callee4$(_context4) {
|
|
269
284
|
while (1) {
|
|
270
285
|
switch (_context4.prev = _context4.next) {
|
|
271
286
|
case 0:
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
_rlog["default"].debug("加载哪些ci类型可创建链路-getCiTypesConnectable"); // 加载哪些ci类型可创建链路
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
_context4.next = 4;
|
|
287
|
+
_context4.next = 2;
|
|
278
288
|
return _topo["default"].networkLink.getCiTypesConnectable(_ResourceTypeLimit.RESOURCE_LIMIT_TYPES);
|
|
279
289
|
|
|
280
|
-
case
|
|
290
|
+
case 2:
|
|
281
291
|
ciTypesConnectable = _context4.sent;
|
|
282
|
-
nodes =
|
|
283
|
-
|
|
284
|
-
_rlog["default"].debug("加载哪些ci类型可创建链路", ciTypesConnectable, topo, nodes);
|
|
285
|
-
|
|
292
|
+
nodes = (0, _htElementUtils.getNodes)(topo.getDataModel());
|
|
286
293
|
ciIds = [];
|
|
294
|
+
ciNodes = [];
|
|
287
295
|
nodes.map(function (node) {
|
|
288
|
-
|
|
296
|
+
// rlog.debug("过滤属性", node.a("operation"));
|
|
297
|
+
if (ciTypesConnectable[node.a("ciType")] && ["delete", "write"].indexOf(node.a("operation")) >= 0) {
|
|
289
298
|
ciIds.push(node.id);
|
|
299
|
+
ciNodes.push(node);
|
|
290
300
|
}
|
|
291
301
|
});
|
|
292
302
|
linkDispatchers.update({
|
|
293
303
|
ciConnectable: ciIds
|
|
294
304
|
});
|
|
295
305
|
setCiIdsConnectable(ciIds);
|
|
296
|
-
return _context4.abrupt("return",
|
|
306
|
+
return _context4.abrupt("return", ciNodes);
|
|
297
307
|
|
|
298
|
-
case
|
|
308
|
+
case 10:
|
|
299
309
|
case "end":
|
|
300
310
|
return _context4.stop();
|
|
301
311
|
}
|
|
@@ -310,40 +320,37 @@ function AddLinkDrawer(props) {
|
|
|
310
320
|
|
|
311
321
|
|
|
312
322
|
(0, _react.useEffect)(function () {
|
|
313
|
-
var notifier = topo.view.topoClient.notifier;
|
|
314
|
-
|
|
315
|
-
_rlog["default"].debug("注册事件"); // 进入划线模式,置灰不可用的节点
|
|
316
|
-
|
|
323
|
+
var notifier = topo.view.topoClient.notifier; // rlog.debug("注册事件");
|
|
324
|
+
// 进入划线模式,置灰不可用的节点
|
|
317
325
|
|
|
318
326
|
var enterHandleEvent = function enterHandleEvent() {
|
|
319
|
-
getCiTypesConnectable().then(function (
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
topo.view.topoClient.emitEvent("topo_link_set_connectable_nodes", ciIds);
|
|
327
|
+
getCiTypesConnectable().then(function (ciNodes) {
|
|
328
|
+
// rlog.debug("设置可连线节点", ciIdsConnectable, ciNodes);
|
|
329
|
+
topo.view.topoClient.emitEvent("topo_link_set_connectable_nodes", ciNodes);
|
|
323
330
|
});
|
|
324
331
|
};
|
|
325
332
|
|
|
326
333
|
notifier.on(_event["default"].TOPO_LINK_ENTER_CREATE_MODE, enterHandleEvent);
|
|
327
334
|
notifier.on(_event["default"].TOPO_LINK_CREATED, handleEvent);
|
|
335
|
+
notifier.on(_event["default"].TOPO_LINK_SELECT_SOURCE_NODE, selectedSourceNodeHandleEvent);
|
|
328
336
|
return function () {
|
|
329
337
|
// 取消注册事件
|
|
330
|
-
|
|
331
|
-
|
|
338
|
+
// rlog.debug("取消注册事件");
|
|
332
339
|
notifier.off(_event["default"].TOPO_LINK_ENTER_CREATE_MODE, enterHandleEvent);
|
|
333
340
|
notifier.off(_event["default"].TOPO_LINK_CREATED, handleEvent);
|
|
334
341
|
};
|
|
335
342
|
}, []);
|
|
336
343
|
|
|
337
344
|
var translationNode = function translationNode(node, Ports) {
|
|
338
|
-
var _Ports$ports;
|
|
345
|
+
var _topo$ciTyeCache$getC, _topo$ciTyeCache$getC2, _attrObject$ciType, _Ports$ports;
|
|
339
346
|
|
|
340
347
|
var attrObject = node._attrObject;
|
|
341
348
|
return {
|
|
342
349
|
id: attrObject.id,
|
|
343
350
|
name: attrObject.name,
|
|
344
351
|
ipAddress: attrObject.ipAddress,
|
|
345
|
-
ciName: topo.ciTyeCache.getCiType(attrObject.ciType).displayName,
|
|
346
|
-
ciType: attrObject.ciType,
|
|
352
|
+
ciName: (_topo$ciTyeCache$getC = (_topo$ciTyeCache$getC2 = topo.ciTyeCache.getCiType(attrObject.ciType)) === null || _topo$ciTyeCache$getC2 === void 0 ? void 0 : _topo$ciTyeCache$getC2.displayName) !== null && _topo$ciTyeCache$getC !== void 0 ? _topo$ciTyeCache$getC : attrObject.customName,
|
|
353
|
+
ciType: (_attrObject$ciType = attrObject.ciType) !== null && _attrObject$ciType !== void 0 ? _attrObject$ciType : "customNode",
|
|
347
354
|
ports: (_Ports$ports = Ports.ports) !== null && _Ports$ports !== void 0 ? _Ports$ports : [],
|
|
348
355
|
portsDoc: Ports.portsDoc
|
|
349
356
|
};
|
|
@@ -351,8 +358,7 @@ function AddLinkDrawer(props) {
|
|
|
351
358
|
|
|
352
359
|
var closeDrawer = function closeDrawer() {
|
|
353
360
|
//editDispatchers.update({ addLinkIsOpen: false });
|
|
354
|
-
|
|
355
|
-
|
|
361
|
+
// rlog.debug("关闭");
|
|
356
362
|
editDispatchers.update({
|
|
357
363
|
addLinkIsOpen: false,
|
|
358
364
|
currentLink: null
|
|
@@ -361,19 +367,18 @@ function AddLinkDrawer(props) {
|
|
|
361
367
|
|
|
362
368
|
var addLinkToGraph = function addLinkToGraph(_ref5) {
|
|
363
369
|
var linkData = _ref5.linkData,
|
|
364
|
-
|
|
370
|
+
linkType = _ref5.linkType,
|
|
371
|
+
targetName = _ref5.targetName;
|
|
365
372
|
var htTopo = topo.getHtTopo();
|
|
366
373
|
var _linkNodesRef$current = linkNodesRef.current,
|
|
367
374
|
source = _linkNodesRef$current.source,
|
|
368
375
|
target = _linkNodesRef$current.target;
|
|
369
376
|
|
|
370
|
-
_rlog["default"].debug("addLinkToGraph", source, target, htTopo);
|
|
371
|
-
|
|
372
377
|
try {
|
|
373
378
|
// 获取两个节点间的连线数据列表
|
|
374
379
|
var edgesInNodes = (0, _htElementUtils.getEdgesBetweenNodes)(source, target);
|
|
375
380
|
|
|
376
|
-
if (
|
|
381
|
+
if (linkType === "agg") {
|
|
377
382
|
// 聚合链路
|
|
378
383
|
if (edgesInNodes.length === 0) {
|
|
379
384
|
htTopo.createEdge(source, target, linkData);
|
|
@@ -384,21 +389,15 @@ function AddLinkDrawer(props) {
|
|
|
384
389
|
|
|
385
390
|
htTopo.toggleEdgeGroup(source, target, false);
|
|
386
391
|
} else {
|
|
387
|
-
//
|
|
392
|
+
// 出口链路
|
|
388
393
|
// 有连线组无子连线时,设置连线数据,切换到连线并选中
|
|
389
|
-
// 注释代码,因为 createEdge 内置该逻辑
|
|
390
|
-
// const firstEdge = edgesInNodes[0]
|
|
391
|
-
// if (edgesInNodes.length === 1 && !htTopo.getEdgeData(firstEdge)) {
|
|
392
|
-
// htTopo.setEdgeData(firstEdge, linkData);
|
|
393
|
-
// } else {
|
|
394
|
-
// htTopo.createEdge(source, target, linkData);
|
|
395
|
-
// }
|
|
396
394
|
var edge = htTopo.createEdge(source, target, linkData);
|
|
397
395
|
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
396
|
+
if (linkType === "exit" && target.getTag() === undefined) {
|
|
397
|
+
// rlog.debug("addLinkToGraph-exit-target", target, target.getTag());
|
|
398
|
+
target.a("name", targetName);
|
|
399
|
+
}
|
|
400
|
+
}
|
|
402
401
|
|
|
403
402
|
topo.getGraphView().dm().sm().ss(topo.getDataModel().getDataByTag(linkData.id));
|
|
404
403
|
} catch (error) {
|
|
@@ -406,17 +405,43 @@ function AddLinkDrawer(props) {
|
|
|
406
405
|
}
|
|
407
406
|
};
|
|
408
407
|
|
|
408
|
+
var mergeExitLinkData = function mergeExitLinkData(data, attributes) {
|
|
409
|
+
return {
|
|
410
|
+
id: data.id,
|
|
411
|
+
name: data.name,
|
|
412
|
+
source: data["network_link.source_device_id"],
|
|
413
|
+
target: data["network_link.destination_device_id"],
|
|
414
|
+
operation: data.operation,
|
|
415
|
+
interfaceSource: data["source_id"],
|
|
416
|
+
interfaceTarget: data["destination_id"],
|
|
417
|
+
ciType: data.ciType,
|
|
418
|
+
attributes: (0, _extends2["default"])({}, attributes, {
|
|
419
|
+
display_name: data.display_name,
|
|
420
|
+
name: data.name,
|
|
421
|
+
"network_link.actual_bandwidth": data["network_link.actual_bandwidth"],
|
|
422
|
+
"network_link.connect_type": data["network_link.connect_type"],
|
|
423
|
+
"network_link.destination_ipv4": data["network_link.destination_ipv4"],
|
|
424
|
+
"network_link.source_device_id": data["network_link.source_device_id"],
|
|
425
|
+
source_id: data.source_id,
|
|
426
|
+
support_templates: data.support_templates,
|
|
427
|
+
use: data.use,
|
|
428
|
+
source_id_object: {
|
|
429
|
+
displayName: sourceIFDoc[data.source_id].label
|
|
430
|
+
}
|
|
431
|
+
})
|
|
432
|
+
};
|
|
433
|
+
};
|
|
434
|
+
|
|
409
435
|
var onSave = /*#__PURE__*/function () {
|
|
410
436
|
var _ref6 = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee5(data) {
|
|
411
|
-
var parm, result, config, _yield$editDispatcher, elements, linkData,
|
|
437
|
+
var parm, result, linkType, config, exportLinkIdList, _yield$editDispatcher, elements, linkData, edge, aobj, target, links, linkAttrKey, newLinkData, newLinks, newData;
|
|
412
438
|
|
|
413
439
|
return _regenerator["default"].wrap(function _callee5$(_context5) {
|
|
414
440
|
while (1) {
|
|
415
441
|
switch (_context5.prev = _context5.next) {
|
|
416
442
|
case 0:
|
|
417
443
|
//editDispatchers.update({ addLinkIsOpen: false });
|
|
418
|
-
|
|
419
|
-
|
|
444
|
+
// rlog.debug("保存链路信息", isAddMode, data);
|
|
420
445
|
setLoading(true);
|
|
421
446
|
parm = {
|
|
422
447
|
attributes: data
|
|
@@ -424,84 +449,123 @@ function AddLinkDrawer(props) {
|
|
|
424
449
|
result = null;
|
|
425
450
|
|
|
426
451
|
if (!isAddMode) {
|
|
427
|
-
_context5.next =
|
|
452
|
+
_context5.next = 9;
|
|
428
453
|
break;
|
|
429
454
|
}
|
|
430
455
|
|
|
431
|
-
_context5.next =
|
|
456
|
+
_context5.next = 6;
|
|
432
457
|
return _server["default"].addLink(parm);
|
|
433
458
|
|
|
434
|
-
case
|
|
459
|
+
case 6:
|
|
435
460
|
result = _context5.sent;
|
|
436
|
-
_context5.next =
|
|
461
|
+
_context5.next = 13;
|
|
437
462
|
break;
|
|
438
463
|
|
|
439
|
-
case
|
|
464
|
+
case 9:
|
|
440
465
|
parm.id = currentLink.id;
|
|
441
|
-
_context5.next =
|
|
466
|
+
_context5.next = 12;
|
|
442
467
|
return _server["default"].editLink(parm);
|
|
443
468
|
|
|
444
|
-
case
|
|
469
|
+
case 12:
|
|
445
470
|
result = _context5.sent;
|
|
446
471
|
|
|
447
|
-
case
|
|
448
|
-
setLoading(false);
|
|
449
|
-
|
|
450
|
-
// }
|
|
451
|
-
|
|
472
|
+
case 13:
|
|
473
|
+
setLoading(false);
|
|
474
|
+
linkType = data["network_link.connect_type"];
|
|
452
475
|
_context5.prev = 15;
|
|
453
476
|
|
|
454
477
|
if (!result) {
|
|
455
|
-
_context5.next =
|
|
478
|
+
_context5.next = 35;
|
|
456
479
|
break;
|
|
457
480
|
}
|
|
458
481
|
|
|
459
|
-
config = topo.resourceConfig.getConfigFromHt();
|
|
460
|
-
|
|
461
|
-
|
|
482
|
+
config = topo.resourceConfig.getConfigFromHt(); // 新建后显示到图上
|
|
483
|
+
|
|
484
|
+
if (!isAddMode) {
|
|
485
|
+
_context5.next = 31;
|
|
486
|
+
break;
|
|
487
|
+
}
|
|
488
|
+
|
|
489
|
+
exportLinkIdList = config.exportLinkIdList;
|
|
490
|
+
|
|
491
|
+
if (data["network_link.connect_type"] === "exit") {
|
|
492
|
+
exportLinkIdList.push(result);
|
|
493
|
+
}
|
|
494
|
+
|
|
495
|
+
topo.resourceConfig.updateConfig((0, _extends2["default"])({}, config, {
|
|
496
|
+
exportLinkIdList: exportLinkIdList
|
|
497
|
+
})); // const linkType = data["network_link.connect_type"];
|
|
498
|
+
|
|
499
|
+
_context5.next = 24;
|
|
462
500
|
return editDispatchers.fetchDataByConfig();
|
|
463
501
|
|
|
464
|
-
case
|
|
502
|
+
case 24:
|
|
465
503
|
_yield$editDispatcher = _context5.sent;
|
|
466
504
|
elements = _yield$editDispatcher.elements;
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
505
|
+
linkData = elements.find(function (element) {
|
|
506
|
+
return element.id === result;
|
|
507
|
+
});
|
|
508
|
+
addLinkToGraph({
|
|
509
|
+
linkData: (0, _copyUtil.clone)(linkData),
|
|
510
|
+
linkType: linkType,
|
|
511
|
+
targetName: data["network_link.destination_ipv4"]
|
|
512
|
+
});
|
|
513
|
+
|
|
514
|
+
_message["default"].success("创建成功");
|
|
471
515
|
|
|
472
|
-
|
|
473
|
-
|
|
516
|
+
_context5.next = 33;
|
|
517
|
+
break;
|
|
474
518
|
|
|
475
|
-
|
|
476
|
-
|
|
519
|
+
case 31:
|
|
520
|
+
// console.log("保存编辑信息", data, linkType);
|
|
521
|
+
if (linkType === "exit") {
|
|
522
|
+
edge = topo.getGraphView().dm().sm().ld();
|
|
523
|
+
aobj = edge.getAttrObject();
|
|
524
|
+
edge.setAttrObject((0, _extends2["default"])({}, aobj, data));
|
|
525
|
+
target = edge.getTarget();
|
|
526
|
+
|
|
527
|
+
if (target.getTag() === undefined) {
|
|
528
|
+
target.a("name", data["network_link.destination_ipv4"]);
|
|
529
|
+
}
|
|
530
|
+
|
|
531
|
+
links = topoState.data.links;
|
|
532
|
+
linkAttrKey = links.findIndex(function (item) {
|
|
533
|
+
return item.id === aobj.id;
|
|
534
|
+
});
|
|
535
|
+
newLinkData = mergeExitLinkData(edge.getAttrObject(), links[linkAttrKey]);
|
|
536
|
+
newLinks = (0, _copyUtil.clone)(links);
|
|
537
|
+
newLinks.splice(linkAttrKey, 1, newLinkData);
|
|
538
|
+
newData = (0, _extends2["default"])({}, topoState.data, {
|
|
539
|
+
links: newLinks
|
|
477
540
|
});
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
linkData: (0, _copyUtil.clone)(linkData),
|
|
481
|
-
isAgg: isAgg
|
|
541
|
+
topoDispatchers.update({
|
|
542
|
+
data: newData
|
|
482
543
|
});
|
|
483
|
-
} else {
|
|
484
|
-
_message["default"].success("保存成功");
|
|
485
544
|
}
|
|
486
545
|
|
|
546
|
+
_message["default"].success("保存成功");
|
|
547
|
+
|
|
548
|
+
case 33:
|
|
549
|
+
editDispatchers.update({
|
|
550
|
+
addLinkIsOpen: false,
|
|
551
|
+
currentLink: null
|
|
552
|
+
});
|
|
487
553
|
topo.linkDynamicStyleExecutor.execute();
|
|
488
554
|
|
|
489
|
-
case
|
|
490
|
-
_context5.next =
|
|
555
|
+
case 35:
|
|
556
|
+
_context5.next = 39;
|
|
491
557
|
break;
|
|
492
558
|
|
|
493
|
-
case
|
|
494
|
-
_context5.prev =
|
|
559
|
+
case 37:
|
|
560
|
+
_context5.prev = 37;
|
|
495
561
|
_context5.t0 = _context5["catch"](15);
|
|
496
562
|
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
case 31:
|
|
563
|
+
case 39:
|
|
500
564
|
case "end":
|
|
501
565
|
return _context5.stop();
|
|
502
566
|
}
|
|
503
567
|
}
|
|
504
|
-
}, _callee5, null, [[15,
|
|
568
|
+
}, _callee5, null, [[15, 37]]);
|
|
505
569
|
}));
|
|
506
570
|
|
|
507
571
|
return function onSave(_x3) {
|