@riil-frontend/component-topology 12.1.0-dev.9 → 12.1.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 (54) hide show
  1. package/build/1.js +1 -1
  2. package/build/index.css +1 -1
  3. package/build/index.js +14 -14
  4. package/es/components/ResourceSelectDrawer/ResourceSelectDrawer.js +1 -1
  5. package/es/core/components/TopoView/topoView.js +7 -4
  6. package/es/core/editor/components/Sidebar/views/ImagePanel/ImagePanel.js +11 -3
  7. package/es/core/editor/components/settings/core/updateElementProperty.js +3 -2
  8. package/es/core/editor/components/settings/propertyViews/view/GlobalEdgeToggle.js +2 -2
  9. package/es/core/editor/hooks/useKeyboardShortcut.js +4 -0
  10. package/es/core/editor/hooks/useNewElementTheme.js +20 -16
  11. package/es/core/hooks/useGraphAlarmDisplay.js +4 -0
  12. package/es/core/hooks/usePolling.js +2 -1
  13. package/es/core/hooks/useTopoEdit.js +208 -243
  14. package/es/core/models/AttributeMetricDisplay.js +4 -3
  15. package/es/core/models/HistoryManager.js +11 -9
  16. package/es/core/models/TopoApp.js +17 -15
  17. package/es/core/models/topoData.js +7 -14
  18. package/es/core/models/utils/linkUtils.js +2 -2
  19. package/es/core/store/models/topoConfig.js +7 -11
  20. package/es/core/utils/edgeUtil.js +7 -11
  21. package/es/core/viewer/components/plugins/ResourceDetail/components/ResourceOverview/EventsCard.js +1 -1
  22. package/es/core/viewer/components/plugins/ResourceDetail/components/ResourceOverview/components/LinkTopo/LinkTopo.module.scss +1 -1
  23. package/es/networkTopo/models/LinkDynamicStyleExecutor.js +7 -63
  24. package/es/networkTopo/utils/exitLinkUtil.js +23 -11
  25. package/es/style.js +1 -1
  26. package/es/utils/clusterUtil.js +3 -3
  27. package/es/utils/htElementUtils.js +11 -109
  28. package/lib/components/ResourceSelectDrawer/ResourceSelectDrawer.js +1 -1
  29. package/lib/core/components/TopoView/topoView.js +15 -19
  30. package/lib/core/editor/components/Sidebar/views/ImagePanel/ImagePanel.js +12 -3
  31. package/lib/core/editor/components/settings/core/updateElementProperty.js +7 -2
  32. package/lib/core/editor/components/settings/propertyViews/view/GlobalEdgeToggle.js +2 -2
  33. package/lib/core/editor/hooks/useKeyboardShortcut.js +4 -0
  34. package/lib/core/editor/hooks/useNewElementTheme.js +20 -16
  35. package/lib/core/hooks/useGraphAlarmDisplay.js +4 -0
  36. package/lib/core/hooks/usePolling.js +6 -5
  37. package/lib/core/hooks/useTopoEdit.js +214 -267
  38. package/lib/core/models/AttributeMetricDisplay.js +6 -6
  39. package/lib/core/models/HistoryManager.js +13 -17
  40. package/lib/core/models/TopoApp.js +18 -15
  41. package/lib/core/models/topoData.js +7 -14
  42. package/lib/core/models/utils/linkUtils.js +1 -1
  43. package/lib/core/store/models/topoConfig.js +13 -25
  44. package/lib/core/utils/edgeUtil.js +6 -10
  45. package/lib/core/viewer/components/plugins/ResourceDetail/components/ResourceOverview/EventsCard.js +1 -1
  46. package/lib/core/viewer/components/plugins/ResourceDetail/components/ResourceOverview/components/LinkTopo/LinkTopo.module.scss +1 -1
  47. package/lib/networkTopo/models/LinkDynamicStyleExecutor.js +6 -64
  48. package/lib/networkTopo/utils/exitLinkUtil.js +23 -11
  49. package/lib/style.js +1 -1
  50. package/lib/utils/clusterUtil.js +2 -2
  51. package/lib/utils/htElementUtils.js +12 -120
  52. package/package.json +2 -2
  53. package/es/networkTopo/models/LinkTagsTipsBuilder.js +0 -235
  54. package/lib/networkTopo/models/LinkTagsTipsBuilder.js +0 -245
@@ -4,19 +4,19 @@ import _Button from "@alifd/next/es/button";
4
4
  import _Dialog from "@alifd/next/es/dialog";
5
5
  import _asyncToGenerator from "@babel/runtime/helpers/asyncToGenerator";
6
6
  import _regeneratorRuntime from "@babel/runtime/regenerator";
7
- import React, { useCallback, useEffect, useMemo, useState } from "react";
8
- import _ from "lodash";
9
- import rlog from "@riil-frontend/component-topology-utils/es/rlog";
7
+ import React, { useCallback, useState } from "react";
8
+ import Logger from 'loglevel';
10
9
  import { TopoEvent } from "@riil-frontend/component-topology-graph";
11
10
  import { TPL_BLANK, TPL_TREE } from "../../utils/template";
12
- import { getGroupElementByTag, isEdge, isExistedElement, isGroup, isLayer, isNode, getGroupChildren } from "../../utils/htElementUtils";
11
+ import { getGroupElementByTag, isEdge, containsElement, isGroup, isLayer, isNode, getGroupChildren, getElements } from "../../utils/htElementUtils";
13
12
  import useResourceConfig from "./useResourceConfig";
