@riil-frontend/component-topology 2.15.38 → 2.15.41

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.
@@ -24,6 +24,10 @@
24
24
  line-height: 24px;
25
25
  }
26
26
 
27
+ .listTitleLink:hover {
28
+ color: #75A8FF;
29
+ }
30
+
27
31
  :global {
28
32
  .#{$css-prefix}dialog-body {
29
33
  padding: 0px;
@@ -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,176 +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
- }, // 发送带宽利用率
742
- {
743
- code: 'out_bandwidth_utilization',
744
- calcType: 'avg',
745
- showWhenSameSource: true
746
- }, // 接收带宽利用率
747
- {
748
- code: 'in_bandwidth_utilization',
749
- calcType: 'avg',
750
- showWhenSameSource: true
751
- }, {
752
- code: 'out_rate',
753
- calcType: 'sum',
754
- showWhenSameSource: true
755
- }, {
756
- code: 'in_rate',
757
- calcType: 'sum',
758
- showWhenSameSource: true
759
- }];
760
- var connectTypePrefixMap = {
761
- phy: 'physical_link.',
762
- exit: 'export_link.'
763
- };
764
- var calcFnMap = {
765
- sum: function sum(values) {
766
- return values.reduce(function (total, val) {
767
- return total + parseInt(val || 0, 10);
768
- }, 0);
769
- },
770
- avg: function avg(values) {
771
- return values.reduce(function (total, val) {
772
- return total + parseFloat(val || 0, 10);
773
- }, 0) / values.length;
774
- }
775
- };
776
-
777
- var filterField = function filterField(item, linkChildren) {
778
- var fieldConfig = metrics.find(function (m) {
779
- return item.code.endsWith(m.code);
780
- });
781
-
782
- if (item.type !== 'metric' || !fieldConfig) {
783
- return false;
784
- } // 如果需要校验取值接口,如果取值接口为不同设备的接口,则不显示这四个指标
785
-
786
-
787
- if (fieldConfig.showWhenSameSource) {
788
- var sources = [];
789
- linkChildren.forEach(function (link) {
790
- if (sources.indexOf(link.source) === -1) {
791
- sources.push(link.source);
792
- }
793
- });
794
-
795
- if (sources.length > 1) {
796
- return false;
797
- }
798
- }
799
-
800
- return true;
801
- }; // 计算标注和指标
802
-
803
-
804
- var edgeGroupsTagsTips = Object.keys(groupMap) // 过滤非连线组
805
- .filter(function (groupId) {
806
- var linkChildren = groupMap[groupId];
807
- var edgeGroup = (0, _htElementUtils.getEdgeGroupByNodeTags)(_this5.topo.getDataModel(), linkChildren[0].source, linkChildren[0].target);
808
- return !!edgeGroup;
809
- }).map(function (groupId) {
810
- var linkChildren = groupMap[groupId]; // 查询配置,过滤不在范围内的属性
811
-
812
- var config = ciConfigs.find(function (item) {
813
- return item.id === linkChildren[0].id;
814
- });
815
- config = (0, _extends2["default"])({}, config, {
816
- tags: config.tags.filter(function (item) {
817
- return filterField(item, linkChildren);
818
- }),
819
- tips: config.tips.filter(function (item) {
820
- return filterField(item, linkChildren);
821
- })
822
- }); // 构造数据,计算指标值
823
-
824
- var linkChildrenData = linkChildren.map(function (link) {
825
- return data.find(function (item) {
826
- return item.id === link.id;
827
- });
828
- });
829
- var mergeData = {
830
- ciType: 'network_link',
831
- metricMap: {}
832
- };
833
- var connectType = linkChildren[0].attributes['network_link.connect_type'];
834
- metrics.forEach(function (m) {
835
- var metricCode = "" + connectTypePrefixMap[connectType] + m.code;
836
-
837
- try {
838
- var values = linkChildrenData.map(function (linkData) {
839
- return linkData.metricMap[metricCode];
840
- });
841
- mergeData.metricMap[metricCode] = calcFnMap[m.calcType](values);
842
- } catch (error) {
843
- _rlog["default"].warn('连线组指标计算异常', error);
844
- }
845
- }); // console.error(groupId, {config, linkChildrenData, mergeData})
846
- // 构造标注、悬浮框数据
847
-
848
- var formatter = new _attributeFormatter["default"](_this5.topo);
849
- return {
850
- type: 'edgeGroup',
851
- edgeGroupId: groupId,
852
- tags: formatter.formatAttrs(config.tags, mergeData),
853
- tips: formatter.formatAttrs(config.tips, mergeData)
854
- };
855
- }); // console.error({
856
- // noParentLinks, groupMap, edgeGroups: edgeGroupsTagsTips, ciTagsAndTips, data
857
- // })
858
-
859
- return edgeGroupsTagsTips;
860
693
  };
