@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
@@ -155,6 +155,15 @@ var AttributeMetricDisplay = /*#__PURE__*/function () {
155
155
  tips: filterByPermission(node, ciTypeConfig.tips)
156
156
  };
157
157
  });
158
+ } // eslint-disable-next-line class-methods-use-this
159
+ ;
160
+
161
+ _proto.getModelType = function getModelType(ci) {
162
+ if (ci.ciType === 'network_link') {
163
+ return ci.attributes.support_templates;
164
+ }
165
+
166
+ return ci.ciType;
158
167
  }
159
168
  /**
160
169
  * 按链路类型获取对应的属性、指标配置
@@ -168,75 +177,8 @@ var AttributeMetricDisplay = /*#__PURE__*/function () {
168
177
  linkTag = _this$getConfig2.linkTag,
169
178
  linkTip = _this$getConfig2.linkTip;
170
179
 
171
- var ciTypeMeta;
172
- var isNetworkLink = link.ciType === 'network_link';
173
-
174
- if (isNetworkLink) {
175
- var linkConnectType = link.attributes['network_link.connect_type'];
176
- ciTypeMeta = this.topo.ciTyeCache.getNetworkLinkCiType(linkConnectType);
177
- } else {
178
- ciTypeMeta = this.topo.ciTyeCache.getCiType(link.ciType);
179
- }
180
-
181
- var dataType = isNetworkLink ? link.attributes['network_link.connect_type'] : link.ciType;
182
-
183
- function getNetworkFieldItems(configItems) {
184
- var getMetricCode = function getMetricCode(code) {
185
- var _connectTypeMap$linkC;
186
-
187
- var linkConnectType = link.attributes['network_link.connect_type'];
188
- var connectTypeMap = {
189
- phy: {
190
- id: 'phy',
191
- metricPrefix: 'physical_link.'
192
- },
193
- agg: {
194
- id: 'agg',
195
- metricPrefix: 'agg_link.'
196
- },
197
- exit: {
198
- id: 'exit',
199
- metricPrefix: 'export_link.'
200
- }
201
- };
202
- var metricPrefix = (_connectTypeMap$linkC = connectTypeMap[linkConnectType]) === null || _connectTypeMap$linkC === void 0 ? void 0 : _connectTypeMap$linkC.metricPrefix;
203
-
204
- if (!metricPrefix) {
205
- return null;
206
- }
207
-
208
- var finalCode = null;
209
-
210
- if (ciTypeMeta.metricMap[code]) {
211
- finalCode = code;
212
- } else if (ciTypeMeta.metricMap["" + metricPrefix + code]) {
213
- finalCode = "" + metricPrefix + code;
214
- }
215
-
216
- return finalCode;
217
- };
218
-
219
- var formatItems = function formatItems(items) {
220
- var newItems = [];
221
- items.forEach(function (item) {
222
- if (item.type === 'metric') {
223
- var code = item.code;
224
- var finalCode = getMetricCode(code);
225
-
226
- if (finalCode) {
227
- newItems.push((0, _extends2["default"])({}, item, {
228
- code: finalCode
229
- }));
230
- }
231
- } else {
232
- newItems.push(item);
233
- }
234
- });
235
- return newItems;
236
- };
237
-
238
- return formatItems(configItems);
239
- }
180
+ var ciTypeMeta = this.topo.ciTyeCache.getCiTypeByCi(link);
181
+ var modelType = this.getModelType(link);
240
182
 
241
183
  function getItems(cfg) {
242
184
  if (!ciTypeMeta || !cfg) {
@@ -245,8 +187,7 @@ var AttributeMetricDisplay = /*#__PURE__*/function () {
245
187
 
246
188
  var isCustom = cfg.isCustom,
247
189
  data = cfg.data;
248
- var configItems = (isCustom ? data[dataType] : data) || [];
249
- var items = isNetworkLink ? getNetworkFieldItems(configItems) : configItems; // 过滤不存在的
190
+ var items = (isCustom ? data[modelType] : data) || []; // 过滤不存在的
250
191
 
251
192
  return filterUnExistedFields(items, ciTypeMeta);
252
193
  }
@@ -695,14 +636,31 @@ var AttributeMetricDisplay = /*#__PURE__*/function () {
695
636
  return;
696
637
  }
697
638
 
698
- var elementTagsAndTips = this.buildTagsTips().map(function (item) {
699
- // 开锁状态下禁用悬停展示悬浮框
639
+ var elementTagsAndTips = this.buildTagsTips() // 开锁状态下禁用悬停展示悬浮框
640
+ .map(function (item) {
700
641
  var _topo$store$getModelS = topo.store.getModelState('lock'),
701
642
  lock = _topo$store$getModelS.lock;
702
643
 
703
644
  return lock ? item : (0, _extends2["default"])({}, item, {
704
645
  tips: []
705
646
  });
647
+ }) // 链路指标都没值时不显示
648
+ .map(function (item) {
649
+ var tags = item.tags;
650
+
651
+ if (item.type === 'edge') {
652
+ var allNoValue = tags.data.filter(function (tItem) {
653
+ return tItem.value === '- ';
654
+ }).length === tags.data.length;
655
+
656
+ if (allNoValue) {
657
+ tags.data = [];
658
+ }
659
+ }
660
+
661
+ return (0, _extends2["default"])({}, item, {
662
+ tags: tags
663
+ });
706
664
  });
707
665
 
708
666
  _rlog["default"].debug("AttributeMetricDisplay.updateTagsTips " + new Date().toLocaleString(), elementTagsAndTips);
@@ -9,77 +9,83 @@ var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends")
9
9
 
10
10
  var _rlog = _interopRequireDefault(require("@riil-frontend/component-topology-utils/es/rlog"));
11
11
 
12
- var _lodash = require("lodash");
13
-
14
12
  var ht = window.ht;
15
13
 
16
14
  var HistoryManager = /*#__PURE__*/function () {
17
- function HistoryManager(topo) {
18
- var _this = this;
19
-
15
+ function HistoryManager(topo, htHistoryManager) {
20
16
  this.topo = null;
21
17
  this.htHistoryManager = void 0;
22
18
  this.storeHistory = [];
23
19
  this.topo = topo;
24
- var dm = topo.getDataModel();
25
- this.htHistoryManager = new ht.HistoryManager(dm);
26
- this.htHistoryManager.isPropertyUndoable = this.isPropertyUndoable;
27
- window.addEventListener('keydown', function (e) {
28
- //增加快捷键支持
29
- if (e.ctrlKey) {
30
- if (e.keyCode == 90) {
31
- //ctrl+z 撤销
32
- _this.undo();
33
- } else if (e.keyCode == 89) {
34
- //ctrl+y 重做
35
- _this.redo();
36
- }
37
- }
38
- });
39
- }
20
+ this.htHistoryManager = htHistoryManager;
21
+
22
+ _rlog["default"].info('HistoryManager 初始化', htHistoryManager);
23
+ } // 增加快捷键支持
24
+
40
25
 
41
26
  var _proto = HistoryManager.prototype;
42
27
 
43
- _proto.xxx = function xxx() {// 记录自定义历史数据到htHistoryManager最后一个历史
44
- } // eslint-disable-next-line class-methods-use-this
45
- ;
28
+ _proto.handleKeyDown = function handleKeyDown(e) {
29
+ // 事务中禁用回退
30
+ // eslint-disable-next-line no-underscore-dangle
31
+ if (this.htHistoryManager._betweenTransaction) {
32
+ return;
33
+ }
34
+
35
+ var isCtrlDown = ht.Default.isCtrlDown;
46
36
 
47
- _proto.isPropertyUndoable = function isPropertyUndoable(property) {
48
- var ignore = ['s:edge.color', 'a:arrow.color', 'icons', 'a:runtimeStyles'];
37
+ if (isCtrlDown(e)) {
38
+ if (e.keyCode === 90) {
39
+ // ctrl+z 撤销
40
+ this.undo();
41
+ } // else if (e.keyCode == 89) {//ctrl+y 重做
42
+ // this.redo();
43
+ // }
49
44
 
50
- if (ignore.includes(property)) {
51
- return false;
52
45
  }
46
+ };
47
+
48
+ _proto.setDisabled = function setDisabled(disabled, message) {
49
+ this.htHistoryManager.setDisabled(disabled);
53
50
 
54
- return true;
51
+ _rlog["default"].debug("HistoryManager.setDisabled " + (disabled ? '禁用' : '启用') + (message ? "(" + message + ")" : '') + ": " + this.toString(), this.getHistories());
55
52
  };
56
53
 
57
54
  _proto.beginTransaction = function beginTransaction() {
58
- var _this2 = this;
55
+ var _this = this;
59
56
 
60
57
  this.htHistoryManager.beginTransaction();
61
58
  var items = [{
62
59
  modelName: 'topoMod',
63
60
  property: 'data'
61
+ }, // 拓扑类型
62
+ {
63
+ modelName: 'topoMod',
64
+ property: 'type'
64
65
  }, {
65
66
  modelName: 'displayConfig',
66
67
  property: 'expandAllEdges'
68
+ }, {
69
+ modelName: 'displayConfig',
70
+ property: 'nodeLabelStyle'
71
+ }, {
72
+ modelName: 'background',
73
+ property: 'current'
67
74
  }];
68
75
  this.storeHistory = items.map(function (item) {
69
76
  return (0, _extends2["default"])({}, item, {
70
- oldValue: _this2.topo.store.getModelState(item.modelName)[item.property]
77
+ oldValue: _this.topo.store.getModelState(item.modelName)[item.property]
71
78
  });
72
79
  });
80
+
81
+ _rlog["default"].debug("HistoryManager.beginTransaction: " + this.toString(), this.getHistories());
73
82
  };
74
83
 
75
- _proto.endTransaction = function endTransaction() {
76
- var _this3 = this;
84
+ _proto.addStoreHistory = function addStoreHistory() {
85
+ var _this2 = this;
77
86
 
78
- // eslint-disable-next-line no-underscore-dangle
79
- var betweenTransaction = this.htHistoryManager._betweenTransaction;
80
- this.htHistoryManager.endTransaction();
81
87
  var storeChanged = this.storeHistory.map(function (item) {
82
- var newValue = _this3.topo.store.getModelState(item.modelName)[item.property];
88
+ var newValue = _this2.topo.store.getModelState(item.modelName)[item.property];
83
89
 
84
90
  if (item.oldValue === newValue) {
85
91
  return false;
@@ -92,19 +98,25 @@ var HistoryManager = /*#__PURE__*/function () {
92
98
  return !!item;
93
99
  });
94
100
 
95
- _rlog["default"].debug('endTransaction', storeChanged, betweenTransaction);
96
-
97
- if (betweenTransaction === 1 && storeChanged.length) {
98
- var histories = this.getHistories();
99
- var item = histories[histories.length - 1][0];
100
- item.storeData = storeChanged;
101
+ if (storeChanged.length) {
102
+ this.htHistoryManager.addHistory({
103
+ type: 'store',
104
+ data: storeChanged
105
+ });
101
106
 
102
- _rlog["default"].debug('endTransaction', item);
107
+ _rlog["default"].debug('HistoryManager.addStoreHistory', storeChanged);
103
108
  }
104
109
 
105
110
  this.storeHistory = [];
106
111
  };
107
112
 
113
+ _proto.endTransaction = function endTransaction() {
114
+ this.addStoreHistory();
115
+ this.htHistoryManager.endTransaction();
116
+
117
+ _rlog["default"].debug("HistoryManager.endTransaction: " + this.toString(), this.getHistories());
118
+ };
119
+
108
120
  _proto.clear = function clear() {
109
121
  this.htHistoryManager.clear();
110
122
  };
@@ -113,19 +125,42 @@ var HistoryManager = /*#__PURE__*/function () {
113
125
  return this.htHistoryManager.getHistories();
114
126
  };
115
127
 
116
- _proto.undo = function undo() {
117
- var _histories$,
118
- _this4 = this;
128
+ _proto.getHistoryIndex = function getHistoryIndex() {
129
+ return this.htHistoryManager.getHistoryIndex();
130
+ };
119
131
 
120
- // 从htHistoryManager获取最后一个历史获取 自定义历史数据
132
+ _proto.getCurrentStoreHistory = function getCurrentStoreHistory(isUndo) {
133
+ var historyIndex = this.getHistoryIndex();
121
134
  var histories = this.getHistories();
122
- var storeHistory = (_histories$ = histories[histories.length - 1][0]) === null || _histories$ === void 0 ? void 0 : _histories$.storeData;
135
+ var history = histories[isUndo ? historyIndex : historyIndex + 1];
136
+
137
+ if (!history) {
138
+ return null;
139
+ }
140
+
141
+ var storeHistory = history.filter(function (item) {
142
+ return item.type === 'store';
143
+ });
144
+
145
+ if (storeHistory.length) {
146
+ return storeHistory[0].data;
147
+ }
148
+
149
+ return null;
150
+ };
151
+
152
+ _proto.undo = function undo() {
153
+ var _this3 = this;
154
+
155
+ _rlog["default"].debug('HistoryManager.undo', this.getHistories(), this.getHistoryIndex());
156
+
157
+ var storeHistory = this.getCurrentStoreHistory(true);
123
158
 
124
159
  if (storeHistory) {
125
160
  storeHistory.forEach(function (item) {
126
- var _this4$topo$store$get;
161
+ var _this3$topo$store$get;
127
162
 
128
- _this4.topo.store.getModelDispatchers(item.modelName).update((_this4$topo$store$get = {}, _this4$topo$store$get[item.property] = item.oldValue, _this4$topo$store$get));
163
+ _this3.topo.store.getModelDispatchers(item.modelName).update((_this3$topo$store$get = {}, _this3$topo$store$get[item.property] = item.oldValue, _this3$topo$store$get));
129
164
  });
130
165
  } // 回退绘图区
131
166
 
@@ -134,9 +169,28 @@ var HistoryManager = /*#__PURE__*/function () {
134
169
  };
135
170
 
136
171
  _proto.redo = function redo() {
172
+ var _this4 = this;
173
+
174
+ _rlog["default"].debug('HistoryManager.redo', this.getHistories(), this.getHistoryIndex());
175
+
176
+ var storeHistory = this.getCurrentStoreHistory(false);
177
+
178
+ if (storeHistory) {
179
+ storeHistory.forEach(function (item) {
180
+ var _this4$topo$store$get;
181
+
182
+ _this4.topo.store.getModelDispatchers(item.modelName).update((_this4$topo$store$get = {}, _this4$topo$store$get[item.property] = item.newValue, _this4$topo$store$get));
183
+ });
184
+ } // 回退绘图区
185
+
186
+
137
187
  this.htHistoryManager.redo();
138
188
  };
139
189
 
190
+ _proto.toString = function toString() {
191
+ return "{Histories: " + this.getHistories().length + ", Index: " + this.getHistoryIndex() + "}";
192
+ };
193
+
140
194
  return HistoryManager;
141
195
  }();
142
196
 
@@ -50,7 +50,7 @@ var _topoFactory = _interopRequireDefault(require("./topoFactory"));
50
50
  var _ElementTagTipConfig = _interopRequireDefault(require("./tagstips/ElementTagTipConfig"));
51
51
 
52
52
  // eslint-disable-next-line no-undef
53
- var version = typeof "5.0.0-alpha.9" === 'string' ? "5.0.0-alpha.9" : null;
53
+ var version = typeof "5.0.2" === 'string' ? "5.0.2" : null;
54
54
  console.info("\u62D3\u6251\u7248\u672C: " + version);
55
55
  /**
56
56
  * 拓扑显示和编辑
@@ -15,6 +15,8 @@ var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/creat
15
15
 
16
16
  var _topo = _interopRequireDefault(require("@riil-frontend/component-topology-common/es/services/topo"));
17
17
 
18
+ var _rlog = _interopRequireDefault(require("@riil-frontend/component-topology-utils/lib/rlog"));
19
+
18
20
  var _keyBy = _interopRequireDefault(require("lodash/keyBy"));
19
21
 
20
22
  /**
@@ -22,7 +24,6 @@ var _keyBy = _interopRequireDefault(require("lodash/keyBy"));
22
24
  */
23
25
  var CiTyeCache = /*#__PURE__*/function () {
24
26
  function CiTyeCache() {
25
- this.cache = void 0;
26
27
  this.cache = {};
27
28
  }
28
29
 
@@ -45,7 +46,8 @@ var CiTyeCache = /*#__PURE__*/function () {
45
46
  case 5:
46
47
  _context.prev = 5;
47
48
  _context.t0 = _context["catch"](0);
48
- console.error('查询Ci模型异常', _context.t0);
49
+
50
+ _rlog["default"].error('查询Ci模型异常', _context.t0);
49
51
 
50
52
  case 8:
51
53
  return _context.abrupt("return", this.cache);
@@ -130,6 +132,14 @@ var CiTyeCache = /*#__PURE__*/function () {
130
132
  return this.cache[typeCode];
131
133
  };
132
134
 
135
+ _proto.getCiTypeByCi = function getCiTypeByCi(ci) {
136
+ // if (ci.ciType === 'network_link') {
137
+ // const supportTemplates = link.attributes.support_templates;
138
+ // } else {
139
+ // }
140
+ return this.getCiType(ci.ciType);
141
+ };
142
+
133
143
  _proto.getAttribute = function getAttribute(typeCode, attrCode) {
134
144
  var ciType = this.getCiType(typeCode);
135
145
  return ciType === null || ciType === void 0 ? void 0 : ciType.attributeMap[attrCode];
@@ -140,48 +150,6 @@ var CiTyeCache = /*#__PURE__*/function () {
140
150
  return ciType === null || ciType === void 0 ? void 0 : ciType.metricMap[metricCode];
141
151
  };
142
152
 
143
- _proto.getNetworkLinkCiType = function getNetworkLinkCiType(connectType) {
144
- var ciType = this.getCiType('network_link');
145
- var types = [{
146
- id: 'phy',
147
- metricPprefix: 'physical_link.'
148
- }, {
149
- id: 'agg',
150
- metricPprefix: 'agg_link.'
151
- }, {
152
- id: 'exit',
153
- metricPprefix: 'export_link.'
154
- }];
155
- var excludeMetricPprefixs = types.filter(function (t) {
156
- return t.id !== connectType;
157
- }).map(function (t) {
158
- return t.metricPprefix;
159
- });
160
- var model = null;
161
- types.forEach(function (type) {
162
- if (type.id === connectType) {
163
- var metrics = ciType.metrics // 仅出口链路有:ping状态、专线连通状态
164
- .filter(function (metric) {
165
- if (connectType === 'exit') {
166
- return true;
167
- }
168
-
169
- return ['icmp_discards_rate', 'ping_status'].indexOf(metric.code) === -1;
170
- }) // 按链路类型过滤对应指标
171
- .filter(function (metric) {
172
- return !excludeMetricPprefixs.filter(function (excludeMetricPprefix) {
173
- return metric.code.indexOf(excludeMetricPprefix) !== -1;
174
- }).length;
175
- });
176
- model = (0, _extends2["default"])({}, ciType, {
177
- metrics: metrics,
178
- metricMap: (0, _keyBy["default"])(metrics || [], 'code')
179
- });
180
- }
181
- });
182
- return model;
183
- };
184
-
185
153
  (0, _createClass2["default"])(CiTyeCache, [{
186
154
  key: "ciTypes",
187
155
  get: function get() {
@@ -13,6 +13,8 @@ var _utils = require("@riil-frontend/utils");
13
13
 
14
14
  var modelService = _interopRequireWildcard(require("@riil-frontend/component-topology-common/es/services/model"));
15
15
 
16
+ var _rlog = _interopRequireDefault(require("@riil-frontend/component-topology-utils/lib/rlog"));
17
+
16
18
  function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
17
19
 
18
20
  function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { "default": obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj["default"] = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
@@ -57,7 +59,8 @@ var DictCache = /*#__PURE__*/function () {
57
59
  case 7:
58
60
  _context.next = 9;
59
61
  return modelService.queryDicts()["catch"](function (e) {
60
- console.error('初始化数据字典异常', e);
62
+ _rlog["default"].error('初始化数据字典异常', e);
63
+
61
64
  return [];
62
65
  });
63
66
 
@@ -1,8 +1,14 @@
1
1
  "use strict";
2
2
 
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+
3
5
  exports.__esModule = true;
4
6
  exports["default"] = void 0;
5
7
 
8
+ var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
9
+
10
+ var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
11
+
6
12
  /**
7
13
  * 拓扑背景图
8
14
  */
@@ -10,22 +16,36 @@ var Background = /*#__PURE__*/function () {
10
16
  function Background(view) {
11
17
  var _this = this;
12
18
 
13
- this.setSize = function (_ref) {
14
- var width = _ref.width,
15
- height = _ref.height;
16
-
17
- var backgroundNode = _this.getBackgroundNode();
18
-
19
- backgroundNode.setWidth(width);
20
- backgroundNode.setHeight(height);
21
-
22
- var backgroundDispatchers = _this.view.store.getModelDispatchers('background');
23
-
24
- backgroundDispatchers.setSize({
25
- width: width,
26
- height: height
27
- });
28
- };
19
+ this.setSize = /*#__PURE__*/function () {
20
+ var _ref2 = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee(_ref) {
21
+ var width, height, backgroundNode, backgroundDispatchers;
22
+ return _regenerator["default"].wrap(function _callee$(_context) {
23
+ while (1) {
24
+ switch (_context.prev = _context.next) {
25
+ case 0:
26
+ width = _ref.width, height = _ref.height;
27
+ backgroundNode = _this.getBackgroundNode();
28
+ backgroundNode.setWidth(width);
29
+ backgroundNode.setHeight(height);
30
+ backgroundDispatchers = _this.view.store.getModelDispatchers('background');
31
+ _context.next = 7;
32
+ return backgroundDispatchers.setSize({
33
+ width: width,
34
+ height: height
35
+ });
36
+
37
+ case 7:
38
+ case "end":
39
+ return _context.stop();
40
+ }
41
+ }
42
+ }, _callee);
43
+ }));
44
+
45
+ return function (_x) {
46
+ return _ref2.apply(this, arguments);
47
+ };
48
+ }();
29
49
 
30
50
  this.view = view;
31
51
  }
@@ -7,12 +7,16 @@ exports["default"] = void 0;
7
7
 
8
8
  var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
9
9
 
10
+ var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
11
+
10
12
  var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
11
13
 
12
14
  var _utils = require("./utils");
13
15
 
14
16
  var _topo = require("../../services/topo");
15
17
 
18
+ var _rlog = _interopRequireDefault(require("@riil-frontend/component-topology-utils/lib/rlog"));
19
+
16
20
  var ElementTagTipConfig = /*#__PURE__*/function () {
17
21
  function ElementTagTipConfig(topo) {
18
22
  this.topoData = void 0;
@@ -32,19 +36,30 @@ var ElementTagTipConfig = /*#__PURE__*/function () {
32
36
  case 0:
33
37
  this.topoData = topoData;
34
38
  this.mtCodes = (0, _utils.getMonitorTemplateCodesFromTopoData)(topoData);
35
- _context.next = 4;
39
+ _context.prev = 2;
40
+ _context.next = 5;
36
41
  return (0, _topo.getMetricsByMonitorTemplateCodes)(this.mtCodes);
37
42
 
38
- case 4:
43
+ case 5:
39
44
  this.mtMetricsMap = _context.sent;
45
+ _context.next = 11;
46
+ break;
47
+
48
+ case 8:
49
+ _context.prev = 8;
50
+ _context.t0 = _context["catch"](2);
51
+
52
+ _rlog["default"].error('查询监控模板指标失败', _context.t0);
53
+
54
+ case 11:
40
55
  this.mtCiTypeMap = (0, _utils.getMtCodeCiTypeMap)(topoData);
41
56
 
42
- case 6:
57
+ case 12:
43
58
  case "end":
44
59
  return _context.stop();
45
60
  }
46
61
  }
47
- }, _callee, this);
62
+ }, _callee, this, [[2, 8]]);
48
63
  }));
49
64
 
50
65
  function init(_x) {
@@ -72,6 +87,26 @@ var ElementTagTipConfig = /*#__PURE__*/function () {
72
87
  return this.getFiedldMapByType(mtCodes, 'link');
73
88
  };
74
89
 
90
+ _proto.getLinkConfigItems = function getLinkConfigItems() {
91
+ var mtCodes = (0, _utils.getLinkMtCodes)(this.topoData);
92
+ var linkFidldMap = this.getLinkFidldMap();
93
+ return [{
94
+ id: 'm.critical_link',
95
+ label: '关键链路'
96
+ }, {
97
+ id: 'm.ethernet_link',
98
+ label: '网络链路'
99
+ }] // 只拓扑图上已有资源的监控模板
100
+ .filter(function (item) {
101
+ return mtCodes.includes(item.id);
102
+ }).map(function (t) {
103
+ return (0, _extends2["default"])({}, t, {
104
+ icon: '/img/model/networkLink.svg',
105
+ list: linkFidldMap[t.id] || []
106
+ });
107
+ });
108
+ };
109
+
75
110
  _proto.getFiedldMapByType = function getFiedldMapByType(mtCodes, type) {
76
111
  var _this = this;
77
112
 
@@ -87,24 +122,26 @@ var ElementTagTipConfig = /*#__PURE__*/function () {
87
122
 
88
123
  var extItems = type === 'node' ? [{
89
124
  lavel: '图片名称',
90
- value: 'graph:name'
125
+ value: 'graph:name',
126
+ typeName: null
91
127
  }, {
92
128
  lavel: '资源类型',
93
- value: 'ciType:name'
129
+ value: 'ciType:name',
130
+ typeName: null
94
131
  }] : [];
95
132
  map[mtCode] = [].concat(extItems, attributes.map(function (item) {
96
133
  return {
97
134
  type: 'attribute',
98
- label: item.name,
99
- value: "attribute:" + item.code,
100
- data: item
135
+ typeName: '属性',
136
+ name: item.name,
137
+ code: "attribute:" + item.code
101
138
  };
102
139
  }), metrics.map(function (item) {
103
140
  return {
104
141
  type: 'metric',
105
- label: item.name,
106
- value: "metric:" + item.code,
107
- data: item
142
+ typeName: '指标',
143
+ name: item.name,
144
+ code: "metric:" + item.code
108
145
  };
109
146
  }));
110
147
  });
@@ -43,7 +43,7 @@ function getLinkMtCodes(data) {
43
43
  }
44
44
 
45
45
  function getMonitorTemplateCodesFromTopoData(data) {
46
- return [].concat(getNodeMtCodes(data), getLinkMtCodes(data));
46
+ return [].concat(getLinkMtCodes(data)); // return [...getNodeMtCodes(data), ...getLinkMtCodes(data)]
47
47
  }
48
48
 
49
49
  function getMtCodeCiTypeMap(data) {