@riil-frontend/component-topology 5.0.0-alpha.9 → 5.0.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 (195) hide show
  1. package/build/1.js +2 -2
  2. package/build/2.js +1 -1
  3. package/build/index.css +1 -1
  4. package/build/index.js +20 -20
  5. package/es/common/components/ColorPicker/ColorPicker.js +5 -3
  6. package/es/components/BatchAttrMetric/setting.js +3 -5
  7. package/es/components/ResourceSelectDrawer/ResourceSelectDrawer.js +2 -1
  8. package/es/core/components/DisplaySettingDrawer/DisplaySettingDrawer.js +2 -1
  9. package/es/core/components/DisplaySettingDrawer/LinkTip.js +5 -1
  10. package/es/core/components/DisplaySettingDrawer/demo/Demo.js +63 -0
  11. package/es/core/components/ResourceViewAttributeSetting/Setting.js +9 -48
  12. package/es/core/components/TopoView/TopoView.module.scss +1 -1
  13. package/es/core/components/TopoView/topoView.js +31 -22
  14. package/es/core/editor/components/BackgroundView/index.js +74 -35
  15. package/es/core/editor/components/settings/common/LineType/index.js +7 -1
  16. package/es/core/editor/components/settings/common/text/FontStyleCheckbox.js +3 -3
  17. package/es/core/editor/components/settings/common/text/TextStyle.js +21 -6
  18. package/es/core/editor/components/settings/common/text/fontStyleUtil.js +0 -1
  19. package/es/core/editor/components/settings/propertyViews/box/BoxPropertyView.js +12 -1
  20. package/es/core/editor/components/settings/propertyViews/box/NameInput.js +9 -1
  21. package/es/core/editor/components/settings/propertyViews/edge/CommonEdgePropertyView.js +15 -1
  22. package/es/core/editor/components/settings/propertyViews/group/DataTab/GroupNodeList.js +2 -0
  23. package/es/core/editor/components/settings/propertyViews/group/SettingTab/GroupExpandSetting.js +9 -5
  24. package/es/core/editor/components/settings/propertyViews/group/SettingTab/GroupExpandStatus.js +10 -2
  25. package/es/core/editor/components/settings/propertyViews/group/SettingTab/Setting.js +12 -1
  26. package/es/core/editor/components/settings/propertyViews/layer/SettingTab/Setting.js +13 -3
  27. package/es/core/editor/components/settings/propertyViews/layer/SettingTab/Setting_bak.js +0 -1
  28. package/es/core/editor/components/settings/propertyViews/multipleElements/BatchSetNodeIcon.js +2 -0
  29. package/es/core/editor/components/settings/propertyViews/multipleElements/BatchSetNodeSize/BatchSetNodeSize.js +2 -0
  30. package/es/core/editor/components/settings/propertyViews/multipleElements/MultipleElementPropertyView.js +4 -1
  31. package/es/core/editor/components/settings/propertyViews/node/Setting/Setting.js +4 -0
  32. package/es/core/editor/components/settings/propertyViews/node/data/Data.js +34 -6
  33. package/es/core/editor/components/settings/propertyViews/text/TextPropertyView.js +9 -2
  34. package/es/core/editor/components/settings/propertyViews/view/BackgroundSize.js +30 -1
  35. package/es/core/editor/components/settings/propertyViews/view/GlobalLayout.js +2 -0
  36. package/es/core/editor/components/settings/propertyViews/view/GlobalNodeLabelStyle.js +15 -1
  37. package/es/core/editor/components/settings/propertyViews/view/hooks/useBackgroundSizeConfig.js +0 -1
  38. package/es/core/editor/components/titlebar/TopoEditorTitleBar.js +4 -1
  39. package/es/core/editor/components/titlebar/widgets/DebugTools.js +29 -0
  40. package/es/core/hooks/useAlarm.js +18 -0
  41. package/es/core/hooks/useGraphAlarmDisplay.js +25 -3
  42. package/es/core/hooks/useResourceConfig.js +2 -1
  43. package/es/core/hooks/useRouterAdapter.js +7 -1
  44. package/es/core/hooks/useTopoEdit.js +220 -163
  45. package/es/core/models/AttributeMetricDisplay.js +31 -73
  46. package/es/core/models/HistoryManager.js +100 -50
  47. package/es/core/models/TopoApp.js +1 -1
  48. package/es/core/models/cache/CiTypeCache.js +10 -44
  49. package/es/core/models/cache/DictCache.js +2 -1
  50. package/es/core/models/graph/Background.js +31 -14
  51. package/es/core/models/tagstips/ElementTagTipConfig.js +46 -12
  52. package/es/core/models/tagstips/utils.js +1 -1
  53. package/es/core/models/topoData.js +7 -3
  54. package/es/core/models/utils/linkUtils.js +18 -0
  55. package/es/core/store/models/topoAlarm.js +5 -1
  56. package/es/core/store/models/topoMod.js +6 -31
  57. package/es/core/viewer/components/plugins/ResourceDetail/ResourceDetail.js +51 -249
  58. package/es/core/viewer/components/plugins/ResourceDetail/ResourceDetailDrawer.js +218 -0
  59. package/es/core/viewer/components/plugins/ResourceDetail/ResourceDetailPlugin.js +2 -2
  60. package/es/core/viewer/components/plugins/ResourceDetail/components/ClusterMemberTable.js +1 -1
  61. package/es/core/viewer/components/plugins/ResourceDetail/components/ResourceOverview/BaseInfoBlock.js +0 -1
  62. package/es/core/viewer/components/plugins/ResourceDetail/components/ResourceOverview/ResourceOverview.js +79 -43
  63. package/es/core/viewer/components/plugins/ResourceDetail/components/ResourceOverview/ResourceOverviewMetric.js +2 -3
  64. package/es/core/viewer/components/plugins/ResourceDetail/components/ResourceOverview/components/Configurator/index.js +2 -2
  65. package/es/core/viewer/components/plugins/ResourceDetail/components/ResourceOverview/components/LinkTopo/LinkTopo.js +23 -0
  66. package/es/core/viewer/components/plugins/ResourceDetail/components/ResourceOverview/components/LinkTopo/LinkTopo.module.scss +11 -0
  67. package/es/core/viewer/components/plugins/ResourceDetail/components/ResourceOverview/components/LinkTopo/LinkTopoCard.js +34 -0
  68. package/es/core/viewer/components/plugins/ResourceDetail/components/ResourceOverview/components/LinkTopo/constants.js +6 -0
  69. package/es/core/viewer/components/plugins/ResourceDetail/components/ResourceOverview/components/LinkTopo/hooks/useMetricPolling.js +62 -0
  70. package/es/core/viewer/components/plugins/ResourceDetail/components/ResourceOverview/components/LinkTopo/services/index.js +188 -0
  71. package/es/core/viewer/components/titlebar/BasicTools.js +1 -1
  72. package/es/core/viewer/components/titlebar/widgets/NodesDragSwitchWrapper.js +18 -0
  73. package/es/core/viewer/components/titlebar/widgets/SettingButton.js +11 -1
  74. package/es/networkTopo/components/TopoView.js +2 -1
  75. package/es/networkTopo/components/editor/propertyViews/edge/addLinkDrawer/AddLinkDrawer.js +164 -225
  76. package/es/networkTopo/components/editor/propertyViews/edge/addLinkDrawer/components/NetworkLinkForm.js +4 -0
  77. package/es/networkTopo/components/editor/propertyViews/edge/addLinkDrawer/components/editLinkInfo.js +161 -137
  78. package/es/networkTopo/components/editor/propertyViews/edge/addLinkDrawer/hooks/useAddLink.js +104 -0
  79. package/es/networkTopo/components/editor/propertyViews/edge/link/BindExitLinkSelect.js +17 -7
  80. package/es/networkTopo/components/editor/propertyViews/edge/link/LinkInfoPreview.js +8 -9
  81. package/es/networkTopo/components/viewer/displaySetting/LinkAttrCustomSettingDrawer.js +59 -0
  82. package/es/networkTopo/components/viewer/displaySetting/LinkTagV2.js +10 -4
  83. package/es/networkTopo/getTopoData.js +11 -14
  84. package/es/networkTopo/hooks/editor/useDeleteEdges.js +11 -8
  85. package/es/networkTopo/hooks/viewer/useRelateTopo.js +1 -1
  86. package/es/networkTopo/models/LinkDynamicStyleExecutor.js +2 -0
  87. package/es/networkTopo/models/TopoCenter.js +1 -1
  88. package/es/networkTopo/services/index.js +6 -4
  89. package/es/networkTopo/services/link.js +2 -2
  90. package/es/networkTopo/store/topoCenter.js +5 -2
  91. package/es/networkTopo/store/topoTreeMod.js +84 -43
  92. package/es/networkTopo/utils/__tests__/resourcePermissionUtil.test.js +135 -0
  93. package/es/networkTopo/utils/resourcePermissionUtil.js +10 -6
  94. package/es/style.js +2 -1
  95. package/es/utils/ResourceConfigUtil.js +79 -39
  96. package/es/utils/clusterUtil.js +1 -1
  97. package/es/utils/htElementUtils.js +0 -1
  98. package/es/utils/topoData.js +24 -63
  99. package/es/utils/tree.js +1 -3
  100. package/lib/common/components/ColorPicker/ColorPicker.js +6 -3
  101. package/lib/components/BatchAttrMetric/setting.js +3 -6
  102. package/lib/components/ResourceSelectDrawer/ResourceSelectDrawer.js +4 -1
  103. package/lib/core/components/DisplaySettingDrawer/DisplaySettingDrawer.js +4 -1
  104. package/lib/core/components/DisplaySettingDrawer/LinkTip.js +6 -1
  105. package/lib/core/components/DisplaySettingDrawer/demo/Demo.js +71 -0
  106. package/lib/core/components/ResourceViewAttributeSetting/Setting.js +8 -48
  107. package/lib/core/components/TopoView/TopoView.module.scss +1 -1
  108. package/lib/core/components/TopoView/topoView.js +26 -17
  109. package/lib/core/editor/components/BackgroundView/index.js +75 -35
  110. package/lib/core/editor/components/settings/common/LineType/index.js +7 -1
  111. package/lib/core/editor/components/settings/common/text/FontStyleCheckbox.js +5 -4
  112. package/lib/core/editor/components/settings/common/text/TextStyle.js +23 -7
  113. package/lib/core/editor/components/settings/common/text/fontStyleUtil.js +0 -1
  114. package/lib/core/editor/components/settings/propertyViews/box/BoxPropertyView.js +13 -1
  115. package/lib/core/editor/components/settings/propertyViews/box/NameInput.js +9 -1
  116. package/lib/core/editor/components/settings/propertyViews/edge/CommonEdgePropertyView.js +15 -1
  117. package/lib/core/editor/components/settings/propertyViews/group/DataTab/GroupNodeList.js +2 -0
  118. package/lib/core/editor/components/settings/propertyViews/group/SettingTab/GroupExpandSetting.js +9 -5
  119. package/lib/core/editor/components/settings/propertyViews/group/SettingTab/GroupExpandStatus.js +10 -2
  120. package/lib/core/editor/components/settings/propertyViews/group/SettingTab/Setting.js +12 -1
  121. package/lib/core/editor/components/settings/propertyViews/layer/SettingTab/Setting.js +17 -3
  122. package/lib/core/editor/components/settings/propertyViews/layer/SettingTab/Setting_bak.js +0 -1
  123. package/lib/core/editor/components/settings/propertyViews/multipleElements/BatchSetNodeIcon.js +2 -0
  124. package/lib/core/editor/components/settings/propertyViews/multipleElements/BatchSetNodeSize/BatchSetNodeSize.js +2 -0
  125. package/lib/core/editor/components/settings/propertyViews/multipleElements/MultipleElementPropertyView.js +4 -1
  126. package/lib/core/editor/components/settings/propertyViews/node/Setting/Setting.js +4 -0
  127. package/lib/core/editor/components/settings/propertyViews/node/data/Data.js +36 -6
  128. package/lib/core/editor/components/settings/propertyViews/text/TextPropertyView.js +9 -2
  129. package/lib/core/editor/components/settings/propertyViews/view/BackgroundSize.js +32 -1
  130. package/lib/core/editor/components/settings/propertyViews/view/GlobalLayout.js +2 -0
  131. package/lib/core/editor/components/settings/propertyViews/view/GlobalNodeLabelStyle.js +15 -1
  132. package/lib/core/editor/components/settings/propertyViews/view/hooks/useBackgroundSizeConfig.js +0 -1
  133. package/lib/core/editor/components/titlebar/TopoEditorTitleBar.js +5 -1
  134. package/lib/core/editor/components/titlebar/widgets/DebugTools.js +38 -0
  135. package/lib/core/hooks/useAlarm.js +19 -0
  136. package/lib/core/hooks/useGraphAlarmDisplay.js +27 -3
  137. package/lib/core/hooks/useResourceConfig.js +2 -1
  138. package/lib/core/hooks/useRouterAdapter.js +8 -1
  139. package/lib/core/hooks/useTopoEdit.js +219 -162
  140. package/lib/core/models/AttributeMetricDisplay.js +31 -73
  141. package/lib/core/models/HistoryManager.js +105 -51
  142. package/lib/core/models/TopoApp.js +1 -1
  143. package/lib/core/models/cache/CiTypeCache.js +12 -44
  144. package/lib/core/models/cache/DictCache.js +4 -1
  145. package/lib/core/models/graph/Background.js +36 -16
  146. package/lib/core/models/tagstips/ElementTagTipConfig.js +49 -12
  147. package/lib/core/models/tagstips/utils.js +1 -1
  148. package/lib/core/models/topoData.js +7 -3
  149. package/lib/core/models/utils/linkUtils.js +22 -0
  150. package/lib/core/store/models/topoAlarm.js +5 -1
  151. package/lib/core/store/models/topoMod.js +7 -32
  152. package/lib/core/viewer/components/plugins/ResourceDetail/ResourceDetail.js +51 -261
  153. package/lib/core/viewer/components/plugins/ResourceDetail/ResourceDetailDrawer.js +245 -0
  154. package/lib/core/viewer/components/plugins/ResourceDetail/ResourceDetailPlugin.js +2 -2
  155. package/lib/core/viewer/components/plugins/ResourceDetail/components/ClusterMemberTable.js +1 -1
  156. package/lib/core/viewer/components/plugins/ResourceDetail/components/ResourceOverview/BaseInfoBlock.js +0 -1
  157. package/lib/core/viewer/components/plugins/ResourceDetail/components/ResourceOverview/ResourceOverview.js +79 -42
  158. package/lib/core/viewer/components/plugins/ResourceDetail/components/ResourceOverview/ResourceOverviewMetric.js +2 -3
  159. package/lib/core/viewer/components/plugins/ResourceDetail/components/ResourceOverview/components/Configurator/index.js +2 -2
  160. package/lib/core/viewer/components/plugins/ResourceDetail/components/ResourceOverview/components/LinkTopo/LinkTopo.js +36 -0
  161. package/lib/core/viewer/components/plugins/ResourceDetail/components/ResourceOverview/components/LinkTopo/LinkTopo.module.scss +11 -0
  162. package/lib/core/viewer/components/plugins/ResourceDetail/components/ResourceOverview/components/LinkTopo/LinkTopoCard.js +45 -0
  163. package/lib/core/viewer/components/plugins/ResourceDetail/components/ResourceOverview/components/LinkTopo/constants.js +11 -0
  164. package/lib/core/viewer/components/plugins/ResourceDetail/components/ResourceOverview/components/LinkTopo/hooks/useMetricPolling.js +77 -0
  165. package/lib/core/viewer/components/plugins/ResourceDetail/components/ResourceOverview/components/LinkTopo/services/index.js +214 -0
  166. package/lib/core/viewer/components/titlebar/BasicTools.js +2 -2
  167. package/lib/core/viewer/components/titlebar/widgets/NodesDragSwitchWrapper.js +28 -0
  168. package/lib/core/viewer/components/titlebar/widgets/SettingButton.js +10 -0
  169. package/lib/networkTopo/components/TopoView.js +3 -2
  170. package/lib/networkTopo/components/editor/propertyViews/edge/addLinkDrawer/AddLinkDrawer.js +160 -223
  171. package/lib/networkTopo/components/editor/propertyViews/edge/addLinkDrawer/components/NetworkLinkForm.js +12 -0
  172. package/lib/networkTopo/components/editor/propertyViews/edge/addLinkDrawer/components/editLinkInfo.js +161 -137
  173. package/lib/networkTopo/components/editor/propertyViews/edge/addLinkDrawer/hooks/useAddLink.js +120 -0
  174. package/lib/networkTopo/components/editor/propertyViews/edge/link/BindExitLinkSelect.js +19 -7
  175. package/lib/networkTopo/components/editor/propertyViews/edge/link/LinkInfoPreview.js +8 -9
  176. package/lib/networkTopo/components/viewer/displaySetting/LinkAttrCustomSettingDrawer.js +76 -0
  177. package/lib/networkTopo/components/viewer/displaySetting/LinkTagV2.js +10 -4
  178. package/lib/networkTopo/getTopoData.js +10 -13
  179. package/lib/networkTopo/hooks/editor/useDeleteEdges.js +11 -8
  180. package/lib/networkTopo/hooks/viewer/useRelateTopo.js +2 -1
  181. package/lib/networkTopo/models/LinkDynamicStyleExecutor.js +2 -0
  182. package/lib/networkTopo/models/TopoCenter.js +2 -2
  183. package/lib/networkTopo/services/index.js +6 -4
  184. package/lib/networkTopo/services/link.js +2 -2
  185. package/lib/networkTopo/store/topoCenter.js +5 -2
  186. package/lib/networkTopo/store/topoTreeMod.js +84 -43
  187. package/lib/networkTopo/utils/__tests__/resourcePermissionUtil.test.js +137 -0
  188. package/lib/networkTopo/utils/resourcePermissionUtil.js +11 -6
  189. package/lib/style.js +2 -1
  190. package/lib/utils/ResourceConfigUtil.js +78 -37
  191. package/lib/utils/clusterUtil.js +1 -1
  192. package/lib/utils/htElementUtils.js +0 -1
  193. package/lib/utils/topoData.js +25 -64
  194. package/lib/utils/tree.js +1 -3
  195. package/package.json +3 -2
