@riil-frontend/component-topology 3.5.0-a.9 → 3.5.2

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 (106) hide show
  1. package/build/1.js +1 -1
  2. package/build/index.css +1 -1
  3. package/build/index.js +12 -12
  4. package/es/components/index.module.scss +3 -114
  5. package/es/core/components/AlarmListPanel/index.js +7 -12
  6. package/es/core/components/DisplaySettingDrawer/DisplaySetting.js +8 -5
  7. package/es/core/components/DisplaySettingDrawer/NodeTag.js +10 -5
  8. package/es/core/components/DisplaySettingDrawer/NodeTip.js +10 -5
  9. package/es/core/components/DisplaySettingDrawer/hooks/useDisplaySetting.js +3 -21
  10. package/es/core/components/TopoView/topoView.js +1 -0
  11. package/es/core/editor/components/settings/propertyViews/edge/CommonEdgePropertyView.js +7 -140
  12. package/es/core/editor/components/settings/propertyViews/edge/EdgePropertyView.js +1 -1
  13. package/es/core/editor/components/settings/propertyViews/node/Setting/Setting.js +1 -1
  14. package/es/core/editor/components/settings/propertyViews/node/data/Data.js +18 -17
  15. package/es/core/editor/components/titlebar/TopoEditorTitleBar.js +62 -18
  16. package/es/core/models/Alarm.js +206 -120
  17. package/es/core/models/DataModel.js +15 -1
  18. package/es/core/models/TopoApp.js +4 -6
  19. package/es/core/models/cache/CiTyeCache.js +4 -0
  20. package/es/core/models/utils/linkUtils.js +87 -42
  21. package/es/core/services/index.js +28 -0
  22. package/es/core/utils/saveSerialize.js +34 -0
  23. package/es/core/viewer/components/plugins/ResourceDetail/ResourceDetail.js +0 -37
  24. package/es/core/viewer/components/plugins/ResourceDetail/components/ResourceOverview/BaseInfo.js +31 -28
  25. package/es/core/viewer/components/plugins/ResourceDetail/components/ResourceOverview/ResourceOverview.js +44 -43
  26. package/es/core/viewer/components/plugins/ResourceDetail/components/ResourceOverview/ResourceOverviewMetric.js +39 -26
  27. package/es/core/viewer/components/plugins/ResourceDetail/components/ResourceOverview/hooks/useCiData.js +0 -0
  28. package/es/core/viewer/components/plugins/ResourceDetail/components/ResourceOverview/hooks/useMetricModels.js +143 -0
  29. package/es/core/viewer/components/plugins/ResourceDetail/getCiDisplayMetricModels.js +37 -0
  30. package/es/core/viewer/components/titlebar/BasicTools.js +11 -1
  31. package/es/core/viewer/components/titlebar/widgets/AlarmListShowButton.js +21 -13
  32. package/es/hooks/useGraphAlarmDisplay.js +3 -4
  33. package/es/hooks/useManageStatus.js +1 -1
  34. package/es/hooks/useTopoEdit.js +200 -144
  35. package/es/hooks/useTopoEventListener.js +13 -6
  36. package/es/index.js +3 -2
  37. package/es/models/topoConfig.js +0 -1
  38. package/es/models/topoMod.js +15 -10
  39. package/es/topoCenter/components/Topo404.js +3 -1
  40. package/es/topoCenter/components/TopoNoPermission.js +3 -1
  41. package/es/topoCenter/components/TopoView.js +77 -32
  42. package/es/topoCenter/components/Topology.js +2 -0
  43. package/es/topoCenter/components/editor/propertyViews/edge/EdgePropertyView.js +10 -0
  44. package/es/topoCenter/components/editor/propertyViews/edge/LinkPropertyView/Data/index.js +5 -20
  45. package/es/topoCenter/components/editor/propertyViews/edge/LinkPropertyView/LinkPropertyView.js +12 -6
  46. package/es/topoCenter/components/editor/propertyViews/edge/addLinkDrawer/AddLinkDrawer.js +84 -43
  47. package/es/topoCenter/components/editor/propertyViews/edge/addLinkDrawer/components/editLinkInfo.js +60 -34
  48. package/es/topoCenter/components/editor/propertyViews/edge/addLinkDrawer/index.module.scss +9 -0
  49. package/es/topoCenter/components/editor/propertyViews/edge/addLinkDrawer/server.js +62 -19
  50. package/es/topoCenter/components/editor/propertyViews/edge/link/BindExitLinkSelect.js +157 -0
  51. package/es/topoCenter/components/editor/propertyViews/edge/link/LinkInfoPreview.js +1 -2
  52. package/es/topoCenter/hooks/editor/useDeleteEdges.js +2 -3
  53. package/es/topoCenter/utils/resourcePermissionUtil.js +18 -12
  54. package/es/utils/topoData.js +15 -13
  55. package/lib/components/index.module.scss +3 -114
  56. package/lib/core/components/AlarmListPanel/index.js +7 -12
  57. package/lib/core/components/DisplaySettingDrawer/DisplaySetting.js +9 -5
  58. package/lib/core/components/DisplaySettingDrawer/NodeTag.js +11 -5
  59. package/lib/core/components/DisplaySettingDrawer/NodeTip.js +12 -5
  60. package/lib/core/components/DisplaySettingDrawer/hooks/useDisplaySetting.js +3 -21
  61. package/lib/core/components/TopoView/topoView.js +1 -0
  62. package/lib/core/editor/components/settings/propertyViews/edge/CommonEdgePropertyView.js +7 -151
  63. package/lib/core/editor/components/settings/propertyViews/edge/EdgePropertyView.js +2 -2
  64. package/lib/core/editor/components/settings/propertyViews/node/Setting/Setting.js +1 -1
  65. package/lib/core/editor/components/settings/propertyViews/node/data/Data.js +17 -16
  66. package/lib/core/editor/components/titlebar/TopoEditorTitleBar.js +66 -20
  67. package/lib/core/models/Alarm.js +206 -121
  68. package/lib/core/models/DataModel.js +15 -1
  69. package/lib/core/models/TopoApp.js +4 -6
  70. package/lib/core/models/cache/CiTyeCache.js +4 -0
  71. package/lib/core/models/utils/linkUtils.js +92 -43
  72. package/lib/core/services/index.js +29 -0
  73. package/lib/core/utils/saveSerialize.js +43 -0
  74. package/lib/core/viewer/components/plugins/ResourceDetail/ResourceDetail.js +0 -37
  75. package/lib/core/viewer/components/plugins/ResourceDetail/components/ResourceOverview/BaseInfo.js +29 -26
  76. package/lib/core/viewer/components/plugins/ResourceDetail/components/ResourceOverview/ResourceOverview.js +45 -43
  77. package/lib/core/viewer/components/plugins/ResourceDetail/components/ResourceOverview/ResourceOverviewMetric.js +38 -24
  78. package/lib/core/viewer/components/plugins/ResourceDetail/components/ResourceOverview/hooks/useCiData.js +1 -0
  79. package/lib/core/viewer/components/plugins/ResourceDetail/components/ResourceOverview/hooks/useMetricModels.js +155 -0
  80. package/lib/core/viewer/components/plugins/ResourceDetail/getCiDisplayMetricModels.js +47 -0
  81. package/lib/core/viewer/components/titlebar/BasicTools.js +11 -1
  82. package/lib/core/viewer/components/titlebar/widgets/AlarmListShowButton.js +22 -15
  83. package/lib/hooks/useGraphAlarmDisplay.js +3 -5
  84. package/lib/hooks/useManageStatus.js +1 -1
  85. package/lib/hooks/useTopoEdit.js +197 -141
  86. package/lib/hooks/useTopoEventListener.js +13 -6
  87. package/lib/index.js +5 -0
  88. package/lib/models/topoConfig.js +0 -1
  89. package/lib/models/topoMod.js +15 -10
  90. package/lib/topoCenter/components/Topo404.js +4 -1
  91. package/lib/topoCenter/components/TopoNoPermission.js +4 -1
  92. package/lib/topoCenter/components/TopoView.js +78 -33
  93. package/lib/topoCenter/components/Topology.js +3 -0
  94. package/lib/topoCenter/components/editor/propertyViews/edge/EdgePropertyView.js +22 -0
  95. package/lib/topoCenter/components/editor/propertyViews/edge/LinkPropertyView/Data/index.js +5 -21
  96. package/lib/topoCenter/components/editor/propertyViews/edge/LinkPropertyView/LinkPropertyView.js +13 -8
  97. package/lib/topoCenter/components/editor/propertyViews/edge/addLinkDrawer/AddLinkDrawer.js +87 -42
  98. package/lib/topoCenter/components/editor/propertyViews/edge/addLinkDrawer/components/editLinkInfo.js +61 -37
  99. package/lib/topoCenter/components/editor/propertyViews/edge/addLinkDrawer/index.module.scss +9 -0
  100. package/lib/topoCenter/components/editor/propertyViews/edge/addLinkDrawer/server.js +62 -18
  101. package/lib/topoCenter/components/editor/propertyViews/edge/link/BindExitLinkSelect.js +183 -0
  102. package/lib/topoCenter/components/editor/propertyViews/edge/link/LinkInfoPreview.js +1 -2
  103. package/lib/topoCenter/hooks/editor/useDeleteEdges.js +2 -3
  104. package/lib/topoCenter/utils/resourcePermissionUtil.js +20 -12
  105. package/lib/utils/topoData.js +15 -13
  106. package/package.json +5 -5
