@riil-frontend/component-topology 11.0.11 → 11.0.13
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/es/components/BatchAttrMetric2/setting.js +23 -6
- package/es/components/BatchAttrMetric2/utils.js +19 -1
- package/es/core/components/ResourceViewAttributeSetting/nodeCiTypeAttrUtil.js +24 -5
- package/es/core/editor/components/BottomFloatTool/HelpIcon.js +2 -6
- package/es/core/editor/components/BottomFloatTool/HelpIcon.module.scss +3 -0
- package/es/core/models/AttributeMetricDisplay.js +1 -5
- package/es/core/models/TopoApp.js +1 -1
- package/es/core/models/cache/CiTypeCache.js +50 -39
- package/es/core/models/tagstips/ElementTagTipConfig.js +199 -65
- package/lib/components/BatchAttrMetric2/setting.js +22 -5
- package/lib/components/BatchAttrMetric2/utils.js +24 -2
- package/lib/core/components/ResourceViewAttributeSetting/nodeCiTypeAttrUtil.js +24 -5
- package/lib/core/editor/components/BottomFloatTool/HelpIcon.js +2 -6
- package/lib/core/editor/components/BottomFloatTool/HelpIcon.module.scss +3 -0
- package/lib/core/models/AttributeMetricDisplay.js +1 -5
- package/lib/core/models/TopoApp.js +1 -1
- package/lib/core/models/cache/CiTypeCache.js +49 -39
- package/lib/core/models/tagstips/ElementTagTipConfig.js +200 -65
- package/package.json +2 -2
@@ -6,7 +6,7 @@ import _Message from "@alifd/next/es/message";
|
|
6
6
|
import _extends from "@babel/runtime/helpers/extends";
|
7
7
|
import _objectWithoutPropertiesLoose from "@babel/runtime/helpers/objectWithoutPropertiesLoose";
|
8
8
|
var _excluded = ["value", "defaultSet", "dataSource"];
|
9
|
-
import React, { useState, useMemo } from 'react';
|
9
|
+
import React, { useState, useMemo, useEffect } from 'react';
|
10
10
|
import rlog from '@riil-frontend/component-topology-utils/es/rlog';
|
11
11
|
import ActionTree from '@riil-frontend/component-action-tree';
|
12
12
|
import NoDataPage from '@riil-frontend/component-topology-common/es/components/NoDataPage';
|
@@ -28,15 +28,21 @@ var Setting = function Setting(_ref) {
|
|
28
28
|
var allCiSet = useMemo(function () {
|
29
29
|
var map = {};
|
30
30
|
loopTreeNode(dataSource, function (item) {
|
31
|
-
|
31
|
+
if (item.type !== 'folder') {
|
32
|
+
map[item.id] = item;
|
33
|
+
}
|
32
34
|
});
|
33
35
|
return map;
|
34
36
|
}, [dataSource]);
|
35
37
|
|
36
|
-
var _useState = useState(
|
38
|
+
var _useState = useState(utils.getDefaultSelectedCiType(dataSource)),
|
37
39
|
ciType = _useState[0],
|
38
40
|
setCiType = _useState[1];
|
39
41
|
|
42
|
+
useEffect(function () {
|
43
|
+
setCiType(utils.getDefaultSelectedCiType(dataSource));
|
44
|
+
}, [dataSource]);
|
45
|
+
|
40
46
|
var _useState2 = useState(''),
|
41
47
|
search = _useState2[0],
|
42
48
|
setSearch = _useState2[1];
|
@@ -72,7 +78,7 @@ var Setting = function Setting(_ref) {
|
|
72
78
|
var onTreeSelect = function onTreeSelect(_ref2) {
|
73
79
|
var selectedKey = _ref2[0];
|
74
80
|
|
75
|
-
if (selectedKey && allCiSet[selectedKey].type !== 'folder') {
|
81
|
+
if (selectedKey && allCiSet[selectedKey] && allCiSet[selectedKey].type !== 'folder') {
|
76
82
|
setCiType(selectedKey);
|
77
83
|
}
|
78
84
|
};
|
@@ -126,12 +132,23 @@ var Setting = function Setting(_ref) {
|
|
126
132
|
}, /*#__PURE__*/React.createElement(_Grid.Col, {
|
127
133
|
span: 8,
|
128
134
|
className: styles['tree-wrap']
|
129
|
-
}, /*#__PURE__*/React.createElement(ActionTree, {
|
135
|
+
}, dataSource.length && /*#__PURE__*/React.createElement(ActionTree, {
|
130
136
|
dataSource: dataSource,
|
131
137
|
onSelect: onTreeSelect,
|
132
138
|
draggable: false,
|
133
139
|
treeProps: {
|
134
|
-
selectedKeys: [ciType]
|
140
|
+
selectedKeys: [ciType],
|
141
|
+
defaultExpandedKeys: dataSource.filter(function (item) {
|
142
|
+
return item.type === 'folder';
|
143
|
+
}).map(function (item) {
|
144
|
+
return item.id;
|
145
|
+
}),
|
146
|
+
expandedKeys: dataSource.filter(function (item) {
|
147
|
+
return item.type === 'folder';
|
148
|
+
}).map(function (item) {
|
149
|
+
return item.id;
|
150
|
+
}),
|
151
|
+
defaultExpandAll: true
|
135
152
|
}
|
136
153
|
})), /*#__PURE__*/React.createElement(_Grid.Col, {
|
137
154
|
className: styles['table-wrap']
|
@@ -1,6 +1,7 @@
|
|
1
1
|
import React from "react";
|
2
2
|
import styles from "./index.module.scss";
|
3
3
|
import rlog from "@riil-frontend/component-topology-utils/es/rlog";
|
4
|
+
import { loopTreeNode } from "../../utils/treeUtil";
|
4
5
|
/**
|
5
6
|
* 获取树结构数据源
|
6
7
|
* @param {*} allCiSet 数据源
|
@@ -77,4 +78,21 @@ export var typeCell = function typeCell(text) {
|
|
77
78
|
}
|
78
79
|
|
79
80
|
return "-";
|
80
|
-
};
|
81
|
+
};
|
82
|
+
/**
|
83
|
+
* 获得默认选中第一个模型
|
84
|
+
* @param {*} tree
|
85
|
+
* @returns
|
86
|
+
*/
|
87
|
+
|
88
|
+
export function getDefaultSelectedCiType(tree) {
|
89
|
+
var ciType = null;
|
90
|
+
loopTreeNode(tree, function (item) {
|
91
|
+
if (item.type !== 'folder') {
|
92
|
+
if (!ciType) {
|
93
|
+
ciType = item.id;
|
94
|
+
}
|
95
|
+
}
|
96
|
+
});
|
97
|
+
return ciType;
|
98
|
+
}
|
@@ -6,11 +6,10 @@ import { getCiTypesFromCiElements } from "../../../utils/topoData";
|
|
6
6
|
*/
|
7
7
|
|
8
8
|
export function getNodeModels(topo) {
|
9
|
-
var data = topo.store.getModelState('topoMod').data;
|
10
|
-
var ciTypeMap = topo.ciTyeCache.ciTypes;
|
11
9
|
return getNodeModSet();
|
12
10
|
|
13
11
|
function getNodeModSet() {
|
12
|
+
var data = topo.store.getModelState('topoMod').data;
|
14
13
|
var ciTypes = getCiTypesFromCiElements(data.nodes);
|
15
14
|
return getMods(ciTypes);
|
16
15
|
}
|
@@ -22,6 +21,7 @@ export function getNodeModels(topo) {
|
|
22
21
|
|
23
22
|
|
24
23
|
function getMods(ciTypeCodes) {
|
24
|
+
var ciTypeMap = topo.ciTyeCache.ciTypes;
|
25
25
|
return Object.keys(ciTypeMap).filter(function (item) {
|
26
26
|
return ciTypeCodes.includes(item);
|
27
27
|
}).map(function (key) {
|
@@ -29,11 +29,21 @@ export function getNodeModels(topo) {
|
|
29
29
|
return {
|
30
30
|
id: ciTypeObj.code,
|
31
31
|
label: ciTypeObj.displayName,
|
32
|
-
|
33
|
-
|
32
|
+
typeCode: ciTypeObj.typeCode,
|
33
|
+
icon: "/img/model/" + ciTypeObj.icon + ".svg",
|
34
|
+
list: buildModelFields(ciTypeObj, 'node')
|
34
35
|
};
|
35
36
|
});
|
36
37
|
}
|
38
|
+
|
39
|
+
function buildModels(ciTypeObj) {
|
40
|
+
return {
|
41
|
+
id: ciTypeObj.code,
|
42
|
+
label: ciTypeObj.displayName,
|
43
|
+
icon: "/img/model/" + ciTypeObj.icon + ".svg",
|
44
|
+
list: buildModelFields(ciTypeObj, 'node')
|
45
|
+
};
|
46
|
+
}
|
37
47
|
/**
|
38
48
|
* 过滤ci元数据中的属性和指标,用于属性和指标显示设置
|
39
49
|
* @param {} ciTypeObj
|
@@ -41,7 +51,7 @@ export function getNodeModels(topo) {
|
|
41
51
|
*/
|
42
52
|
|
43
53
|
|
44
|
-
function
|
54
|
+
function buildModelFields(ciTypeObj, type) {
|
45
55
|
var custom = [];
|
46
56
|
|
47
57
|
if (type === 'node') {
|
@@ -56,6 +66,15 @@ export function getNodeModels(topo) {
|
|
56
66
|
name: '资源类型',
|
57
67
|
type: 'custom'
|
58
68
|
}]);
|
69
|
+
|
70
|
+
if (topo.isCMPTopo) {
|
71
|
+
custom.push.apply(custom, [{
|
72
|
+
id: 'p:source',
|
73
|
+
code: 'name',
|
74
|
+
name: '所属平台',
|
75
|
+
type: 'custom'
|
76
|
+
}]);
|
77
|
+
}
|
59
78
|
}
|
60
79
|
|
61
80
|
var attributes = ciTypeObj.attributes.filter(function (attr) {
|
@@ -48,11 +48,7 @@ function HelpIcon(props) {
|
|
48
48
|
}
|
49
49
|
}, /*#__PURE__*/React.createElement("img", {
|
50
50
|
src: "/img/topo/editor/bottomFloatTool/default.svg",
|
51
|
-
alt: ""
|
52
|
-
style: {
|
53
|
-
width: '15px',
|
54
|
-
height: '15px'
|
55
|
-
}
|
51
|
+
alt: ""
|
56
52
|
})),
|
57
53
|
closable: true,
|
58
54
|
visible: helpBoxIsShow,
|
@@ -89,7 +85,7 @@ function HelpIcon(props) {
|
|
89
85
|
span: "8"
|
90
86
|
}, "ctrl/\u2318+b")), /*#__PURE__*/React.createElement(Row, null, /*#__PURE__*/React.createElement(Col, {
|
91
87
|
span: "16"
|
92
|
-
}, "\u9009\u62E9-\u62D6\
|
88
|
+
}, "\u9009\u62E9-\u62D6\u52A8"), /*#__PURE__*/React.createElement(Col, {
|
93
89
|
span: "8"
|
94
90
|
}, "\u7A7A\u683C")), /*#__PURE__*/React.createElement(Row, null, /*#__PURE__*/React.createElement(Col, {
|
95
91
|
span: "16"
|
@@ -158,11 +158,7 @@ var AttributeMetricDisplay = /*#__PURE__*/function () {
|
|
158
158
|
;
|
159
159
|
|
160
160
|
_proto.getModelType = function getModelType(ci) {
|
161
|
-
|
162
|
-
return ci.attributes.support_templates;
|
163
|
-
}
|
164
|
-
|
165
|
-
return ci.ciType;
|
161
|
+
return this.topo.elementTagTipConfig.getModelType(ci);
|
166
162
|
}
|
167
163
|
/**
|
168
164
|
* 按链路类型获取对应的属性、指标配置
|
@@ -24,7 +24,7 @@ import ElementTagTipConfig from "./tagstips/ElementTagTipConfig";
|
|
24
24
|
import SelectionModel from "./SelectionModel";
|
25
25
|
import CiCache from "./cache/CiCache"; // eslint-disable-next-line no-undef
|
26
26
|
|
27
|
-
var version = typeof "11.0.
|
27
|
+
var version = typeof "11.0.13" === 'string' ? "11.0.13" : null;
|
28
28
|
console.info("\u62D3\u6251\u7248\u672C: " + version);
|
29
29
|
/**
|
30
30
|
* 拓扑显示和编辑
|
@@ -9,12 +9,12 @@ import keyBy from 'lodash/keyBy';
|
|
9
9
|
* Ci类型属性、指标缓存
|
10
10
|
*/
|
11
11
|
|
12
|
-
var
|
13
|
-
function
|
12
|
+
var CiTypeCache = /*#__PURE__*/function () {
|
13
|
+
function CiTypeCache() {
|
14
14
|
this.cache = {};
|
15
15
|
}
|
16
16
|
|
17
|
-
var _proto =
|
17
|
+
var _proto = CiTypeCache.prototype;
|
18
18
|
|
19
19
|
_proto.getCiTypeMap = /*#__PURE__*/function () {
|
20
20
|
var _getCiTypeMap = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(ciTypeIds) {
|
@@ -57,7 +57,7 @@ var CiTyeCache = /*#__PURE__*/function () {
|
|
57
57
|
var _load = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2(ciTypeIds) {
|
58
58
|
var _this = this;
|
59
59
|
|
60
|
-
var unLoadCiTypeIds, ciTypeMetas
|
60
|
+
var unLoadCiTypeIds, ciTypeMetas;
|
61
61
|
return _regeneratorRuntime.wrap(function _callee2$(_context2) {
|
62
62
|
while (1) {
|
63
63
|
switch (_context2.prev = _context2.next) {
|
@@ -70,36 +70,10 @@ var CiTyeCache = /*#__PURE__*/function () {
|
|
70
70
|
|
71
71
|
case 3:
|
72
72
|
ciTypeMetas = _context2.sent;
|
73
|
-
|
74
|
-
ciTypeMetas.forEach(function (ciTypeMeta) {
|
75
|
-
var attributes = (ciTypeMeta.attributes || []).map(function (attr) {
|
76
|
-
if (ciTypeMeta.code !== 'network_link') {
|
77
|
-
return attr;
|
78
|
-
} // 链路属性名称转化,临时方案
|
79
|
-
|
80
|
-
|
81
|
-
var name = {
|
82
|
-
source_id: '源端口',
|
83
|
-
destination_id: '目的端口'
|
84
|
-
}[attr.code] || attr.name;
|
85
|
-
var userVisible = ['source_id', 'destination_id'].indexOf(attr.code) !== -1 ? true : attr.userVisible;
|
86
|
-
return _extends({}, attr, {
|
87
|
-
name: name,
|
88
|
-
userVisible: userVisible
|
89
|
-
});
|
90
|
-
});
|
91
|
-
var metrics = ciTypeMeta.metrics || [];
|
92
|
-
cache[ciTypeMeta.code] = _extends({}, ciTypeMeta, {
|
93
|
-
attributes: attributes,
|
94
|
-
attributeMap: keyBy(attributes, 'code'),
|
95
|
-
metrics: metrics,
|
96
|
-
metricMap: keyBy(metrics, 'code')
|
97
|
-
});
|
98
|
-
});
|
99
|
-
this.cache = cache;
|
73
|
+
this.addCiTypes(ciTypeMetas);
|
100
74
|
return _context2.abrupt("return", this.cache);
|
101
75
|
|
102
|
-
case
|
76
|
+
case 6:
|
103
77
|
case "end":
|
104
78
|
return _context2.stop();
|
105
79
|
}
|
@@ -114,15 +88,33 @@ var CiTyeCache = /*#__PURE__*/function () {
|
|
114
88
|
return load;
|
115
89
|
}();
|
116
90
|
|
91
|
+
_proto.addCiTypes = function addCiTypes(ciTypeMetas) {
|
92
|
+
var _this2 = this;
|
93
|
+
|
94
|
+
ciTypeMetas.forEach(function (ciTypeMeta) {
|
95
|
+
_this2.addCiType(ciTypeMeta);
|
96
|
+
});
|
97
|
+
};
|
98
|
+
|
99
|
+
_proto.addCiType = function addCiType(ciTypeMeta) {
|
100
|
+
var cache = _extends({}, this.cache);
|
101
|
+
|
102
|
+
var attributes = adapterNetworkLinkAttributes(ciTypeMeta, ciTypeMeta.attributes || []);
|
103
|
+
var metrics = ciTypeMeta.metrics || [];
|
104
|
+
cache[ciTypeMeta.code] = _extends({}, ciTypeMeta, {
|
105
|
+
attributes: attributes,
|
106
|
+
attributeMap: keyBy(attributes, 'code'),
|
107
|
+
metrics: metrics,
|
108
|
+
metricMap: keyBy(metrics, 'code')
|
109
|
+
});
|
110
|
+
this.cache = cache;
|
111
|
+
};
|
112
|
+
|
117
113
|
_proto.getCiType = function getCiType(typeCode) {
|
118
114
|
return this.cache[typeCode];
|
119
115
|
};
|
120
116
|
|
121
117
|
_proto.getCiTypeByCi = function getCiTypeByCi(ci) {
|
122
|
-
// if (ci.ciType === 'network_link') {
|
123
|
-
// const supportTemplates = link.attributes.support_templates;
|
124
|
-
// } else {
|
125
|
-
// }
|
126
118
|
return this.getCiType(ci.ciType);
|
127
119
|
};
|
128
120
|
|
@@ -136,14 +128,33 @@ var CiTyeCache = /*#__PURE__*/function () {
|
|
136
128
|
return ciType === null || ciType === void 0 ? void 0 : ciType.metricMap[metricCode];
|
137
129
|
};
|
138
130
|
|
139
|
-
_createClass(
|
131
|
+
_createClass(CiTypeCache, [{
|
140
132
|
key: "ciTypes",
|
141
133
|
get: function get() {
|
142
134
|
return this.cache;
|
143
135
|
}
|
144
136
|
}]);
|
145
137
|
|
146
|
-
return
|
138
|
+
return CiTypeCache;
|
147
139
|
}();
|
148
140
|
|
149
|
-
|
141
|
+
function adapterNetworkLinkAttributes(ciTypeMeta, attributes) {
|
142
|
+
return attributes.map(function (attr) {
|
143
|
+
if (ciTypeMeta.code !== 'network_link') {
|
144
|
+
return attr;
|
145
|
+
} // 链路属性名称转化,临时方案
|
146
|
+
|
147
|
+
|
148
|
+
var name = {
|
149
|
+
source_id: '源端口',
|
150
|
+
destination_id: '目的端口'
|
151
|
+
}[attr.code] || attr.name;
|
152
|
+
var userVisible = ['source_id', 'destination_id'].indexOf(attr.code) !== -1 ? true : attr.userVisible;
|
153
|
+
return _extends({}, attr, {
|
154
|
+
name: name,
|
155
|
+
userVisible: userVisible
|
156
|
+
});
|
157
|
+
});
|
158
|
+
}
|
159
|
+
|
160
|
+
export default new CiTypeCache();
|
@@ -1,13 +1,18 @@
|
|
1
1
|
import _extends from "@babel/runtime/helpers/extends";
|
2
2
|
import _asyncToGenerator from "@babel/runtime/helpers/asyncToGenerator";
|
3
3
|
import _regeneratorRuntime from "@babel/runtime/regenerator";
|
4
|
-
import
|
5
|
-
import { getMetricsByMonitorTemplateCodes } from "../../services/topo/tagtip";
|
4
|
+
import keyBy from 'lodash/keyBy';
|
6
5
|
import rlog from '@riil-frontend/component-topology-utils/lib/rlog';
|
6
|
+
import { getLinkMtCodes, getMtCodeCiTypeMap, getNodeMtCodes } from "./utils";
|
7
|
+
import { getMetricsByMonitorTemplateCodes } from "../../services/topo/tagtip";
|
8
|
+
/**
|
9
|
+
* 标注、悬浮框字段模型
|
10
|
+
*/
|
7
11
|
|
8
12
|
var ElementTagTipConfig = /*#__PURE__*/function () {
|
9
13
|
function ElementTagTipConfig(topo) {
|
10
14
|
this.topoData = void 0;
|
15
|
+
this.modelMap = {};
|
11
16
|
this.mtCodes = void 0;
|
12
17
|
this.mtMetricsMap = {};
|
13
18
|
this.mtCiTypeMap = void 0;
|
@@ -23,51 +28,213 @@ var ElementTagTipConfig = /*#__PURE__*/function () {
|
|
23
28
|
switch (_context.prev = _context.next) {
|
24
29
|
case 0:
|
25
30
|
this.topoData = topoData;
|
26
|
-
|
27
|
-
|
31
|
+
_context.next = 3;
|
32
|
+
return this.initNetworkLinkModel();
|
33
|
+
|
34
|
+
case 3:
|
35
|
+
this.mtCiTypeMap = getMtCodeCiTypeMap(topoData);
|
36
|
+
|
37
|
+
case 4:
|
38
|
+
case "end":
|
39
|
+
return _context.stop();
|
40
|
+
}
|
41
|
+
}
|
42
|
+
}, _callee, this);
|
43
|
+
}));
|
44
|
+
|
45
|
+
function init(_x) {
|
46
|
+
return _init.apply(this, arguments);
|
47
|
+
}
|
28
48
|
|
29
|
-
|
30
|
-
|
49
|
+
return init;
|
50
|
+
}();
|
51
|
+
|
52
|
+
_proto.initNetworkLinkModel = /*#__PURE__*/function () {
|
53
|
+
var _initNetworkLinkModel = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2() {
|
54
|
+
var mtCodes;
|
55
|
+
return _regeneratorRuntime.wrap(function _callee2$(_context2) {
|
56
|
+
while (1) {
|
57
|
+
switch (_context2.prev = _context2.next) {
|
58
|
+
case 0:
|
59
|
+
_context2.prev = 0;
|
60
|
+
mtCodes = ['m.critical_link', 'm.ethernet_link'];
|
61
|
+
|
62
|
+
if (!mtCodes.length) {
|
63
|
+
_context2.next = 6;
|
31
64
|
break;
|
32
65
|
}
|
33
66
|
|
34
|
-
|
35
|
-
return getMetricsByMonitorTemplateCodes(
|
67
|
+
_context2.next = 5;
|
68
|
+
return getMetricsByMonitorTemplateCodes(mtCodes);
|
36
69
|
|
37
|
-
case
|
38
|
-
this.mtMetricsMap =
|
70
|
+
case 5:
|
71
|
+
this.mtMetricsMap = _context2.sent;
|
39
72
|
|
40
|
-
case
|
41
|
-
|
73
|
+
case 6:
|
74
|
+
_context2.next = 11;
|
42
75
|
break;
|
43
76
|
|
44
|
-
case
|
45
|
-
|
46
|
-
|
47
|
-
rlog.error('查询监控模板指标失败',
|
77
|
+
case 8:
|
78
|
+
_context2.prev = 8;
|
79
|
+
_context2.t0 = _context2["catch"](0);
|
80
|
+
rlog.error('查询监控模板指标失败', _context2.t0);
|
48
81
|
|
49
|
-
case
|
50
|
-
this.mtCiTypeMap = getMtCodeCiTypeMap(topoData);
|
51
|
-
|
52
|
-
case 13:
|
82
|
+
case 11:
|
53
83
|
case "end":
|
54
|
-
return
|
84
|
+
return _context2.stop();
|
55
85
|
}
|
56
86
|
}
|
57
|
-
},
|
87
|
+
}, _callee2, this, [[0, 8]]);
|
58
88
|
}));
|
59
89
|
|
60
|
-
function
|
61
|
-
return
|
90
|
+
function initNetworkLinkModel() {
|
91
|
+
return _initNetworkLinkModel.apply(this, arguments);
|
62
92
|
}
|
63
93
|
|
64
|
-
return
|
65
|
-
}()
|
94
|
+
return initNetworkLinkModel;
|
95
|
+
}();
|
96
|
+
|
97
|
+
_proto.getModelTypes = function getModelTypes(cis) {
|
98
|
+
var _this = this;
|
99
|
+
|
100
|
+
var modelTypes = [];
|
101
|
+
cis.forEach(function (ci) {
|
102
|
+
var modelType = _this.getModelType(ci);
|
103
|
+
|
104
|
+
if (modelType && modelTypes.indexOf(modelType) < 0) {
|
105
|
+
modelTypes.push(modelType);
|
106
|
+
}
|
107
|
+
});
|
108
|
+
return modelTypes;
|
109
|
+
}
|
66
110
|
/**
|
67
|
-
*
|
111
|
+
* 查询模型
|
112
|
+
* @param {*} ci
|
113
|
+
* @returns
|
68
114
|
*/
|
115
|
+
// eslint-disable-next-line class-methods-use-this
|
69
116
|
;
|
70
117
|
|
118
|
+
_proto.getModelType = function getModelType(ci) {
|
119
|
+
if (ci.ciType === 'network_link') {
|
120
|
+
return ci.attributes.support_templates;
|
121
|
+
}
|
122
|
+
|
123
|
+
return ci.ciType;
|
124
|
+
};
|
125
|
+
|
126
|
+
_proto.getModelByType = function getModelByType(type) {
|
127
|
+
return this.getNetworkLinkModel(type) || this.topo.ciTyeCache.getCiType(type);
|
128
|
+
};
|
129
|
+
|
130
|
+
_proto.getNetworkLinkModel = function getNetworkLinkModel(type) {
|
131
|
+
var _this2 = this;
|
132
|
+
|
133
|
+
var baseInfo = [{
|
134
|
+
code: 'm.critical_link',
|
135
|
+
displayName: '关键链路',
|
136
|
+
typeCode: 'network_link'
|
137
|
+
}, {
|
138
|
+
code: 'm.ethernet_link',
|
139
|
+
displayName: '网络链路',
|
140
|
+
typeCode: 'network_link'
|
141
|
+
}].find(function (item) {
|
142
|
+
return item.code === type;
|
143
|
+
});
|
144
|
+
|
145
|
+
if (!baseInfo) {
|
146
|
+
return null;
|
147
|
+
}
|
148
|
+
|
149
|
+
var ciTypeModel = this.topo.ciTyeCache.getCiType('network_link');
|
150
|
+
var metrics = ciTypeModel.metrics.filter(function (m) {
|
151
|
+
return _this2.mtMetricsMap[type] && !!_this2.mtMetricsMap[type][m.code];
|
152
|
+
});
|
153
|
+
return _extends({}, ciTypeModel, baseInfo, {
|
154
|
+
metrics: metrics,
|
155
|
+
metricMap: keyBy(metrics, 'code')
|
156
|
+
});
|
157
|
+
}
|
158
|
+
/**
|
159
|
+
* 获取链路标注悬浮框属性配置数据
|
160
|
+
* @returns
|
161
|
+
*/
|
162
|
+
;
|
163
|
+
|
164
|
+
_proto.getLinkConfigItems = function getLinkConfigItems() {
|
165
|
+
var _this3 = this;
|
166
|
+
|
167
|
+
var _this$topo$dataModel$ = this.topo.dataModel.getData(),
|
168
|
+
links = _this$topo$dataModel$.links;
|
169
|
+
|
170
|
+
var modelTypes = this.getModelTypes(links);
|
171
|
+
var list = modelTypes.map(this.getModelByType.bind(this)).map(function (item) {
|
172
|
+
return _this3.buildModels(item, 'link');
|
173
|
+
});
|
174
|
+
return list;
|
175
|
+
} // eslint-disable-next-line
|
176
|
+
;
|
177
|
+
|
178
|
+
_proto.buildModels = function buildModels(ciTypeObj, type) {
|
179
|
+
return {
|
180
|
+
id: ciTypeObj.code,
|
181
|
+
label: ciTypeObj.displayName,
|
182
|
+
typeCode: ciTypeObj.typeCode,
|
183
|
+
icon: "/img/model/" + ciTypeObj.icon + ".svg",
|
184
|
+
list: this.buildModelFields(ciTypeObj, type)
|
185
|
+
};
|
186
|
+
}
|
187
|
+
/**
|
188
|
+
* 过滤ci元数据中的属性和指标,用于属性和指标显示设置
|
189
|
+
* @param {} ciTypeObj
|
190
|
+
* @returns
|
191
|
+
*/
|
192
|
+
// eslint-disable-next-line
|
193
|
+
;
|
194
|
+
|
195
|
+
_proto.buildModelFields = function buildModelFields(ciTypeObj, type) {
|
196
|
+
var custom = [];
|
197
|
+
|
198
|
+
if (type === 'node') {
|
199
|
+
custom.push.apply(custom, [{
|
200
|
+
id: 'graph:name',
|
201
|
+
code: 'name',
|
202
|
+
name: '图片名称',
|
203
|
+
type: 'custom'
|
204
|
+
}, {
|
205
|
+
id: 'ciType:display_name',
|
206
|
+
code: 'ciType',
|
207
|
+
name: '资源类型',
|
208
|
+
type: 'custom'
|
209
|
+
}]);
|
210
|
+
}
|
211
|
+
|
212
|
+
var attributes = ciTypeObj.attributes.filter(function (attr) {
|
213
|
+
return !!attr.userVisible;
|
214
|
+
}).map(function (item) {
|
215
|
+
return {
|
216
|
+
type: 'attribute',
|
217
|
+
id: "attribute:" + item.code,
|
218
|
+
code: "attribute:" + item.code,
|
219
|
+
name: item.name,
|
220
|
+
typeName: '属性'
|
221
|
+
};
|
222
|
+
});
|
223
|
+
var metrics = ciTypeObj.metrics.map(function (item) {
|
224
|
+
return {
|
225
|
+
type: 'metric',
|
226
|
+
id: "metric:" + item.code,
|
227
|
+
code: "metric:" + item.code,
|
228
|
+
name: item.name,
|
229
|
+
typeName: '指标'
|
230
|
+
};
|
231
|
+
});
|
232
|
+
return [].concat(custom, attributes, metrics);
|
233
|
+
};
|
234
|
+
|
235
|
+
/**
|
236
|
+
* 获得节点字段配置项map
|
237
|
+
*/
|
71
238
|
_proto.getNodeFiedldMap = function getNodeFiedldMap() {
|
72
239
|
var mtCodes = getNodeMtCodes(this.topoData);
|
73
240
|
return this.getFiedldMapByMtCodes(mtCodes, 'node');
|
@@ -80,48 +247,15 @@ var ElementTagTipConfig = /*#__PURE__*/function () {
|
|
80
247
|
_proto.getLinkFidldMap = function getLinkFidldMap() {
|
81
248
|
var mtCodes = getLinkMtCodes(this.topoData);
|
82
249
|
return this.getFiedldMapByMtCodes(mtCodes, 'link');
|
83
|
-
}
|
84
|
-
/**
|
85
|
-
* 获取链路标注悬浮框属性配置数据
|
86
|
-
* @returns
|
87
|
-
*/
|
88
|
-
;
|
89
|
-
|
90
|
-
_proto.getLinkConfigItems = function getLinkConfigItems() {
|
91
|
-
var mtCodes = getLinkMtCodes(this.topoData);
|
92
|
-
var linkFidldMap = this.getLinkFidldMap();
|
93
|
-
var list = [{
|
94
|
-
id: 'm.critical_link',
|
95
|
-
label: '关键链路'
|
96
|
-
}, {
|
97
|
-
id: 'm.ethernet_link',
|
98
|
-
label: '网络链路'
|
99
|
-
}] // 只拓扑图上已有资源的监控模板
|
100
|
-
.filter(function (item) {
|
101
|
-
return mtCodes.includes(item.id);
|
102
|
-
}).map(function (t) {
|
103
|
-
return _extends({}, t, {
|
104
|
-
icon: '/img/model/networkLink.svg',
|
105
|
-
list: linkFidldMap[t.id] || []
|
106
|
-
});
|
107
|
-
});
|
108
|
-
return list; // return [
|
109
|
-
// { id: 'ax1', label: '本级平台', children: list, type: 'folder', disabled: true },
|
110
|
-
// {
|
111
|
-
// id: 'bb22', label: '下级平台', type: 'folder', children: [
|
112
|
-
// { id: 'xvdafa', label: '关键链路', icon: '/img/model/networkLink.svg' },
|
113
|
-
// ]
|
114
|
-
// },
|
115
|
-
// ]
|
116
250
|
};
|
117
251
|
|
118
252
|
_proto.getFiedldMapByMtCodes = function getFiedldMapByMtCodes(mtCodes, type) {
|
119
|
-
var
|
253
|
+
var _this4 = this;
|
120
254
|
|
121
255
|
var map = {};
|
122
256
|
mtCodes.forEach(function (mtCode) {
|
123
|
-
var ciType =
|
124
|
-
map[mtCode] =
|
257
|
+
var ciType = _this4.mtCiTypeMap[mtCode];
|
258
|
+
map[mtCode] = _this4.getFiedldMapByType(ciType, type, mtCode);
|
125
259
|
});
|
126
260
|
return map;
|
127
261
|
};
|
@@ -160,12 +294,12 @@ var ElementTagTipConfig = /*#__PURE__*/function () {
|
|
160
294
|
};
|
161
295
|
|
162
296
|
_proto.getMtMetricModels = function getMtMetricModels(mtCode) {
|
163
|
-
var
|
297
|
+
var _this5 = this;
|
164
298
|
|
165
299
|
var ciType = this.mtCiTypeMap[mtCode];
|
166
300
|
var ciTypeModel = this.topo.ciTyeCache.getCiType(ciType);
|
167
301
|
var metrics = ciTypeModel.metrics.filter(function (m) {
|
168
|
-
return
|
302
|
+
return _this5.mtMetricsMap[mtCode] && !!_this5.mtMetricsMap[mtCode][m.code];
|
169
303
|
});
|
170
304
|
return metrics;
|
171
305
|
};
|