@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
@@ -13,7 +13,7 @@ var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/
13
13
 
14
14
  var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
15
15
 
16
- var _topo = _interopRequireDefault(require("@riil-frontend/component-topology-common/es/services/topo"));
16
+ var _services = _interopRequireDefault(require("../services"));
17
17
 
18
18
  var _rlog = _interopRequireDefault(require("@riil-frontend/component-topology-utils/es/rlog"));
19
19
 
@@ -59,7 +59,7 @@ function _default(topoApp) {
59
59
  case 0:
60
60
  id = payload.id;
61
61
  _context.next = 3;
62
- return _topo["default"].getTopoTree();
62
+ return _this.getTopoTree();
63
63
 
64
64
  case 3:
65
65
  resTreeData = _context.sent;
@@ -85,24 +85,65 @@ function _default(topoApp) {
85
85
  }, _callee);
86
86
  }))();
87
87
  },
88
+ getTopoTree: function getTopoTree(payload, rootState) {
89
+ return (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee2() {
90
+ var showAllTree, resTreeData;
91
+ return _regenerator["default"].wrap(function _callee2$(_context2) {
92
+ while (1) {
93
+ switch (_context2.prev = _context2.next) {
94
+ case 0:
95
+ // 拓扑中心 如果有管理导航树权限,展示完整拓扑树
96
+ showAllTree = topoApp.options.full && rootState.functionAuth.permissions.manageNavTree;
97
+
98
+ if (!showAllTree) {
99
+ _context2.next = 7;
100
+ break;
101
+ }
102
+
103
+ _context2.next = 4;
104
+ return _services["default"].getTopoTree();
105
+
106
+ case 4:
107
+ resTreeData = _context2.sent;
108
+ _context2.next = 10;
109
+ break;
110
+
111
+ case 7:
112
+ _context2.next = 9;
113
+ return _services["default"].getTopoTreeByLoginUser();
114
+
115
+ case 9:
116
+ resTreeData = _context2.sent;
117
+
118
+ case 10:
119
+ return _context2.abrupt("return", resTreeData);
120
+
121
+ case 11:
122
+ case "end":
123
+ return _context2.stop();
124
+ }
125
+ }
126
+ }, _callee2);
127
+ }))();
128
+ },
88
129
  getSelectedTopoId: function getSelectedTopoId(payload, rootState) {
89
130
  return rootState.topoTreeMod.selectedNode[0];
90
131
  },