861
694
 
862
695
  return AttributeMetricDisplay;
@@ -48,7 +48,7 @@ var _PluginManager = _interopRequireDefault(require("./PluginManager"));
48
48
  var _topoFactory = _interopRequireDefault(require("./topoFactory"));
49
49
 
50
50
  // eslint-disable-next-line no-undef
51
- var version = typeof "2.15.38" === 'string' ? "2.15.38" : null;
51
+ var version = typeof "2.15.41" === 'string' ? "2.15.41" : null;
52
52
  console.info("\u62D3\u6251\u7248\u672C: " + version);
53
53
  /**
54
54
  * 拓扑显示和编辑
@@ -0,0 +1,220 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+
5
+ exports.__esModule = true;
6
+ exports["default"] = void 0;
7
+
8
+ var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
9
+
10
+ var _rlog = _interopRequireDefault(require("@riil-frontend/component-topology-utils/es/rlog"));
11
+
12
+ var _groupBy = _interopRequireDefault(require("lodash/groupBy"));
13
+
14
+ var _htElementUtils = require("../../../utils/htElementUtils");
15
+
16
+ var _attributeFormatter = _interopRequireDefault(require("../attributeFormatter"));
17
+
18
+ // 参与计算的链路指标
19
+ var metrics = [// 总流速
20
+ {
21
+ code: 'total_flow_rate',
22
+ calcType: 'sum'
23
+ }, // 带宽利用率
24
+ {
25
+ code: 'bandwidth_utilization',
26
+ calcType: 'avg'
27
+ }, // 发送带宽利用率
28
+ {
29
+ code: 'out_bandwidth_utilization',
30
+ calcType: 'avg',
31
+ showWhenSameSource: true
32
+ }, // 接收带宽利用率
33
+ {
34
+ code: 'in_bandwidth_utilization',
35
+ calcType: 'avg',
36
+ showWhenSameSource: true
37
+ }, {
38
+ code: 'out_rate',
39
+ calcType: 'sum',
40
+ showWhenSameSource: true
41
+ }, {
42
+ code: 'in_rate',
43
+ calcType: 'sum',
44
+ showWhenSameSource: true
45
+ }];
46
+ var connectTypePrefixMap = {
47
+ phy: 'physical_link.',
48
+ exit: 'export_link.'
49
+ };
50
+ var calcFnMap = {
51
+ sum: function sum(values) {
52
+ return values.reduce(function (total, val) {
53
+ return total + parseInt(val || 0, 10);
54
+ }, 0);
55
+ },
56
+ avg: function avg(values) {
57
+ return values.reduce(function (total, val) {
58
+ return total + parseFloat(val || 0, 10);
59
+ }, 0) / values.length;
60
+ }
61
+ };
62
+
63
+ var LinkTagsTipsBuilder = /*#__PURE__*/function () {
64
+ function LinkTagsTipsBuilder(amDisplay) {
65
+ this.amDisplay = void 0;
66
+ this.topo = void 0;
67
+ this.amDisplay = amDisplay;
68
+ this.topo = amDisplay.topo;
69
+ }
70
+ /**
71
+ * 获得未关联聚合链路的连线组标注和悬浮框数据
72
+ * @param {*} ciTagsAndTips
73
+ * @returns
74
+ */
75
+
76
+
77
+ var _proto = LinkTagsTipsBuilder.prototype;
78
+
79
+ _proto.getEdgeGroupTagsAndTips = function getEdgeGroupTagsAndTips() {
80
+ var _this = this;
81
+
82
+ var ciConfigs = this.amDisplay.getResourceTagTipConfig();
83
+ var data = this.amDisplay.getData(); // 查询没有关联链路的连线组及对应子链路列表
84
+
85
+ var _this$topo$dataModel$ = this.topo.dataModel.getData(),
86
+ links = _this$topo$dataModel$.links,
87
+ linkGroups = _this$topo$dataModel$.linkGroups;
88
+
89
+ var getLinkUId = function getLinkUId(link) {
90
+ return [link.source, link.target].sort().join('-');
91
+ };
92
+
93
+ var linkGroupUIds = linkGroups.filter(function (link) {
94
+ return link.ciType === 'network_link';
95
+ }).map(function (link) {
96
+ return getLinkUId(link);
97
+ }); // 查询没有聚合链路的物理链路/出口链路
98
+
99
+ var noParentLinks = links.filter(function (link) {
100
+ return link.ciType === 'network_link';
101
+ }).map(function (link) {
102
+ return (0, _extends2["default"])({}, link, {
103
+ linkUId: getLinkUId(link)
104
+ });
105
+ }).filter(function (link) {
106
+ return linkGroupUIds.indexOf(link.linkUId) === -1;
107
+ });
108
+ var groupMap = (0, _groupBy["default"])(noParentLinks, 'linkUId'); // 计算标注和指标
109
+
110
+ var edgeGroupsTagsTips = Object.keys(groupMap) // 过滤非连线组
111
+ .filter(function (groupId) {
112
+ var linkChildren = groupMap[groupId];
113
+ var edgeGroup = (0, _htElementUtils.getEdgeGroupByNodeTags)(_this.topo.getDataModel(), linkChildren[0].source, linkChildren[0].target);
114
+ return !!edgeGroup;
115
+ }).map(function (groupId) {
116
+ var linkChildren = groupMap[groupId];
117
+ var config = ciConfigs.find(function (item) {
118
+ return item.id === linkChildren[0].id;
119
+ });
120
+ return _this.buildEdgeGroupTagTagsAndTips({
121
+ groupId: groupId,
122
+ config: config,
123
+ linkChildren: linkChildren,
124
+ data: data
125
+ });
126
+ }); // console.error({
127
+ // noParentLinks, groupMap, edgeGroups: edgeGroupsTagsTips, ciTagsAndTips, data
128
+ // })
129
+
130
+ return edgeGroupsTagsTips;
131
+ };
132
+
133
+ _proto.buildEdgeGroupTagTagsAndTips = function buildEdgeGroupTagTagsAndTips(_ref) {
134
+ var _this2 = this;
135
+
136
+ var groupId = _ref.groupId,
137
+ config = _ref.config,
138
+ linkChildren = _ref.linkChildren,
139
+ data = _ref.data;
140
+ // 查询配置,过滤不在范围内的属性
141
+ var finalConfig = (0, _extends2["default"])({}, config, {
142
+ tags: config.tags.filter(function (item) {
143
+ return _this2.filterField(item, linkChildren);
144
+ }),
145
+ tips: config.tips.filter(function (item) {
146
+ return _this2.filterField(item, linkChildren);
147
+ })
148
+ }); // 构造数据,计算指标值
149
+
150
+ var mergeData = this.buildData(data, linkChildren); // 构造标注、悬浮框数据
151
+
152
+ var formatter = new _attributeFormatter["default"](this.topo);
153
+ return {
154
+ type: 'edgeGroup',
155
+ edgeGroupId: groupId,
156
+ tags: formatter.formatAttrs(finalConfig.tags, mergeData),
157
+ tips: formatter.formatAttrs(finalConfig.tips, mergeData)
158
+ };
159
+ } // eslint-disable-next-line class-methods-use-this
160
+ ;
161
+
162
+ _proto.filterField = function filterField(item, linkChildren) {
163
+ var fieldConfig = metrics.find(function (m) {
164
+ return item.code.endsWith("." + m.code);
165
+ });
166
+
167
+ if (item.type !== 'metric' || !fieldConfig) {
168
+ return false;
169
+ } // 如果需要校验取值接口,如果取值接口为不同设备的接口,则不显示这四个指标
170
+
171
+
172
+ if (fieldConfig.showWhenSameSource) {
173
+ var sources = [];
174
+ linkChildren.forEach(function (link) {
175
+ if (sources.indexOf(link.source) === -1) {
176
+ sources.push(link.source);
177
+ }
178
+ });
179
+
180
+ if (sources.length > 1) {
181
+ return false;
182
+ }
183
+ }
184
+
185
+ return true;
186
+ } // eslint-disable-next-line class-methods-use-this
187
+ ;
188
+
189
+ _proto.buildData = function buildData(data, linkChildren) {
190
+ var linkChildrenData = linkChildren.map(function (link) {
191
+ return data.find(function (item) {
192
+ return item.id === link.id;
193
+ });
194
+ });
195
+ var mergeData = {
196
+ ciType: 'network_link',
197
+ metricMap: {}
198
+ };
199
+ var connectType = linkChildren[0].attributes['network_link.connect_type'];
200
+ metrics.forEach(function (m) {
201
+ var metricCode = "" + connectTypePrefixMap[connectType] + m.code;
202
+
203
+ try {
204
+ var values = linkChildrenData.map(function (linkData) {
205
+ return linkData.metricMap[metricCode];
206
+ });
207
+ mergeData.metricMap[metricCode] = calcFnMap[m.calcType](values);
208
+ } catch (error) {
209
+ _rlog["default"].warn('连线组指标计算异常', error);
210
+ }
211
+ }); // console.error(groupId, {config, linkChildrenData, mergeData})
212
+
213
+ return mergeData;
214
+ };
215
+
216
+ return LinkTagsTipsBuilder;
217
+ }();
218
+
219
+ exports["default"] = LinkTagsTipsBuilder;
220
+ ;
@@ -383,7 +383,7 @@ function EditLinkInfo(props) {
383
383
  type: "primary",
384
384
  loading: loading,
385
385
  onClick: saveHandleChange
386
- }, "\u786E\u5B9A"), /*#__PURE__*/_react["default"].createElement(_button["default"], {
386
+ }, isAdd ? "确定" : "保存"), /*#__PURE__*/_react["default"].createElement(_button["default"], {
387
387
  className: _indexModule["default"].button,
388
388
  onClick: onClose
389
389
  }, "\u53D6\u6D88")));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@riil-frontend/component-topology",
3
- "version": "2.15.38",
3
+ "version": "2.15.41",
4
4
  "description": "拓扑",
5
5
  "scripts": {
6
6
  "start": "build-scripts start",
@@ -110,6 +110,6 @@
110
110
  "access": "public"
111
111
  },
112
112
  "license": "MIT",
113
- "homepage": "https://unpkg.com/@riil-frontend/component-topology@2.15.38/build/index.html",
113
+ "homepage": "https://unpkg.com/@riil-frontend/component-topology@2.15.41/build/index.html",
114
114
  "gitHead": "2da19ffccbb7ca60a8acf396e39f542c68bb33f5"
115
115
  }