@@ -23,7 +23,7 @@ var _topo = _interopRequireDefault(require("@riil-frontend/component-topology-co
23
23
 
24
24
  var _ResourceTypeLimit = require("../../../../../../constants/ResourceTypeLimit");
25
25
 
26
- var _ahooks = require("ahooks");
26
+ var _lodash = _interopRequireDefault(require("lodash"));
27
27
 
28
28
  var _rlog = _interopRequireDefault(require("@riil-frontend/component-topology-utils/es/rlog"));
29
29
 
@@ -37,13 +37,14 @@ var _server = _interopRequireDefault(require("./server"));
37
37
 
38
38
  var _copyUtil = require("../../../../../../utils/copyUtil");
39
39
 
40
+ var _linkUtils = require("../../../../../../core/models/utils/linkUtils");
41
+
40
42
  var _htElementUtils = require("../../../../../../utils/htElementUtils");
41
43
 
42
44
  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); }
43
45
 
44
46
  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; }
45
47
 
46
- // import { Drawer } from "../../../../../../components/Drawer";
47
48
  var CollapsePanel = _collapse["default"].Panel;
48
49
 
49
50
  function AddLinkDrawer(props) {
@@ -80,18 +81,22 @@ function AddLinkDrawer(props) {
80
81
 
81
82
  var _useState4 = (0, _react.useState)(),
82
83
  sourceIFDoc = _useState4[0],
83
- setSourceIFDoc = _useState4[1]; // 保存后更新拓扑图状态
84
+ setSourceIFDoc = _useState4[1];
85
+
86
+ var _useState5 = (0, _react.useState)(),
87
+ targetIFDoc = _useState5[0],
88
+ setTargetIFDoc = _useState5[1]; // 保存后更新拓扑图状态
84
89
 
85
90
 
86
- var _useState5 = (0, _react.useState)([]),
87
- ciIdsConnectable = _useState5[0],
88
- setCiIdsConnectable = _useState5[1];
91
+ var _useState6 = (0, _react.useState)([]),
92
+ ciIdsConnectable = _useState6[0],
93
+ setCiIdsConnectable = _useState6[1];
89
94
 
90
95
  var linkNodesRef = (0, _react.useRef)();
91
96
 
92
97
  var getPortsById = /*#__PURE__*/function () {
93
98
  var _ref = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee(id) {
94
- var result, portsDoc, ports;
99
+ var result, links, ifTypes, ifDoc, usedPorts, portsDoc, ports;
95
100
  return _regenerator["default"].wrap(function _callee$(_context) {
96
101
  while (1) {
97
102
  switch (_context.prev = _context.next) {
@@ -101,14 +106,41 @@ function AddLinkDrawer(props) {
101
106
 
102
107
  case 2:
103
108
  result = _context.sent;
104
- // rlog.debug("端口列表", result);
105
- //const list = result[id];
109
+ _context.next = 5;
110
+ return _server["default"].queryLinksByNodeId(id);
111
+
112
+ case 5:
113
+ links = _context.sent;
114
+ ifTypes = result.map(function (item) {
115
+ return item.type;
116
+ });
117
+ console.log("端口类型列表", ifTypes);
118
+ _context.next = 10;
119
+ return (0, _linkUtils.getInterfaceObject)(ifTypes);
120
+
121
+ case 10:
122
+ ifDoc = _context.sent;
123
+ console.log("端口类型字典", ifDoc);
124
+ usedPorts = [];
125
+ links.data.map(function (link) {
126
+ usedPorts.push(link.attributes.destination_id);
127
+ usedPorts.push(link.attributes.source_id);
128
+ });
129
+ usedPorts = _lodash["default"].uniq(usedPorts);
130
+
131
+ _rlog["default"].debug("端口列表", result, links); //const list = result[id];
132
+
133
+
106
134
  portsDoc = {};
107
135
  ports = result.map(function (item) {
136
+ var _ifDoc$item$type$disp, _ifDoc$item$type;
137
+
108
138
  var obj = {
109
139
  value: item.id,
110
140
  label: item.name,
111
141
  type: item.type,
142
+ typeName: (_ifDoc$item$type$disp = (_ifDoc$item$type = ifDoc[item.type]) === null || _ifDoc$item$type === void 0 ? void 0 : _ifDoc$item$type.displayName) !== null && _ifDoc$item$type$disp !== void 0 ? _ifDoc$item$type$disp : "",
143
+ disabled: usedPorts.indexOf(item.id) >= 0,
112
144
  ratedBandwidth: parseInt(item.ratedBandwidth, 10)
113
145
  };
114
146
  portsDoc[item.id] = obj;
@@ -119,7 +151,7 @@ function AddLinkDrawer(props) {
119
151
  portsDoc: portsDoc
120
152
  });
121
153
 
122
- case 6:
154
+ case 19:
123
155
  case "end":
124
156
  return _context.stop();
125
157
  }
@@ -140,28 +172,31 @@ function AddLinkDrawer(props) {
140
172
  switch (_context2.prev = _context2.next) {
141
173
  case 0:
142
174
  linkNodesRef.current = e; // const { type, data } = e;
143
- // rlog.debug("接到打开创建链路抽屉信息", e);
175
+
176
+ _rlog["default"].debug("接到打开创建链路抽屉信息", e);
144
177
 
145
178
  setIsAddMode(true); // setTrue();
146
179
 
147
- _context2.prev = 2;
148
- _context2.next = 5;
180
+ _context2.prev = 3;
181
+ _context2.next = 6;
149
182
  return getPortsById(e.source._attrObject.id);
150
183
 
151
- case 5:
184
+ case 6:
152
185
  sourcePorts = _context2.sent;
153
- _context2.next = 8;
186
+ _context2.next = 9;
154
187
  return getPortsById(e.target._attrObject.id);
155
188
 
156
- case 8:
189
+ case 9:
157
190
  targetPorts = _context2.sent;
191
+ setSourceIFDoc(sourcePorts.portsDoc);
192
+ setTargetIFDoc(targetPorts.portsDoc);
158
193
  source = translationNode(e.source, sourcePorts);
159
194
  target = translationNode(e.target, targetPorts);
160
195
  editDispatchers.update({
161
196
  addLinkIsOpen: true,
162
197
  currentLink: null
163
198
  });
164
- connect_type = target.ciType !== "customNode" && target.ipAddress ? "phy" : "exit";
199
+ connect_type = target.ciType !== "customNode" && target.ipAddress && targetPorts.ports.length > 0 ? "phy" : "exit";
165
200
  setLink({
166
201
  source: source,
167
202
  target: target,
@@ -180,21 +215,21 @@ function AddLinkDrawer(props) {
180
215
  connect_type: connect_type
181
216
  }
182
217
  });
183
- _context2.next = 19;
218
+ _context2.next = 22;
184
219
  break;
185
220
 
186
- case 16:
187
- _context2.prev = 16;
188
- _context2.t0 = _context2["catch"](2);
221
+ case 19:
222
+ _context2.prev = 19;
223
+ _context2.t0 = _context2["catch"](3);
189
224
 
190
225
  _rlog["default"].error("出现异常", _context2.t0);
191
226
 
192
- case 19:
227
+ case 22:
193
228
  case "end":
194
229
  return _context2.stop();
195
230
  }
196
231
  }
197
- }, _callee2, null, [[2, 16]]);
232
+ }, _callee2, null, [[3, 19]]);
198
233
  }));
199
234
 
200
235
  return function handleEvent(_x2) {
@@ -230,11 +265,13 @@ function AddLinkDrawer(props) {
230
265
  case 6:
231
266
  targetPorts = _context3.sent;
232
267
  setSourceIFDoc(sourcePorts.portsDoc);
268
+ setTargetIFDoc(targetPorts.portsDoc);
233
269
  connect_type = currentLink.attributes["network_link.connect_type"] === "exit" ? "exit" : "phy";
234
270
  setLink({
235
271
  source: {
236
272
  id: currentLink.source,
237
273
  name: currentLink.attributes["network_link.source_device_id_object"].displayName,
274
+ ciId: currentLink.attributes["network_link.source_device_id"],
238
275
  ipAddress: currentLink.attributes["network_link.source_ipv4"],
239
276
  ciName: (_currentLink$attribut = currentLink.attributes.source_type_object) === null || _currentLink$attribut === void 0 ? void 0 : _currentLink$attribut.displayName,
240
277
  ciType: currentLink.attributes.source_type,
@@ -245,19 +282,21 @@ function AddLinkDrawer(props) {
245
282
  target: {
246
283
  id: currentLink.target,
247
284
  name: currentLink.attributes["network_link.destination_device_id_object"].displayName,
285
+ ciId: currentLink.attributes["network_link.destination_device_id"],
248
286
  ipAddress: currentLink.attributes["network_link.destination_ipv4"],
249
287
  ciName: (_currentLink$attribut2 = currentLink.attributes.destination_type_object) === null || _currentLink$attribut2 === void 0 ? void 0 : _currentLink$attribut2.displayName,
250
- ciType: currentLink.attributes.destination_type !== "" ? currentLink.attributes.destination_type : "customNode",
288
+ ciType: currentLink.target !== "" ? currentLink.attributes.destination_type : "customNode",
251
289
  interfaceTarget: currentLink.interfaceTarget,
252
290
  ports: (_targetPorts$ports = targetPorts.ports) !== null && _targetPorts$ports !== void 0 ? _targetPorts$ports : [],
253
291
  portsDoc: targetPorts.portsDoc
254
292
  },
255
293
  attributes: (0, _extends2["default"])({}, currentLink.attributes, {
294
+ linkId: currentLink.id,
256
295
  connect_type: connect_type
257
296
  })
258
297
  });
259
298
 
260
- case 10:
299
+ case 11:
261
300
  case "end":
262
301
  return _context3.stop();
263
302
  }
@@ -349,6 +388,7 @@ function AddLinkDrawer(props) {
349
388
  return {
350
389
  id: attrObject.id,
351
390
  name: attrObject.name,
391
+ ciId: attrObject.id,
352
392
  ipAddress: attrObject.ipAddress,
353
393
  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,
354
394
  ciType: (_attrObject$ciType = attrObject.ciType) !== null && _attrObject$ciType !== void 0 ? _attrObject$ciType : "customNode",
@@ -395,7 +435,7 @@ function AddLinkDrawer(props) {
395
435
  var edge = htTopo.createEdge(source, target, linkData);
396
436
 
397
437
  if (linkType === "exit" && target.getTag() === undefined) {
398
- // rlog.debug("addLinkToGraph-exit-target", target, target.getTag());
438
+ // rlog.debug("addLinkToGraph-export-target", target, target.getTag());
399
439
  target.a("name", targetName);
400
440
  }
401
441
  }
@@ -406,8 +446,9 @@ function AddLinkDrawer(props) {
406
446
  }
407
447
  };
408
448
 
409
- var mergeExitLinkData = function mergeExitLinkData(data, attributes) {
410
- return {
449
+ var mergeExportLinkData = function mergeExportLinkData(data, attributes) {
450
+ console.log("mergeExportLinkData", data, attributes);
451
+ return (0, _extends2["default"])({}, attributes, {
411
452
  id: data.id,
412
453
  name: data.name,
413
454
  source: data["network_link.source_device_id"],
@@ -416,7 +457,7 @@ function AddLinkDrawer(props) {
416
457
  interfaceSource: data["source_id"],
417
458
  interfaceTarget: data["destination_id"],
418
459
  ciType: data.ciType,
419
- attributes: (0, _extends2["default"])({}, attributes, {
460
+ attributes: (0, _extends2["default"])({}, attributes.attributes, {
420
461
  display_name: data.display_name,
421
462
  name: data.name,
422
463
  "network_link.actual_bandwidth": data["network_link.actual_bandwidth"],
@@ -428,9 +469,12 @@ function AddLinkDrawer(props) {
428
469
  use: data.use,
429
470
  source_id_object: {
430
471
  displayName: sourceIFDoc[data.source_id].label
472
+ },
473
+ destination_id_object: {
474
+ displayName: targetIFDoc[data.destination_id].label
431
475
  }
432
476
  })
433
- };
477
+ });
434
478
  };
435
479
 
436
480
  var onSave = /*#__PURE__*/function () {
@@ -476,14 +520,14 @@ function AddLinkDrawer(props) {
476
520
  _context5.prev = 15;
477
521
 
478
522
  if (!result) {
479
- _context5.next = 35;
523
+ _context5.next = 36;
480
524
  break;
481
525
  }
482
526
 
483
527
  config = topo.resourceConfig.getConfigFromHt(); // 新建后显示到图上
484
528
 
485
529
  if (!isAddMode) {
486
- _context5.next = 31;
530
+ _context5.next = 32;
487
531
  break;
488
532
  }
489
533
 
@@ -506,6 +550,7 @@ function AddLinkDrawer(props) {
506
550
  linkData = elements.find(function (element) {
507
551
  return element.id === result;
508
552
  });
553
+ console.log("创建成功-parm,linkData", parm, linkData);
509
554
  addLinkToGraph({
510
555
  linkData: (0, _copyUtil.clone)(linkData),
511
556
  linkType: linkType,
@@ -514,10 +559,10 @@ function AddLinkDrawer(props) {
514
559
 
515
560
  _message["default"].success("创建成功");
516
561
 
517
- _context5.next = 33;
562
+ _context5.next = 34;
518
563
  break;
519
564
 
520
- case 31:
565
+ case 32:
521
566
  // console.log("保存编辑信息", data, linkType);
522
567
  if (linkType === "exit") {
523
568
  edge = topo.getGraphView().dm().sm().ld();
@@ -533,7 +578,7 @@ function AddLinkDrawer(props) {
533
578
  linkAttrKey = links.findIndex(function (item) {
534
579
  return item.id === aobj.id;
535
580
  });
536
- newLinkData = mergeExitLinkData(edge.getAttrObject(), links[linkAttrKey]);
581
+ newLinkData = mergeExportLinkData(edge.getAttrObject(), links[linkAttrKey]);
537
582
  newLinks = (0, _copyUtil.clone)(links);
538
583
  newLinks.splice(linkAttrKey, 1, newLinkData);
539
584
  newData = (0, _extends2["default"])({}, topoState.data, {
@@ -546,27 +591,27 @@ function AddLinkDrawer(props) {
546
591
 
547
592
  _message["default"].success("保存成功");
548
593
 
549
- case 33:
594
+ case 34:
550
595
  editDispatchers.update({
551
596
  addLinkIsOpen: false,
552
597
  currentLink: null
553
598
  });
554
599
  topo.linkDynamicStyleExecutor.execute();
555
600
 
556
- case 35:
557
- _context5.next = 39;
601
+ case 36:
602
+ _context5.next = 40;
558
603
  break;
559
604
 
560
- case 37:
561
- _context5.prev = 37;
605
+ case 38:
606
+ _context5.prev = 38;
562
607
  _context5.t0 = _context5["catch"](15);
563
608
 
564
- case 39:
609
+ case 40:
565
610
  case "end":
566
611
  return _context5.stop();
567
612
  }
568
613
  }
569
- }, _callee5, null, [[15, 37]]);
614
+ }, _callee5, null, [[15, 38]]);
570
615
  }));
571
616
 
572
617
  return function onSave(_x3) {
@@ -31,6 +31,8 @@ var _radio = _interopRequireDefault(require("@alifd/next/lib/radio"));
31
31
 
32
32
  var _react = _interopRequireWildcard(require("react"));
33
33
 
34
+ var _validator = _interopRequireDefault(require("validator"));
35
+
34
36
  var _rlog = _interopRequireDefault(require("@riil-frontend/component-topology-utils/es/rlog"));
35
37
 
36
38
  var _indexModule = _interopRequireDefault(require("./index.module.scss"));
@@ -49,27 +51,17 @@ function parseValues(values) {
49
51
  }
50
52
 
51
53
  function EditLinkInfo(props) {
54
+ var _sourceValue$ipAddres2, _sourceValue$portsDoc5, _sourceValue$portsDoc6, _targetValue$portsDoc5, _targetValue$portsDoc6;
55
+
52
56
  var topo = props.topo,
53
57
  lineData = props.lineData,
54
58
  onClose = props.onClose,
55
- addLinkIsOpen = props.addLinkIsOpen,
56
59
  onSave = props.onSave,
57
60
  isAdd = props.isAdd,
58
61
  loading = props.loading;
59
-
60
- var _topo$store$useModel = topo.store.useModel("topoMod"),
61
- topoState = _topo$store$useModel[0],
62
- topoDispatchers = _topo$store$useModel[1];
63
-
64
- var _topo$store$useModel2 = topo.store.useModel("topoBizMod"),
65
- bizState = _topo$store$useModel2[0],
66
- bizDispatchers = _topo$store$useModel2[1]; // const { resAndMetrics } = topoState;
67
- // const { resAndMetrics } = bizState;
68
-
69
-
70
62
  var source = lineData.source,
71
63
  target = lineData.target,
72
- attributes = lineData.attributes; // rlog.debug("lineData-----init", source, target, targetValue.portsDoc);
64
+ attributes = lineData.attributes;
73
65
 
74
66
  var _useState = (0, _react.useState)(attributes),
75
67
  valus = _useState[0],
@@ -83,9 +75,9 @@ function EditLinkInfo(props) {
83
75
  targetValue = _useState3[0],
84
76
  setTarget = _useState3[1];
85
77
 
86
- var _useState4 = (0, _react.useState)(true),
87
- connectEnable = _useState4[0],
88
- setConnectEnable = _useState4[1];
78
+ var _useState4 = (0, _react.useState)(),
79
+ ratedBandwidth = _useState4[0],
80
+ setRatedBandwidth = _useState4[1];
89
81
 
90
82
  var fieldOnChange = function fieldOnChange(name, value) {
91
83
  var newValues = field.getValues();
@@ -103,9 +95,6 @@ function EditLinkInfo(props) {
103
95
 
104
96
  (0, _react.useEffect)(function () {
105
97
  setValus(attributes);
106
-
107
- _rlog["default"].debug("useEffect", source, target, attributes);
108
-
109
98
  setSource(source);
110
99
  setTarget(target);
111
100
  field.setValues(attributes);
@@ -130,7 +119,7 @@ function EditLinkInfo(props) {
130
119
 
131
120
  if (type === "exit") {
132
121
  connect = "exit";
133
- support = "m.exit_link";
122
+ support = "m.export_link";
134
123
  }
135
124
 
136
125
  return {
@@ -141,8 +130,11 @@ function EditLinkInfo(props) {
141
130
 
142
131
  var connectHandleChange = function connectHandleChange(v) {
143
132
  field.setValue("connect_type", v);
133
+ field.reset("destination_id");
144
134
  };
145
135
 
136
+ var getRatedBandwidth = function getRatedBandwidth() {};
137
+
146
138
  var portsHandleChange = function portsHandleChange(type, value) {
147
139
  var _sourceValue$portsDoc, _sourceValue$portsDoc2, _targetValue$portsDoc, _targetValue$portsDoc2;
148
140
 
@@ -160,28 +152,49 @@ function EditLinkInfo(props) {
160
152
  } // rlog.debug("network_link.actual_bandwidth", actualBandwidth);
161
153
 
162
154
 
155
+ setRatedBandwidth(actualBandwidth);
163
156
  field.setValue("network_link.actual_bandwidth", actualBandwidth);
164
157
  };
165
158
 
159
+ var checkName = function checkName(rule, value, callback) {
160
+ // const { validate, getValue } = field;
161
+ var displayName = value;
162
+ var links = topo.getEdges();
163
+ var usedNames = [];
164
+ links.map(function (link) {
165
+ console.log('checkName', link.id, lineData);
166
+
167
+ if (link.dtype === "link" && link.name && link.id !== lineData.attributes.linkId) {
168
+ usedNames.push(link.name);
169
+ }
170
+ });
171
+
172
+ if (usedNames.indexOf(displayName) >= 0) {
173
+ console.log("setError", checkName, usedNames, displayName); // field.setError("display_name", "链路名称重复");
174
+
175
+ return callback("链路名称重复");
176
+ } else {
177
+ return callback();
178
+ }
179
+ };
180
+
166
181
  var saveHandleChange = function saveHandleChange() {
167
182
  field.validate(function (errors, values) {
168
183
  if (errors) {
169
- _rlog["default"].debug("saveHandleChange-error", errors, values);
184
+ _rlog["default"].error("saveHandleChange-error", errors, values);
170
185
  } else {
171
186
  var _valus$destination_id, _sourceValue$portsDoc3, _sourceValue$portsDoc4, _targetValue$portsDoc3, _targetValue$portsDoc4, _targetValue$ipAddres, _sourceValue$ipAddres, _targetValue$id;
172
187
 
173
- _rlog["default"].debug("saveHandleChange", valus, source, target);
174
-
175
188
  var sourceId = valus["source_id"];
176
189
  var destinationId = (_valus$destination_id = valus["destination_id"]) !== null && _valus$destination_id !== void 0 ? _valus$destination_id : "";
177
190
  var sourceType = (_sourceValue$portsDoc3 = (_sourceValue$portsDoc4 = sourceValue.portsDoc[sourceId]) === null || _sourceValue$portsDoc4 === void 0 ? void 0 : _sourceValue$portsDoc4.type) !== null && _sourceValue$portsDoc3 !== void 0 ? _sourceValue$portsDoc3 : "";
178
191
  var destinationType = (_targetValue$portsDoc3 = (_targetValue$portsDoc4 = targetValue.portsDoc[destinationId]) === null || _targetValue$portsDoc4 === void 0 ? void 0 : _targetValue$portsDoc4.type) !== null && _targetValue$portsDoc3 !== void 0 ? _targetValue$portsDoc3 : "";
179
192
  var typeJudge = linkTypeJudge(sourceType, destinationType, valus["connect_type"]);
180
- var destination_ipv4 = valus["connect_type"] !== "exit" ? (_targetValue$ipAddres = targetValue.ipAddress) !== null && _targetValue$ipAddres !== void 0 ? _targetValue$ipAddres : valus["network_link.destination_ipv4"] : valus["network_link.destination_ipv4"];
193
+ var destination_ipv4 = (_targetValue$ipAddres = targetValue.ipAddress) !== null && _targetValue$ipAddres !== void 0 ? _targetValue$ipAddres : valus["network_link.destination_ipv4"];
181
194
  var obj = {
182
195
  display_name: valus["display_name"],
183
196
  // 链路名称
184
- name: valus["display_name"],
197
+ name: isAdd ? valus["display_name"] : attributes["name"],
185
198
  // 链路名称
186
199
  "network_link.source_ipv4": (_sourceValue$ipAddres = sourceValue.ipAddress) !== null && _sourceValue$ipAddres !== void 0 ? _sourceValue$ipAddres : valus["network_link.source_ipv4"],
187
200
  // 源IP
@@ -220,6 +233,17 @@ function EditLinkInfo(props) {
220
233
  obj["destination_type"] = "";
221
234
  }
222
235
 
236
+ if (isAdd) {
237
+ obj["network_link.network_category"] = "CAN";
238
+ obj["network_link.work_mode"] = "AandS"; // 工作模式
239
+
240
+ obj.rated_bandwidth = ratedBandwidth; // 额定带宽
241
+
242
+ obj["network_link.role"] = "master";
243
+ }
244
+
245
+ console.log("保存数据-obj", obj);
246
+
223
247
  if (isAdd) {
224
248
  onSave(obj);
225
249
  } else {
@@ -291,17 +315,16 @@ function EditLinkInfo(props) {
291
315
  }, /*#__PURE__*/_react["default"].createElement(FormItem, (0, _extends2["default"])({}, formItemLayout, {
292
316
  labelAlign: labelAlign,
293
317
  label: "\u6E90\u8282\u70B9IP"
294
- }), sourceValue.ipAddress ? /*#__PURE__*/_react["default"].createElement("div", {
318
+ }), /*#__PURE__*/_react["default"].createElement("div", {
295
319
  className: _indexModule["default"].label
296
- }, sourceValue.ipAddress) : /*#__PURE__*/_react["default"].createElement(_input["default"], {
297
- placeholder: "\u8BF7\u8F93\u5165",
298
- name: "network_link.source_ipv4",
299
- maxLength: 128
300
- }))), /*#__PURE__*/_react["default"].createElement(Col, {
320
+ }, (_sourceValue$ipAddres2 = sourceValue.ipAddress) !== null && _sourceValue$ipAddres2 !== void 0 ? _sourceValue$ipAddres2 : '-'))), /*#__PURE__*/_react["default"].createElement(Col, {
301
321
  span: "12"
302
322
  }, /*#__PURE__*/_react["default"].createElement(FormItem, (0, _extends2["default"])({}, formItemLayout, {
303
323
  labelAlign: labelAlign,
304
- label: "\u76EE\u7684\u8282\u70B9IP"
324
+ label: "\u76EE\u7684\u8282\u70B9IP",
325
+ pattern: /^((25[0-5]|2[0-4]\d|((1\d{2})|([1-9]?\d)))\.){3}(25[0-5]|2[0-4]\d|((1\d{2})|([1-9]?\d)))$/,
326
+ patternTrigger: "onBlur",
327
+ patternMessage: "IP\u5730\u5740\u683C\u5F0F\u4E0D\u6B63\u786E"
305
328
  }), targetIpComp(target)))), /*#__PURE__*/_react["default"].createElement(Row, {
306
329
  gutter: "16"
307
330
  }, /*#__PURE__*/_react["default"].createElement(Col, {
@@ -311,7 +334,7 @@ function EditLinkInfo(props) {
311
334
  label: "\u6E90\u7AEF\u53E3",
312
335
  required: true,
313
336
  requiredMessage: "\u6E90\u7AEF\u53E3\u4E0D\u80FD\u4E3A\u7A7A"
314
- }), sourceValue.ipAddress ? /*#__PURE__*/_react["default"].createElement(_select["default"], {
337
+ }), sourceValue.ciId ? /*#__PURE__*/_react["default"].createElement(_select["default"], {
315
338
  name: "source_id",
316
339
  disabled: sourceValue.ports.length === 0,
317
340
  className: _indexModule["default"].selectList,
@@ -343,14 +366,14 @@ function EditLinkInfo(props) {
343
366
  label: "\u8D44\u6E90\u7C7B\u578B"
344
367
  }), /*#__PURE__*/_react["default"].createElement("div", {
345
368
  className: _indexModule["default"].label
346
- }, sourceValue.ciName))), /*#__PURE__*/_react["default"].createElement(Col, {
369
+ }, (_sourceValue$portsDoc5 = (_sourceValue$portsDoc6 = sourceValue.portsDoc[valus.source_id]) === null || _sourceValue$portsDoc6 === void 0 ? void 0 : _sourceValue$portsDoc6.typeName) !== null && _sourceValue$portsDoc5 !== void 0 ? _sourceValue$portsDoc5 : sourceValue.ciName))), /*#__PURE__*/_react["default"].createElement(Col, {
347
370
  span: "12"
348
371
  }, /*#__PURE__*/_react["default"].createElement(FormItem, (0, _extends2["default"])({}, formItemLayout, {
349
372
  labelAlign: labelAlign,
350
373
  label: "\u8D44\u6E90\u7C7B\u578B"
351
374
  }), /*#__PURE__*/_react["default"].createElement("div", {
352
375
  className: _indexModule["default"].label
353
- }, targetValue.ciName)))), /*#__PURE__*/_react["default"].createElement(Row, {
376
+ }, (_targetValue$portsDoc5 = (_targetValue$portsDoc6 = targetValue.portsDoc[valus.destination_id]) === null || _targetValue$portsDoc6 === void 0 ? void 0 : _targetValue$portsDoc6.typeName) !== null && _targetValue$portsDoc5 !== void 0 ? _targetValue$portsDoc5 : targetValue.ciName)))), /*#__PURE__*/_react["default"].createElement(Row, {
354
377
  gutter: "16"
355
378
  }, /*#__PURE__*/_react["default"].createElement(Col, {
356
379
  span: "24"
@@ -362,7 +385,8 @@ function EditLinkInfo(props) {
362
385
  requiredTrigger: "onBlur",
363
386
  pattern: /^[^'"\\%]+[^'"\\%]*[^'"\\%]*$/,
364
387
  patternTrigger: "onBlur",
365
- patternMessage: "\u4E0D\u5141\u8BB8\u8F93\u5165\u2018\u3001\u201C\u3001\\\u3001%"
388
+ patternMessage: "\u4E0D\u5141\u8BB8\u8F93\u5165\u2018\u3001\u201C\u3001\\\u3001%",
389
+ validator: checkName
366
390
  }), /*#__PURE__*/_react["default"].createElement(_input["default"], {
367
391
  placeholder: "\u8BF7\u8F93\u5165",
368
392
  name: "display_name",
@@ -382,7 +406,7 @@ function EditLinkInfo(props) {
382
406
  }, /*#__PURE__*/_react["default"].createElement(_radio["default"], {
383
407
  id: "phy",
384
408
  value: "phy",
385
- disabled: target.ciType === "customNode" || !targetValue.ipAddress
409
+ disabled: target.ciType === "customNode" || !targetValue.ipAddress || targetValue.ports.length === 0
386
410
  }, "\u7269\u7406/\u805A\u5408"), /*#__PURE__*/_react["default"].createElement(_radio["default"], {
387
411
  id: "exit",
388
412
  value: "exit"
@@ -1,3 +1,12 @@
1
+ @import '~@alifd/next/variables.scss';
2
+
1
3
  .drawer {
2
4
  width: 504px;
5
+
6
+ :global {
7
+ .#{$css-prefix}drawer-body {
8
+ padding: 20px 24px 50px 20px;
9
+ }
10
+ }
11
+
3
12
  }