14
13
  import useGroupAddResource from "./useGroupAddResource";
15
14
  import { findGroupChildren } from "../../utils/topoData";
16
15
  import { isResourceElement } from "../../utils/htElementDataUtil";
17
16
  import { isClusterHtElement, isClusterMemberHtElement } from "../../utils/clusterUtil";
18
- import { isExitLink, mergeExportLinkData } from "../models/utils/linkUtils";
17
+ import { isExitLink } from "../models/utils/linkUtils";
19
18
  import { isUniqueIp, buildIpNode } from "../../networkTopo/utils/exitLinkUtil";
19
+ var rlog = Logger.getLogger('topo');
20
20
 
21
21
  var useTopoEdit = function useTopoEdit(params) {
22
22
  var topo = params.topo,
@@ -193,48 +193,7 @@ var useTopoEdit = function useTopoEdit(params) {
193
193
  return onOk;
194
194
  }()
195
195
  });
196
- }; // const deleteGroupFooterBtn = () => {
197
- // return (
198
- // <div>
199
- // <Button type="primary" onClick={doDeleteOnlyGroup()}>
200
- // 仅删除区域
201
- // </Button>
202
- // <Button type="primary" onClick={doDeleteOnlyGroup()}>
203
- // 确定
204
- // </Button>
205
- // </div>
206
- // );
207
- // };
208
- // const [groupDeleteVisible, setGroupDeleteVisible] = useState(false);
209
- // function doDeleteOnlyGroup(data,group) {
210
- // topo.historyManager.beginTransaction();
211
- // console.log("仅删除区域", topo.view.topoClient, data);
212
- // const children = getGroupChildren(group);
213
- // children.map((child) => {
214
- // child.setParent(null);
215
- // // var viewRect = topo.getGraphView().getViewRect();
216
- // // var nodeRect = child.getRect();
217
- // // child.setPosition(
218
- // // viewRect.x + nodeRect.width + 2,
219
- // // viewRect.y + nodeRect.height + 4
220
- // // ); // 解决集群从区域内移出时,连线位置未更新的问题
221
- // setTimeout(function () {
222
- // child.iv();
223
- // topo.historyManager.endTransaction();
224
- // }, 50);
225
- // });
226
- // topo.view.topoClient.deleteGroup(data);
227
- // topo.historyManager.endTransaction();
228
- // setGroupDeleteVisible(false);
229
- // // console.log("仅删除区域", children, group);
230
- // }
231
- // function doDelete(data) {
232
- // topo.historyManager.beginTransaction();
233
- // // FIXME 。如果命中其他的动态条件,则立即显示
234
- // topo.view.topoClient.deleteGroup(data);
235
- // setGroupDeleteVisible(false);
236
- // }
237
-
196
+ };
238
197
  /**
239
198
  * 删除容器。
240
199
  *
@@ -265,21 +224,17 @@ var useTopoEdit = function useTopoEdit(params) {
265
224
  // content: "若执行相关操作,此区域包含的内容也会一同被删除,确定删除吗?",
266
225
  content: "是否仅删除区域或将区域包含的内容一同删除?",
267
226
  footer: [/*#__PURE__*/React.createElement(_Button, {
227
+ key: "1",
268
228
  type: "normal",
269
229
  onClick: doDeleteOnlyGroup,
270
230
  style: {
271
231
  marginRight: "15px"
272
232
  }
273
233
  }, "\u4EC5\u5220\u9664\u533A\u57DF"), /*#__PURE__*/React.createElement(_Button, {
234
+ key: "2",
274
235
  type: "normal",
275
236
  onClick: doDelete
276
237
  }, "\u5168\u90E8\u5220\u9664")],
277
- // okProps: {
278
- // children: "仅删除区域",
279
- // type: "normal",
280
- // className: "next-btn-normal",
281
- // },
282
- // cancelProps: { children: "全部删除" },
283
238
  messageProps: {
284
239
  type: "warning"
285
240
  }
