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

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