@riil-frontend/component-topology 3.1.5 → 3.1.8

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 (65) hide show
  1. package/CHANGELOG.md +4 -15
  2. package/build/1.js +1 -1
  3. package/build/index.css +1 -1
  4. package/build/index.js +11 -11
  5. package/demo/1/345/237/272/346/234/254//345/256/232/345/210/266/345/214/226/350/265/204/346/272/220/346/246/202/350/247/210.md +11 -0
  6. package/demo/1/345/237/272/346/234/254//350/207/252/345/256/232/344/271/211/346/240/207/346/263/250/345/222/214/346/202/254/346/265/256/346/241/206.md +11 -0
  7. package/demo//346/240/207/346/263/250/345/222/214/346/202/254/346/265/256/346/241/206//350/207/252/345/256/232/344/271/211/345/261/236/346/200/247/345/222/214/346/214/207/346/240/207.md +2 -2
  8. package/demo-mock/basic/topo/v1/api/attributes/once +9164 -2796
  9. package/demo-mock/basic/topo/v1/api/attributes/once.json +9164 -2796
  10. package/es/core/components/DisplaySettingDrawer/DisplaySetting.js +4 -5
  11. package/es/core/components/DisplaySettingDrawer/DisplaySettingDrawer.js +2 -2
  12. package/es/core/components/DisplaySettingDrawer/hooks/useDisplaySetting.js +4 -4
  13. package/es/core/models/AttributeMetricDisplay.js +112 -98
  14. package/es/core/models/TopoApp.js +1 -1
  15. package/es/core/viewer/components/plugins/{BaseInfo/index.js → ResourceDetail/ResourceDetail.js} +23 -11
  16. package/es/core/viewer/components/plugins/ResourceDetail/ResourceDetailPlugin.js +11 -0
  17. package/es/core/viewer/components/plugins/ResourceDetail/components/ResourceOverview/BaseInfo.js +131 -0
  18. package/es/core/viewer/components/plugins/ResourceDetail/components/ResourceOverview/BaseInfoBlock.js +31 -0
  19. package/es/core/viewer/components/plugins/{BaseInfo → ResourceDetail}/components/ResourceOverview/BlockBox.js +0 -0
  20. package/es/core/viewer/components/plugins/{BaseInfo → ResourceDetail}/components/ResourceOverview/BlockBox.module.scss +0 -0
  21. package/es/core/viewer/components/plugins/ResourceDetail/components/ResourceOverview/ResourceOverviewMetric.js +46 -0
  22. package/es/core/viewer/components/plugins/{BaseInfo → ResourceDetail}/components/ResourceOverview/SingleResourceStrategyLink.js +4 -2
  23. package/es/core/viewer/components/plugins/{BaseInfo → ResourceDetail}/components/ResourceOverview/index.js +70 -180
  24. package/es/core/viewer/components/plugins/{BaseInfo → ResourceDetail}/components/ResourceOverview/index.module.scss +0 -0
  25. package/es/core/viewer/components/plugins/ResourceDetail/components/ResourceOverview/useCiAttrAndMetricData.js +12 -0
  26. package/es/core/viewer/components/plugins/ResourceDetail/index.js +2 -0
  27. package/es/core/viewer/components/plugins/ResourceDetail/index.module.scss +39 -30
  28. package/es/core/viewer/components/plugins/ViewerPlugin.js +2 -2
  29. package/es/core/viewer/components/titlebar/BasicTools.js +1 -1
  30. package/es/core/viewer/components/titlebar/widgets/SettingButton.js +3 -4
  31. package/es/core/viewer/components/titlebar/widgets/SettingButtonWidget.js +19 -0
  32. package/es/topoCenter/components/TopoView.js +3 -4
  33. package/es/topoCenter/models/TopoCenter.js +9 -5
  34. package/lib/core/components/DisplaySettingDrawer/DisplaySetting.js +4 -5
  35. package/lib/core/components/DisplaySettingDrawer/DisplaySettingDrawer.js +2 -2
  36. package/lib/core/components/DisplaySettingDrawer/hooks/useDisplaySetting.js +4 -4
  37. package/lib/core/models/AttributeMetricDisplay.js +111 -97
  38. package/lib/core/models/TopoApp.js +1 -1
  39. package/lib/core/viewer/components/plugins/{BaseInfo/index.js → ResourceDetail/ResourceDetail.js} +25 -12
  40. package/lib/core/viewer/components/plugins/ResourceDetail/ResourceDetailPlugin.js +21 -0
  41. package/lib/core/viewer/components/plugins/ResourceDetail/components/ResourceOverview/BaseInfo.js +141 -0
  42. package/lib/core/viewer/components/plugins/ResourceDetail/components/ResourceOverview/BaseInfoBlock.js +42 -0
  43. package/lib/core/viewer/components/plugins/{BaseInfo → ResourceDetail}/components/ResourceOverview/BlockBox.js +0 -0
  44. package/lib/core/viewer/components/plugins/{BaseInfo → ResourceDetail}/components/ResourceOverview/BlockBox.module.scss +0 -0
  45. package/lib/core/viewer/components/plugins/ResourceDetail/components/ResourceOverview/ResourceOverviewMetric.js +56 -0
  46. package/lib/core/viewer/components/plugins/{BaseInfo → ResourceDetail}/components/ResourceOverview/SingleResourceStrategyLink.js +4 -2
  47. package/lib/core/viewer/components/plugins/{BaseInfo → ResourceDetail}/components/ResourceOverview/index.js +73 -182
  48. package/lib/core/viewer/components/plugins/{BaseInfo → ResourceDetail}/components/ResourceOverview/index.module.scss +0 -0
  49. package/lib/core/viewer/components/plugins/ResourceDetail/components/ResourceOverview/useCiAttrAndMetricData.js +17 -0
  50. package/lib/core/viewer/components/plugins/ResourceDetail/index.js +11 -0
  51. package/lib/core/viewer/components/plugins/ResourceDetail/index.module.scss +39 -30
  52. package/lib/core/viewer/components/plugins/ViewerPlugin.js +2 -2
  53. package/lib/core/viewer/components/titlebar/BasicTools.js +2 -2
  54. package/lib/core/viewer/components/titlebar/widgets/SettingButton.js +2 -3
  55. package/lib/core/viewer/components/titlebar/widgets/SettingButtonWidget.js +28 -0
  56. package/lib/topoCenter/components/TopoView.js +3 -4
  57. package/lib/topoCenter/models/TopoCenter.js +9 -5
  58. package/package.json +2 -2
  59. package/demo/1/345/237/272/346/234/254//350/207/252/345/256/232/344/271/211/345/261/236/346/200/247/345/222/214/346/214/207/346/240/207.md +0 -11
  60. package/es/core/viewer/components/plugins/BaseInfo/index.module.scss +0 -49
  61. package/es/core/viewer/components/plugins/ResourceDetail/ResourceDetailDrawerPlugin.js +0 -37
  62. package/es/core/viewer/components/plugins/ResourceDetail/topoDrawer.js +0 -147
  63. package/lib/core/viewer/components/plugins/BaseInfo/index.module.scss +0 -49
  64. package/lib/core/viewer/components/plugins/ResourceDetail/ResourceDetailDrawerPlugin.js +0 -50
  65. package/lib/core/viewer/components/plugins/ResourceDetail/topoDrawer.js +0 -167
