@riil-frontend/component-topology 6.0.0-alpha.33 → 6.0.0-alpha.35
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 +2 -2
- package/build/2.js +1 -1
- package/build/index.css +1 -1
- package/build/index.js +19 -19
- package/es/components/collapse/Collapse.module.scss +5 -4
- package/es/core/editor/components/Sidebar/views/ImagePanel/HtCustomImagePanel.js +12 -1
- package/es/core/editor/components/Sidebar/views/ImagePanel/HtImagePalette.js +12 -2
- package/es/core/editor/components/Sidebar/views/ImagePanel/HtImagePalette.module.scss +1 -1
- package/es/core/editor/components/Toolbar/widgets/components/ButtonBox.js +1 -1
- package/es/core/editor/components/Toolbar/widgets/components/ButtonBox.module.scss +3 -0
- package/es/core/editor/components/Toolbar/widgets/components/textStyleSetting/ElementTextStyleSetting/colorUtil.js +50 -0
- package/es/core/editor/components/Toolbar/widgets/components/textStyleSetting/ElementTextStyleSetting/elements/edgeTag.js +7 -2
- package/es/core/editor/components/Toolbar/widgets/components/textStyleSetting/ElementTextStyleSetting/elements/text.js +20 -5
- package/es/core/models/TopoApp.js +1 -1
- package/es/core/viewer/components/plugins/ResourceDetail/components/ResourceOverview/components/LinkTopo/hooks/useMetricPolling.js +3 -4
- package/es/core/viewer/components/plugins/ResourceDetail/components/ResourceOverview/components/LinkTopo/services/index.js +19 -5
- package/lib/components/collapse/Collapse.module.scss +5 -4
- package/lib/core/editor/components/Sidebar/views/ImagePanel/HtCustomImagePanel.js +13 -1
- package/lib/core/editor/components/Sidebar/views/ImagePanel/HtImagePalette.js +13 -2
- package/lib/core/editor/components/Sidebar/views/ImagePanel/HtImagePalette.module.scss +1 -1
- package/lib/core/editor/components/Toolbar/widgets/components/ButtonBox.js +1 -1
- package/lib/core/editor/components/Toolbar/widgets/components/ButtonBox.module.scss +3 -0
- package/lib/core/editor/components/Toolbar/widgets/components/textStyleSetting/ElementTextStyleSetting/colorUtil.js +61 -0
- package/lib/core/editor/components/Toolbar/widgets/components/textStyleSetting/ElementTextStyleSetting/elements/edgeTag.js +7 -2
- package/lib/core/editor/components/Toolbar/widgets/components/textStyleSetting/ElementTextStyleSetting/elements/text.js +20 -5
- package/lib/core/models/TopoApp.js +1 -1
- package/lib/core/viewer/components/plugins/ResourceDetail/components/ResourceOverview/components/LinkTopo/hooks/useMetricPolling.js +3 -4
- package/lib/core/viewer/components/plugins/ResourceDetail/components/ResourceOverview/components/LinkTopo/services/index.js +19 -5
- package/package.json +3 -2
@@ -37,20 +37,21 @@
|
|
37
37
|
flex-direction: column;
|
38
38
|
|
39
39
|
:global {
|
40
|
-
.#{$css-prefix}collapse-panel-content {
|
41
|
-
flex: 1;
|
42
|
-
overflow: auto;
|
43
|
-
}
|
44
40
|
.#{$css-prefix}collapse-panel.#{$css-prefix}collapse-panel-expanded {
|
45
41
|
flex: 1;
|
46
42
|
display: flex;
|
47
43
|
flex-direction: column;
|
44
|
+
overflow: auto;
|
48
45
|
|
49
46
|
.#{$css-prefix}collapse-panel-content {
|
50
47
|
flex: 1;
|
51
48
|
overflow: auto;
|
52
49
|
}
|
53
50
|
}
|
51
|
+
.#{$css-prefix}collapse-panel-content {
|
52
|
+
flex: 1;
|
53
|
+
overflow: auto;
|
54
|
+
}
|
54
55
|
}
|
55
56
|
}
|
56
57
|
|
@@ -1,4 +1,5 @@
|
|
1
1
|
import React, { useEffect, useRef } from 'react';
|
2
|
+
import ResizeObserver from 'resize-observer-polyfill';
|
2
3
|
import rlog from '@riil-frontend/component-topology-utils/es/rlog';
|
3
4
|
import styles from "./HtImagePalette.module.scss";
|
4
5
|
/**
|
@@ -25,10 +26,20 @@ export default function HtCustomImagePanel(props) {
|
|
25
26
|
});
|
26
27
|
} catch (error) {
|
27
28
|
rlog.error('初始化资源面板失败', error);
|
28
|
-
}
|
29
|
+
}
|
29
30
|
|
31
|
+
var hanleResize = function hanleResize() {
|
32
|
+
if (viewRef.current) {
|
33
|
+
topo.getHtTopo().invalideComponents();
|
34
|
+
}
|
35
|
+
};
|
36
|
+
|
37
|
+
var resizeObserver = new ResizeObserver(hanleResize);
|
38
|
+
resizeObserver.observe(container); // 注销组件
|
30
39
|
|
31
40
|
return function () {
|
41
|
+
resizeObserver.disconnect();
|
42
|
+
|
32
43
|
if (viewRef.current) {
|
33
44
|
viewRef.current.destroy();
|
34
45
|
viewRef.current = null;
|
@@ -1,5 +1,6 @@
|
|
1
1
|
import React, { useEffect, useRef } from 'react';
|
2
2
|
import rlog from '@riil-frontend/component-topology-utils/es/rlog';
|
3
|
+
import ResizeObserver from 'resize-observer-polyfill';
|
3
4
|
import styles from "./HtImagePalette.module.scss";
|
4
5
|
/**
|
5
6
|
* 组件面板
|
@@ -23,13 +24,22 @@ export default function HtImagePalette(props) {
|
|
23
24
|
viewRef.current = htTopo.createImagePalette(container, {
|
24
25
|
icons: icons
|
25
26
|
});
|
26
|
-
console.error(viewRef.current);
|
27
27
|
} catch (error) {
|
28
28
|
rlog.error('初始化资源面板失败', error);
|
29
|
-
}
|
29
|
+
}
|
30
30
|
|
31
|
+
var hanleResize = function hanleResize() {
|
32
|
+
if (viewRef.current) {
|
33
|
+
topo.getHtTopo().invalideComponents();
|
34
|
+
}
|
35
|
+
};
|
36
|
+
|
37
|
+
var resizeObserver = new ResizeObserver(hanleResize);
|
38
|
+
resizeObserver.observe(container); // 注销组件
|
31
39
|
|
32
40
|
return function () {
|
41
|
+
resizeObserver.disconnect();
|
42
|
+
|
33
43
|
if (viewRef.current) {
|
34
44
|
viewRef.current.destroy();
|
35
45
|
viewRef.current = null;
|
@@ -23,7 +23,7 @@ function ButtonBox(props) {
|
|
23
23
|
}, otherProps), children, showArrow && /*#__PURE__*/React.createElement(React.Fragment, null, "\xA0", /*#__PURE__*/React.createElement(_Icon, {
|
24
24
|
type: "tree_fold_arrow",
|
25
25
|
size: "xxs",
|
26
|
-
className: classNames(styles.icon, (_classNames2 = {}, _classNames2[styles.active] = active, _classNames2))
|
26
|
+
className: classNames(styles.icon, (_classNames2 = {}, _classNames2[styles.active] = active, _classNames2[styles.disabled] = disabled, _classNames2))
|
27
27
|
})));
|
28
28
|
}
|
29
29
|
|
@@ -0,0 +1,50 @@
|
|
1
|
+
import Color from 'color';
|
2
|
+
/**
|
3
|
+
* 解析颜色字符串为对象
|
4
|
+
*
|
5
|
+
* @param {string} colorStr
|
6
|
+
* @returns {null|{hex, rgb:{r,g,b,a}}}
|
7
|
+
*/
|
8
|
+
|
9
|
+
export function parseColor(colorStr) {
|
10
|
+
if (!colorStr) {
|
11
|
+
return null;
|
12
|
+
}
|
13
|
+
|
14
|
+
var color = Color(colorStr);
|
15
|
+
var rgb = color.rgb();
|
16
|
+
return {
|
17
|
+
hex: color.hex(),
|
18
|
+
rgb: {
|
19
|
+
r: rgb.color[0],
|
20
|
+
g: rgb.color[1],
|
21
|
+
b: rgb.color[2],
|
22
|
+
a: rgb.valpha
|
23
|
+
}
|
24
|
+
};
|
25
|
+
}
|
26
|
+
export function formatHexColor(color) {
|
27
|
+
return color ? color.hex : null;
|
28
|
+
}
|
29
|
+
/**
|
30
|
+
* 格式化背景rgba颜色
|
31
|
+
* @param {{background, opacity}} prevColor
|
32
|
+
* @param {{background, opacity}} currentColor
|
33
|
+
*/
|
34
|
+
|
35
|
+
export function formatBackgroundRgbaColor(prevColor, currentColor) {
|
36
|
+
if (!('background' in currentColor) && !('opacity' in currentColor)) {
|
37
|
+
return null;
|
38
|
+
}
|
39
|
+
|
40
|
+
var colorObj = Object.assign(prevColor, currentColor);
|
41
|
+
var background = colorObj.background,
|
42
|
+
opacity = colorObj.opacity;
|
43
|
+
|
44
|
+
if (!background) {
|
45
|
+
return null;
|
46
|
+
}
|
47
|
+
|
48
|
+
var rgb = background.rgb;
|
49
|
+
return "rgba(" + rgb.r + ", " + rgb.g + ", " + rgb.b + ", " + opacity + ")";
|
50
|
+
}
|
@@ -1,9 +1,14 @@
|
|
1
1
|
export function getTextStyle(element) {
|
2
2
|
return {
|
3
3
|
color: null,
|
4
|
+
// 文字颜色
|
4
5
|
fontFamily: null,
|
5
|
-
fontSize: null,
|
6
|
-
|
6
|
+
fontSize: null // fontBold: false, // 文字样式加粗 @V1.2
|
7
|
+
// fontItalic: false, // 文字样式斜体 @V1.2
|
8
|
+
// fontUnderline: false, // 文字样式下划线 @V1.2
|
9
|
+
// background: {rgb: {}, hex: ''}, // 背景颜色,rgba格式。null表示无
|
10
|
+
// opacity: 1, // 背景透明度。值范围 0-1, null,null表示无
|
11
|
+
|
7
12
|
};
|
8
13
|
}
|
9
14
|
export function setTextStyle(element, style) {}
|
@@ -1,19 +1,34 @@
|
|
1
1
|
import _extends from "@babel/runtime/helpers/extends";
|
2
2
|
import fontStyleUtil from "../../../../../../settings/common/text/fontStyleUtil";
|
3
|
+
import { formatBackgroundRgbaColor, parseColor } from "../colorUtil";
|
3
4
|
export function getTextStyle(element) {
|
5
|
+
var _background$rgb;
|
6
|
+
|
4
7
|
var underline = element.s('text.decoration') === 'underline';
|
8
|
+
var background = parseColor(element.s('textBackground'));
|
5
9
|
return _extends({
|
6
|
-
color:
|
10
|
+
color: parseColor(element.s('text.color')),
|
7
11
|
underline: underline
|
8
|
-
}, fontStyleUtil.toMap(element.s('text.font'))
|
12
|
+
}, fontStyleUtil.toMap(element.s('text.font')), {
|
13
|
+
background: background,
|
14
|
+
// 背景颜色,格式: {rgba: {}, hex: ''} | null
|
15
|
+
opacity: background === null || background === void 0 ? void 0 : (_background$rgb = background.rgb) === null || _background$rgb === void 0 ? void 0 : _background$rgb.a // 背景透明度。值范围 0-1, null,null表示无
|
16
|
+
|
17
|
+
});
|
9
18
|
}
|
10
19
|
export function setTextStyle(element, style) {
|
11
|
-
var underline = style.underline;
|
12
|
-
|
13
20
|
if ('underline' in style) {
|
14
|
-
element.s('text.decoration', underline ? 'underline' : null);
|
21
|
+
element.s('text.decoration', style.underline ? 'underline' : null);
|
15
22
|
}
|
16
23
|
|
24
|
+
if ('color' in style) {
|
25
|
+
element.s('text.color', style.color.hex);
|
26
|
+
} // 背景颜色
|
27
|
+
|
28
|
+
|
29
|
+
var prevStyle = getTextStyle(element);
|
30
|
+
element.s('textBackground', formatBackgroundRgbaColor(prevStyle, style));
|
31
|
+
|
17
32
|
var fontStyle = _extends({}, getTextStyle(element), style);
|
18
33
|
|
19
34
|
var fontStr = fontStyleUtil.build(fontStyle);
|
@@ -22,7 +22,7 @@ import topoFactory from "./topoFactory";
|
|
22
22
|
import ElementTagTipConfig from "./tagstips/ElementTagTipConfig";
|
23
23
|
import SelectionManager from "./SelectionManager"; // eslint-disable-next-line no-undef
|
24
24
|
|
25
|
-
var version = typeof "6.0.0-alpha.
|
25
|
+
var version = typeof "6.0.0-alpha.35" === 'string' ? "6.0.0-alpha.35" : null;
|
26
26
|
console.info("\u62D3\u6251\u7248\u672C: " + version);
|
27
27
|
/**
|
28
28
|
* 拓扑显示和编辑
|
@@ -13,7 +13,8 @@ export default function useMetricPolling(_ref) {
|
|
13
13
|
sourceMetrics: null,
|
14
14
|
destinationMetrics: null,
|
15
15
|
// 链路指标列表
|
16
|
-
linkMetrics: []
|
16
|
+
linkMetrics: [],
|
17
|
+
linkMetricsTs: null
|
17
18
|
}),
|
18
19
|
data = _useState[0],
|
19
20
|
setData = _useState[1]; // 轮询hooks
|
@@ -25,9 +26,7 @@ export default function useMetricPolling(_ref) {
|
|
25
26
|
debounceInterval: 200,
|
26
27
|
manual: true,
|
27
28
|
onSuccess: function onSuccess(result) {
|
28
|
-
setData(_extends({}, data,
|
29
|
-
linkMetrics: result
|
30
|
-
}));
|
29
|
+
setData(_extends({}, data, result));
|
31
30
|
rlog.info('链路拓扑指标轮询', result);
|
32
31
|
}
|
33
32
|
});
|
@@ -68,6 +68,8 @@ export function queryLinkLatestMetrics(_x3, _x4) {
|
|
68
68
|
|
69
69
|
function _queryLinkLatestMetrics() {
|
70
70
|
_queryLinkLatestMetrics = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee3(linkCi, linkMetricCodes) {
|
71
|
+
var _linkMetrics$;
|
72
|
+
|
71
73
|
var linkMetrics, resultData;
|
72
74
|
return _regeneratorRuntime.wrap(function _callee3$(_context3) {
|
73
75
|
while (1) {
|
@@ -91,6 +93,10 @@ function _queryLinkLatestMetrics() {
|
|
91
93
|
|
92
94
|
case 5:
|
93
95
|
linkMetrics = _context3.sent;
|
96
|
+
_context3.next = 8;
|
97
|
+
return ciTypeCache.load([linkCi.ciType || linkCi.typeCode]);
|
98
|
+
|
99
|
+
case 8:
|
94
100
|
// format
|
95
101
|
resultData = linkMetricCodes.map(function (code) {
|
96
102
|
var _linkMetrics$find;
|
@@ -98,16 +104,19 @@ function _queryLinkLatestMetrics() {
|
|
98
104
|
var value = (_linkMetrics$find = linkMetrics.find(function (m) {
|
99
105
|
return m.metricCode === code;
|
100
106
|
})) === null || _linkMetrics$find === void 0 ? void 0 : _linkMetrics$find.metricValue;
|
101
|
-
var metricDef = ciTypeCache.getMetric(linkCi.ciType, code);
|
107
|
+
var metricDef = ciTypeCache.getMetric(linkCi.ciType || linkCi.typeCode, code);
|
102
108
|
return {
|
103
109
|
code: code,
|
104
110
|
name: metricDef.name,
|
105
111
|
value: formatMetric(value, metricDef) || ''
|
106
112
|
};
|
107
113
|
});
|
108
|
-
return _context3.abrupt("return",
|
114
|
+
return _context3.abrupt("return", {
|
115
|
+
linkMetrics: resultData,
|
116
|
+
linkMetricsTs: (_linkMetrics$ = linkMetrics[0]) === null || _linkMetrics$ === void 0 ? void 0 : _linkMetrics$.ts
|
117
|
+
});
|
109
118
|
|
110
|
-
case
|
119
|
+
case 10:
|
111
120
|
case "end":
|
112
121
|
return _context3.stop();
|
113
122
|
}
|
@@ -130,6 +139,8 @@ function _queryLinkInterfacesLatestMetrics() {
|
|
130
139
|
switch (_context4.prev = _context4.next) {
|
131
140
|
case 0:
|
132
141
|
parseInterfaceMetrics = function _parseInterfaceMetric(subCiId) {
|
142
|
+
var _metrics$;
|
143
|
+
|
133
144
|
var metrics = interfaceMetrics.filter(function (metric) {
|
134
145
|
return metric.subCiId === subCiId;
|
135
146
|
});
|
@@ -139,11 +150,14 @@ function _queryLinkInterfacesLatestMetrics() {
|
|
139
150
|
var value = (_metrics$find = metrics.find(function (m) {
|
140
151
|
return m.metricCode === code;
|
141
152
|
})) === null || _metrics$find === void 0 ? void 0 : _metrics$find.metricValue;
|
142
|
-
var metricDef = ciTypeCache.getMetric(linkCi.ciType, code);
|
153
|
+
var metricDef = ciTypeCache.getMetric(linkCi.ciType || linkCi.typeCode, code);
|
143
154
|
var formatValue = formatMetric(value, metricDef);
|
144
155
|
res[code] = formatValue === 'undefined' ? '-' : formatValue;
|
145
156
|
return res;
|
146
|
-
}, {
|
157
|
+
}, {
|
158
|
+
_ts: (_metrics$ = metrics[0]) === null || _metrics$ === void 0 ? void 0 : _metrics$.ts // 指标时间
|
159
|
+
|
160
|
+
});
|
147
161
|
};
|
148
162
|
|
149
163
|
_linkCi$attributes = linkCi.attributes, sourceType = _linkCi$attributes.source_type, sourceId = _linkCi$attributes.source_id, destinationId = _linkCi$attributes.destination_id, destinationType = _linkCi$attributes.destination_type;
|
@@ -37,20 +37,21 @@
|
|
37
37
|
flex-direction: column;
|
38
38
|
|
39
39
|
:global {
|
40
|
-
.#{$css-prefix}collapse-panel-content {
|
41
|
-
flex: 1;
|
42
|
-
overflow: auto;
|
43
|
-
}
|
44
40
|
.#{$css-prefix}collapse-panel.#{$css-prefix}collapse-panel-expanded {
|
45
41
|
flex: 1;
|
46
42
|
display: flex;
|
47
43
|
flex-direction: column;
|
44
|
+
overflow: auto;
|
48
45
|
|
49
46
|
.#{$css-prefix}collapse-panel-content {
|
50
47
|
flex: 1;
|
51
48
|
overflow: auto;
|
52
49
|
}
|
53
50
|
}
|
51
|
+
.#{$css-prefix}collapse-panel-content {
|
52
|
+
flex: 1;
|
53
|
+
overflow: auto;
|
54
|
+
}
|
54
55
|
}
|
55
56
|
}
|
56
57
|
|
@@ -7,6 +7,8 @@ exports["default"] = HtCustomImagePanel;
|
|
7
7
|
|
8
8
|
var _react = _interopRequireWildcard(require("react"));
|
9
9
|
|
10
|
+
var _resizeObserverPolyfill = _interopRequireDefault(require("resize-observer-polyfill"));
|
11
|
+
|
10
12
|
var _rlog = _interopRequireDefault(require("@riil-frontend/component-topology-utils/es/rlog"));
|
11
13
|
|
12
14
|
var _HtImagePaletteModule = _interopRequireDefault(require("./HtImagePalette.module.scss"));
|
@@ -38,10 +40,20 @@ function HtCustomImagePanel(props) {
|
|
38
40
|
});
|
39
41
|
} catch (error) {
|
40
42
|
_rlog["default"].error('初始化资源面板失败', error);
|
41
|
-
}
|
43
|
+
}
|
44
|
+
|
45
|
+
var hanleResize = function hanleResize() {
|
46
|
+
if (viewRef.current) {
|
47
|
+
topo.getHtTopo().invalideComponents();
|
48
|
+
}
|
49
|
+
};
|
42
50
|
|
51
|
+
var resizeObserver = new _resizeObserverPolyfill["default"](hanleResize);
|
52
|
+
resizeObserver.observe(container); // 注销组件
|
43
53
|
|
44
54
|
return function () {
|
55
|
+
resizeObserver.disconnect();
|
56
|
+
|
45
57
|
if (viewRef.current) {
|
46
58
|
viewRef.current.destroy();
|
47
59
|
viewRef.current = null;
|
@@ -9,6 +9,8 @@ var _react = _interopRequireWildcard(require("react"));
|
|
9
9
|
|
10
10
|
var _rlog = _interopRequireDefault(require("@riil-frontend/component-topology-utils/es/rlog"));
|
11
11
|
|
12
|
+
var _resizeObserverPolyfill = _interopRequireDefault(require("resize-observer-polyfill"));
|
13
|
+
|
12
14
|
var _HtImagePaletteModule = _interopRequireDefault(require("./HtImagePalette.module.scss"));
|
13
15
|
|
14
16
|
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
@@ -36,13 +38,22 @@ function HtImagePalette(props) {
|
|
36
38
|
viewRef.current = htTopo.createImagePalette(container, {
|
37
39
|
icons: icons
|
38
40
|
});
|
39
|
-
console.error(viewRef.current);
|
40
41
|
} catch (error) {
|
41
42
|
_rlog["default"].error('初始化资源面板失败', error);
|
42
|
-
}
|
43
|
+
}
|
44
|
+
|
45
|
+
var hanleResize = function hanleResize() {
|
46
|
+
if (viewRef.current) {
|
47
|
+
topo.getHtTopo().invalideComponents();
|
48
|
+
}
|
49
|
+
};
|
43
50
|
|
51
|
+
var resizeObserver = new _resizeObserverPolyfill["default"](hanleResize);
|
52
|
+
resizeObserver.observe(container); // 注销组件
|
44
53
|
|
45
54
|
return function () {
|
55
|
+
resizeObserver.disconnect();
|
56
|
+
|
46
57
|
if (viewRef.current) {
|
47
58
|
viewRef.current.destroy();
|
48
59
|
viewRef.current = null;
|
@@ -36,7 +36,7 @@ function ButtonBox(props) {
|
|
36
36
|
}, otherProps), children, showArrow && /*#__PURE__*/_react["default"].createElement(_react["default"].Fragment, null, "\xA0", /*#__PURE__*/_react["default"].createElement(_icon["default"], {
|
37
37
|
type: "tree_fold_arrow",
|
38
38
|
size: "xxs",
|
39
|
-
className: (0, _classnames["default"])(_ButtonBoxModule["default"].icon, (_classNames2 = {}, _classNames2[_ButtonBoxModule["default"].active] = active, _classNames2))
|
39
|
+
className: (0, _classnames["default"])(_ButtonBoxModule["default"].icon, (_classNames2 = {}, _classNames2[_ButtonBoxModule["default"].active] = active, _classNames2[_ButtonBoxModule["default"].disabled] = disabled, _classNames2))
|
40
40
|
})));
|
41
41
|
}
|
42
42
|
|
@@ -0,0 +1,61 @@
|
|
1
|
+
"use strict";
|
2
|
+
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
4
|
+
|
5
|
+
exports.__esModule = true;
|
6
|
+
exports.formatBackgroundRgbaColor = formatBackgroundRgbaColor;
|
7
|
+
exports.formatHexColor = formatHexColor;
|
8
|
+
exports.parseColor = parseColor;
|
9
|
+
|
10
|
+
var _color = _interopRequireDefault(require("color"));
|
11
|
+
|
12
|
+
/**
|
13
|
+
* 解析颜色字符串为对象
|
14
|
+
*
|
15
|
+
* @param {string} colorStr
|
16
|
+
* @returns {null|{hex, rgb:{r,g,b,a}}}
|
17
|
+
*/
|
18
|
+
function parseColor(colorStr) {
|
19
|
+
if (!colorStr) {
|
20
|
+
return null;
|
21
|
+
}
|
22
|
+
|
23
|
+
var color = (0, _color["default"])(colorStr);
|
24
|
+
var rgb = color.rgb();
|
25
|
+
return {
|
26
|
+
hex: color.hex(),
|
27
|
+
rgb: {
|
28
|
+
r: rgb.color[0],
|
29
|
+
g: rgb.color[1],
|
30
|
+
b: rgb.color[2],
|
31
|
+
a: rgb.valpha
|
32
|
+
}
|
33
|
+
};
|
34
|
+
}
|
35
|
+
|
36
|
+
function formatHexColor(color) {
|
37
|
+
return color ? color.hex : null;
|
38
|
+
}
|
39
|
+
/**
|
40
|
+
* 格式化背景rgba颜色
|
41
|
+
* @param {{background, opacity}} prevColor
|
42
|
+
* @param {{background, opacity}} currentColor
|
43
|
+
*/
|
44
|
+
|
45
|
+
|
46
|
+
function formatBackgroundRgbaColor(prevColor, currentColor) {
|
47
|
+
if (!('background' in currentColor) && !('opacity' in currentColor)) {
|
48
|
+
return null;
|
49
|
+
}
|
50
|
+
|
51
|
+
var colorObj = Object.assign(prevColor, currentColor);
|
52
|
+
var background = colorObj.background,
|
53
|
+
opacity = colorObj.opacity;
|
54
|
+
|
55
|
+
if (!background) {
|
56
|
+
return null;
|
57
|
+
}
|
58
|
+
|
59
|
+
var rgb = background.rgb;
|
60
|
+
return "rgba(" + rgb.r + ", " + rgb.g + ", " + rgb.b + ", " + opacity + ")";
|
61
|
+
}
|
@@ -8,9 +8,14 @@ exports.setTextStyle = setTextStyle;
|
|
8
8
|
function getTextStyle(element) {
|
9
9
|
return {
|
10
10
|
color: null,
|
11
|
+
// 文字颜色
|
11
12
|
fontFamily: null,
|
12
|
-
fontSize: null,
|
13
|
-
|
13
|
+
fontSize: null // fontBold: false, // 文字样式加粗 @V1.2
|
14
|
+
// fontItalic: false, // 文字样式斜体 @V1.2
|
15
|
+
// fontUnderline: false, // 文字样式下划线 @V1.2
|
16
|
+
// background: {rgb: {}, hex: ''}, // 背景颜色,rgba格式。null表示无
|
17
|
+
// opacity: 1, // 背景透明度。值范围 0-1, null,null表示无
|
18
|
+
|
14
19
|
};
|
15
20
|
}
|
16
21
|
|
@@ -11,21 +11,36 @@ var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends")
|
|
11
11
|
|
12
12
|
var _fontStyleUtil = _interopRequireDefault(require("../../../../../../settings/common/text/fontStyleUtil"));
|
13
13
|
|
14
|
+
var _colorUtil = require("../colorUtil");
|
15
|
+
|
14
16
|
function getTextStyle(element) {
|
17
|
+
var _background$rgb;
|
18
|
+
|
15
19
|
var underline = element.s('text.decoration') === 'underline';
|
20
|
+
var background = (0, _colorUtil.parseColor)(element.s('textBackground'));
|
16
21
|
return (0, _extends2["default"])({
|
17
|
-
color:
|
22
|
+
color: (0, _colorUtil.parseColor)(element.s('text.color')),
|
18
23
|
underline: underline
|
19
|
-
}, _fontStyleUtil["default"].toMap(element.s('text.font'))
|
24
|
+
}, _fontStyleUtil["default"].toMap(element.s('text.font')), {
|
25
|
+
background: background,
|
26
|
+
// 背景颜色,格式: {rgba: {}, hex: ''} | null
|
27
|
+
opacity: background === null || background === void 0 ? void 0 : (_background$rgb = background.rgb) === null || _background$rgb === void 0 ? void 0 : _background$rgb.a // 背景透明度。值范围 0-1, null,null表示无
|
28
|
+
|
29
|
+
});
|
20
30
|
}
|
21
31
|
|
22
32
|
function setTextStyle(element, style) {
|
23
|
-
var underline = style.underline;
|
24
|
-
|
25
33
|
if ('underline' in style) {
|
26
|
-
element.s('text.decoration', underline ? 'underline' : null);
|
34
|
+
element.s('text.decoration', style.underline ? 'underline' : null);
|
27
35
|
}
|
28
36
|
|
37
|
+
if ('color' in style) {
|
38
|
+
element.s('text.color', style.color.hex);
|
39
|
+
} // 背景颜色
|
40
|
+
|
41
|
+
|
42
|
+
var prevStyle = getTextStyle(element);
|
43
|
+
element.s('textBackground', (0, _colorUtil.formatBackgroundRgbaColor)(prevStyle, style));
|
29
44
|
var fontStyle = (0, _extends2["default"])({}, getTextStyle(element), style);
|
30
45
|
|
31
46
|
var fontStr = _fontStyleUtil["default"].build(fontStyle);
|
@@ -52,7 +52,7 @@ var _ElementTagTipConfig = _interopRequireDefault(require("./tagstips/ElementTag
|
|
52
52
|
var _SelectionManager = _interopRequireDefault(require("./SelectionManager"));
|
53
53
|
|
54
54
|
// eslint-disable-next-line no-undef
|
55
|
-
var version = typeof "6.0.0-alpha.
|
55
|
+
var version = typeof "6.0.0-alpha.35" === 'string' ? "6.0.0-alpha.35" : null;
|
56
56
|
console.info("\u62D3\u6251\u7248\u672C: " + version);
|
57
57
|
/**
|
58
58
|
* 拓扑显示和编辑
|
@@ -29,7 +29,8 @@ function useMetricPolling(_ref) {
|
|
29
29
|
sourceMetrics: null,
|
30
30
|
destinationMetrics: null,
|
31
31
|
// 链路指标列表
|
32
|
-
linkMetrics: []
|
32
|
+
linkMetrics: [],
|
33
|
+
linkMetricsTs: null
|
33
34
|
}),
|
34
35
|
data = _useState[0],
|
35
36
|
setData = _useState[1]; // 轮询hooks
|
@@ -41,9 +42,7 @@ function useMetricPolling(_ref) {
|
|
41
42
|
debounceInterval: 200,
|
42
43
|
manual: true,
|
43
44
|
onSuccess: function onSuccess(result) {
|
44
|
-
setData((0, _extends2["default"])({}, data,
|
45
|
-
linkMetrics: result
|
46
|
-
}));
|
45
|
+
setData((0, _extends2["default"])({}, data, result));
|
47
46
|
|
48
47
|
_rlog["default"].info('链路拓扑指标轮询', result);
|
49
48
|
}
|
@@ -86,6 +86,8 @@ function queryLinkLatestMetrics(_x3, _x4) {
|
|
86
86
|
|
87
87
|
function _queryLinkLatestMetrics() {
|
88
88
|
_queryLinkLatestMetrics = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee3(linkCi, linkMetricCodes) {
|
89
|
+
var _linkMetrics$;
|
90
|
+
|
89
91
|
var linkMetrics, resultData;
|
90
92
|
return _regenerator["default"].wrap(function _callee3$(_context3) {
|
91
93
|
while (1) {
|
@@ -109,6 +111,10 @@ function _queryLinkLatestMetrics() {
|
|
109
111
|
|
110
112
|
case 5:
|
111
113
|
linkMetrics = _context3.sent;
|
114
|
+
_context3.next = 8;
|
115
|
+
return _CiTypeCache["default"].load([linkCi.ciType || linkCi.typeCode]);
|
116
|
+
|
117
|
+
case 8:
|
112
118
|
// format
|
113
119
|
resultData = linkMetricCodes.map(function (code) {
|
114
120
|
var _linkMetrics$find;
|
@@ -117,7 +123,7 @@ function _queryLinkLatestMetrics() {
|
|
117
123
|
return m.metricCode === code;
|
118
124
|
})) === null || _linkMetrics$find === void 0 ? void 0 : _linkMetrics$find.metricValue;
|
119
125
|
|
120
|
-
var metricDef = _CiTypeCache["default"].getMetric(linkCi.ciType, code);
|
126
|
+
var metricDef = _CiTypeCache["default"].getMetric(linkCi.ciType || linkCi.typeCode, code);
|
121
127
|
|
122
128
|
return {
|
123
129
|
code: code,
|
@@ -125,9 +131,12 @@ function _queryLinkLatestMetrics() {
|
|
125
131
|
value: (0, _attributeFormatter.formatMetric)(value, metricDef) || ''
|
126
132
|
};
|
127
133
|
});
|
128
|
-
return _context3.abrupt("return",
|
134
|
+
return _context3.abrupt("return", {
|
135
|
+
linkMetrics: resultData,
|
136
|
+
linkMetricsTs: (_linkMetrics$ = linkMetrics[0]) === null || _linkMetrics$ === void 0 ? void 0 : _linkMetrics$.ts
|
137
|
+
});
|
129
138
|
|
130
|
-
case
|
139
|
+
case 10:
|
131
140
|
case "end":
|
132
141
|
return _context3.stop();
|
133
142
|
}
|
@@ -150,6 +159,8 @@ function _queryLinkInterfacesLatestMetrics() {
|
|
150
159
|
switch (_context4.prev = _context4.next) {
|
151
160
|
case 0:
|
152
161
|
parseInterfaceMetrics = function _parseInterfaceMetric(subCiId) {
|
162
|
+
var _metrics$;
|
163
|
+
|
153
164
|
var metrics = interfaceMetrics.filter(function (metric) {
|
154
165
|
return metric.subCiId === subCiId;
|
155
166
|
});
|
@@ -160,12 +171,15 @@ function _queryLinkInterfacesLatestMetrics() {
|
|
160
171
|
return m.metricCode === code;
|
161
172
|
})) === null || _metrics$find === void 0 ? void 0 : _metrics$find.metricValue;
|
162
173
|
|
163
|
-
var metricDef = _CiTypeCache["default"].getMetric(linkCi.ciType, code);
|
174
|
+
var metricDef = _CiTypeCache["default"].getMetric(linkCi.ciType || linkCi.typeCode, code);
|
164
175
|
|
165
176
|
var formatValue = (0, _attributeFormatter.formatMetric)(value, metricDef);
|
166
177
|
res[code] = formatValue === 'undefined' ? '-' : formatValue;
|
167
178
|
return res;
|
168
|
-
}, {
|
179
|
+
}, {
|
180
|
+
_ts: (_metrics$ = metrics[0]) === null || _metrics$ === void 0 ? void 0 : _metrics$.ts // 指标时间
|
181
|
+
|
182
|
+
});
|
169
183
|
};
|
170
184
|
|
171
185
|
_linkCi$attributes = linkCi.attributes, sourceType = _linkCi$attributes.source_type, sourceId = _linkCi$attributes.source_id, destinationId = _linkCi$attributes.destination_id, destinationType = _linkCi$attributes.destination_type;
|