@riil-frontend/component-topology 3.1.4 → 3.1.7
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.
- package/build/1.js +1 -1
- package/build/index.css +1 -1
- package/build/index.js +11 -11
- 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 +1 -1
- package/demo-mock/basic/topo/v1/api/attributes/once +9164 -2796
- package/demo-mock/basic/topo/v1/api/attributes/once.json +9164 -2796
- package/es/core/components/DisplaySettingDrawer/DisplaySetting.js +4 -5
- package/es/core/components/DisplaySettingDrawer/DisplaySettingDrawer.js +2 -2
- package/es/core/components/DisplaySettingDrawer/hooks/useDisplaySetting.js +4 -4
- package/es/core/models/AttributeMetricDisplay.js +112 -98
- package/es/core/models/TopoApp.js +1 -1
- package/es/core/viewer/components/plugins/BaseInfo/ResourceDetail.js +288 -0
- package/es/core/viewer/components/plugins/BaseInfo/ResourceDetailPlugin.js +11 -0
- package/es/core/viewer/components/plugins/BaseInfo/components/ResourceOverview/BaseInfo.js +129 -0
- package/es/core/viewer/components/plugins/BaseInfo/components/ResourceOverview/ResourceOverviewMetric.js +46 -0
- package/es/core/viewer/components/plugins/BaseInfo/components/ResourceOverview/index.js +64 -172
- package/es/core/viewer/components/plugins/BaseInfo/components/ResourceOverview/useCiAttrAndMetricData.js +12 -0
- package/es/core/viewer/components/plugins/BaseInfo/index.js +2 -276
- package/es/core/viewer/components/titlebar/BasicTools.js +1 -1
- package/es/core/viewer/components/titlebar/widgets/SettingButton.js +3 -4
- package/es/core/viewer/components/titlebar/widgets/SettingButtonWidget.js +19 -0
- package/es/topoCenter/components/TopoView.js +3 -4
- package/es/topoCenter/models/TopoCenter.js +9 -5
- package/lib/core/components/DisplaySettingDrawer/DisplaySetting.js +4 -5
- package/lib/core/components/DisplaySettingDrawer/DisplaySettingDrawer.js +2 -2
- package/lib/core/components/DisplaySettingDrawer/hooks/useDisplaySetting.js +4 -4
- package/lib/core/models/AttributeMetricDisplay.js +111 -97
- package/lib/core/models/TopoApp.js +1 -1
- package/lib/core/viewer/components/plugins/BaseInfo/ResourceDetail.js +313 -0
- package/lib/core/viewer/components/plugins/BaseInfo/ResourceDetailPlugin.js +21 -0
- package/lib/core/viewer/components/plugins/BaseInfo/components/ResourceOverview/BaseInfo.js +139 -0
- package/lib/core/viewer/components/plugins/BaseInfo/components/ResourceOverview/ResourceOverviewMetric.js +56 -0
- package/lib/core/viewer/components/plugins/BaseInfo/components/ResourceOverview/index.js +65 -173
- package/lib/core/viewer/components/plugins/BaseInfo/components/ResourceOverview/useCiAttrAndMetricData.js +17 -0
- package/lib/core/viewer/components/plugins/BaseInfo/index.js +2 -291
- package/lib/core/viewer/components/titlebar/BasicTools.js +2 -2
- package/lib/core/viewer/components/titlebar/widgets/SettingButton.js +2 -3
- package/lib/core/viewer/components/titlebar/widgets/SettingButtonWidget.js +28 -0
- package/lib/topoCenter/components/TopoView.js +3 -4
- package/lib/topoCenter/models/TopoCenter.js +9 -5
- package/package.json +3 -3
|
@@ -17,16 +17,15 @@ import EdgeFlowDirection from "./EdgeFlowDirection";
|
|
|
17
17
|
|
|
18
18
|
function DisplaySetting(props, ref) {
|
|
19
19
|
var topo = props.topo,
|
|
20
|
-
|
|
20
|
+
displaySettingProps = props.displaySettingProps;
|
|
21
21
|
var displayConfig = topo.store.getModelState('displayConfig');
|
|
22
22
|
|
|
23
|
-
var _ref =
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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 (
|
|
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
|
|
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 = (
|
|
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 {
|
|
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(
|
|
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.
|
|
23
|
+
var version = typeof "3.1.7" === 'string' ? "3.1.7" : null;
|
|
24
24
|
console.info("\u62D3\u6251\u7248\u672C: " + version);
|
|
25
25
|
/**
|
|
26
26
|
* 拓扑显示和编辑
|
|
@@ -0,0 +1,288 @@
|
|
|
1
|
+
import _Drawer from "@alifd/next/es/drawer";
|
|
2
|
+
import _Tab from "@alifd/next/es/tab";
|
|
3
|
+
import _extends from "@babel/runtime/helpers/extends";
|
|
4
|
+
import _asyncToGenerator from "@babel/runtime/helpers/asyncToGenerator";
|
|
5
|
+
import _MenuButton from "@alifd/next/es/menu-button";
|
|
6
|
+
import _Search from "@alifd/next/es/search";
|
|
7
|
+
import _regeneratorRuntime from "@babel/runtime/regenerator";
|
|
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';
|
|
12
|
+
import service from "../../../../services/overview";
|
|
13
|
+
import ResourceOverview from "./components/ResourceOverview";
|
|
14
|
+
import styles from "./index.module.scss";
|
|
15
|
+
|
|
16
|
+
function Title(_ref) {
|
|
17
|
+
var id = _ref.id,
|
|
18
|
+
name = _ref.name,
|
|
19
|
+
type = _ref.type,
|
|
20
|
+
onChange = _ref.onChange,
|
|
21
|
+
topo = _ref.topo;
|
|
22
|
+
|
|
23
|
+
if (type === 'node') {
|
|
24
|
+
var _useState = useState(''),
|
|
25
|
+
keyword = _useState[0],
|
|
26
|
+
setKeyword = _useState[1];
|
|
27
|
+
|
|
28
|
+
var nodes = topo.store.getModelState('topoMod').data.nodes; // 查询资源列表
|
|
29
|
+
|
|
30
|
+
nodes = nodes.filter(function (item) {
|
|
31
|
+
return item.id !== id;
|
|
32
|
+
});
|
|
33
|
+
if (!nodes.length) return name;
|
|
34
|
+
var filterNodes = dataSearch(nodes, ['name'], keyword);
|
|
35
|
+
return /*#__PURE__*/React.createElement(_MenuButton, {
|
|
36
|
+
text: true,
|
|
37
|
+
autoWidth: false,
|
|
38
|
+
size: "large",
|
|
39
|
+
popupClassName: styles['title-popup'],
|
|
40
|
+
menuProps: {
|
|
41
|
+
header: /*#__PURE__*/React.createElement(_Search, {
|
|
42
|
+
shape: "simple",
|
|
43
|
+
placeholder: "\u8BF7\u8F93\u5165\u5173\u952E\u5B57",
|
|
44
|
+
className: styles.search,
|
|
45
|
+
hasClear: true,
|
|
46
|
+
onChange: function onChange(val) {
|
|
47
|
+
return !val && setKeyword(val);
|
|
48
|
+
},
|
|
49
|
+
onSearch: setKeyword
|
|
50
|
+
})
|
|
51
|
+
},
|
|
52
|
+
label: /*#__PURE__*/React.createElement("div", {
|
|
53
|
+
className: styles['drawer-title']
|
|
54
|
+
}, name),
|
|
55
|
+
onItemClick: function onItemClick(key) {
|
|
56
|
+
return onChange(nodes.find(function (item) {
|
|
57
|
+
return item.id === key;
|
|
58
|
+
}) || '');
|
|
59
|
+
}
|
|
60
|
+
}, isAvailableArray(filterNodes) && filterNodes.length ? filterNodes.map(function (item) {
|
|
61
|
+
return /*#__PURE__*/React.createElement(_MenuButton.Item, {
|
|
62
|
+
key: item.id,
|
|
63
|
+
disabled: !item.operation
|
|
64
|
+
}, item.name);
|
|
65
|
+
}) : /*#__PURE__*/React.createElement("div", {
|
|
66
|
+
className: styles['not-data']
|
|
67
|
+
}, "\u6682\u65E0\u6570\u636E"));
|
|
68
|
+
} else {
|
|
69
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
70
|
+
className: styles['drawer-title']
|
|
71
|
+
}, "\u94FE\u8DEF\u8BE6\u60C5");
|
|
72
|
+
}
|
|
73
|
+
} // 基本信息
|
|
74
|
+
|
|
75
|
+
|
|
76
|
+
function ResourceDetail(props) {
|
|
77
|
+
var topo = props.topo,
|
|
78
|
+
canShow = props.canShow;
|
|
79
|
+
|
|
80
|
+
var _topo$store$useModel = topo.store.useModel('topoBaseInfoOverview'),
|
|
81
|
+
topoState = _topo$store$useModel[0],
|
|
82
|
+
topoDispatchers = _topo$store$useModel[1];
|
|
83
|
+
|
|
84
|
+
var _topo$store$useModelS = topo.store.useModelState('topoMod'),
|
|
85
|
+
topoId = _topo$store$useModelS.topoId,
|
|
86
|
+
topoModData = _topo$store$useModelS.data;
|
|
87
|
+
|
|
88
|
+
var _useState2 = useState(false),
|
|
89
|
+
visible = _useState2[0],
|
|
90
|
+
setVisible = _useState2[1];
|
|
91
|
+
|
|
92
|
+
var _useState3 = useState({
|
|
93
|
+
id: '',
|
|
94
|
+
name: '',
|
|
95
|
+
type: '',
|
|
96
|
+
// 类型: node、link
|
|
97
|
+
ciType: '',
|
|
98
|
+
ciName: ''
|
|
99
|
+
}),
|
|
100
|
+
activeData = _useState3[0],
|
|
101
|
+
setActiveData = _useState3[1];
|
|
102
|
+
|
|
103
|
+
var _useState4 = useState(''),
|
|
104
|
+
userId = _useState4[0],
|
|
105
|
+
setUserId = _useState4[1];
|
|
106
|
+
|
|
107
|
+
useEffect(function () {
|
|
108
|
+
var notifier = topo.view.topoClient.notifier;
|
|
109
|
+
notifier.on(TopoEvent.EVENT_DOUBLE_CLICK, openOverview);
|
|
110
|
+
notifier.on('topo_element_click', changeOverview);
|
|
111
|
+
return function () {
|
|
112
|
+
notifier.off(TopoEvent.EVENT_DOUBLE_CLICK, openOverview);
|
|
113
|
+
notifier.off('topo_element_click', changeOverview); // 清除数据
|
|
114
|
+
|
|
115
|
+
topoDispatchers.update({
|
|
116
|
+
id: '',
|
|
117
|
+
metricCodes: []
|
|
118
|
+
});
|
|
119
|
+
};
|
|
120
|
+
}, []); // 解决切换拓扑图隐藏概览
|
|
121
|
+
|
|
122
|
+
useEffect(function () {
|
|
123
|
+
setVisible(false); // TODO 其他数据重置
|
|
124
|
+
}, [topoId]);
|
|
125
|
+
|
|
126
|
+
function getUser() {
|
|
127
|
+
return _getUser.apply(this, arguments);
|
|
128
|
+
} // select切换
|
|
129
|
+
|
|
130
|
+
|
|
131
|
+
function _getUser() {
|
|
132
|
+
_getUser = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2() {
|
|
133
|
+
return _regeneratorRuntime.wrap(function _callee2$(_context2) {
|
|
134
|
+
while (1) {
|
|
135
|
+
switch (_context2.prev = _context2.next) {
|
|
136
|
+
case 0:
|
|
137
|
+
setUserId(function (prev) {
|
|
138
|
+
console.log('获取用户id', prev); // 如果已经获取过,就不再重新获取
|
|
139
|
+
|
|
140
|
+
if (!prev) {
|
|
141
|
+
_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee() {
|
|
142
|
+
var res;
|
|
143
|
+
return _regeneratorRuntime.wrap(function _callee$(_context) {
|
|
144
|
+
while (1) {
|
|
145
|
+
switch (_context.prev = _context.next) {
|
|
146
|
+
case 0:
|
|
147
|
+
_context.next = 2;
|
|
148
|
+
return service.getUserId();
|
|
149
|
+
|
|
150
|
+
case 2:
|
|
151
|
+
res = _context.sent;
|
|
152
|
+
setUserId((res === null || res === void 0 ? void 0 : res.user_id) || '');
|
|
153
|
+
|
|
154
|
+
case 4:
|
|
155
|
+
case "end":
|
|
156
|
+
return _context.stop();
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
}, _callee);
|
|
160
|
+
}))();
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
return prev;
|
|
164
|
+
});
|
|
165
|
+
|
|
166
|
+
case 1:
|
|
167
|
+
case "end":
|
|
168
|
+
return _context2.stop();
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
}, _callee2);
|
|
172
|
+
}));
|
|
173
|
+
return _getUser.apply(this, arguments);
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
function onChangeActive(activeNode) {
|
|
177
|
+
activeNode && init(_extends({}, activeNode, {
|
|
178
|
+
type: 'node'
|
|
179
|
+
}), 'select');
|
|
180
|
+
} // 单击切换
|
|
181
|
+
|
|
182
|
+
|
|
183
|
+
function changeOverview(node) {
|
|
184
|
+
var data = node.getAttrObject();
|
|
185
|
+
init(data, 'click');
|
|
186
|
+
} // 双击打开
|
|
187
|
+
|
|
188
|
+
|
|
189
|
+
function openOverview(data) {
|
|
190
|
+
init(data, 'doubleClick');
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
function init(data, targetType) {
|
|
194
|
+
console.log('初始化基本信息', data, targetType);
|
|
195
|
+
var id = data.id,
|
|
196
|
+
name = data.name,
|
|
197
|
+
type = data.type,
|
|
198
|
+
ciType = data.ciType,
|
|
199
|
+
ciName = data.ciName,
|
|
200
|
+
operation = data.operation; // 仅展示资源和链路的概览
|
|
201
|
+
|
|
202
|
+
if (!['node', 'link', 'linkGroup'].includes(type)) return; // 没有权限不显示
|
|
203
|
+
|
|
204
|
+
if (!operation) return;
|
|
205
|
+
var htElement = topo.getDataModel().getDataByTag(id);
|
|
206
|
+
|
|
207
|
+
if (!canShow(htElement)) {
|
|
208
|
+
return;
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
setActiveData({
|
|
212
|
+
id: id,
|
|
213
|
+
name: name,
|
|
214
|
+
type: type === 'linkGroup' ? 'link' : type,
|
|
215
|
+
ciType: ciType,
|
|
216
|
+
ciName: ciName
|
|
217
|
+
}); // 显示隐藏
|
|
218
|
+
|
|
219
|
+
targetType === 'doubleClick' && setVisible(true); // userId
|
|
220
|
+
|
|
221
|
+
getUser();
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
useEffect(function () {
|
|
225
|
+
console.log('topoData', activeData.ciType, topoModData);
|
|
226
|
+
|
|
227
|
+
if (topoModData && activeData !== null && activeData !== void 0 && activeData.id) {
|
|
228
|
+
var id = activeData.id,
|
|
229
|
+
ciType = activeData.ciType;
|
|
230
|
+
var ciTypeMeta;
|
|
231
|
+
|
|
232
|
+
if (ciType === 'network_link') {
|
|
233
|
+
// 网络链路要按链路类型查询属性、指标
|
|
234
|
+
var linkGroups = topoModData.linkGroups,
|
|
235
|
+
links = topoModData.links;
|
|
236
|
+
var link = [].concat(linkGroups, links).find(function (item) {
|
|
237
|
+
return item.id === id;
|
|
238
|
+
});
|
|
239
|
+
var linkConnectType = link.attributes['network_link.connect_type'];
|
|
240
|
+
ciTypeMeta = topo.ciTyeCache.getNetworkLinkCiType(linkConnectType);
|
|
241
|
+
} else {
|
|
242
|
+
ciTypeMeta = topo.ciTyeCache.getCiType(ciType);
|
|
243
|
+
}
|
|
244
|
+
|
|
245
|
+
var _ciTypeMeta = ciTypeMeta,
|
|
246
|
+
metrics = _ciTypeMeta.metrics; // 同步需要实时展示的指标
|
|
247
|
+
|
|
248
|
+
topoDispatchers.update({
|
|
249
|
+
id: id,
|
|
250
|
+
metricCodes: metrics.slice(0, 6).map(function (item) {
|
|
251
|
+
return item.code;
|
|
252
|
+
}) // 需要展示的关键指标 code
|
|
253
|
+
|
|
254
|
+
});
|
|
255
|
+
}
|
|
256
|
+
}, [topoModData, activeData]);
|
|
257
|
+
return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(_Drawer, {
|
|
258
|
+
className: styles.baseInfo,
|
|
259
|
+
closeMode: ['close', 'esc'],
|
|
260
|
+
visible: visible,
|
|
261
|
+
title: /*#__PURE__*/React.createElement(Title, _extends({}, activeData, {
|
|
262
|
+
topo: topo,
|
|
263
|
+
onChange: onChangeActive
|
|
264
|
+
})),
|
|
265
|
+
width: 580,
|
|
266
|
+
hasMask: false,
|
|
267
|
+
onClose: function onClose() {
|
|
268
|
+
return setVisible(false);
|
|
269
|
+
}
|
|
270
|
+
}, visible && /*#__PURE__*/React.createElement(_Tab, {
|
|
271
|
+
className: styles.tab
|
|
272
|
+
}, /*#__PURE__*/React.createElement(_Tab.Item, {
|
|
273
|
+
title: "\u8D44\u6E90\u6982\u89C8",
|
|
274
|
+
key: "1"
|
|
275
|
+
}, activeData.id && /*#__PURE__*/React.createElement(ResourceOverview, _extends({}, props, activeData, {
|
|
276
|
+
userId: userId
|
|
277
|
+
}))))));
|
|
278
|
+
}
|
|
279
|
+
|
|
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;
|