@@ -17,16 +17,15 @@ import EdgeFlowDirection from "./EdgeFlowDirection";
17
17
 
18
18
  function DisplaySetting(props, ref) {
19
19
  var topo = props.topo,
20
- viewerProps = props.viewerProps;
20
+ displaySettingProps = props.displaySettingProps;
21
21
  var displayConfig = topo.store.getModelState('displayConfig');
22
22
 
23
- var _ref = (viewerProps === null || viewerProps === void 0 ? void 0 : viewerProps.displaySettingDrawerProps) || {},
23
+ var _ref = displaySettingProps || {},
24
24
  linkTagConfig = _ref.linkTagConfig,
25
25
  linkTipConfig = _ref.linkTipConfig,
26
26
  showEdgeExpandConfig = _ref.showEdgeExpandConfig,
27
- extraConfig = _ref.extraConfig;
28
-
29
- var showLinkConfig = !!(viewerProps !== null && viewerProps !== void 0 && viewerProps.showLinkConfig);
27
+ extraConfig = _ref.extraConfig,
28
+ showLinkConfig = _ref.showLinkConfig;
30
29
 
31
30
  var field = _Field.useField({
32
31
  autoUnmount: false,
@@ -9,7 +9,7 @@ import useDisplaySetting from "./hooks/useDisplaySetting";
9
9
  export default function DisplaySettingDrawer(props) {
10
10
  var visible = props.visible,
11
11
  topo = props.topo,
12
- viewerProps = props.viewerProps,
12
+ displaySettingProps = props.displaySettingProps,
13
13
  onClose = props.onClose;
14
14
  var settingRef = useRef();
15
15
 
@@ -76,7 +76,7 @@ export default function DisplaySettingDrawer(props) {
76
76
  }, visible && /*#__PURE__*/React.createElement(DisplaySetting, {
77
77
  ref: settingRef,
78
78
  topo: topo,
79
- viewerProps: viewerProps
79
+ displaySettingProps: displaySettingProps
80
80
  }));
81
81
  }
82
82
  ;
@@ -4,7 +4,7 @@ import _regeneratorRuntime from "@babel/runtime/regenerator";
4
4
  import topoService from '@riil-frontend/component-topology-common/es/services/topo';
5
5
  export default (function (props) {
6
6
  var topo = props.topo,
7
- viewerProps = props.viewerProps,
7
+ displaySettingProps = props.displaySettingProps,
8
8
  settingRef = props.settingRef;
9
9
 
10
10
  var executeByConfig = /*#__PURE__*/function () {
@@ -17,7 +17,7 @@ export default (function (props) {
17
17
  // 更新节点名称显示隐藏
18
18
  topo.attributeMetricDisplay.updateNodesNameVisible(); // 更新连线展开折叠状态
19
19
 
20
- if (viewerProps !== null && viewerProps !== void 0 && viewerProps.showLinkConfig) {
20
+ if (displaySettingProps !== null && displaySettingProps !== void 0 && displaySettingProps.showLinkConfig) {
21
21
  if (config.expandAllEdges) {
22
22
  topo.getHtTopo().expandAllEdgeGroups();
23
23
  } else {
@@ -49,7 +49,7 @@ export default (function (props) {
49
49
 
50
50
  var save = /*#__PURE__*/function () {
51
51
  var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2() {
52
- var _viewerProps$displayS;
52
+ var _displaySettingProps$;
53
53
 
54
54
  var values, prevDisplayConfig, displayConfig, displayConfigDispatchers, extraOnOk;
55
55
  return _regeneratorRuntime.wrap(function _callee2$(_context2) {
@@ -73,7 +73,7 @@ export default (function (props) {
73
73
  displayConfigDispatchers.update(displayConfig); // 按配置执行
74
74
 
75
75
  executeByConfig(displayConfig);
76
- extraOnOk = (viewerProps === null || viewerProps === void 0 ? void 0 : (_viewerProps$displayS = viewerProps.displaySettingDrawerProps) === null || _viewerProps$displayS === void 0 ? void 0 : _viewerProps$displayS.onOk) || (viewerProps === null || viewerProps === void 0 ? void 0 : viewerProps.onDisplaySettingDrawerOk);
76
+ extraOnOk = (displaySettingProps === null || displaySettingProps === void 0 ? void 0 : (_displaySettingProps$ = displaySettingProps.displaySettingProps) === null || _displaySettingProps$ === void 0 ? void 0 : _displaySettingProps$.onOk) || (displaySettingProps === null || displaySettingProps === void 0 ? void 0 : displaySettingProps.onDisplaySettingDrawerOk);
77
77
 
78
78
  if (extraOnOk) {
79
79
  extraOnOk();
@@ -4,7 +4,7 @@ import _regeneratorRuntime from "@babel/runtime/regenerator";
4
4
  import topoServer from '@riil-frontend/component-topology-common/es/services/topo';
5
5
  import rlog from '@riil-frontend/component-topology-utils/es/rlog';
6
6
  import { keyBy } from 'lodash';
7
- import { DEFAULT_LINK_TAG_COMMON_CONFIG, DEFAULT_NODE_TAG_COMMON_CONFIG, DEFAULT_TAG_COMMON_CONFIG, DEFAULT_TIP_COMMON_CONFIG } from "../../constants/ResourceInfoDisplay";
7
+ import { DEFAULT_NODE_TAG_COMMON_CONFIG, DEFAULT_TIP_COMMON_CONFIG } from "../../constants/ResourceInfoDisplay";
8
8
  import { findItem } from "../../utils/topoData";
9
9
  import { queryCisByIds } from "../services";
10
10
  import AttributeFormatter from "./attributeFormatter";
@@ -35,8 +35,10 @@ var filterByPermission = function filterByPermission(resource, items) {
35
35
 
36
36
  var AttributeMetricDisplay = /*#__PURE__*/function () {
37
37
  function AttributeMetricDisplay(topo) {
38
+ var _this$topo$options$ta;
39
+
38
40
  this.topo = topo;
39
- var ExtElementTagTipBuilder = this.topo.options.ExtElementTagTipBuilder;
41
+ var ExtElementTagTipBuilder = (_this$topo$options$ta = this.topo.options.tagTip) === null || _this$topo$options$ta === void 0 ? void 0 : _this$topo$options$ta.ExtElementTagTipBuilder;
40
42
 
41
43
  if (ExtElementTagTipBuilder) {
42
44
  this.extElementTagTipBuilder = new ExtElementTagTipBuilder(this);
@@ -76,6 +78,10 @@ var AttributeMetricDisplay = /*#__PURE__*/function () {
76
78
  var ciTypeMeta = this.topo.ciTyeCache.getCiType(ciType);
77
79
 
78
80
  function getItems(cfg) {
81
+ if (!ciTypeMeta || !cfg) {
82
+ return [];
83
+ }
84
+
79
85
  var isCustom = cfg.isCustom,
80
86
  data = cfg.data;
81
87
  var items = (isCustom ? data[ciType] : data) || []; // 过滤类型不存在的属性和指标、图片名称
@@ -90,94 +96,6 @@ var AttributeMetricDisplay = /*#__PURE__*/function () {
90
96
  tips: getItems(nodeTip || DEFAULT_TIP_COMMON_CONFIG)
91
97
  };
92
98
  }
93
- /**
94
- * 按链路类型获取对应的属性、指标配置
95
- * @param {*} link
96
- * @param {*} config
97
- * @returns
98
- */
99
- ;
100
-
101
- _proto.getNetworkLinkConfig = function getNetworkLinkConfig(link, config) {
102
- var _this$getConfig2 = this.getConfig(config),
103
- linkTag = _this$getConfig2.linkTag,
104
- linkTip = _this$getConfig2.linkTip;
105
-
106
- var linkConnectType = link.attributes['network_link.connect_type'];
107
- var ciTypeMeta = this.topo.ciTyeCache.getNetworkLinkCiType(linkConnectType);
108
-
109
- var getMetricCode = function getMetricCode(code) {
110
- var _connectTypeMap$linkC;
111
-
112
- var connectTypeMap = {
113
- phy: {
114
- id: 'phy',
115
- metricPrefix: 'physical_link.'
116
- },
117
- agg: {
118
- id: 'agg',
119
- metricPrefix: 'agg_link.'
120
- },
121
- exit: {
122
- id: 'exit',
123
- metricPrefix: 'export_link.'
124
- }
125
- };
126
- var metricPrefix = (_connectTypeMap$linkC = connectTypeMap[linkConnectType]) === null || _connectTypeMap$linkC === void 0 ? void 0 : _connectTypeMap$linkC.metricPrefix;
127
-
128
- if (!metricPrefix) {
129
- return null;
130
- }
131
-
132
- var finalCode = null;
133
-
134
- if (ciTypeMeta.metricMap[code]) {
135
- finalCode = code;
136
- } else if (ciTypeMeta.metricMap["" + metricPrefix + code]) {
137
- finalCode = "" + metricPrefix + code;
138
- }
139
-
140
- return finalCode;
141
- };
142
-
143
- var formatItems = function formatItems(items) {
144
- var newItems = [];
145
- items.forEach(function (item) {
146
- if (item.type === 'metric') {
147
- var code = item.code;
148
- var finalCode = getMetricCode(code);
149
-
150
- if (finalCode) {
151
- newItems.push(_extends({}, item, {
152
- code: finalCode
153
- }));
154
- }
155
- } else {
156
- newItems.push(item);
157
- }
158
- });
159
- return newItems;
160
- };
161
-
162
- function getItems(cfg) {
163
- if (!ciTypeMeta || !cfg) {
164
- return [];
165
- }
166
-
167
- var isCustom = cfg.isCustom,
168
- data = cfg.data;
169
- var configItems = (isCustom ? data[linkConnectType] : data) || [];
170
- var items = formatItems(configItems); // 过滤不存在的
171
-
172
- return filterUnExistedFields(items, ciTypeMeta);
173
- }
174
-
175
- var defaultLinkTagTipConfig = this.topo.options.defaultLinkTagTipConfig;
176
- return {
177
- tags: getItems(linkTag || (defaultLinkTagTipConfig === null || defaultLinkTagTipConfig === void 0 ? void 0 : defaultLinkTagTipConfig.tag)),
178
- tips: getItems(linkTip || (defaultLinkTagTipConfig === null || defaultLinkTagTipConfig === void 0 ? void 0 : defaultLinkTagTipConfig.tip))
179
- };
180
- }
181
99
  /**
182
100
  * 查询需要查询数据的连线
183
101
  *
@@ -203,10 +121,6 @@ var AttributeMetricDisplay = /*#__PURE__*/function () {
203
121
  }));
204
122
  };
205
123
 
206
- _proto.getLinkTagTipConfig = function getLinkTagTipConfig(link) {
207
- return this.getNetworkLinkConfig(link);
208
- };
209
-
210
124
  _proto.getNodesTagTipConfig = function getNodesTagTipConfig() {
211
125
  var _this = this;
212
126
 
@@ -228,6 +142,109 @@ var AttributeMetricDisplay = /*#__PURE__*/function () {
228
142
  tips: filterByPermission(node, ciTypeConfig.tips)
229
143
  };
230
144
  });
145
+ }
146
+ /**
147
+ * 按链路类型获取对应的属性、指标配置
148
+ * @param {*} link
149
+ * @returns
150
+ */
151
+ ;
152
+
153
+ _proto.getLinkTagTipConfig = function getLinkTagTipConfig(link) {
154
+ var _this$getConfig2 = this.getConfig(),
155
+ linkTag = _this$getConfig2.linkTag,
156
+ linkTip = _this$getConfig2.linkTip;
157
+
158
+ var ciTypeMeta;
159
+ var isNetworkLink = link.ciType === 'network_link';
160
+
161
+ if (isNetworkLink) {
162
+ var linkConnectType = link.attributes['network_link.connect_type'];
163
+ ciTypeMeta = this.topo.ciTyeCache.getNetworkLinkCiType(linkConnectType);
164
+ } else {
165
+ ciTypeMeta = this.topo.ciTyeCache.getCiType(link.ciType);
166
+ }
167
+
168
+ var dataType = isNetworkLink ? link.attributes['network_link.connect_type'] : link.ciType;
169
+
170
+ function getNetworkFieldItems(configItems) {
171
+ var getMetricCode = function getMetricCode(code) {
172
+ var _connectTypeMap$linkC;
173
+
174
+ var linkConnectType = link.attributes['network_link.connect_type'];
175
+ var connectTypeMap = {
176
+ phy: {
177
+ id: 'phy',
178
+ metricPrefix: 'physical_link.'
179
+ },
180
+ agg: {
181
+ id: 'agg',
182
+ metricPrefix: 'agg_link.'
183
+ },
184
+ exit: {
185
+ id: 'exit',
186
+ metricPrefix: 'export_link.'
187
+ }
188
+ };
189
+ var metricPrefix = (_connectTypeMap$linkC = connectTypeMap[linkConnectType]) === null || _connectTypeMap$linkC === void 0 ? void 0 : _connectTypeMap$linkC.metricPrefix;
190
+
191
+ if (!metricPrefix) {
192
+ return null;
193
+ }
194
+
195
+ var finalCode = null;
196
+
197
+ if (ciTypeMeta.metricMap[code]) {
198
+ finalCode = code;
199
+ } else if (ciTypeMeta.metricMap["" + metricPrefix + code]) {
200
+ finalCode = "" + metricPrefix + code;
201
+ }
202
+
203
+ return finalCode;
204
+ };
205
+
206
+ var formatItems = function formatItems(items) {
207
+ var newItems = [];
208
+ items.forEach(function (item) {
209
+ if (item.type === 'metric') {
210
+ var code = item.code;
211
+ var finalCode = getMetricCode(code);
212
+
213
+ if (finalCode) {
214
+ newItems.push(_extends({}, item, {
215
+ code: finalCode
216
+ }));
217
+ }
218
+ } else {
219
+ newItems.push(item);
220
+ }
221
+ });
222
+ return newItems;
223
+ };
224
+
225
+ return formatItems(configItems);
226
+ }
227
+
228
+ function getItems(cfg) {
229
+ if (!ciTypeMeta || !cfg) {
230
+ return [];
231
+ }
232
+
233
+ var isCustom = cfg.isCustom,
234
+ data = cfg.data;
235
+ var configItems = (isCustom ? data[dataType] : data) || [];
236
+ var items = isNetworkLink ? getNetworkFieldItems(configItems) : configItems; // 过滤不存在的
237
+
238
+ return filterUnExistedFields(items, ciTypeMeta);
239
+ }
240
+
241
+ var tagTipOptions = this.topo.options.tagTip;
242
+ var defaultLinkTagConfig = tagTipOptions !== null && tagTipOptions !== void 0 && tagTipOptions.getDefaultLinkTagConfig ? tagTipOptions === null || tagTipOptions === void 0 ? void 0 : tagTipOptions.getDefaultLinkTagConfig(link) : null;
243
+ var defaultLinkTipConfig = tagTipOptions !== null && tagTipOptions !== void 0 && tagTipOptions.getDefaultLinkTipConfig ? tagTipOptions === null || tagTipOptions === void 0 ? void 0 : tagTipOptions.getDefaultLinkTipConfig(link) : null;
244
+ return {
245
+ tags: getItems(linkTag || defaultLinkTagConfig),
246
+ tips: getItems(linkTip || defaultLinkTipConfig)
247
+ };
231
248
  };
232
249
 
233
250
  _proto.getLinksTagTipConfig = function getLinksTagTipConfig() {
@@ -580,10 +597,7 @@ var AttributeMetricDisplay = /*#__PURE__*/function () {
580
597
  });
581
598
  });
582
599
  } else {
583
- rlog.warn('推送属性指标数据:未查询到ciType', {
584
- ciData: ciData,
585
- ciType: ciType
586
- });
600
+ rlog.warn("\u63A8\u9001\u5C5E\u6027\u6307\u6807\u6570\u636E\uFF1A\u672A\u67E5\u8BE2\u5230ciType " + ciType, ciData);
587
601
  }
588
602
  });
589
603
  refIds = Object.keys(refIdMap);
@@ -20,7 +20,7 @@ import { updateEdgeExpanded } from "../utils/edgeUtil";
20
20
  import PluginManager from "./PluginManager";
21
21
  import topoFactory from "./topoFactory"; // eslint-disable-next-line no-undef
22
22
 
23
- var version = typeof "3.1.5" === 'string' ? "3.1.5" : null;
23
+ var version = typeof "3.1.8" === 'string' ? "3.1.8" : null;
24
24
  console.info("\u62D3\u6251\u7248\u672C: " + version);
25
25
  /**
26
26
  * 拓扑显示和编辑
@@ -5,12 +5,13 @@ import _asyncToGenerator from "@babel/runtime/helpers/asyncToGenerator";
5
5
  import _MenuButton from "@alifd/next/es/menu-button";
6
6
  import _Search from "@alifd/next/es/search";
7
7
  import _regeneratorRuntime from "@babel/runtime/regenerator";
8
- import React, { useState, useEffect, useRef, useCallback } from 'react';
9
- import { isAvailableArray, dataSearch } from '@riil-frontend/utils';
10
8
  import { TopoEvent } from '@riil-frontend/component-topology-graph';
9
+ import { dataSearch, isAvailableArray } from '@riil-frontend/utils';
10
+ import React, { useEffect, useState } from 'react';
11
+ import PropTypes from 'prop-types';
11
12
  import service from "../../../../services/overview";
12
- import styles from "./index.module.scss";
13
13
  import ResourceOverview from "./components/ResourceOverview";
14
+ import styles from "./index.module.scss";
14
15
 
15
16
  function Title(_ref) {
16
17
  var id = _ref.id,
@@ -72,8 +73,9 @@ function Title(_ref) {
72
73
  } // 基本信息
73
74
 
74
75
 
75
- function BaseInfo(props) {
76
- var topo = props.topo;
76
+ function ResourceDetail(props) {
77
+ var topo = props.topo,
78
+ canShow = props.canShow;
77
79
 
78
80
  var _topo$store$useModel = topo.store.useModel('topoBaseInfoOverview'),
79
81
  topoState = _topo$store$useModel[0],
@@ -189,8 +191,6 @@ function BaseInfo(props) {
189
191
  }
190
192
 
191
193
  function init(data, targetType) {
192
- var _topo$options$resourc;
193
-
194
194
  console.log('初始化基本信息', data, targetType);
195
195
  var id = data.id,
196
196
  name = data.name,
@@ -199,11 +199,15 @@ function BaseInfo(props) {
199
199
  ciName = data.ciName,
200
200
  operation = data.operation; // 仅展示资源和链路的概览
201
201
 
202
- if (!['node', 'link', 'linkGroup'].includes(type)) return; // 应用拓扑中没有链路详情
203
-
204
- if ((_topo$options$resourc = topo.options.resourceOverviewDrawer) !== null && _topo$options$resourc !== void 0 && _topo$options$resourc.getData && type === 'link') return; // 没有权限不显示
202
+ if (!['node', 'link', 'linkGroup'].includes(type)) return; // 没有权限不显示
205
203
 
206
204
  if (!operation) return;
205
+ var htElement = topo.getDataModel().getDataByTag(id);
206
+
207
+ if (!canShow(htElement)) {
208
+ return;
209
+ }
210
+
207
211
  setActiveData({
208
212
  id: id,
209
213
  name: name,
@@ -273,4 +277,12 @@ function BaseInfo(props) {
273
277
  }))))));
274
278
  }
275
279
 
276
- export default BaseInfo;
280
+ ResourceDetail.propTypes = {
281
+ canShow: PropTypes.func
282
+ };
283
+ ResourceDetail.defaultProps = {
284
+ canShow: function canShow(htElement) {
285
+ return true;
286
+ }
287
+ };
288
+ export default ResourceDetail;
@@ -0,0 +1,11 @@
1
+ import _extends from "@babel/runtime/helpers/extends";
2
+ import React from 'react';
3
+ import ResourceDetail from "./ResourceDetail";
4
+
5
+ function ResourceDetailPlugin(props) {
6
+ var viewerProps = props.viewerProps;
7
+ var resourceDetailProps = viewerProps === null || viewerProps === void 0 ? void 0 : viewerProps.resourceDetailProps;
8
+ return /*#__PURE__*/React.createElement(ResourceDetail, _extends({}, props, resourceDetailProps));
9
+ }
10
+
11
+ export default ResourceDetailPlugin;
@@ -0,0 +1,131 @@
1
+ import React from 'react';
2
+ import { Link } from 'react-router-dom';
3
+ import styles from "./index.module.scss"; // url 处理,UICBB 的地址需截取前缀
4
+
5
+ function formatUrl(url) {
6
+ var _window, _window$location;
7
+
8
+ var prefix = '/default/pagecenter';
9
+
10
+ if (((_window = window) === null || _window === void 0 ? void 0 : (_window$location = _window.location) === null || _window$location === void 0 ? void 0 : _window$location.pathname.indexOf(prefix)) === 0 && (url === null || url === void 0 ? void 0 : url.indexOf(prefix)) === 0) {
11
+ return url.split(prefix)[1];
12
+ } else {
13
+ return url;
14
+ }
15
+ }
16
+
17
+ function AttributeItem(props) {
18
+ var style = props.style,
19
+ key = props.key,
20
+ label = props.label,
21
+ contentTitle = props.contentTitle,
22
+ children = props.children;
23
+ return /*#__PURE__*/React.createElement("div", {
24
+ className: styles.item,
25
+ style: style || {},
26
+ key: key
27
+ }, /*#__PURE__*/React.createElement("span", {
28
+ className: styles.label
29
+ }, label), /*#__PURE__*/React.createElement("span", {
30
+ className: styles.content,
31
+ title: contentTitle
32
+ }, children));
33
+ }
34
+
35
+ function BaseInfoContent(props) {
36
+ var _itemCols$type;
37
+
38
+ var topo = props.topo,
39
+ type = props.type,
40
+ data = props.data;
41
+ var itemCols = {
42
+ node: [{
43
+ label: '资源名称:',
44
+ objKey: 'resource',
45
+ render: function render(valueData, key) {
46
+ var display_name = valueData.display_name,
47
+ link = valueData.link;
48
+ return /*#__PURE__*/React.createElement(AttributeItem, {
49
+ key: key,
50
+ label: "\u8D44\u6E90\u540D\u79F0\uFF1A",
51
+ contentTitle: display_name
52
+ }, valueData ? /*#__PURE__*/React.createElement(Link, {
53
+ className: styles.link,
54
+ to: formatUrl(link)
55
+ }, display_name || '-') : '-');
56
+ }
57
+ }, {
58
+ label: 'IP地址:',
59
+ objKey: 'ipv4_address'
60
+ }, {
61
+ label: '资产编号:',
62
+ objKey: 'asset_number'
63
+ }, {
64
+ label: '资源类型:',
65
+ objKey: 'ciName'
66
+ }, {
67
+ label: '资源位置:',
68
+ objKey: 'res_address'
69
+ } // {
70
+ // label: '负责人:',
71
+ // objKey: 'principal'
72
+ // },
73
+ ],
74
+ link: [{
75
+ label: '链路带宽:',
76
+ objKey: 'rated_bandwidth',
77
+ style: {
78
+ width: '100%'
79
+ }
80
+ }, {
81
+ label: '源IP地址:',
82
+ objKey: 'source_ipv4'
83
+ }, {
84
+ label: '目的IP地址:',
85
+ objKey: 'destination_ipv4'
86
+ }, {
87
+ label: '源端口:',
88
+ objKey: 'source_Interface'
89
+ }, {
90
+ label: '目的端口:',
91
+ objKey: 'destination_Interface'
92
+ }]
93
+ };
94
+ return /*#__PURE__*/React.createElement(React.Fragment, null, (_itemCols$type = itemCols[type]) === null || _itemCols$type === void 0 ? void 0 : _itemCols$type.map(function (_ref, key) {
95
+ var label = _ref.label,
96
+ objKey = _ref.objKey,
97
+ style = _ref.style,
98
+ render = _ref.render;
99
+ return data[objKey] === false ? '' : render ? render(data[objKey], key) : /*#__PURE__*/React.createElement(AttributeItem, {
100
+ key: key,
101
+ label: label,
102
+ style: style || {},
103
+ contentTitle: data[objKey]
104
+ }, data[objKey] || '-');
105
+ }));
106
+ } // 基本信息
107
+
108
+
109
+ export default function BaseInfo(props) {
110
+ var topo = props.topo,
111
+ type = props.type,
112
+ data = props.data,
113
+ baseInfo = props.baseInfo,
114
+ renderContent = props.renderContent;
115
+ var content = renderContent ? renderContent({
116
+ type: type,
117
+ data: data,
118
+ AttributeItem: AttributeItem
119
+ }) : null;
120
+
121
+ if (!content) {
122
+ content = /*#__PURE__*/React.createElement(BaseInfoContent, {
123
+ type: type,
124
+ data: baseInfo
125
+ });
126
+ }
127
+
128
+ return /*#__PURE__*/React.createElement("div", {
129
+ className: styles['base-info']
130
+ }, content);
131
+ }
@@ -0,0 +1,31 @@
1
+ import React from 'react';
2
+ import BaseInfo from "./BaseInfo";
3
+ import BlockBox from "./BlockBox";
4
+ import SingleResourceStrategyLink from "./SingleResourceStrategyLink";
5
+ export default function BaseInfoBlock(props) {
6
+ var topo = props.topo,
7
+ data = props.data,
8
+ ciTypeMeta = props.ciTypeMeta,
9
+ headerExtra = props.headerExtra,
10
+ renderContent = props.renderContent,
11
+ baseInfo = props.baseInfo;
12
+ var id = data.id,
13
+ ciType = data.ciType,
14
+ type = data.type,
15
+ name = data.name;
16
+ return /*#__PURE__*/React.createElement(BlockBox, {
17
+ headerTitle: "\u57FA\u672C\u4FE1\u606F",
18
+ headerExtra: headerExtra ? headerExtra(props) : ciType === 'network_link' && /*#__PURE__*/React.createElement(SingleResourceStrategyLink, {
19
+ id: id,
20
+ ciType: ciType,
21
+ name: name
22
+ })
23
+ }, /*#__PURE__*/React.createElement(BaseInfo, {
24
+ topo: topo,
25
+ type: type,
26
+ data: data,
27
+ ciTypeMeta: ciTypeMeta,
28
+ renderContent: renderContent,
29
+ baseInfo: baseInfo
30
+ }));
31
+ }
@@ -0,0 +1,46 @@
1
+ import React from 'react';
2
+ import { metricValueFormat } from '@riil-frontend/utils';
3
+ import styles from "./index.module.scss"; // 关键指标
4
+
5
+ export default function ResourceOverviewMetric(props) {
6
+ var topo = props.topo,
7
+ type = props.type,
8
+ data = props.data;
9
+
10
+ function formatValue(itemData) {
11
+ var format = metricValueFormat({
12
+ value: itemData.value,
13
+ dataType: itemData.dataType,
14
+ dict: topo.dictCache.getDictObject(),
15
+ unit: itemData.unit,
16
+ code: itemData.code
17
+ });
18
+ return format.value + " " + (format.value === '-' ? '' : format.unit);
19
+ }
20
+
21
+ return /*#__PURE__*/React.createElement("div", {
22
+ className: styles.indicator
23
+ }, /*#__PURE__*/React.createElement("div", {
24
+ className: styles.row
25
+ }, data.slice(0, 3).map(function (item) {
26
+ return /*#__PURE__*/React.createElement("div", {
27
+ className: styles.item,
28
+ key: item.code
29
+ }, /*#__PURE__*/React.createElement("span", {
30
+ className: styles.content
31
+ }, formatValue(item)), /*#__PURE__*/React.createElement("span", {
32
+ className: styles.label
33
+ }, item.name));
34
+ })), type === 'node' ? /*#__PURE__*/React.createElement("div", {
35
+ className: styles.row
36
+ }, data.slice(3, 6).map(function (item) {
37
+ return /*#__PURE__*/React.createElement("div", {
38
+ className: styles.item,
39
+ key: item.code
40
+ }, /*#__PURE__*/React.createElement("span", {
41
+ className: styles.content
42
+ }, formatValue(item)), /*#__PURE__*/React.createElement("span", {
43
+ className: styles.label
44
+ }, item.name));
45
+ })) : '');
46
+ }
@@ -3,9 +3,11 @@ import { Link } from 'react-router-dom';
3
3
  export default function SingleResourceStrategyLink(props) {
4
4
  var id = props.id,
5
5
  ciType = props.ciType,
6
- name = props.name;
6
+ name = props.name,
7
+ _props$label = props.label,
8
+ label = _props$label === void 0 ? '监控策略' : _props$label;
7
9
  var url = "/default/singleResourceStrategy/" + id + "?title=" + encodeURIComponent(name) + "-\u76D1\u63A7\u914D\u7F6E&ciId=" + id + "&ciType=" + ciType + "&ciName=" + encodeURIComponent(name);
8
10
  return /*#__PURE__*/React.createElement(Link, {
9
11
  to: url
10
- }, "\u76D1\u63A7\u7B56\u7565");
12
+ }, label);
11
13
  }