91
132
  refreshTree: function refreshTree(payload, rootState) {
92
133
  var _this2 = this;
93
134
 
94
- return (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee2() {
135
+ return (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee3() {
95
136
  var resTreeData, _formatTree2, treeData, defId;
96
137
 
97
- return _regenerator["default"].wrap(function _callee2$(_context2) {
138
+ return _regenerator["default"].wrap(function _callee3$(_context3) {
98
139
  while (1) {
99
- switch (_context2.prev = _context2.next) {
140
+ switch (_context3.prev = _context3.next) {
100
141
  case 0:
101
- _context2.next = 2;
102
- return _topo["default"].getTopoTree();
142
+ _context3.next = 2;
143
+ return _this2.getTopoTree();
103
144
 
104
145
  case 2:
105
- resTreeData = _context2.sent;
146
+ resTreeData = _context3.sent;
106
147
  // 格式化tree数据
107
148
  _formatTree2 = (0, _tree.formatTree)(resTreeData, rootState.functionAuth.permissions), treeData = _formatTree2[0], defId = _formatTree2[1];
108
149
 
@@ -114,20 +155,20 @@ function _default(topoApp) {
114
155
 
115
156
  case 5:
116
157
  case "end":
117
- return _context2.stop();
158
+ return _context3.stop();
118
159
  }
119
160
  }
120
- }, _callee2);
161
+ }, _callee3);
121
162
  }))();
122
163
  },
123
164
  editTopoOnTree: function editTopoOnTree(conditions, state) {
124
165
  var _this3 = this;
125
166
 
126
- return (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee3() {
167
+ return (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee4() {
127
168
  var resTreeData, treeData;
128
- return _regenerator["default"].wrap(function _callee3$(_context3) {
169
+ return _regenerator["default"].wrap(function _callee4$(_context4) {
129
170
  while (1) {
130
- switch (_context3.prev = _context3.next) {
171
+ switch (_context4.prev = _context4.next) {
131
172
  case 0:
132
173
  if (conditions === void 0) {
133
174
  conditions = {};
@@ -135,11 +176,11 @@ function _default(topoApp) {
135
176
 
136
177
  _rlog["default"].debug('editTopoOnTree', conditions);
137
178
 
138
- _context3.next = 4;
139
- return _topo["default"].editTopoonTree(parseInt(conditions.id, 10), conditions.name, conditions.type);
179
+ _context4.next = 4;
180
+ return _services["default"].editTopoonTree(parseInt(conditions.id, 10), conditions.name, conditions.type);
140
181
 
141
182
  case 4:
142
- resTreeData = _context3.sent;
183
+ resTreeData = _context4.sent;
143
184
  treeData = clone(state.topoTreeMod.treeData);
144
185
 
145
186
  if (resTreeData) {
@@ -161,10 +202,10 @@ function _default(topoApp) {
161
202
 
162
203
  case 7:
163
204
  case "end":
164
- return _context3.stop();
205
+ return _context4.stop();
165
206
  }
166
207
  }
167
- }, _callee3);
208
+ }, _callee4);
168
209
  }))();
169
210
  },
170
211
 
@@ -196,36 +237,36 @@ function _default(topoApp) {
196
237
  * @param {*} state
197
238
  */
198
239
  deleteTopoOnTree: function deleteTopoOnTree(conditions, state) {
199
- return (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee4() {
240
+ return (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee5() {
200
241
  var currentTopoId, isDeleteCurrentP;
201
- return _regenerator["default"].wrap(function _callee4$(_context4) {
242
+ return _regenerator["default"].wrap(function _callee5$(_context5) {
202
243
  while (1) {
203
- switch (_context4.prev = _context4.next) {
244
+ switch (_context5.prev = _context5.next) {
204
245
  case 0:
205
246
  _rlog["default"].debug('deleteTopoOnTree', conditions, state, dispatch.topoMod);
206
247
 
207
248
  currentTopoId = state.topoMod.topoId;
208
249
 
209
250
  if (!("" + conditions === "" + currentTopoId)) {
210
- _context4.next = 13;
251
+ _context5.next = 13;
211
252
  break;
212
253
  }
213
254
 
214
255
  _rlog["default"].debug('deleteTopo-currentTopo', conditions);
215
256
 
216
- _context4.next = 6;
257
+ _context5.next = 6;
217
258
  return dispatch.topoMod.updateDelId("" + conditions);
218
259
 
219
260
  case 6:
220
- _context4.next = 8;
261
+ _context5.next = 8;
221
262
  return topoApp.alarm.close();
222
263
 
223
264
  case 8:
224
- _context4.next = 10;
225
- return _topo["default"].deleteTopoonTree(parseInt(conditions, 10));
265
+ _context5.next = 10;
266
+ return _services["default"].deleteTopoonTree(parseInt(conditions, 10));
226
267
 
227
268
  case 10:
228
- return _context4.abrupt("return", _context4.sent);
269
+ return _context5.abrupt("return", _context5.sent);
229
270
 
230
271
  case 13:
231
272
  // 判断删除的拓扑或文件,是否包含当前拓扑,如果包含就先关闭告警
@@ -237,36 +278,36 @@ function _default(topoApp) {
237
278
  });
238
279
 
239
280
  if (!isDeleteCurrentP) {
240
- _context4.next = 18;
281
+ _context5.next = 18;
241
282
  break;
242
283
  }
243
284
 
244
- _context4.next = 18;
285
+ _context5.next = 18;
245
286
  return topoApp.alarm.close();
246
287
 
247
288
  case 18:
248
- _context4.next = 20;
249
- return _topo["default"].deleteTopoonTree(parseInt(conditions, 10));
289
+ _context5.next = 20;
290
+ return _services["default"].deleteTopoonTree(parseInt(conditions, 10));
250
291
 
251
292
  case 20:
252
- return _context4.abrupt("return", _context4.sent);
293
+ return _context5.abrupt("return", _context5.sent);
253
294
 
254
295
  case 21:
255
296
  case "end":
256
- return _context4.stop();
297
+ return _context5.stop();
257
298
  }
258
299
  }
259
- }, _callee4);
300
+ }, _callee5);
260
301
  }))();
261
302
  },
262
303
  setDefTopoOnTree: function setDefTopoOnTree(conditions, state) {
263
304
  var _this4 = this;
264
305
 
265
- return (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee5() {
306
+ return (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee6() {
266
307
  var resTreeData;
267
- return _regenerator["default"].wrap(function _callee5$(_context5) {
308
+ return _regenerator["default"].wrap(function _callee6$(_context6) {
268
309
  while (1) {
269
- switch (_context5.prev = _context5.next) {
310
+ switch (_context6.prev = _context6.next) {
270
311
  case 0:
271
312
  if (conditions === void 0) {
272
313
  conditions = {};
@@ -274,12 +315,12 @@ function _default(topoApp) {
274
315
 
275
316
  _rlog["default"].debug('setDefTopoOnTree', conditions);
276
317
 
277
- _context5.next = 4;
278
- return _topo["default"].setDefTopo(parseInt(conditions, 10));
318
+ _context6.next = 4;
319
+ return _services["default"].setDefTopo(parseInt(conditions, 10));
279
320
 
280
321
  case 4:
281
- resTreeData = _context5.sent;
282
- _context5.next = 7;
322
+ resTreeData = _context6.sent;
323
+ _context6.next = 7;
283
324
  return _this4.refreshTree();
284
325
 
285
326
  case 7:
@@ -287,10 +328,10 @@ function _default(topoApp) {
287
328
 
288
329
  case 8:
289
330
  case "end":
290
- return _context5.stop();
331
+ return _context6.stop();
291
332
  }
292
333
  }
293
- }, _callee5);
334
+ }, _callee6);
294
335
  }))();
295
336
  },
296
337
  setDefaultTopoId: function setDefaultTopoId(defaultTopoId) {
@@ -0,0 +1,137 @@
1
+ "use strict";
2
+
3
+ var _resourcePermissionUtil = require("../resourcePermissionUtil");
4
+
5
+ function test(data) {
6
+ var message = data.message,
7
+ expected = data.expected,
8
+ link = data.link,
9
+ source = data.source,
10
+ target = data.target;
11
+ var result = (0, _resourcePermissionUtil.getLinkPermission)(link, source, target);
12
+
13
+ if (JSON.stringify(result) !== JSON.stringify(expected)) {
14
+ console.error(message, '失败', {
15
+ result: result,
16
+ expected: expected,
17
+ data: {
18
+ link: link,
19
+ source: source,
20
+ target: target
21
+ }
22
+ });
23
+ } else {
24
+ console.debug(message, '通过');
25
+ }
26
+ }
27
+
28
+ var exitLink = {
29
+ attributes: {
30
+ 'network_link.is_crucial': false
31
+ }
32
+ };
33
+ var commonLink = {
34
+ attributes: {
35
+ 'network_link.is_crucial': false,
36
+ 'network_link.destination_device_id': 'xxx'
37
+ }
38
+ };
39
+ var data = [{
40
+ message: '[链路权限]出口链路源设备有write权限',
41
+ link: exitLink,
42
+ source: {
43
+ operation: 'write'
44
+ },
45
+ target: null,
46
+ expected: {
47
+ readable: true,
48
+ writeable: true,
49
+ deleteable: true
50
+ }
51
+ }, {
52
+ message: '[链路权限]出口链路源设备无权限',
53
+ link: exitLink,
54
+ source: {
55
+ operation: null
56
+ },
57
+ target: null,
58
+ expected: {
59
+ readable: false,
60
+ writeable: false,
61
+ deleteable: false
62
+ }
63
+ }, {
64
+ message: '[链路权限]普通链路源设备无权限',
65
+ link: commonLink,
66
+ source: {
67
+ operation: null
68
+ },
69
+ target: {
70
+ operation: null
71
+ },
72
+ expected: {
73
+ readable: false,
74
+ writeable: false,
75
+ deleteable: false
76
+ }
77
+ }, {
78
+ message: '[链路权限]普通链路源设备一端write权限',
79
+ link: commonLink,
80
+ source: {
81
+ operation: 'write'
82
+ },
83
+ target: {
84
+ operation: null
85
+ },
86
+ expected: {
87
+ readable: true,
88
+ writeable: false,
89
+ deleteable: true
90
+ }
91
+ }, {
92
+ message: '[链路权限]普通链路源设备一端delete权限',
93
+ link: commonLink,
94
+ source: {
95
+ operation: 'delete'
96
+ },
97
+ target: {
98
+ operation: null
99
+ },
100
+ expected: {
101
+ readable: true,
102
+ writeable: false,
103
+ deleteable: true
104
+ }
105
+ }, {
106
+ message: '[链路权限]普通链路源设备2端write权限',
107
+ link: commonLink,
108
+ source: {
109
+ operation: 'write'
110
+ },
111
+ target: {
112
+ operation: 'write'
113
+ },
114
+ expected: {
115
+ readable: true,
116
+ writeable: true,
117
+ deleteable: true
118
+ }
119
+ }, {
120
+ message: '[链路权限]关键链路权限',
121
+ link: {
122
+ attributes: {
123
+ 'network_link.is_crucial': true
124
+ },
125
+ operation: 'write'
126
+ },
127
+ source: {},
128
+ target: {},
129
+ expected: {
130
+ readable: true,
131
+ writeable: true,
132
+ deleteable: false
133
+ }
134
+ }];
135
+ data.forEach(function (item) {
136
+ test(item);
137
+ });
@@ -11,6 +11,8 @@ exports.parseBasicPermission = parseBasicPermission;
11
11
 
12
12
  var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
13
13
 
14
+ var _linkUtils = require("../../core/models/utils/linkUtils");
15
+
14
16
  function getNodePermission(node) {
15
17
  return parseBasicPermission(node === null || node === void 0 ? void 0 : node.operation);
16
18
  }
@@ -33,22 +35,25 @@ function parseBasicPermission(operation) {
33
35
 
34
36
 
35
37
  function getLinkPermission(link, source, target) {
36
- var linkType = link.attributes['network_link.connect_type']; // 出口链路使用权限中心配置
37
-
38
- if (linkType === 'exit') {
38
+ // 关键链路使用权限中心配置
39
+ if ((0, _linkUtils.isCrucialLink)(link)) {
39
40
  return parseBasicPermission(link === null || link === void 0 ? void 0 : link.operation);
40
41
  }
41
42
 
43
+ var deviceNodes = target ? [source, target] : [source];
44
+
42
45
  var isWriteable = function isWriteable() {
43
- return [source, target].filter(function (node) {
46
+ return deviceNodes.filter(function (node) {
44
47
  return ['write', 'delete'].indexOf(node === null || node === void 0 ? void 0 : node.operation) !== -1;
45
- }).length === 2;
48
+ }).length === deviceNodes.length;
46
49
  };
47
50
 
48
51
  return {
49
52
  readable: !!(source !== null && source !== void 0 && source.operation) || !!(target !== null && target !== void 0 && target.operation),
53
+ // 一端设备有权限可查看
50
54
  writeable: isWriteable(),
51
- deleteable: [source, target].filter(function (node) {
55
+ // 两端设备都有编辑权限可编辑(出口链路仅验证一端)
56
+ deleteable: deviceNodes.filter(function (node) {
52
57
  return ['write', 'delete'].includes(node === null || node === void 0 ? void 0 : node.operation);
53
58
  }).length >= 1
54
59
  };
package/lib/style.js CHANGED
@@ -1,6 +1,7 @@
1
1
  require('@riil-frontend/component-topology-graph/lib/style');
2
2
  require('@alifd/next/lib/message/style');
3
3
  require('@alifd/next/lib/dialog/style');
4
+ require('@riil-frontend/component-topology-utils/lib/style');
4
5
  require('@riil-frontend/utils/lib/style');
5
6
  require('@alifd/next/lib/upload/style');
6
7
  require('@alifd/next/lib/icon/style');
@@ -11,7 +12,6 @@ require('@alifd/next/lib/form/style');
11
12
  require('@alifd/next/lib/loading/style');
12
13
  require('@alifd/next/lib/drawer/style');
13
14
  require('@alifd/next/lib/button/style');
14
- require('@riil-frontend/component-topology-utils/lib/style');
15
15
  require('@riil-frontend/component-common-res-list/lib/style');
16
16
  require('@riil-frontend/component-no-data-page/lib/style');
17
17
  require('@alifd/next/lib/tab/style');
@@ -24,6 +24,7 @@ require('@alifd/next/lib/divider/style');
24
24
 
25
25
  require('@alifd/next/lib/overlay/style');
26
26
  require('@alifd/next/lib/checkbox/style');
27
+ require('@riil-frontend/component-crucial-link-topo/lib/style');
27
28
  require('@alifd/next/lib/box/style');
28
29
  require('@alifd/next/lib/list/style');
29
30
  require('@alifd/next/lib/card/style');
@@ -9,6 +9,8 @@ var _rlog = _interopRequireDefault(require("@riil-frontend/component-topology-ut
9
9
 
10
10
  var _sortBy = _interopRequireDefault(require("lodash/sortBy"));
11
11
 
12
+ var _linkUtils = require("../core/models/utils/linkUtils");
13
+
12
14
  var _clusterUtil = require("./clusterUtil");
13
15
 
14
16
  var _htElementDataUtil = require("./htElementDataUtil");
@@ -25,34 +27,19 @@ function getResourceConfigFromHt(topo) {
25
27
  var htTopo = topo.getHtTopo();
26
28
  var dataModel = topo.getDataModel(); // 获得分层
27
29
 
28
- var layerElements = (0, _htElementUtils.getLayers)(dataModel);
29
- var layers = layerElements.map(function (layerElement) {
30
- return {
31
- id: layerElement.getTag(),
32
- tag: layerElement.a("tag"),
33
- name: layerElement.s("label"),
34
- order: layerElement.a("order"),
35
- resources: {
36
- "static": (0, _htElementDataUtil.getLayerChildrenResourceElements)(layerElement).map(function (node) {
37
- return node.getTag();
38
- })
39
- }
40
- };
41
- }); // 获得容器
30
+ var layers = getLayerDatas(dataModel); // 获得容器
42
31
 
43
32
  var groupElements = (0, _htElementUtils.getGroups)(dataModel); // 获得视图上的区域配置
44
33
 
45
- var groups = groupElements.filter(function (node) {
46
- return !node.getParent();
47
- }).filter(function (groupElement) {
48
- return !(0, _clusterUtil.isClusterHtElement)(groupElement);
49
- }).map(getGroupConfigByElement);
50
- groups = (0, _sortBy["default"])([].concat(layers, groups), "order"); // 获得视图上的资源列表
34
+ var groups = getGroupDatas({
35
+ groupElements: groupElements,
36
+ layers: layers
37
+ }); // 获得视图上的资源列表
51
38
 
52
39
  var viewNodes = (0, _htElementUtils.getNodes)(dataModel).filter(function (node) {
53
40
  return !node.getParent();
54
41
  }).filter(function (node) {
55
- return node.a("type") === "node";
42
+ return node.a('type') === 'node';
56
43
  }).filter(function (node) {
57
44
  return !!node.getTag();
58
45
  });
@@ -63,15 +50,44 @@ function getResourceConfigFromHt(topo) {
63
50
  "static": [].concat(viewNodes, viewClusters).map(function (node) {
64
51
  return node.getTag();
65
52
  })
66
- }; // console.error('getResourceConfigFromHt', {
67
- // viewNodes,
68
- // });
69
- // 查询出口链路列表
53
+ };
54
+ return {
55
+ layers: (0, _sortBy["default"])(layers, 'order'),
56
+ groups: groups,
57
+ resources: resources,
58
+ exportLinkIdList: getExportLinkIdList({
59
+ topo: topo,
60
+ htTopo: htTopo,
61
+ dataModel: dataModel
62
+ }),
63
+ // 出口链路id列表
64
+ relateTopoIdList: getRelateTopoIdList(dataModel)
65
+ };
66
+ } // 查询关联拓扑id列表
67
+
68
+
69
+ function getRelateTopoIdList(dataModel) {
70
+ return (0, _htElementUtils.getNodes)(dataModel).reduce(function (topoIds, node) {
71
+ var bindType = node.a('bindType');
72
+ var bindTopo = node.a('bindTopo');
73
+
74
+ if (bindType === 'topo' && bindTopo && !topoIds.includes(bindTopo)) {
75
+ return [].concat(topoIds, [bindTopo]);
76
+ }
70
77
 
78
+ return topoIds;
79
+ }, []);
80
+ } // 查询出口链路列表
81
+
82
+
83
+ function getExportLinkIdList(_ref) {
84
+ var topo = _ref.topo,
85
+ htTopo = _ref.htTopo,
86
+ dataModel = _ref.dataModel;
71
87
  var exportLinkIdList = [];
72
88
  var edges = (0, _htElementUtils.getEdges)(dataModel);
73
89
 
74
- _rlog["default"].debug(" 查询出口链路列表-edges", edges, dataModel);
90
+ _rlog["default"].debug(' 查询出口链路列表-edges', edges, dataModel);
75
91
 
76
92
  edges.forEach(function (edge) {
77
93
  var edgeData = htTopo.getEdgeData(edge); // 有组无子连线返回null
@@ -82,29 +98,54 @@ function getResourceConfigFromHt(topo) {
82
98
 
83
99
  if (id) {
84
100
  var linkData = topo.dataModel.getDataById(id);
85
- var connectType = linkData !== null && linkData !== void 0 && linkData.attributes ? linkData === null || linkData === void 0 ? void 0 : linkData.attributes["network_link.connect_type"] : undefined;
86
101
 
87
- if (connectType === "exit" && !exportLinkIdList.includes(id)) {
102
+ if ((0, _linkUtils.isExitLink)(linkData) && !exportLinkIdList.includes(id)) {
88
103
  exportLinkIdList.push(id);
89
104
  }
90
105
  }
91
106
  }
92
107
  });
93
- return {
94
- layers: (0, _sortBy["default"])(layers, "order"),
95
- groups: groups,
96
- resources: resources,
97
- exportLinkIdList: exportLinkIdList // 出口链路id列表
108
+ return exportLinkIdList;
109
+ }
98
110
 
99
- };
111
+ function getLayerDatas(dataModel) {
112
+ // 获得分层
113
+ var layerElements = (0, _htElementUtils.getLayers)(dataModel);
114
+ var layers = layerElements.map(function (layerElement) {
115
+ return {
116
+ id: layerElement.getTag(),
117
+ tag: layerElement.a('tag'),
118
+ name: layerElement.s('label'),
119
+ order: layerElement.a('order'),
120
+ resources: {
121
+ "static": (0, _htElementDataUtil.getLayerChildrenResourceElements)(layerElement).map(function (node) {
122
+ return node.getTag();
123
+ })
124
+ }
125
+ };
126
+ });
127
+ return layers;
128
+ }
129
+
130
+ function getGroupDatas(_ref2) {
131
+ var groupElements = _ref2.groupElements,
132
+ layers = _ref2.layers;
133
+ // 获得视图上的区域配置
134
+ var groups = groupElements.filter(function (node) {
135
+ return !node.getParent();
136
+ }).filter(function (groupElement) {
137
+ return !(0, _clusterUtil.isClusterHtElement)(groupElement);
138
+ }).map(getGroupConfigByElement);
139
+ groups = (0, _sortBy["default"])([].concat(layers, groups), 'order');
140
+ return groups;
100
141
  }
101
142
 
102
143
  function getGroupConfigByElement(groupElement) {
103
144
  return {
104
145
  id: groupElement.getTag(),
105
- tag: groupElement.a("tag"),
106
- name: groupElement.a("name"),
107
- order: groupElement.a("order"),
146
+ tag: groupElement.a('tag'),
147
+ name: groupElement.a('name'),
148
+ order: groupElement.a('order'),
108
149
  resources: {
109
150
  "static": (0, _htElementDataUtil.getGroupChildrenResourceElements)(groupElement).filter(function (node) {
110
151
  return !!node.getTag();
@@ -145,7 +145,7 @@ function upgradeV103GraphClusterNode(topo, topoData) {
145
145
  return;
146
146
  }
147
147
 
148
- _rlog["default"].error('集群1.0.2升级', unExistedList);
148
+ _rlog["default"].info('集群1.0.2升级', unExistedList);
149
149
 
150
150
  var groups = unExistedList.filter(function (item) {
151
151
  return item.type === 'group';
@@ -410,6 +410,5 @@ function isExistedElement(htTopo, dataModel, data) {
410
410
  }
411
411
  }
412
412
 
413
- console.error(111, data);
414
413
  return false;
415
414
  }