@@ -138,6 +138,15 @@ var AttributeMetricDisplay = /*#__PURE__*/function () {
138
138
  tips: filterByPermission(node, ciTypeConfig.tips)
139
139
  };
140
140
  });
141
+ } // eslint-disable-next-line class-methods-use-this
142
+ ;
143
+
144
+ _proto.getModelType = function getModelType(ci) {
145
+ if (ci.ciType === 'network_link') {
146
+ return ci.attributes.support_templates;
147
+ }
148
+
149
+ return ci.ciType;
141
150
  }
142
151
  /**
143
152
  * 按链路类型获取对应的属性、指标配置
@@ -151,75 +160,8 @@ var AttributeMetricDisplay = /*#__PURE__*/function () {
151
160
  linkTag = _this$getConfig2.linkTag,
152
161
  linkTip = _this$getConfig2.linkTip;
153
162
 
154
- var ciTypeMeta;
155
- var isNetworkLink = link.ciType === 'network_link';
156
-
157
- if (isNetworkLink) {
158
- var linkConnectType = link.attributes['network_link.connect_type'];
159
- ciTypeMeta = this.topo.ciTyeCache.getNetworkLinkCiType(linkConnectType);
160
- } else {
161
- ciTypeMeta = this.topo.ciTyeCache.getCiType(link.ciType);
162
- }
163
-
164
- var dataType = isNetworkLink ? link.attributes['network_link.connect_type'] : link.ciType;
165
-
166
- function getNetworkFieldItems(configItems) {
167
- var getMetricCode = function getMetricCode(code) {
168
- var _connectTypeMap$linkC;
169
-
170
- var linkConnectType = link.attributes['network_link.connect_type'];
171
- var connectTypeMap = {
172
- phy: {
173
- id: 'phy',
174
- metricPrefix: 'physical_link.'
175
- },
176
- agg: {
177
- id: 'agg',
178
- metricPrefix: 'agg_link.'
179
- },
180
- exit: {
181
- id: 'exit',
182
- metricPrefix: 'export_link.'
183
- }
184
- };
185
- var metricPrefix = (_connectTypeMap$linkC = connectTypeMap[linkConnectType]) === null || _connectTypeMap$linkC === void 0 ? void 0 : _connectTypeMap$linkC.metricPrefix;
186
-
187
- if (!metricPrefix) {
188
- return null;
189
- }
190
-
191
- var finalCode = null;
192
-
193
- if (ciTypeMeta.metricMap[code]) {
194
- finalCode = code;
195
- } else if (ciTypeMeta.metricMap["" + metricPrefix + code]) {
196
- finalCode = "" + metricPrefix + code;
197
- }
198
-
199
- return finalCode;
200
- };
201
-
202
- var formatItems = function formatItems(items) {
203
- var newItems = [];
204
- items.forEach(function (item) {
205
- if (item.type === 'metric') {
206
- var code = item.code;
207
- var finalCode = getMetricCode(code);
208
-
209
- if (finalCode) {
210
- newItems.push(_extends({}, item, {
211
- code: finalCode
212
- }));
213
- }
214
- } else {
215
- newItems.push(item);
216
- }
217
- });
218
- return newItems;
219
- };
220
-
221
- return formatItems(configItems);
222
- }
163
+ var ciTypeMeta = this.topo.ciTyeCache.getCiTypeByCi(link);
164
+ var modelType = this.getModelType(link);
223
165
 
224
166
  function getItems(cfg) {
225
167
  if (!ciTypeMeta || !cfg) {
@@ -228,8 +170,7 @@ var AttributeMetricDisplay = /*#__PURE__*/function () {
228
170
 
229
171
  var isCustom = cfg.isCustom,
230
172
  data = cfg.data;
231
- var configItems = (isCustom ? data[dataType] : data) || [];
232
- var items = isNetworkLink ? getNetworkFieldItems(configItems) : configItems; // 过滤不存在的
173
+ var items = (isCustom ? data[modelType] : data) || []; // 过滤不存在的
233
174
 
234
175
  return filterUnExistedFields(items, ciTypeMeta);
235
176
  }
@@ -679,14 +620,31 @@ var AttributeMetricDisplay = /*#__PURE__*/function () {
679
620
  return;
680
621
  }
681
622
 
682
- var elementTagsAndTips = this.buildTagsTips().map(function (item) {
683
- // 开锁状态下禁用悬停展示悬浮框
623
+ var elementTagsAndTips = this.buildTagsTips() // 开锁状态下禁用悬停展示悬浮框
624
+ .map(function (item) {
684
625
  var _topo$store$getModelS = topo.store.getModelState('lock'),
685
626
  lock = _topo$store$getModelS.lock;
686
627
 
687
628
  return lock ? item : _extends({}, item, {
688
629
  tips: []
689
630
  });
631
+ }) // 链路指标都没值时不显示
632
+ .map(function (item) {
633
+ var tags = item.tags;
634
+
635
+ if (item.type === 'edge') {
636
+ var allNoValue = tags.data.filter(function (tItem) {
637
+ return tItem.value === '- ';
638
+ }).length === tags.data.length;
639
+
640
+ if (allNoValue) {
641
+ tags.data = [];
642
+ }
643
+ }
644
+
645
+ return _extends({}, item, {
646
+ tags: tags
647
+ });
690
648
  });
691
649
  rlog.debug("AttributeMetricDisplay.updateTagsTips " + new Date().toLocaleString(), elementTagsAndTips);
692
650
  var htTopo = topo.getHtTopo();
@@ -1,74 +1,78 @@
1
1
  import _extends from "@babel/runtime/helpers/extends";
2
- import rlog from "@riil-frontend/component-topology-utils/es/rlog";
3
- import { property } from "lodash";
2
+ import rlog from '@riil-frontend/component-topology-utils/es/rlog';
4
3
  var ht = window.ht;
5
4
  export var HistoryManager = /*#__PURE__*/function () {
6
- function HistoryManager(topo) {
7
- var _this = this;
8
-
5
+ function HistoryManager(topo, htHistoryManager) {
9
6
  this.topo = null;
10
7
  this.htHistoryManager = void 0;
11
8
  this.storeHistory = [];
12
9
  this.topo = topo;
13
- var dm = topo.getDataModel();
14
- this.htHistoryManager = new ht.HistoryManager(dm);
15
- this.htHistoryManager.isPropertyUndoable = this.isPropertyUndoable;
16
- window.addEventListener('keydown', function (e) {
17
- //增加快捷键支持
18
- if (e.ctrlKey) {
19
- if (e.keyCode == 90) {
20
- //ctrl+z 撤销
21
- _this.undo();
22
- } else if (e.keyCode == 89) {
23
- //ctrl+y 重做
24
- _this.redo();
25
- }
26
- }
27
- });
28
- }
10
+ this.htHistoryManager = htHistoryManager;
11
+ rlog.info('HistoryManager 初始化', htHistoryManager);
12
+ } // 增加快捷键支持
13
+
29
14
 
30
15
  var _proto = HistoryManager.prototype;
31
16
 
32
- _proto.xxx = function xxx() {// 记录自定义历史数据到htHistoryManager最后一个历史
33
- } // eslint-disable-next-line class-methods-use-this
34
- ;
17
+ _proto.handleKeyDown = function handleKeyDown(e) {
18
+ // 事务中禁用回退
19
+ // eslint-disable-next-line no-underscore-dangle
20
+ if (this.htHistoryManager._betweenTransaction) {
21
+ return;
22
+ }
35
23
 
36
- _proto.isPropertyUndoable = function isPropertyUndoable(property) {
37
- var ignore = ['s:edge.color', 'a:arrow.color', 'icons', 'a:runtimeStyles'];
24
+ var isCtrlDown = ht.Default.isCtrlDown;
25
+
26
+ if (isCtrlDown(e)) {
27
+ if (e.keyCode === 90) {
28
+ // ctrl+z 撤销
29
+ this.undo();
30
+ } // else if (e.keyCode == 89) {//ctrl+y 重做
31
+ // this.redo();
32
+ // }
38
33
 
39
- if (ignore.includes(property)) {
40
- return false;
41
34
  }
35
+ };
42
36
 
43
- return true;
37
+ _proto.setDisabled = function setDisabled(disabled, message) {
38
+ this.htHistoryManager.setDisabled(disabled);
39
+ rlog.debug("HistoryManager.setDisabled " + (disabled ? '禁用' : '启用') + (message ? "(" + message + ")" : '') + ": " + this.toString(), this.getHistories());
44
40
  };
45
41
 
46
42
  _proto.beginTransaction = function beginTransaction() {
47
- var _this2 = this;
43
+ var _this = this;
48
44
 
49
45
  this.htHistoryManager.beginTransaction();
50
46
  var items = [{
51
47
  modelName: 'topoMod',
52
48
  property: 'data'
49
+ }, // 拓扑类型
50
+ {
51
+ modelName: 'topoMod',
52
+ property: 'type'
53
53
  }, {
54
54
  modelName: 'displayConfig',
55
55
  property: 'expandAllEdges'
56
+ }, {
57
+ modelName: 'displayConfig',
58
+ property: 'nodeLabelStyle'
59
+ }, {
60
+ modelName: 'background',
61
+ property: 'current'
56
62
  }];
57
63
  this.storeHistory = items.map(function (item) {
58
64
  return _extends({}, item, {
59
- oldValue: _this2.topo.store.getModelState(item.modelName)[item.property]
65
+ oldValue: _this.topo.store.getModelState(item.modelName)[item.property]
60
66
  });
61
67
  });
68
+ rlog.debug("HistoryManager.beginTransaction: " + this.toString(), this.getHistories());
62
69
  };
63
70
 
64
- _proto.endTransaction = function endTransaction() {
65
- var _this3 = this;
71
+ _proto.addStoreHistory = function addStoreHistory() {
72
+ var _this2 = this;
66
73
 
67
- // eslint-disable-next-line no-underscore-dangle
68
- var betweenTransaction = this.htHistoryManager._betweenTransaction;
69
- this.htHistoryManager.endTransaction();
70
74
  var storeChanged = this.storeHistory.map(function (item) {
71
- var newValue = _this3.topo.store.getModelState(item.modelName)[item.property];
75
+ var newValue = _this2.topo.store.getModelState(item.modelName)[item.property];
72
76
 
73
77
  if (item.oldValue === newValue) {
74
78
  return false;
@@ -80,18 +84,24 @@ export var HistoryManager = /*#__PURE__*/function () {
80
84
  }).filter(function (item) {
81
85
  return !!item;
82
86
  });
83
- rlog.debug('endTransaction', storeChanged, betweenTransaction);
84
87
 
85
- if (betweenTransaction === 1 && storeChanged.length) {
86
- var histories = this.getHistories();
87
- var item = histories[histories.length - 1][0];
88
- item.storeData = storeChanged;
89
- rlog.debug('endTransaction', item);
88
+ if (storeChanged.length) {
89
+ this.htHistoryManager.addHistory({
90
+ type: 'store',
91
+ data: storeChanged
92
+ });
93
+ rlog.debug('HistoryManager.addStoreHistory', storeChanged);
90
94
  }
91
95
 
92
96
  this.storeHistory = [];
93
97
  };
94
98
 
99
+ _proto.endTransaction = function endTransaction() {
100
+ this.addStoreHistory();
101
+ this.htHistoryManager.endTransaction();
102
+ rlog.debug("HistoryManager.endTransaction: " + this.toString(), this.getHistories());
103
+ };
104
+
95
105
  _proto.clear = function clear() {
96
106
  this.htHistoryManager.clear();
97
107
  };
@@ -100,19 +110,41 @@ export var HistoryManager = /*#__PURE__*/function () {
100
110
  return this.htHistoryManager.getHistories();
101
111
  };
102
112
 
103
- _proto.undo = function undo() {
104
- var _histories$,
105
- _this4 = this;
113
+ _proto.getHistoryIndex = function getHistoryIndex() {
114
+ return this.htHistoryManager.getHistoryIndex();
115
+ };
106
116
 
107
- // 从htHistoryManager获取最后一个历史获取 自定义历史数据
117
+ _proto.getCurrentStoreHistory = function getCurrentStoreHistory(isUndo) {
118
+ var historyIndex = this.getHistoryIndex();
108
119
  var histories = this.getHistories();
109
- var storeHistory = (_histories$ = histories[histories.length - 1][0]) === null || _histories$ === void 0 ? void 0 : _histories$.storeData;
120
+ var history = histories[isUndo ? historyIndex : historyIndex + 1];
121
+
122
+ if (!history) {
123
+ return null;
124
+ }
125
+
126
+ var storeHistory = history.filter(function (item) {
127
+ return item.type === 'store';
128
+ });
129
+
130
+ if (storeHistory.length) {
131
+ return storeHistory[0].data;
132
+ }
133
+
134
+ return null;
135
+ };
136
+
137
+ _proto.undo = function undo() {
138
+ var _this3 = this;
139
+
140
+ rlog.debug('HistoryManager.undo', this.getHistories(), this.getHistoryIndex());
141
+ var storeHistory = this.getCurrentStoreHistory(true);
110
142
 
111
143
  if (storeHistory) {
112
144
  storeHistory.forEach(function (item) {
113
- var _this4$topo$store$get;
145
+ var _this3$topo$store$get;
114
146
 
115
- _this4.topo.store.getModelDispatchers(item.modelName).update((_this4$topo$store$get = {}, _this4$topo$store$get[item.property] = item.oldValue, _this4$topo$store$get));
147
+ _this3.topo.store.getModelDispatchers(item.modelName).update((_this3$topo$store$get = {}, _this3$topo$store$get[item.property] = item.oldValue, _this3$topo$store$get));
116
148
  });
117
149
  } // 回退绘图区
118
150
 
@@ -121,8 +153,26 @@ export var HistoryManager = /*#__PURE__*/function () {
121
153
  };
122
154
 
123
155
  _proto.redo = function redo() {
156
+ var _this4 = this;
157
+
158
+ rlog.debug('HistoryManager.redo', this.getHistories(), this.getHistoryIndex());
159
+ var storeHistory = this.getCurrentStoreHistory(false);
160
+
161
+ if (storeHistory) {
162
+ storeHistory.forEach(function (item) {
163
+ var _this4$topo$store$get;
164
+
165
+ _this4.topo.store.getModelDispatchers(item.modelName).update((_this4$topo$store$get = {}, _this4$topo$store$get[item.property] = item.newValue, _this4$topo$store$get));
166
+ });
167
+ } // 回退绘图区
168
+
169
+
124
170
  this.htHistoryManager.redo();
125
171
  };
126
172
 
173
+ _proto.toString = function toString() {
174
+ return "{Histories: " + this.getHistories().length + ", Index: " + this.getHistoryIndex() + "}";
175
+ };
176
+
127
177
  return HistoryManager;
128
178
  }();
@@ -21,7 +21,7 @@ import PluginManager from "./PluginManager";
21
21
  import topoFactory from "./topoFactory";
22
22
  import ElementTagTipConfig from "./tagstips/ElementTagTipConfig"; // eslint-disable-next-line no-undef
23
23
 
24
- var version = typeof "5.0.0-alpha.9" === 'string' ? "5.0.0-alpha.9" : null;
24
+ var version = typeof "5.0.2" === 'string' ? "5.0.2" : null;
25
25
  console.info("\u62D3\u6251\u7248\u672C: " + version);
26
26
  /**
27
27
  * 拓扑显示和编辑
@@ -3,6 +3,7 @@ import _asyncToGenerator from "@babel/runtime/helpers/asyncToGenerator";
3
3
  import _createClass from "@babel/runtime/helpers/createClass";
4
4
  import _regeneratorRuntime from "@babel/runtime/regenerator";
5
5
  import topoService from '@riil-frontend/component-topology-common/es/services/topo';
6
+ import rlog from '@riil-frontend/component-topology-utils/lib/rlog';
6
7
  import keyBy from 'lodash/keyBy';
7
8
  /**
8
9
  * Ci类型属性、指标缓存
@@ -10,7 +11,6 @@ import keyBy from 'lodash/keyBy';
10
11
 
11
12
  var CiTyeCache = /*#__PURE__*/function () {
12
13
  function CiTyeCache() {
13
- this.cache = void 0;
14
14
  this.cache = {};
15
15
  }
16
16
 
@@ -33,7 +33,7 @@ var CiTyeCache = /*#__PURE__*/function () {
33
33
  case 5:
34
34
  _context.prev = 5;
35
35
  _context.t0 = _context["catch"](0);
36
- console.error('查询Ci模型异常', _context.t0);
36
+ rlog.error('查询Ci模型异常', _context.t0);
37
37
 
38
38
  case 8:
39
39
  return _context.abrupt("return", this.cache);
@@ -118,6 +118,14 @@ var CiTyeCache = /*#__PURE__*/function () {
118
118
  return this.cache[typeCode];
119
119
  };
120
120
 
121
+ _proto.getCiTypeByCi = function getCiTypeByCi(ci) {
122
+ // if (ci.ciType === 'network_link') {
123
+ // const supportTemplates = link.attributes.support_templates;
124
+ // } else {
125
+ // }
126
+ return this.getCiType(ci.ciType);
127
+ };
128
+
121
129
  _proto.getAttribute = function getAttribute(typeCode, attrCode) {
122
130
  var ciType = this.getCiType(typeCode);
123
131
  return ciType === null || ciType === void 0 ? void 0 : ciType.attributeMap[attrCode];
@@ -128,48 +136,6 @@ var CiTyeCache = /*#__PURE__*/function () {
128
136
  return ciType === null || ciType === void 0 ? void 0 : ciType.metricMap[metricCode];
129
137
  };
130
138
 
131
- _proto.getNetworkLinkCiType = function getNetworkLinkCiType(connectType) {
132
- var ciType = this.getCiType('network_link');
133
- var types = [{
134
- id: 'phy',
135
- metricPprefix: 'physical_link.'
136
- }, {
137
- id: 'agg',
138
- metricPprefix: 'agg_link.'
139
- }, {
140
- id: 'exit',
141
- metricPprefix: 'export_link.'
142
- }];
143
- var excludeMetricPprefixs = types.filter(function (t) {
144
- return t.id !== connectType;
145
- }).map(function (t) {
146
- return t.metricPprefix;
147
- });
148
- var model = null;
149
- types.forEach(function (type) {
150
- if (type.id === connectType) {
151
- var metrics = ciType.metrics // 仅出口链路有:ping状态、专线连通状态
152
- .filter(function (metric) {
153
- if (connectType === 'exit') {
154
- return true;
155
- }
156
-
157
- return ['icmp_discards_rate', 'ping_status'].indexOf(metric.code) === -1;
158
- }) // 按链路类型过滤对应指标
159
- .filter(function (metric) {
160
- return !excludeMetricPprefixs.filter(function (excludeMetricPprefix) {
161
- return metric.code.indexOf(excludeMetricPprefix) !== -1;
162
- }).length;
163
- });
164
- model = _extends({}, ciType, {
165
- metrics: metrics,
166
- metricMap: keyBy(metrics || [], 'code')
167
- });
168
- }
169
- });
170
- return model;
171
- };
172
-
173
139
  _createClass(CiTyeCache, [{
174
140
  key: "ciTypes",
175
141
  get: function get() {
@@ -2,6 +2,7 @@ import _asyncToGenerator from "@babel/runtime/helpers/asyncToGenerator";
2
2
  import _regeneratorRuntime from "@babel/runtime/regenerator";
3
3
  import { dictFormat } from '@riil-frontend/utils';
4
4
  import * as modelService from '@riil-frontend/component-topology-common/es/services/model';
5
+ import rlog from '@riil-frontend/component-topology-utils/lib/rlog';
5
6
  /**
6
7
  * 数据字典缓存
7
8
  */
@@ -43,7 +44,7 @@ var DictCache = /*#__PURE__*/function () {
43
44
  case 7:
44
45
  _context.next = 9;
45
46
  return modelService.queryDicts()["catch"](function (e) {
46
- console.error('初始化数据字典异常', e);
47
+ rlog.error('初始化数据字典异常', e);
47
48
  return [];
48
49
  });
49
50
 
@@ -1,3 +1,6 @@
1
+ import _asyncToGenerator from "@babel/runtime/helpers/asyncToGenerator";
2
+ import _regeneratorRuntime from "@babel/runtime/regenerator";
3
+
1
4
  /**
2
5
  * 拓扑背景图
3
6
  */
@@ -5,22 +8,36 @@ var Background = /*#__PURE__*/function () {
5
8
  function Background(view) {
6
9
  var _this = this;
7
10
 
8
- this.setSize = function (_ref) {
9
- var width = _ref.width,
10
- height = _ref.height;
11
-
12
- var backgroundNode = _this.getBackgroundNode();
11
+ this.setSize = /*#__PURE__*/function () {
12
+ var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(_ref) {
13
+ var width, height, backgroundNode, backgroundDispatchers;
14
+ return _regeneratorRuntime.wrap(function _callee$(_context) {
15
+ while (1) {
16
+ switch (_context.prev = _context.next) {
17
+ case 0:
18
+ width = _ref.width, height = _ref.height;
19
+ backgroundNode = _this.getBackgroundNode();
20
+ backgroundNode.setWidth(width);
21
+ backgroundNode.setHeight(height);
22
+ backgroundDispatchers = _this.view.store.getModelDispatchers('background');
23
+ _context.next = 7;
24
+ return backgroundDispatchers.setSize({
25
+ width: width,
26
+ height: height
27
+ });
13
28
 
14
- backgroundNode.setWidth(width);
15
- backgroundNode.setHeight(height);
29
+ case 7:
30
+ case "end":
31
+ return _context.stop();
32
+ }
33
+ }
34
+ }, _callee);
35
+ }));
16
36
 
17
- var backgroundDispatchers = _this.view.store.getModelDispatchers('background');
18
-
19
- backgroundDispatchers.setSize({
20
- width: width,
21
- height: height
22
- });
23
- };
37
+ return function (_x) {
38
+ return _ref2.apply(this, arguments);
39
+ };
40
+ }();
24
41
 
25
42
  this.view = view;
26
43
  }
@@ -1,7 +1,9 @@
1
+ import _extends from "@babel/runtime/helpers/extends";
1
2
  import _asyncToGenerator from "@babel/runtime/helpers/asyncToGenerator";
2
3
  import _regeneratorRuntime from "@babel/runtime/regenerator";
3
4
  import { getLinkMtCodes, getMonitorTemplateCodesFromTopoData, getMtCodeCiTypeMap, getNodeMtCodes } from "./utils";
4
5
  import { getMetricsByMonitorTemplateCodes } from "../../services/topo";
6
+ import rlog from '@riil-frontend/component-topology-utils/lib/rlog';
5
7
 
6
8
  var ElementTagTipConfig = /*#__PURE__*/function () {
7
9
  function ElementTagTipConfig(topo) {
@@ -22,19 +24,29 @@ var ElementTagTipConfig = /*#__PURE__*/function () {
22
24
  case 0:
23
25
  this.topoData = topoData;
24
26
  this.mtCodes = getMonitorTemplateCodesFromTopoData(topoData);
25
- _context.next = 4;
27
+ _context.prev = 2;
28
+ _context.next = 5;
26
29
  return getMetricsByMonitorTemplateCodes(this.mtCodes);
27
30
 
28
- case 4:
31
+ case 5:
29
32
  this.mtMetricsMap = _context.sent;
33
+ _context.next = 11;
34
+ break;
35
+
36
+ case 8:
37
+ _context.prev = 8;
38
+ _context.t0 = _context["catch"](2);
39
+ rlog.error('查询监控模板指标失败', _context.t0);
40
+
41
+ case 11:
30
42
  this.mtCiTypeMap = getMtCodeCiTypeMap(topoData);
31
43
 
32
- case 6:
44
+ case 12:
33
45
  case "end":
34
46
  return _context.stop();
35
47
  }
36
48
  }
37
- }, _callee, this);
49
+ }, _callee, this, [[2, 8]]);
38
50
  }));
39
51
 
40
52
  function init(_x) {
@@ -62,6 +74,26 @@ var ElementTagTipConfig = /*#__PURE__*/function () {
62
74
  return this.getFiedldMapByType(mtCodes, 'link');
63
75
  };
64
76
 
77
+ _proto.getLinkConfigItems = function getLinkConfigItems() {
78
+ var mtCodes = getLinkMtCodes(this.topoData);
79
+ var linkFidldMap = this.getLinkFidldMap();
80
+ return [{
81
+ id: 'm.critical_link',
82
+ label: '关键链路'
83
+ }, {
84
+ id: 'm.ethernet_link',
85
+ label: '网络链路'
86
+ }] // 只拓扑图上已有资源的监控模板
87
+ .filter(function (item) {
88
+ return mtCodes.includes(item.id);
89
+ }).map(function (t) {
90
+ return _extends({}, t, {
91
+ icon: '/img/model/networkLink.svg',
92
+ list: linkFidldMap[t.id] || []
93
+ });
94
+ });
95
+ };
96
+
65
97
  _proto.getFiedldMapByType = function getFiedldMapByType(mtCodes, type) {
66
98
  var _this = this;
67
99
 
@@ -77,24 +109,26 @@ var ElementTagTipConfig = /*#__PURE__*/function () {
77
109
 
78
110
  var extItems = type === 'node' ? [{
79
111
  lavel: '图片名称',
80
- value: 'graph:name'
112
+ value: 'graph:name',
113
+ typeName: null
81
114
  }, {
82
115
  lavel: '资源类型',
83
- value: 'ciType:name'
116
+ value: 'ciType:name',
117
+ typeName: null
84
118
  }] : [];
85
119
  map[mtCode] = [].concat(extItems, attributes.map(function (item) {
86
120
  return {
87
121
  type: 'attribute',
88
- label: item.name,
89
- value: "attribute:" + item.code,
90
- data: item
122
+ typeName: '属性',
123
+ name: item.name,
124
+ code: "attribute:" + item.code
91
125
  };
92
126
  }), metrics.map(function (item) {
93
127
  return {
94
128
  type: 'metric',
95
- label: item.name,
96
- value: "metric:" + item.code,
97
- data: item
129
+ typeName: '指标',
130
+ name: item.name,
131
+ code: "metric:" + item.code
98
132
  };
99
133
  }));
100
134
  });
@@ -29,7 +29,7 @@ export function getLinkMtCodes(data) {
29
29
  return getMtCodes(links);
30
30
  }
31
31
  export function getMonitorTemplateCodesFromTopoData(data) {
32
- return [].concat(getNodeMtCodes(data), getLinkMtCodes(data));
32
+ return [].concat(getLinkMtCodes(data)); // return [...getNodeMtCodes(data), ...getLinkMtCodes(data)]
33
33
  }
34
34
  export function getMtCodeCiTypeMap(data) {
35
35
  var nodes = data.nodes,
@@ -33,12 +33,12 @@ export function saveTopo(_x) {
33
33
 
34
34
  function _saveTopo() {
35
35
  _saveTopo = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(data) {
36
- var topoId, template, layout, backgroundId, exportLinkIdList, globalConfig, serialize, resources, groups, viewGroupId, groupInfo, viewResources;
36
+ var topoId, template, layout, backgroundId, globalConfig, serialize, resources, groups, exportLinkIdList, relateTopoIdList, viewGroupId, groupInfo, viewResources;
37
37
  return _regeneratorRuntime.wrap(function _callee$(_context) {
38
38
  while (1) {
39
39
  switch (_context.prev = _context.next) {
40
40
  case 0:
41
- topoId = data.id, template = data.template, layout = data.layout, backgroundId = data.backgroundId, exportLinkIdList = data.exportLinkIdList, globalConfig = data.globalConfig, serialize = data.serialize, resources = data.resources, groups = data.groups, viewGroupId = data.viewGroupId;
41
+ topoId = data.id, template = data.template, layout = data.layout, backgroundId = data.backgroundId, globalConfig = data.globalConfig, serialize = data.serialize, resources = data.resources, groups = data.groups, exportLinkIdList = data.exportLinkIdList, relateTopoIdList = data.relateTopoIdList, viewGroupId = data.viewGroupId;
42
42
  rlog.debug("saveTopo", data); // 保存布局
43
43
 
44
44
  if (!(template && layout)) {
@@ -89,7 +89,11 @@ function _saveTopo() {
89
89
 
90
90
  rlog.debug("saveTopo-groupInfo", groupInfo);
91
91
  _context.next = 15;
92
- return topoService.bindResourceToTopo(topoId, null, groupInfo, exportLinkIdList);
92
+ return topoService.bindResourceToTopo(topoId, {
93
+ groups: groupInfo,
94
+ exportLinkIdList: exportLinkIdList,
95
+ relateTopoIdList: relateTopoIdList
96
+ });
93
97
 
94
98
  case 15:
95
99
  if (!serialize) {