@@ -290,13 +245,7 @@ var useTopoEdit = function useTopoEdit(params) {
290
245
  console.log("仅删除区域", topo.view.topoClient, data);
291
246
  var children = getGroupChildren(group);
292
247
  children.map(function (child) {
293
- child.setParent(null); // var viewRect = topo.getGraphView().getViewRect();
294
- // var nodeRect = child.getRect();
295
- // child.setPosition(
296
- // viewRect.x + nodeRect.width + 2,
297
- // viewRect.y + nodeRect.height + 4
298
- // ); // 解决集群从区域内移出时,连线位置未更新的问题
299
-
248
+ child.setParent(null);
300
249
  setTimeout(function () {
301
250
  child.iv();
302
251
  topo.historyManager.endTransaction();
@@ -315,10 +264,6 @@ var useTopoEdit = function useTopoEdit(params) {
315
264
  }
316
265
  };
317
266
 
318
- var deleteNode = function deleteNode(node) {
319
- emitEvent(TopoEvent.EVENT_TRIGGER_DELETE, node);
320
- };
321
-
322
267
  var handleDeleteNode = function handleDeleteNode(element) {
323
268
  var _topo$options$editor;
324
269
 
@@ -335,46 +280,34 @@ var useTopoEdit = function useTopoEdit(params) {
335
280
  if (typeof onNodeDelete === "function") {
336
281
  onNodeDelete(data);
337
282
  } else {
338
- deleteNode(data);
283
+ emitEvent(TopoEvent.EVENT_TRIGGER_DELETE, data);
339
284
  }
340
285
  }
341
286
  }; // 删除关联在节点上的出口链路
342
287
 
343
288
 
344
- var deleteExLink = /*#__PURE__*/function () {
345
- var _ref4 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee4(node) {
346
- var _node$getEdges$toArra, _node$getEdges;
347
-
348
- var edges;
349
- return _regeneratorRuntime.wrap(function _callee4$(_context4) {
350
- while (1) switch (_context4.prev = _context4.next) {
351
- case 0:
352
- // console.log("删除关联在节点上的出口链路- node, config", node, config);
353
- edges = (_node$getEdges$toArra = (_node$getEdges = node.getEdges()) === null || _node$getEdges === void 0 ? void 0 : _node$getEdges.toArray()) !== null && _node$getEdges$toArra !== void 0 ? _node$getEdges$toArra : [];
289
+ var deleteExLink = function deleteExLink(node) {
290
+ var _node$getEdges$toArra, _node$getEdges;
354
291
 
355
- if (edges.length > 0) {
356
- edges.map(function (edge) {
357
- if (edge.getTag()) {
358
- var link = topo.dataModel.getDataById(edge.getTag());
292
+ rlog.debug("删除关联在节点上的出口链路", {
293
+ node: node
294
+ });
295
+ var edges = (_node$getEdges$toArra = (_node$getEdges = node.getEdges()) === null || _node$getEdges === void 0 ? void 0 : _node$getEdges.toArray()) !== null && _node$getEdges$toArra !== void 0 ? _node$getEdges$toArra : [];
359
296
 
360
- if (link && isExitLink(link)) {
361
- topo.getGraphView().dm().remove(edge);
362
- }
363
- }
364
- });
365
- }
297
+ if (edges.length > 0) {
298
+ edges.map(function (edge) {
299
+ if (edge.getTag()) {
300
+ var link = topo.dataModel.getDataById(edge.getTag());
366
301
 
367
- case 2:
368
- case "end":
369
- return _context4.stop();
302
+ if (link && isExitLink(link)) {
303
+ topo.getGraphView().dm().remove(edge);
304
+ }
370
305
  }
371
- }, _callee4);
372
- }));
306
+ });
307
+ }
308
+ };
373
309
 
374
- return function deleteExLink(_x3) {
375
- return _ref4.apply(this, arguments);
376
- };
377
- }();
310
+ var batchDeleteSelectedElement = function batchDeleteSelectedElement() {};
378
311
 
379
312
  var onDeleteElement = function onDeleteElement(data) {
380
313
  var dtype = data.dtype;
@@ -425,7 +358,7 @@ var useTopoEdit = function useTopoEdit(params) {
425
358
  function findUNExistedLinkElements(elements) {
426
359
  var dm = topo.getDataModel();
427
360
  var newLinkElements = elements.filter(function (element) {
428
- return (element.type === "link" || element.type === "linkGroup") && !isExistedElement(topo.getHtTopo(), dm, element);
361
+ return (element.type === "link" || element.type === "linkGroup") && !containsElement(dm, element);
429
362
  });
430
363
  return newLinkElements;
431
364
  }
@@ -438,41 +371,56 @@ var useTopoEdit = function useTopoEdit(params) {
438
371
 
439
372
  function findUNExistedElements(elements) {
440
373
  var dm = topo.getDataModel();
441
- var newLinkElements = elements.filter(function (element) {
442
- return !isExistedElement(topo.getHtTopo(), dm, element);
374
+ var unExistedElements = elements.filter(function (element) {
375
+ return !containsElement(dm, element);
443
376
  });
444
- return newLinkElements;
377
+ return unExistedElements;
445
378
  }
446
379
  /**
447
- * 关联容器的资源
380
+ * 区域关联资源
381
+ * @param {{ id, tag }} group
382
+ * @param {*} resources
448
383
  */
449
384
 
450
385
 
451
- function bindGroupResources(_x4, _x5) {
386
+ function bindGroupResources(_x3, _x4) {
452
387
  return _bindGroupResources.apply(this, arguments);
453
388
  }
454
389
 
455
390
  function _bindGroupResources() {
456
- _bindGroupResources = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee10(group, resources) {
457
- var id, tag, _yield$editDispatcher2, elements, nodeElements, newLinkElements, updateElements;
391
+ _bindGroupResources = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee9(group, resources) {
392
+ var _yield$editDispatcher2, elements, dm, needDeleteHtDatas, nodeElements, newLinkElements, updateElements;
458
393
 
459
- return _regeneratorRuntime.wrap(function _callee10$(_context10) {
460
- while (1) switch (_context10.prev = _context10.next) {
394
+ return _regeneratorRuntime.wrap(function _callee9$(_context9) {
395
+ while (1) switch (_context9.prev = _context9.next) {
461
396
  case 0:
462
- id = group.id, tag = group.tag;
463
- rlog.debug("bindGroupResources--id, tag", id, tag);
397
+ rlog.debug("区域关联资源", {
398
+ group: group,
399
+ resources: resources
400
+ });
464
401
  topo.historyManager.beginTransaction();
465
- _context10.next = 5;
402
+ _context9.next = 4;
466
403
  return resourceConfig.updateGroupResources(group, resources);
467
404
 
468
- case 5:
469
- _context10.next = 7;
405
+ case 4:
406
+ _context9.next = 6;
470
407
  return editDispatchers.fetchDataByConfig();
471
408
 
472
- case 7:
473
- _yield$editDispatcher2 = _context10.sent;
409
+ case 6:
410
+ _yield$editDispatcher2 = _context9.sent;
474
411
  elements = _yield$editDispatcher2.elements;
475
- // 区域里的子区域及子区域的节点、新增的链路
412
+ rlog.debug("区域关联资源: 元素列表", elements); // 先删除多余的元素
413
+
414
+ dm = topo.getDataModel();
415
+ needDeleteHtDatas = getElements(dm).filter(function (htData) {
416
+ return htData.a('id') && !elements.find(function (ele) {
417
+ return ele.id === htData.a('id');
418
+ });
419
+ });
420
+ needDeleteHtDatas.forEach(function (htData) {
421
+ return dm.remove(htData);
422
+ }); // 区域里的所有子节点子区域、新增的链路
423
+
476
424
  nodeElements = findGroupChildren(elements, group);
477
425
  newLinkElements = findUNExistedLinkElements(elements);
478
426
  updateElements = [].concat(nodeElements, newLinkElements);
@@ -487,16 +435,16 @@ var useTopoEdit = function useTopoEdit(params) {
487
435
 
488
436
  topo.historyManager.endTransaction();
489
437
 
490
- case 14:
438
+ case 17:
491
439
  case "end":
492
- return _context10.stop();
440
+ return _context9.stop();
493
441
  }
494
- }, _callee10);
442
+ }, _callee9);
495
443
  }));
496
444
  return _bindGroupResources.apply(this, arguments);
497
445
  }
498
446
 
499
- function addGroupResources(_x6, _x7) {
447
+ function addGroupResources(_x5, _x6) {
500
448
  return _addGroupResources.apply(this, arguments);
501
449
  }
502
450
  /**
@@ -505,10 +453,10 @@ var useTopoEdit = function useTopoEdit(params) {
505
453
 
506
454
 
507
455
  function _addGroupResources() {
508
- _addGroupResources = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee11(group, newResourceIds) {
456
+ _addGroupResources = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee10(group, newResourceIds) {
509
457
  var groupConfig, resources, groupData;
510
- return _regeneratorRuntime.wrap(function _callee11$(_context11) {
511
- while (1) switch (_context11.prev = _context11.next) {
458
+ return _regeneratorRuntime.wrap(function _callee10$(_context10) {
459
+ while (1) switch (_context10.prev = _context10.next) {
512
460
  case 0:
513
461
  groupConfig = resourceConfig.getGroupConfigByElement(group);
514
462
  resources = {
@@ -518,19 +466,19 @@ var useTopoEdit = function useTopoEdit(params) {
518
466
  id: group.getTag(),
519
467
  tag: group.a("tag")
520
468
  };
521
- _context11.next = 5;
469
+ _context10.next = 5;
522
470
  return bindGroupResources(groupData, resources);
523
471
 
524
472
  case 5:
525
473
  case "end":
526
- return _context11.stop();
474
+ return _context10.stop();
527
475
  }
528
- }, _callee11);
476
+ }, _callee10);
529
477
  }));
530
478
  return _addGroupResources.apply(this, arguments);
531
479
  }
532
480
 
533
- function bindViewResources(_x8) {
481
+ function bindViewResources(_x7) {
534
482
  return _bindViewResources.apply(this, arguments);
535
483
  }
536
484
  /**
@@ -542,24 +490,24 @@ var useTopoEdit = function useTopoEdit(params) {
542
490
 
543
491
 
544
492
  function _bindViewResources() {
545
- _bindViewResources = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee12(data) {
493
+ _bindViewResources = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee11(data) {
546
494
  var config, result, _elements;
547
495
 
548
- return _regeneratorRuntime.wrap(function _callee12$(_context12) {
549
- while (1) switch (_context12.prev = _context12.next) {
496
+ return _regeneratorRuntime.wrap(function _callee11$(_context11) {
497
+ while (1) switch (_context11.prev = _context11.next) {
550
498
  case 0:
551
499
  // console.log("关联视图的资源", data);
552
500
  config = resourceConfig.getConfig();
553
501
  config.resources = data;
554
- _context12.next = 4;
502
+ _context11.next = 4;
555
503
  return resourceConfig.updateConfig(config);
556
504
 
557
505
  case 4:
558
- _context12.next = 6;
506
+ _context11.next = 6;
559
507
  return editDispatchers.fetchDataByConfig();
560
508
 
561
509
  case 6:
562
- result = _context12.sent;
510
+ result = _context11.sent;
563
511
  console.log("fetchDataByConfig", result);
564
512
 
565
513
  if (result) {
@@ -573,35 +521,35 @@ var useTopoEdit = function useTopoEdit(params) {
573
521
 
574
522
  case 9:
575
523
  case "end":
576
- return _context12.stop();
524
+ return _context11.stop();
577
525
  }
578
- }, _callee12);
526
+ }, _callee11);
579
527
  }));
580
528
  return _bindViewResources.apply(this, arguments);
581
529
  }
582
530
 
583
- function addLayerResources(_x9, _x10) {
531
+ function addLayerResources(_x8, _x9) {
584
532
  return _addLayerResources.apply(this, arguments);
585
533
  }
586
534
 
587
535
  function _addLayerResources() {
588
- _addLayerResources = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee13(group, newResourceIds) {
536
+ _addLayerResources = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee12(group, newResourceIds) {
589
537
  var _yield$editDispatcher3, elements, newElements;
590
538
 
591
- return _regeneratorRuntime.wrap(function _callee13$(_context13) {
592
- while (1) switch (_context13.prev = _context13.next) {
539
+ return _regeneratorRuntime.wrap(function _callee12$(_context12) {
540
+ while (1) switch (_context12.prev = _context12.next) {
593
541
  case 0:
594
542
  topo.historyManager.beginTransaction(); // 构造新的配置
595
543
 
596
- _context13.next = 3;
544
+ _context12.next = 3;
597
545
  return resourceConfig.addLayerStaticResources(group, newResourceIds);
598
546
 
599
547
  case 3:
600
- _context13.next = 5;
548
+ _context12.next = 5;
601
549
  return editDispatchers.fetchDataByConfig();
602
550
 
603
551
  case 5:
604
- _yield$editDispatcher3 = _context13.sent;
552
+ _yield$editDispatcher3 = _context12.sent;
605
553
  elements = _yield$editDispatcher3.elements;
606
554
  // 2022-11-10 修复 添加资源后分层重新布局问题,仅布局新增资源。替换api topo.updateElements(data)
607
555
  newElements = findUNExistedElements(elements);
@@ -624,32 +572,32 @@ var useTopoEdit = function useTopoEdit(params) {
624
572
 
625
573
  case 14:
626
574
  case "end":
627
- return _context13.stop();
575
+ return _context12.stop();
628
576
  }
629
- }, _callee13);
577
+ }, _callee12);
630
578
  }));
631
579
  return _addLayerResources.apply(this, arguments);
632
580
  }
633
581
 
634
- function addResourceToFirstLayer(_x11) {
582
+ function addResourceToFirstLayer(_x10) {
635
583
  return _addResourceToFirstLayer.apply(this, arguments);
636
584
  }
637
585
 
638
586
  function _addResourceToFirstLayer() {
639
- _addResourceToFirstLayer = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee14(data) {
587
+ _addResourceToFirstLayer = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee13(data) {
640
588
  var group;
641
- return _regeneratorRuntime.wrap(function _callee14$(_context14) {
642
- while (1) switch (_context14.prev = _context14.next) {
589
+ return _regeneratorRuntime.wrap(function _callee13$(_context13) {
590
+ while (1) switch (_context13.prev = _context13.next) {
643
591
  case 0:
644
592
  group = resourceConfig.getGroups()[0];
645
- _context14.next = 3;
593
+ _context13.next = 3;
646
594
  return addLayerResources(group, data);
647
595
 
648
596
  case 3:
649
597
  case "end":
650
- return _context14.stop();
598
+ return _context13.stop();
651
599
  }
652
- }, _callee14);
600
+ }, _callee13);
653
601
  }));
654
602
  return _addResourceToFirstLayer.apply(this, arguments);
655
603
  }
@@ -681,27 +629,27 @@ var useTopoEdit = function useTopoEdit(params) {
681
629
 
682
630
 
683
631
  var onSaveComboRes = /*#__PURE__*/function () {
684
- var _ref5 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee5(data) {
685
- return _regeneratorRuntime.wrap(function _callee5$(_context5) {
686
- while (1) switch (_context5.prev = _context5.next) {
632
+ var _ref4 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee4(data) {
633
+ return _regeneratorRuntime.wrap(function _callee4$(_context4) {
634
+ while (1) switch (_context4.prev = _context4.next) {
687
635
  case 0:
688
636
  rlog.debug("关联资源-----onSaveComboRes", data);
689
637
  topo.historyManager.beginTransaction();
690
638
 
691
639
  if (!(getAddResourceType() === "addToFirstLayer")) {
692
- _context5.next = 7;
640
+ _context4.next = 7;
693
641
  break;
694
642
  }
695
643
 
696
- _context5.next = 5;
644
+ _context4.next = 5;
697
645
  return addResourceToFirstLayer(data);
698
646
 
699
647
  case 5:
700
- _context5.next = 9;
648
+ _context4.next = 9;
701
649
  break;
702
650
 
703
651
  case 7:
704
- _context5.next = 9;
652
+ _context4.next = 9;
705
653
  return bindViewResources(data);
706
654
 
707
655
  case 9:
@@ -713,22 +661,22 @@ var useTopoEdit = function useTopoEdit(params) {
713
661
 
714
662
  case 12:
715
663
  case "end":
716
- return _context5.stop();
664
+ return _context4.stop();
717
665
  }
718
- }, _callee5);
666
+ }, _callee4);
719
667
  }));
720
668
 
721
- return function onSaveComboRes(_x12) {
722
- return _ref5.apply(this, arguments);
669
+ return function onSaveComboRes(_x11) {
670
+ return _ref4.apply(this, arguments);
723
671
  };
724
672
  }();
725
673
 
726
674
  var onSaveTopo = /*#__PURE__*/function () {
727
- var _ref6 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee7(data) {
675
+ var _ref5 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee6(data) {
728
676
  var id, config, serialize, _config$layout, template, layout, saveConfig;
729
677
 
730
- return _regeneratorRuntime.wrap(function _callee7$(_context7) {
731
- while (1) switch (_context7.prev = _context7.next) {
678
+ return _regeneratorRuntime.wrap(function _callee6$(_context6) {
679
+ while (1) switch (_context6.prev = _context6.next) {
732
680
  case 0:
733
681
  id = data.id, config = data.config, serialize = data.serialize;
734
682
  _config$layout = config === null || config === void 0 ? void 0 : config.layout, template = _config$layout.type, layout = _config$layout.layout;
@@ -736,11 +684,11 @@ var useTopoEdit = function useTopoEdit(params) {
736
684
  if (onSave) {
737
685
  // 自定义保存
738
686
  saveConfig = /*#__PURE__*/function () {
739
- var _ref7 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee6() {
740
- return _regeneratorRuntime.wrap(function _callee6$(_context6) {
741
- while (1) switch (_context6.prev = _context6.next) {
687
+ var _ref6 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee5() {
688
+ return _regeneratorRuntime.wrap(function _callee5$(_context5) {
689
+ while (1) switch (_context5.prev = _context5.next) {
742
690
  case 0:
743
- _context6.next = 2;
691
+ _context5.next = 2;
744
692
  return editDispatchers.saveTopo({
745
693
  id: id,
746
694
  layout: layout,
@@ -749,13 +697,13 @@ var useTopoEdit = function useTopoEdit(params) {
749
697
 
750
698
  case 2:
751
699
  case "end":
752
- return _context6.stop();
700
+ return _context5.stop();
753
701
  }
754
- }, _callee6);
702
+ }, _callee5);
755
703
  }));
756
704
 
757
705
  return function saveConfig() {
758
- return _ref7.apply(this, arguments);
706
+ return _ref6.apply(this, arguments);
759
707
  };
760
708
  }();
761
709
 
@@ -768,13 +716,13 @@ var useTopoEdit = function useTopoEdit(params) {
768
716
 
769
717
  case 3:
770
718
  case "end":
771
- return _context7.stop();
719
+ return _context6.stop();
772
720
  }
773
- }, _callee7);
721
+ }, _callee6);
774
722
  }));
775
723
 
776
- return function onSaveTopo(_x13) {
777
- return _ref6.apply(this, arguments);
724
+ return function onSaveTopo(_x12) {
725
+ return _ref5.apply(this, arguments);
778
726
  };
779
727
  }();
780
728
 
@@ -783,7 +731,7 @@ var useTopoEdit = function useTopoEdit(params) {
783
731
  type: type,
784
732
  data: data
785
733
  };
786
- rlog.debug("TopoCenter:onSaveBind", eventData);
734
+ rlog.debug("=> ht: saveBind", eventData);
787
735
  emitEvent(TopoEvent.EVENT_DATA_RESULT, eventData);
788
736
  };
789
737
  /**
@@ -800,11 +748,11 @@ var useTopoEdit = function useTopoEdit(params) {
800
748
 
801
749
 
802
750
  var bindNodeResource = /*#__PURE__*/function () {
803
- var _ref8 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee9(params) {
751
+ var _ref7 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee8(params) {
804
752
  var id, oldResId, newResId, node, parentGroupElement, htTopo, config, groupId, groupTag, _yield$editDispatcher, elements, newData, doBind, _doBind, replaceOrAddRes;
805
753
 
806
- return _regeneratorRuntime.wrap(function _callee9$(_context9) {
807
- while (1) switch (_context9.prev = _context9.next) {
754
+ return _regeneratorRuntime.wrap(function _callee8$(_context8) {
755
+ while (1) switch (_context8.prev = _context8.next) {
808
756
  case 0:
809
757
  replaceOrAddRes = function _replaceOrAddRes(resources, oldResId, newResId) {
810
758
  return _extends({}, resources, {
@@ -815,14 +763,23 @@ var useTopoEdit = function useTopoEdit(params) {
815
763
  };
816
764
 
817
765
  _doBind = function _doBind3() {
818
- _doBind = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee8() {
819
- var dm, newLinkElements, createElementsData, groupChildren, newGroupChildren, existedGroupChildren, groupElement, newElement, sm;
820
- return _regeneratorRuntime.wrap(function _callee8$(_context8) {
821
- while (1) switch (_context8.prev = _context8.next) {
766
+ _doBind = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee7() {
767
+ var dm, needDeleteHtDatas, newLinkElements, createElementsData, groupChildren, newGroupChildren, existedGroupChildren, groupElement, newElement, sm;
768
+ return _regeneratorRuntime.wrap(function _callee7$(_context7) {
769
+ while (1) switch (_context7.prev = _context7.next) {
822
770
  case 0:
823
771
  dm = htTopo.getGraphView().dm(); // 移除旧节点。先删除后创建,解决ip节点替换ping资源后链路丢失问题
824
772
 
825
- dm.remove(node); // 创建
773
+ dm.remove(node); // 先删除多余的元素。解决 区域子节点关联ping,未更新显示链路及删除ip节点
774
+
775
+ needDeleteHtDatas = getElements(dm).filter(function (htData) {
776
+ return htData.a('id') && !elements.find(function (ele) {
777
+ return ele.id === htData.a('id');
778
+ });
779
+ });
780
+ needDeleteHtDatas.forEach(function (htData) {
781
+ return dm.remove(htData);
782
+ }); // 创建
826
783
 
827
784
  newLinkElements = findUNExistedLinkElements(elements);
828
785
  createElementsData = null;
@@ -871,7 +828,7 @@ var useTopoEdit = function useTopoEdit(params) {
871
828
  htTopo.createElements(createElementsData);
872
829
  }
873
830
 
874
- rlog.debug("批量创建元素", createElementsData); // 恢复图标、大小、位置
831
+ rlog.debug("批量创建元素", createElementsData); // 恢复图标、大小、位置、父区域
875
832
 
876
833
  newElement = dm.getDataByTag(newData.id);
877
834
 
@@ -879,21 +836,18 @@ var useTopoEdit = function useTopoEdit(params) {
879
836
  newElement.setSize(node.getSize());
880
837
  newElement.setPosition(node.getPosition());
881
838
  newElement.setImage(node.getImage());
839
+ newElement.setParent(parentGroupElement);
882
840
  } // 选中
883
841
 
884
842
 
885
843
  sm = htTopo.getGraphView().sm();
886
- sm.setSelection([newElement]); // 临时放这里,仅拓扑中心有
844
+ sm.setSelection([newElement]);
887
845
 
888
- if (topo.linkDynamicStyleExecutor) {
889
- topo.linkDynamicStyleExecutor.execute();
890
- }
891
-
892
- case 11:
846
+ case 12:
893
847
  case "end":
894
- return _context8.stop();
848
+ return _context7.stop();
895
849
  }
896
- }, _callee8);
850
+ }, _callee7);
897
851
  }));
898
852
  return _doBind.apply(this, arguments);
899
853
  };
@@ -933,48 +887,55 @@ var useTopoEdit = function useTopoEdit(params) {
933
887
  config.resources = replaceOrAddRes(config.resources, oldResId, newResId);
934
888
  }
935
889
 
936
- _context9.next = 13;
890
+ _context8.next = 13;
937
891
  return resourceConfig.updateConfig(config);
938
892
 
939
893
  case 13:
940
- _context9.next = 15;
894
+ _context8.next = 15;
941
895
  return editDispatchers.fetchDataByConfig();
942
896
 
943
897
  case 15:
944
- _yield$editDispatcher = _context9.sent;
898
+ _yield$editDispatcher = _context8.sent;
945
899
  elements = _yield$editDispatcher.elements;
946
900
  newData = elements.find(function (item) {
947
901
  return item.id === newResId;
948
902
  });
949
903
 
950
- if (newData) {
951
- _context9.next = 23;
904
+ if (!newData) {
905
+ _context8.next = 25;
952
906
  break;
953
907
  }
954
908
 
955
- topo.historyManager.endTransaction();
909
+ _context8.next = 21;
910
+ return doBind();
956
911
 
957
- _Message.error("关联资源失败");
912
+ case 21:
913
+ topo.historyManager.endTransaction(); // 临时放这里,仅拓扑中心有
958
914
 
959
- rlog.error("关联资源失败");
960
- return _context9.abrupt("return", false);
915
+ if (topo.linkDynamicStyleExecutor) {
916
+ topo.linkDynamicStyleExecutor.execute();
917
+ }
961
918
 
962
- case 23:
963
- _context9.next = 25;
964
- return doBind();
919
+ _context8.next = 29;
920
+ break;
965
921
 
966
922
  case 25:
967
923
  topo.historyManager.endTransaction();
968
924
 
969
- case 26:
925
+ _Message.error("关联资源失败");
926
+
927
+ rlog.error("关联资源失败");
928
+ return _context8.abrupt("return", false);
929
+
930
+ case 29:
970
931
  case "end":
971
- return _context9.stop();
932
+ return _context8.stop();
972
933
  }
973
- }, _callee9);
934
+ }, _callee8);
974
935
  }));
975
936
 
976
- return function bindNodeResource(_x14) {
977
- return _ref8.apply(this, arguments);
937
+ return function bindNodeResource(_x13) {
938
+ return _ref7.apply(this, arguments);
978
939
  };
979
940
  }();
980
941
  /**
@@ -982,93 +943,96 @@ var useTopoEdit = function useTopoEdit(params) {
982
943
  */
983
944
 
984
945
 
985
- function relateNodeIp(_x15, _x16) {
946
+ function relateNodeIp(_x14, _x15, _x16) {
986
947
  return _relateNodeIp.apply(this, arguments);
987
948
  }
988
949
 
989
950
  function _relateNodeIp() {
990
- _relateNodeIp = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee15(txtValue, nodeElement) {
991
- var dm, isUnique, ipNodeData, configObj, configData, _elements2, newLinkElements, newLink, newLinkGroup, createElementsData, _htTopo;
951
+ _relateNodeIp = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee14(txtValue, nodeElement, disableHistory) {
952
+ var dm, isUnique, ipNodeData, configObj, configData, elements, newLinkElements, newLink, newLinkGroup, createElementsData, _htTopo;
992
953
 
993
- return _regeneratorRuntime.wrap(function _callee15$(_context15) {
994
- while (1) switch (_context15.prev = _context15.next) {
954
+ return _regeneratorRuntime.wrap(function _callee14$(_context14) {
955
+ while (1) switch (_context14.prev = _context14.next) {
995
956
  case 0:
957
+ if (disableHistory === void 0) {
958
+ disableHistory = false;
959
+ }
960
+
996
961
  if (txtValue) {
997
- _context15.next = 2;
962
+ _context14.next = 3;
998
963
  break;
999
964
  }
1000
965
 
1001
- return _context15.abrupt("return");
966
+ return _context14.abrupt("return");
1002
967
 
1003
- case 2:
1004
- // if (txtValue === nodeElement.a('bindIp')) {
1005
- // return;
1006
- // }
968
+ case 3:
1007
969
  // 根据配置查询拓扑数据
1008
970
  dm = topo.getDataModel(); // 执行唯一性验证
1009
971
 
1010
- isUnique = isUniqueIp(dm, txtValue, nodeElement); // 获取关联链路
972
+ isUnique = isUniqueIp(dm, txtValue, nodeElement);
1011
973
 
1012
- if (!isUnique) {
1013
- _context15.next = 24;
974
+ if (isUnique) {
975
+ _context14.next = 7;
1014
976
  break;
1015
977
  }
1016
978
 
1017
- ipNodeData = buildIpNode(txtValue);
1018
- _context15.next = 8;
1019
- return deleteExLink(nodeElement);
979
+ return _context14.abrupt("return");
1020
980
 
1021
- case 8:
981
+ case 7:
982
+ disableHistory && topo.historyManager.setDisabled(true, '关联IP: 删除关联出口链路、节点绑定IP'); // 删除关联出口链路
983
+
984
+ deleteExLink(nodeElement); // 节点绑定IP
985
+
986
+ ipNodeData = buildIpNode(txtValue);
1022
987
  nodeElement.a(ipNodeData);
1023
988
  nodeElement.setName(txtValue);
1024
- nodeElement.setTag("ip:" + txtValue); // 获取配置
989
+ nodeElement.setTag("ip:" + txtValue);
990
+ disableHistory && topo.historyManager.setDisabled(false, '关联IP: 删除关联出口链路、节点绑定IP'); // 获取配置
1025
991
 
1026
992
  configObj = topo.resourceConfig.getConfig();
1027
- _context15.next = 14;
993
+ _context14.next = 17;
1028
994
  return resourceConfig.updateConfig(configObj);
1029
995
 
1030
- case 14:
1031
- _context15.next = 16;
996
+ case 17:
997
+ _context14.next = 19;
1032
998
  return editDispatchers.fetchDataByConfig();
1033
999
 
1034
- case 16:
1035
- configData = _context15.sent;
1036
- // console.log("configData",configObj, configData);
1037
- _elements2 = configData.elements;
1038
- newLinkElements = findUNExistedLinkElements(_elements2); // console.log("configData", configData, newLinkElements);
1039
-
1000
+ case 19:
1001
+ configData = _context14.sent;
1002
+ elements = configData.elements;
1003
+ newLinkElements = findUNExistedLinkElements(elements);
1040
1004
  newLink = newLinkElements.filter(function (item) {
1041
1005
  return item.type === "link";
1042
1006
  });
1043
1007
  newLinkGroup = newLinkElements.filter(function (item) {
1044
1008
  return item.type === "linkGroup";
1045
- }); // const newData = elements.find((item) => item.id === `ip:${txtValue}`);
1046
- // console.log("newData",newLinkElements, newLink);
1047
-
1009
+ });
1048
1010
  createElementsData = {
1049
1011
  groups: [],
1050
1012
  nodes: [],
1051
1013
  links: newLink,
1052
1014
  linkGroups: newLinkGroup
1053
1015
  };
1054
- console.log("createElementsData", createElementsData);
1016
+ rlog.debug("createElementsData", createElementsData);
1055
1017
 
1056
1018
  if ([].concat(newLink, newLinkGroup).length > 0) {
1057
1019
  _htTopo = topo.getHtTopo();
1020
+ disableHistory && topo.historyManager.setDisabled(true, '关联IP: 创建链路');
1058
1021
 
1059
- _htTopo.createElements(createElementsData); // 临时放这里,仅拓扑中心有
1022
+ _htTopo.createElements(createElementsData);
1060
1023
 
1024
+ disableHistory && topo.historyManager.setDisabled(false, '关联IP: 创建链路'); // 临时放这里,仅拓扑中心有
1061
1025
 
1062
1026
  if (topo.linkDynamicStyleExecutor) {
1063
1027
  topo.linkDynamicStyleExecutor.execute();
1064
1028
  }
1065
1029
  }
1066
1030
 
1067
- case 24:
1031
+ case 27:
1068
1032
  case "end":
1069
- return _context15.stop();
1033
+ return _context14.stop();
1070
1034
  }
1071
- }, _callee15);
1035
+ }, _callee14);
1072
1036
  }));
1073
1037
  return _relateNodeIp.apply(this, arguments);
1074
1038
  }
@@ -1161,6 +1125,7 @@ var useTopoEdit = function useTopoEdit(params) {
1161
1125
  onCloseComboResDrawer: function onCloseComboResDrawer() {
1162
1126
  return setShowComboResDrawer(false);
1163
1127
  },
1128
+ batchDeleteSelectedElement: batchDeleteSelectedElement,
1164
1129
 
1165
1130
  /**
1166
1131
  * 拓扑图元素(节点、连线、容器)删除回调