@riil-frontend/component-topology 2.15.37 → 2.15.40
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/index.css +1 -1
- package/build/index.js +3 -3
- package/es/components/Drawer/index.js +3 -1
- package/es/core/components/AlarmListPanel/index.module.scss +4 -0
- package/es/core/models/AttributeMetricDisplay.js +3 -170
- package/es/core/models/TopoApp.js +1 -1
- package/es/core/models/link/LinkTagsTipsBuilder.js +210 -0
- package/es/topoCenter/components/editor/propertyViews/edge/addLinkDrawer/components/editLinkInfo.js +1 -1
- package/lib/components/Drawer/index.js +3 -1
- package/lib/core/components/AlarmListPanel/index.module.scss +4 -0
- package/lib/core/models/AttributeMetricDisplay.js +4 -172
- package/lib/core/models/TopoApp.js +1 -1
- package/lib/core/models/link/LinkTagsTipsBuilder.js +220 -0
- package/lib/topoCenter/components/editor/propertyViews/edge/addLinkDrawer/components/editLinkInfo.js +1 -1
- package/package.json +2 -2
|
@@ -20,6 +20,8 @@ var Drawer = function Drawer(props) {
|
|
|
20
20
|
disabled = props.disabled,
|
|
21
21
|
loading = props.loading,
|
|
22
22
|
title = props.title,
|
|
23
|
+
_props$showButtons = props.showButtons,
|
|
24
|
+
showButtons = _props$showButtons === void 0 ? true : _props$showButtons,
|
|
23
25
|
_props$buttons = props.buttons,
|
|
24
26
|
buttons = _props$buttons === void 0 ? props.buttons || ['保存', '取消'] : _props$buttons,
|
|
25
27
|
onClose = props.onClose,
|
|
@@ -37,7 +39,7 @@ var Drawer = function Drawer(props) {
|
|
|
37
39
|
}, drawerProps, {
|
|
38
40
|
visible: visible,
|
|
39
41
|
onClose: onClose
|
|
40
|
-
}), children, /*#__PURE__*/React.createElement("div", {
|
|
42
|
+
}), children, showButtons && /*#__PURE__*/React.createElement("div", {
|
|
41
43
|
className: styles.footer
|
|
42
44
|
}, /*#__PURE__*/React.createElement(_Button, {
|
|
43
45
|
className: styles.button,
|
|
@@ -4,13 +4,12 @@ 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 groupBy from 'lodash/groupBy';
|
|
8
7
|
import { DEFAULT_LINK_TAG_COMMON_CONFIG, DEFAULT_NODE_TAG_COMMON_CONFIG, DEFAULT_TAG_COMMON_CONFIG, DEFAULT_TIP_COMMON_CONFIG } from "../../constants/ResourceInfoDisplay";
|
|
9
|
-
import { getEdgeGroupByNodeTags } from "../../utils/htElementUtils";
|
|
10
8
|
import { findItem } from "../../utils/topoData";
|
|
11
9
|
import { queryCisByIds } from "../services";
|
|
12
10
|
import AttributeFormatter from "./attributeFormatter";
|
|
13
11
|
import DictCache from "./cache/DictCache";
|
|
12
|
+
import LinkTagsTipsBuilder from "./link/LinkTagsTipsBuilder";
|
|
14
13
|
|
|
15
14
|
function isGraphField(item) {
|
|
16
15
|
return item.type === 'graph';
|
|
@@ -38,6 +37,7 @@ var filterByPermission = function filterByPermission(resource, items) {
|
|
|
38
37
|
var AttributeMetricDisplay = /*#__PURE__*/function () {
|
|
39
38
|
function AttributeMetricDisplay(topo) {
|
|
40
39
|
this.topo = topo;
|
|
40
|
+
this.edgeTagsTipsBuilder = new LinkTagsTipsBuilder(this);
|
|
41
41
|
}
|
|
42
42
|
|
|
43
43
|
var _proto = AttributeMetricDisplay.prototype;
|
|
@@ -668,177 +668,10 @@ var AttributeMetricDisplay = /*#__PURE__*/function () {
|
|
|
668
668
|
tips: formatter.formatAttrs(ciConfig.tips, ciData)
|
|
669
669
|
};
|
|
670
670
|
});
|
|
671
|
-
var elementTagsAndTips = [].concat(ciTagsAndTips, this.getEdgeGroupTagsAndTips(data, ciConfigs)); // 刷新标注、浮层
|
|
671
|
+
var elementTagsAndTips = [].concat(ciTagsAndTips, this.edgeTagsTipsBuilder.getEdgeGroupTagsAndTips(data, ciConfigs)); // 刷新标注、浮层
|
|
672
672
|
// rlog.debug('AttributeMetricDisplay.buildTagsTips', {tagsAndTips: elementTagsAndTips, ciConfigs});
|
|
673
673
|
|
|
674
674
|
return elementTagsAndTips;
|
|
675
|
-
}
|
|
676
|
-
/**
|
|
677
|
-
* 获得未关联聚合链路的连线组标注和悬浮框数据
|
|
678
|
-
* @param {*} ciTagsAndTips
|
|
679
|
-
* @param {*} data
|
|
680
|
-
* @param {*} ciConfigs
|
|
681
|
-
* @returns
|
|
682
|
-
*/
|
|
683
|
-
;
|
|
684
|
-
|
|
685
|
-
_proto.getEdgeGroupTagsAndTips = function getEdgeGroupTagsAndTips(data, ciConfigs) {
|
|
686
|
-
var _this5 = this;
|
|
687
|
-
|
|
688
|
-
// 查询没有关联链路的连线组及对应子链路列表
|
|
689
|
-
var _this$topo$dataModel$ = this.topo.dataModel.getData(),
|
|
690
|
-
links = _this$topo$dataModel$.links,
|
|
691
|
-
linkGroups = _this$topo$dataModel$.linkGroups;
|
|
692
|
-
|
|
693
|
-
var getLinkUId = function getLinkUId(link) {
|
|
694
|
-
return [link.source, link.target].sort().join('-');
|
|
695
|
-
};
|
|
696
|
-
|
|
697
|
-
var linkGroupUIds = linkGroups.filter(function (link) {
|
|
698
|
-
return link.ciType === 'network_link';
|
|
699
|
-
}).map(function (link) {
|
|
700
|
-
return getLinkUId(link);
|
|
701
|
-
}); // 查询没有聚合链路的物理链路/出口链路
|
|
702
|
-
|
|
703
|
-
var noParentLinks = links.filter(function (link) {
|
|
704
|
-
return link.ciType === 'network_link';
|
|
705
|
-
}).map(function (link) {
|
|
706
|
-
return _extends({}, link, {
|
|
707
|
-
linkUId: getLinkUId(link)
|
|
708
|
-
});
|
|
709
|
-
}).filter(function (link) {
|
|
710
|
-
return linkGroupUIds.indexOf(link.linkUId) === -1;
|
|
711
|
-
});
|
|
712
|
-
var groupMap = groupBy(noParentLinks, 'linkUId'); // 参与计算的链路指标
|
|
713
|
-
|
|
714
|
-
var metrics = [// 总流速
|
|
715
|
-
{
|
|
716
|
-
code: 'total_flow_rate',
|
|
717
|
-
calcType: 'sum'
|
|
718
|
-
}, // 带宽利用率
|
|
719
|
-
{
|
|
720
|
-
code: 'bandwidth_utilization',
|
|
721
|
-
calcType: 'avg',
|
|
722
|
-
showWhenSameSource: true
|
|
723
|
-
}, // 发送带宽利用率
|
|
724
|
-
{
|
|
725
|
-
code: 'out_bandwidth_utilization',
|
|
726
|
-
calcType: 'avg',
|
|
727
|
-
showWhenSameSource: true
|
|
728
|
-
}, // 接收带宽利用率
|
|
729
|
-
{
|
|
730
|
-
code: 'in_bandwidth_utilization',
|
|
731
|
-
calcType: 'avg',
|
|
732
|
-
showWhenSameSource: true
|
|
733
|
-
}, {
|
|
734
|
-
code: 'out_rate',
|
|
735
|
-
calcType: 'sum',
|
|
736
|
-
showWhenSameSource: true
|
|
737
|
-
}, {
|
|
738
|
-
code: 'in_rate',
|
|
739
|
-
calcType: 'sum',
|
|
740
|
-
showWhenSameSource: true
|
|
741
|
-
}];
|
|
742
|
-
var connectTypePrefixMap = {
|
|
743
|
-
phy: 'physical_link.',
|
|
744
|
-
exit: 'export_link.'
|
|
745
|
-
};
|
|
746
|
-
var calcFnMap = {
|
|
747
|
-
sum: function sum(values) {
|
|
748
|
-
return values.reduce(function (total, val) {
|
|
749
|
-
return total + parseInt(val || 0, 10);
|
|
750
|
-
}, 0);
|
|
751
|
-
},
|
|
752
|
-
avg: function avg(values) {
|
|
753
|
-
return values.reduce(function (total, val) {
|
|
754
|
-
return total + parseFloat(val || 0, 10);
|
|
755
|
-
}, 0) / values.length;
|
|
756
|
-
}
|
|
757
|
-
};
|
|
758
|
-
|
|
759
|
-
var filterField = function filterField(item, linkChildren) {
|
|
760
|
-
var fieldConfig = metrics.find(function (m) {
|
|
761
|
-
return item.code.endsWith(m.code);
|
|
762
|
-
});
|
|
763
|
-
|
|
764
|
-
if (item.type !== 'metric' || !fieldConfig) {
|
|
765
|
-
return false;
|
|
766
|
-
} // 如果需要校验取值接口,如果取值接口为不同设备的接口,则不显示这四个指标
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
if (fieldConfig.showWhenSameSource) {
|
|
770
|
-
var sources = [];
|
|
771
|
-
linkChildren.forEach(function (link) {
|
|
772
|
-
if (sources.indexOf(link.source) === -1) {
|
|
773
|
-
sources.push(link.source);
|
|
774
|
-
}
|
|
775
|
-
});
|
|
776
|
-
|
|
777
|
-
if (sources.length > 1) {
|
|
778
|
-
return false;
|
|
779
|
-
}
|
|
780
|
-
}
|
|
781
|
-
|
|
782
|
-
return true;
|
|
783
|
-
}; // 计算标注和指标
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
var edgeGroupsTagsTips = Object.keys(groupMap) // 过滤非连线组
|
|
787
|
-
.filter(function (groupId) {
|
|
788
|
-
var linkChildren = groupMap[groupId];
|
|
789
|
-
var edgeGroup = getEdgeGroupByNodeTags(_this5.topo.getDataModel(), linkChildren[0].source, linkChildren[0].target);
|
|
790
|
-
return !!edgeGroup;
|
|
791
|
-
}).map(function (groupId) {
|
|
792
|
-
var linkChildren = groupMap[groupId]; // 查询配置,过滤不在范围内的属性
|
|
793
|
-
|
|
794
|
-
var config = ciConfigs.find(function (item) {
|
|
795
|
-
return item.id === linkChildren[0].id;
|
|
796
|
-
});
|
|
797
|
-
config = _extends({}, config, {
|
|
798
|
-
tags: config.tags.filter(function (item) {
|
|
799
|
-
return filterField(item, linkChildren);
|
|
800
|
-
}),
|
|
801
|
-
tips: config.tips.filter(function (item) {
|
|
802
|
-
return filterField(item, linkChildren);
|
|
803
|
-
})
|
|
804
|
-
}); // 构造数据,计算指标值
|
|
805
|
-
|
|
806
|
-
var linkChildrenData = linkChildren.map(function (link) {
|
|
807
|
-
return data.find(function (item) {
|
|
808
|
-
return item.id === link.id;
|
|
809
|
-
});
|
|
810
|
-
});
|
|
811
|
-
var mergeData = {
|
|
812
|
-
ciType: 'network_link',
|
|
813
|
-
metricMap: {}
|
|
814
|
-
};
|
|
815
|
-
var connectType = linkChildren[0].attributes['network_link.connect_type'];
|
|
816
|
-
metrics.forEach(function (m) {
|
|
817
|
-
var metricCode = "" + connectTypePrefixMap[connectType] + m.code;
|
|
818
|
-
|
|
819
|
-
try {
|
|
820
|
-
var values = linkChildrenData.map(function (linkData) {
|
|
821
|
-
return linkData.metricMap[metricCode];
|
|
822
|
-
});
|
|
823
|
-
mergeData.metricMap[metricCode] = calcFnMap[m.calcType](values);
|
|
824
|
-
} catch (error) {
|
|
825
|
-
rlog.warn('连线组指标计算异常', error);
|
|
826
|
-
}
|
|
827
|
-
}); // console.error(groupId, {config, linkChildrenData, mergeData})
|
|
828
|
-
// 构造标注、悬浮框数据
|
|
829
|
-
|
|
830
|
-
var formatter = new AttributeFormatter(_this5.topo);
|
|
831
|
-
return {
|
|
832
|
-
type: 'edgeGroup',
|
|
833
|
-
edgeGroupId: groupId,
|
|
834
|
-
tags: formatter.formatAttrs(config.tags, mergeData),
|
|
835
|
-
tips: formatter.formatAttrs(config.tips, mergeData)
|
|
836
|
-
};
|
|
837
|
-
}); // console.error({
|
|
838
|
-
// noParentLinks, groupMap, edgeGroups: edgeGroupsTagsTips, ciTagsAndTips, data
|
|
839
|
-
// })
|
|
840
|
-
|
|
841
|
-
return edgeGroupsTagsTips;
|
|
842
675
|
};
|
|
843
676
|
|
|
844
677
|
return AttributeMetricDisplay;
|
|
@@ -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 "2.15.
|
|
23
|
+
var version = typeof "2.15.40" === 'string' ? "2.15.40" : null;
|
|
24
24
|
console.info("\u62D3\u6251\u7248\u672C: " + version);
|
|
25
25
|
/**
|
|
26
26
|
* 拓扑显示和编辑
|
|
@@ -0,0 +1,210 @@
|
|
|
1
|
+
import _extends from "@babel/runtime/helpers/extends";
|
|
2
|
+
import rlog from '@riil-frontend/component-topology-utils/es/rlog';
|
|
3
|
+
import groupBy from 'lodash/groupBy';
|
|
4
|
+
import { getEdgeGroupByNodeTags } from "../../../utils/htElementUtils";
|
|
5
|
+
import AttributeFormatter from "../attributeFormatter"; // 参与计算的链路指标
|
|
6
|
+
|
|
7
|
+
var metrics = [// 总流速
|
|
8
|
+
{
|
|
9
|
+
code: 'total_flow_rate',
|
|
10
|
+
calcType: 'sum'
|
|
11
|
+
}, // 带宽利用率
|
|
12
|
+
{
|
|
13
|
+
code: 'bandwidth_utilization',
|
|
14
|
+
calcType: 'avg'
|
|
15
|
+
}, // 发送带宽利用率
|
|
16
|
+
{
|
|
17
|
+
code: 'out_bandwidth_utilization',
|
|
18
|
+
calcType: 'avg',
|
|
19
|
+
showWhenSameSource: true
|
|
20
|
+
}, // 接收带宽利用率
|
|
21
|
+
{
|
|
22
|
+
code: 'in_bandwidth_utilization',
|
|
23
|
+
calcType: 'avg',
|
|
24
|
+
showWhenSameSource: true
|
|
25
|
+
}, {
|
|
26
|
+
code: 'out_rate',
|
|
27
|
+
calcType: 'sum',
|
|
28
|
+
showWhenSameSource: true
|
|
29
|
+
}, {
|
|
30
|
+
code: 'in_rate',
|
|
31
|
+
calcType: 'sum',
|
|
32
|
+
showWhenSameSource: true
|
|
33
|
+
}];
|
|
34
|
+
var connectTypePrefixMap = {
|
|
35
|
+
phy: 'physical_link.',
|
|
36
|
+
exit: 'export_link.'
|
|
37
|
+
};
|
|
38
|
+
var calcFnMap = {
|
|
39
|
+
sum: function sum(values) {
|
|
40
|
+
return values.reduce(function (total, val) {
|
|
41
|
+
return total + parseInt(val || 0, 10);
|
|
42
|
+
}, 0);
|
|
43
|
+
},
|
|
44
|
+
avg: function avg(values) {
|
|
45
|
+
return values.reduce(function (total, val) {
|
|
46
|
+
return total + parseFloat(val || 0, 10);
|
|
47
|
+
}, 0) / values.length;
|
|
48
|
+
}
|
|
49
|
+
};
|
|
50
|
+
|
|
51
|
+
var LinkTagsTipsBuilder = /*#__PURE__*/function () {
|
|
52
|
+
function LinkTagsTipsBuilder(amDisplay) {
|
|
53
|
+
this.amDisplay = void 0;
|
|
54
|
+
this.topo = void 0;
|
|
55
|
+
this.amDisplay = amDisplay;
|
|
56
|
+
this.topo = amDisplay.topo;
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* 获得未关联聚合链路的连线组标注和悬浮框数据
|
|
60
|
+
* @param {*} ciTagsAndTips
|
|
61
|
+
* @returns
|
|
62
|
+
*/
|
|
63
|
+
|
|
64
|
+
|
|
65
|
+
var _proto = LinkTagsTipsBuilder.prototype;
|
|
66
|
+
|
|
67
|
+
_proto.getEdgeGroupTagsAndTips = function getEdgeGroupTagsAndTips() {
|
|
68
|
+
var _this = this;
|
|
69
|
+
|
|
70
|
+
var ciConfigs = this.amDisplay.getResourceTagTipConfig();
|
|
71
|
+
var data = this.amDisplay.getData(); // 查询没有关联链路的连线组及对应子链路列表
|
|
72
|
+
|
|
73
|
+
var _this$topo$dataModel$ = this.topo.dataModel.getData(),
|
|
74
|
+
links = _this$topo$dataModel$.links,
|
|
75
|
+
linkGroups = _this$topo$dataModel$.linkGroups;
|
|
76
|
+
|
|
77
|
+
var getLinkUId = function getLinkUId(link) {
|
|
78
|
+
return [link.source, link.target].sort().join('-');
|
|
79
|
+
};
|
|
80
|
+
|
|
81
|
+
var linkGroupUIds = linkGroups.filter(function (link) {
|
|
82
|
+
return link.ciType === 'network_link';
|
|
83
|
+
}).map(function (link) {
|
|
84
|
+
return getLinkUId(link);
|
|
85
|
+
}); // 查询没有聚合链路的物理链路/出口链路
|
|
86
|
+
|
|
87
|
+
var noParentLinks = links.filter(function (link) {
|
|
88
|
+
return link.ciType === 'network_link';
|
|
89
|
+
}).map(function (link) {
|
|
90
|
+
return _extends({}, link, {
|
|
91
|
+
linkUId: getLinkUId(link)
|
|
92
|
+
});
|
|
93
|
+
}).filter(function (link) {
|
|
94
|
+
return linkGroupUIds.indexOf(link.linkUId) === -1;
|
|
95
|
+
});
|
|
96
|
+
var groupMap = groupBy(noParentLinks, 'linkUId'); // 计算标注和指标
|
|
97
|
+
|
|
98
|
+
var edgeGroupsTagsTips = Object.keys(groupMap) // 过滤非连线组
|
|
99
|
+
.filter(function (groupId) {
|
|
100
|
+
var linkChildren = groupMap[groupId];
|
|
101
|
+
var edgeGroup = getEdgeGroupByNodeTags(_this.topo.getDataModel(), linkChildren[0].source, linkChildren[0].target);
|
|
102
|
+
return !!edgeGroup;
|
|
103
|
+
}).map(function (groupId) {
|
|
104
|
+
var linkChildren = groupMap[groupId];
|
|
105
|
+
var config = ciConfigs.find(function (item) {
|
|
106
|
+
return item.id === linkChildren[0].id;
|
|
107
|
+
});
|
|
108
|
+
return _this.buildEdgeGroupTagTagsAndTips({
|
|
109
|
+
groupId: groupId,
|
|
110
|
+
config: config,
|
|
111
|
+
linkChildren: linkChildren,
|
|
112
|
+
data: data
|
|
113
|
+
});
|
|
114
|
+
}); // console.error({
|
|
115
|
+
// noParentLinks, groupMap, edgeGroups: edgeGroupsTagsTips, ciTagsAndTips, data
|
|
116
|
+
// })
|
|
117
|
+
|
|
118
|
+
return edgeGroupsTagsTips;
|
|
119
|
+
};
|
|
120
|
+
|
|
121
|
+
_proto.buildEdgeGroupTagTagsAndTips = function buildEdgeGroupTagTagsAndTips(_ref) {
|
|
122
|
+
var _this2 = this;
|
|
123
|
+
|
|
124
|
+
var groupId = _ref.groupId,
|
|
125
|
+
config = _ref.config,
|
|
126
|
+
linkChildren = _ref.linkChildren,
|
|
127
|
+
data = _ref.data;
|
|
128
|
+
|
|
129
|
+
// 查询配置,过滤不在范围内的属性
|
|
130
|
+
var finalConfig = _extends({}, config, {
|
|
131
|
+
tags: config.tags.filter(function (item) {
|
|
132
|
+
return _this2.filterField(item, linkChildren);
|
|
133
|
+
}),
|
|
134
|
+
tips: config.tips.filter(function (item) {
|
|
135
|
+
return _this2.filterField(item, linkChildren);
|
|
136
|
+
})
|
|
137
|
+
}); // 构造数据,计算指标值
|
|
138
|
+
|
|
139
|
+
|
|
140
|
+
var mergeData = this.buildData(data, linkChildren); // 构造标注、悬浮框数据
|
|
141
|
+
|
|
142
|
+
var formatter = new AttributeFormatter(this.topo);
|
|
143
|
+
return {
|
|
144
|
+
type: 'edgeGroup',
|
|
145
|
+
edgeGroupId: groupId,
|
|
146
|
+
tags: formatter.formatAttrs(finalConfig.tags, mergeData),
|
|
147
|
+
tips: formatter.formatAttrs(finalConfig.tips, mergeData)
|
|
148
|
+
};
|
|
149
|
+
} // eslint-disable-next-line class-methods-use-this
|
|
150
|
+
;
|
|
151
|
+
|
|
152
|
+
_proto.filterField = function filterField(item, linkChildren) {
|
|
153
|
+
var fieldConfig = metrics.find(function (m) {
|
|
154
|
+
return item.code.endsWith("." + m.code);
|
|
155
|
+
});
|
|
156
|
+
|
|
157
|
+
if (item.type !== 'metric' || !fieldConfig) {
|
|
158
|
+
return false;
|
|
159
|
+
} // 如果需要校验取值接口,如果取值接口为不同设备的接口,则不显示这四个指标
|
|
160
|
+
|
|
161
|
+
|
|
162
|
+
if (fieldConfig.showWhenSameSource) {
|
|
163
|
+
var sources = [];
|
|
164
|
+
linkChildren.forEach(function (link) {
|
|
165
|
+
if (sources.indexOf(link.source) === -1) {
|
|
166
|
+
sources.push(link.source);
|
|
167
|
+
}
|
|
168
|
+
});
|
|
169
|
+
|
|
170
|
+
if (sources.length > 1) {
|
|
171
|
+
return false;
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
return true;
|
|
176
|
+
} // eslint-disable-next-line class-methods-use-this
|
|
177
|
+
;
|
|
178
|
+
|
|
179
|
+
_proto.buildData = function buildData(data, linkChildren) {
|
|
180
|
+
var linkChildrenData = linkChildren.map(function (link) {
|
|
181
|
+
return data.find(function (item) {
|
|
182
|
+
return item.id === link.id;
|
|
183
|
+
});
|
|
184
|
+
});
|
|
185
|
+
var mergeData = {
|
|
186
|
+
ciType: 'network_link',
|
|
187
|
+
metricMap: {}
|
|
188
|
+
};
|
|
189
|
+
var connectType = linkChildren[0].attributes['network_link.connect_type'];
|
|
190
|
+
metrics.forEach(function (m) {
|
|
191
|
+
var metricCode = "" + connectTypePrefixMap[connectType] + m.code;
|
|
192
|
+
|
|
193
|
+
try {
|
|
194
|
+
var values = linkChildrenData.map(function (linkData) {
|
|
195
|
+
return linkData.metricMap[metricCode];
|
|
196
|
+
});
|
|
197
|
+
mergeData.metricMap[metricCode] = calcFnMap[m.calcType](values);
|
|
198
|
+
} catch (error) {
|
|
199
|
+
rlog.warn('连线组指标计算异常', error);
|
|
200
|
+
}
|
|
201
|
+
}); // console.error(groupId, {config, linkChildrenData, mergeData})
|
|
202
|
+
|
|
203
|
+
return mergeData;
|
|
204
|
+
};
|
|
205
|
+
|
|
206
|
+
return LinkTagsTipsBuilder;
|
|
207
|
+
}();
|
|
208
|
+
|
|
209
|
+
export { LinkTagsTipsBuilder as default };
|
|
210
|
+
;
|
package/es/topoCenter/components/editor/propertyViews/edge/addLinkDrawer/components/editLinkInfo.js
CHANGED
|
@@ -353,7 +353,7 @@ export default function EditLinkInfo(props) {
|
|
|
353
353
|
type: "primary",
|
|
354
354
|
loading: loading,
|
|
355
355
|
onClick: saveHandleChange
|
|
356
|
-
}, "
|
|
356
|
+
}, isAdd ? "确定" : "保存"), /*#__PURE__*/React.createElement(_Button, {
|
|
357
357
|
className: styles.button,
|
|
358
358
|
onClick: onClose
|
|
359
359
|
}, "\u53D6\u6D88")));
|
|
@@ -32,6 +32,8 @@ var Drawer = function Drawer(props) {
|
|
|
32
32
|
disabled = props.disabled,
|
|
33
33
|
loading = props.loading,
|
|
34
34
|
title = props.title,
|
|
35
|
+
_props$showButtons = props.showButtons,
|
|
36
|
+
showButtons = _props$showButtons === void 0 ? true : _props$showButtons,
|
|
35
37
|
_props$buttons = props.buttons,
|
|
36
38
|
buttons = _props$buttons === void 0 ? props.buttons || ['保存', '取消'] : _props$buttons,
|
|
37
39
|
onClose = props.onClose,
|
|
@@ -49,7 +51,7 @@ var Drawer = function Drawer(props) {
|
|
|
49
51
|
}, drawerProps, {
|
|
50
52
|
visible: visible,
|
|
51
53
|
onClose: onClose
|
|
52
|
-
}), children, /*#__PURE__*/_react["default"].createElement("div", {
|
|
54
|
+
}), children, showButtons && /*#__PURE__*/_react["default"].createElement("div", {
|
|
53
55
|
className: _indexModule["default"].footer
|
|
54
56
|
}, /*#__PURE__*/_react["default"].createElement(_button["default"], {
|
|
55
57
|
className: _indexModule["default"].button,
|
|
@@ -17,12 +17,8 @@ var _rlog = _interopRequireDefault(require("@riil-frontend/component-topology-ut
|
|
|
17
17
|
|
|
18
18
|
var _lodash = require("lodash");
|
|
19
19
|
|
|
20
|
-
var _groupBy = _interopRequireDefault(require("lodash/groupBy"));
|
|
21
|
-
|
|
22
20
|
var _ResourceInfoDisplay = require("../../constants/ResourceInfoDisplay");
|
|
23
21
|
|
|
24
|
-
var _htElementUtils = require("../../utils/htElementUtils");
|
|
25
|
-
|
|
26
22
|
var _topoData = require("../../utils/topoData");
|
|
27
23
|
|
|
28
24
|
var _services = require("../services");
|
|
@@ -31,6 +27,8 @@ var _attributeFormatter = _interopRequireDefault(require("./attributeFormatter")
|
|
|
31
27
|
|
|
32
28
|
var _DictCache = _interopRequireDefault(require("./cache/DictCache"));
|
|
33
29
|
|
|
30
|
+
var _LinkTagsTipsBuilder = _interopRequireDefault(require("./link/LinkTagsTipsBuilder"));
|
|
31
|
+
|
|
34
32
|
function isGraphField(item) {
|
|
35
33
|
return item.type === 'graph';
|
|
36
34
|
}
|
|
@@ -57,6 +55,7 @@ var filterByPermission = function filterByPermission(resource, items) {
|
|
|
57
55
|
var AttributeMetricDisplay = /*#__PURE__*/function () {
|
|
58
56
|
function AttributeMetricDisplay(topo) {
|
|
59
57
|
this.topo = topo;
|
|
58
|
+
this.edgeTagsTipsBuilder = new _LinkTagsTipsBuilder["default"](this);
|
|
60
59
|
}
|
|
61
60
|
|
|
62
61
|
var _proto = AttributeMetricDisplay.prototype;
|
|
@@ -687,177 +686,10 @@ var AttributeMetricDisplay = /*#__PURE__*/function () {
|
|
|
687
686
|
tips: formatter.formatAttrs(ciConfig.tips, ciData)
|
|
688
687
|
};
|
|
689
688
|
});
|
|
690
|
-
var elementTagsAndTips = [].concat(ciTagsAndTips, this.getEdgeGroupTagsAndTips(data, ciConfigs)); // 刷新标注、浮层
|
|
689
|
+
var elementTagsAndTips = [].concat(ciTagsAndTips, this.edgeTagsTipsBuilder.getEdgeGroupTagsAndTips(data, ciConfigs)); // 刷新标注、浮层
|
|
691
690
|
// rlog.debug('AttributeMetricDisplay.buildTagsTips', {tagsAndTips: elementTagsAndTips, ciConfigs});
|
|
692
691
|
|
|
693
692
|
return elementTagsAndTips;
|
|
694
|
-
}
|
|
695
|
-
/**
|
|
696
|
-
* 获得未关联聚合链路的连线组标注和悬浮框数据
|
|
697
|
-
* @param {*} ciTagsAndTips
|
|
698
|
-
* @param {*} data
|
|
699
|
-
* @param {*} ciConfigs
|
|
700
|
-
* @returns
|
|
701
|
-
*/
|
|
702
|
-
;
|
|
703
|
-
|
|
704
|
-
_proto.getEdgeGroupTagsAndTips = function getEdgeGroupTagsAndTips(data, ciConfigs) {
|
|
705
|
-
var _this5 = this;
|
|
706
|
-
|
|
707
|
-
// 查询没有关联链路的连线组及对应子链路列表
|
|
708
|
-
var _this$topo$dataModel$ = this.topo.dataModel.getData(),
|
|
709
|
-
links = _this$topo$dataModel$.links,
|
|
710
|
-
linkGroups = _this$topo$dataModel$.linkGroups;
|
|
711
|
-
|
|
712
|
-
var getLinkUId = function getLinkUId(link) {
|
|
713
|
-
return [link.source, link.target].sort().join('-');
|
|
714
|
-
};
|
|
715
|
-
|
|
716
|
-
var linkGroupUIds = linkGroups.filter(function (link) {
|
|
717
|
-
return link.ciType === 'network_link';
|
|
718
|
-
}).map(function (link) {
|
|
719
|
-
return getLinkUId(link);
|
|
720
|
-
}); // 查询没有聚合链路的物理链路/出口链路
|
|
721
|
-
|
|
722
|
-
var noParentLinks = links.filter(function (link) {
|
|
723
|
-
return link.ciType === 'network_link';
|
|
724
|
-
}).map(function (link) {
|
|
725
|
-
return (0, _extends2["default"])({}, link, {
|
|
726
|
-
linkUId: getLinkUId(link)
|
|
727
|
-
});
|
|
728
|
-
}).filter(function (link) {
|
|
729
|
-
return linkGroupUIds.indexOf(link.linkUId) === -1;
|
|
730
|
-
});
|
|
731
|
-
var groupMap = (0, _groupBy["default"])(noParentLinks, 'linkUId'); // 参与计算的链路指标
|
|
732
|
-
|
|
733
|
-
var metrics = [// 总流速
|
|
734
|
-
{
|
|
735
|
-
code: 'total_flow_rate',
|
|
736
|
-
calcType: 'sum'
|
|
737
|
-
}, // 带宽利用率
|
|
738
|
-
{
|
|
739
|
-
code: 'bandwidth_utilization',
|
|
740
|
-
calcType: 'avg',
|
|
741
|
-
showWhenSameSource: true
|
|
742
|
-
}, // 发送带宽利用率
|
|
743
|
-
{
|
|
744
|
-
code: 'out_bandwidth_utilization',
|
|
745
|
-
calcType: 'avg',
|
|
746
|
-
showWhenSameSource: true
|
|
747
|
-
}, // 接收带宽利用率
|
|
748
|
-
{
|
|
749
|
-
code: 'in_bandwidth_utilization',
|
|
750
|
-
calcType: 'avg',
|
|
751
|
-
showWhenSameSource: true
|
|
752
|
-
}, {
|
|
753
|
-
code: 'out_rate',
|
|
754
|
-
calcType: 'sum',
|
|
755
|
-
showWhenSameSource: true
|
|
756
|
-
}, {
|
|
757
|
-
code: 'in_rate',
|
|
758
|
-
calcType: 'sum',
|
|
759
|
-
showWhenSameSource: true
|
|
760
|
-
}];
|
|
761
|
-
var connectTypePrefixMap = {
|
|
762
|
-
phy: 'physical_link.',
|
|
763
|
-
exit: 'export_link.'
|
|
764
|
-
};
|
|
765
|
-
var calcFnMap = {
|
|
766
|
-
sum: function sum(values) {
|
|
767
|
-
return values.reduce(function (total, val) {
|
|
768
|
-
return total + parseInt(val || 0, 10);
|
|
769
|
-
}, 0);
|
|
770
|
-
},
|
|
771
|
-
avg: function avg(values) {
|
|
772
|
-
return values.reduce(function (total, val) {
|
|
773
|
-
return total + parseFloat(val || 0, 10);
|
|
774
|
-
}, 0) / values.length;
|
|
775
|
-
}
|
|
776
|
-
};
|
|
777
|
-
|
|
778
|
-
var filterField = function filterField(item, linkChildren) {
|
|
779
|
-
var fieldConfig = metrics.find(function (m) {
|
|
780
|
-
return item.code.endsWith(m.code);
|
|
781
|
-
});
|
|
782
|
-
|
|
783
|
-
if (item.type !== 'metric' || !fieldConfig) {
|
|
784
|
-
return false;
|
|
785
|
-
} // 如果需要校验取值接口,如果取值接口为不同设备的接口,则不显示这四个指标
|
|
786
|
-
|
|
787
|
-
|
|
788
|
-
if (fieldConfig.showWhenSameSource) {
|
|
789
|
-
var sources = [];
|
|
790
|
-
linkChildren.forEach(function (link) {
|
|
791
|
-
if (sources.indexOf(link.source) === -1) {
|
|
792
|
-
sources.push(link.source);
|
|
793
|
-
}
|
|
794
|
-
});
|
|
795
|
-
|
|
796
|
-
if (sources.length > 1) {
|
|
797
|
-
return false;
|
|
798
|
-
}
|
|
799
|
-
}
|
|
800
|
-
|
|
801
|
-
return true;
|
|
802
|
-
}; // 计算标注和指标
|
|
803
|
-
|
|
804
|
-
|
|
805
|
-
var edgeGroupsTagsTips = Object.keys(groupMap) // 过滤非连线组
|
|
806
|
-
.filter(function (groupId) {
|
|
807
|
-
var linkChildren = groupMap[groupId];
|
|
808
|
-
var edgeGroup = (0, _htElementUtils.getEdgeGroupByNodeTags)(_this5.topo.getDataModel(), linkChildren[0].source, linkChildren[0].target);
|
|
809
|
-
return !!edgeGroup;
|
|
810
|
-
}).map(function (groupId) {
|
|
811
|
-
var linkChildren = groupMap[groupId]; // 查询配置,过滤不在范围内的属性
|
|
812
|
-
|
|
813
|
-
var config = ciConfigs.find(function (item) {
|
|
814
|
-
return item.id === linkChildren[0].id;
|
|
815
|
-
});
|
|
816
|
-
config = (0, _extends2["default"])({}, config, {
|
|
817
|
-
tags: config.tags.filter(function (item) {
|
|
818
|
-
return filterField(item, linkChildren);
|
|
819
|
-
}),
|
|
820
|
-
tips: config.tips.filter(function (item) {
|
|
821
|
-
return filterField(item, linkChildren);
|
|
822
|
-
})
|
|
823
|
-
}); // 构造数据,计算指标值
|
|
824
|
-
|
|
825
|
-
var linkChildrenData = linkChildren.map(function (link) {
|
|
826
|
-
return data.find(function (item) {
|
|
827
|
-
return item.id === link.id;
|
|
828
|
-
});
|
|
829
|
-
});
|
|
830
|
-
var mergeData = {
|
|
831
|
-
ciType: 'network_link',
|
|
832
|
-
metricMap: {}
|
|
833
|
-
};
|
|
834
|
-
var connectType = linkChildren[0].attributes['network_link.connect_type'];
|
|
835
|
-
metrics.forEach(function (m) {
|
|
836
|
-
var metricCode = "" + connectTypePrefixMap[connectType] + m.code;
|
|
837
|
-
|
|
838
|
-
try {
|
|
839
|
-
var values = linkChildrenData.map(function (linkData) {
|
|
840
|
-
return linkData.metricMap[metricCode];
|
|
841
|
-
});
|
|
842
|
-
mergeData.metricMap[metricCode] = calcFnMap[m.calcType](values);
|
|
843
|
-
} catch (error) {
|
|
844
|
-
_rlog["default"].warn('连线组指标计算异常', error);
|
|
845
|
-
}
|
|
846
|
-
}); // console.error(groupId, {config, linkChildrenData, mergeData})
|
|
847
|
-
// 构造标注、悬浮框数据
|
|
848
|
-
|
|
849
|
-
var formatter = new _attributeFormatter["default"](_this5.topo);
|
|
850
|
-
return {
|
|
851
|
-
type: 'edgeGroup',
|
|
852
|
-
edgeGroupId: groupId,
|
|
853
|
-
tags: formatter.formatAttrs(config.tags, mergeData),
|
|
854
|
-
tips: formatter.formatAttrs(config.tips, mergeData)
|
|
855
|
-
};
|
|
856
|
-
}); // console.error({
|
|
857
|
-
// noParentLinks, groupMap, edgeGroups: edgeGroupsTagsTips, ciTagsAndTips, data
|
|
858
|
-
// })
|
|
859
|
-
|
|
860
|
-
return edgeGroupsTagsTips;
|
|
861
693
|
};
|
|
862
694
|
|
|
863
695
|
return AttributeMetricDisplay;
|