@centreon/ui 23.10.1-MON-20802-fe-implement-new-visualization.4 → 23.10.1-MON-20803-RS-add-basic-filter.1
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/package.json +1 -1
- package/src/Dashboard/Dashboard.styles.ts +1 -6
- package/src/Dashboard/Item.tsx +1 -4
- package/src/Dashboard/Layout.tsx +1 -1
- package/src/Graph/Gauge/Gauge.stories.tsx +0 -10
- package/src/Graph/Gauge/Gauge.tsx +1 -10
- package/src/Graph/Gauge/PieData.tsx +8 -8
- package/src/Graph/Gauge/ResponsiveGauge.tsx +23 -32
- package/src/Graph/Gauge/Thresholds.tsx +25 -2
- package/src/Graph/Gauge/models.ts +0 -1
- package/src/Graph/SingleBar/ResponsiveSingleBar.tsx +23 -41
- package/src/Graph/SingleBar/SingleBar.stories.tsx +0 -46
- package/src/Graph/SingleBar/ThresholdLine.tsx +12 -41
- package/src/Graph/SingleBar/Thresholds.tsx +1 -5
- package/src/Graph/SingleBar/models.ts +0 -4
- package/src/Graph/Text/Text.stories.tsx +0 -13
- package/src/Graph/Text/Text.tsx +12 -19
- package/src/Graph/common/timeSeries/index.test.ts +3 -106
- package/src/Graph/common/timeSeries/index.ts +4 -67
- package/src/Graph/common/timeSeries/models.ts +3 -6
- package/src/Graph/common/utils.ts +2 -4
- package/src/InputField/Select/Autocomplete/Multi/index.tsx +2 -4
- package/src/InputField/Select/Autocomplete/index.tsx +1 -4
- package/src/InputField/Text/index.tsx +7 -10
- package/src/Listing/Cell/index.tsx +2 -2
- package/src/RichTextEditor/ContentEditable.tsx +1 -0
- package/src/RichTextEditor/RichTextEditor.cypress.spec.tsx +13 -5
- package/src/RichTextEditor/RichTextEditor.tsx +2 -5
- package/src/RichTextEditor/plugins/AutoLinkPlugin/index.tsx +1 -40
- package/src/RichTextEditor/plugins/FloatingLinkEditorPlugin.tsx +8 -33
- package/src/RichTextEditor/plugins/ToolbarPlugin/index.tsx +4 -10
- package/src/ThemeProvider/index.tsx +4 -6
- package/src/api/buildListingEndpoint/getSearchQueryParameterValue.ts +2 -4
- package/src/api/buildListingEndpoint/index.ts +1 -1
- package/src/api/useFetchQuery/index.ts +8 -10
- package/src/components/Modal/Modal.styles.ts +1 -3
- package/src/components/index.ts +0 -1
- package/src/index.ts +4 -1
- package/src/utils/index.ts +0 -1
- package/src/utils/useDebounce.ts +7 -2
- package/src/components/Inputs/Switch/Switch.stories.tsx +0 -22
- package/src/components/Inputs/Switch/Switch.styles.ts +0 -13
- package/src/components/Inputs/Switch/Switch.tsx +0 -18
- package/src/components/Inputs/index.ts +0 -1
- package/src/utils/centreonBaseURL.ts +0 -4
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@centreon/ui",
|
|
3
|
-
"version": "23.10.1-MON-
|
|
3
|
+
"version": "23.10.1-MON-20803-RS-add-basic-filter.1",
|
|
4
4
|
"description": "Centreon UI Components",
|
|
5
5
|
"scripts": {
|
|
6
6
|
"eslint": "eslint ./src --ext .js,.jsx,.ts,.tsx --max-warnings 0",
|
|
@@ -79,12 +79,7 @@ export const useDashboardItemStyles = makeStyles<{ hasHeader: boolean }>()(
|
|
|
79
79
|
'&:hover': {
|
|
80
80
|
backgroundColor: theme.palette.action.hover
|
|
81
81
|
},
|
|
82
|
-
'
|
|
83
|
-
cursor: 'default'
|
|
84
|
-
},
|
|
85
|
-
'&[data-canMove="true"]': {
|
|
86
|
-
cursor: 'move'
|
|
87
|
-
},
|
|
82
|
+
cursor: 'move',
|
|
88
83
|
padding: theme.spacing(0.5, 2)
|
|
89
84
|
},
|
|
90
85
|
widgetPadding: {
|
package/src/Dashboard/Item.tsx
CHANGED
|
@@ -15,7 +15,6 @@ import { useMemoComponent } from '../utils';
|
|
|
15
15
|
import { useDashboardItemStyles } from './Dashboard.styles';
|
|
16
16
|
|
|
17
17
|
interface DashboardItemProps {
|
|
18
|
-
canMove?: boolean;
|
|
19
18
|
children: ReactElement;
|
|
20
19
|
className?: string;
|
|
21
20
|
disablePadding?: boolean;
|
|
@@ -38,8 +37,7 @@ const Item = forwardRef(
|
|
|
38
37
|
onMouseUp,
|
|
39
38
|
onTouchEnd,
|
|
40
39
|
id,
|
|
41
|
-
disablePadding = false
|
|
42
|
-
canMove = false
|
|
40
|
+
disablePadding = false
|
|
43
41
|
}: DashboardItemProps,
|
|
44
42
|
ref: ForwardedRef<HTMLDivElement>
|
|
45
43
|
): ReactElement => {
|
|
@@ -68,7 +66,6 @@ const Item = forwardRef(
|
|
|
68
66
|
<div
|
|
69
67
|
{...listeners}
|
|
70
68
|
className={classes.widgetHeader}
|
|
71
|
-
data-canMove={canMove}
|
|
72
69
|
data-testid={`${id}_move_panel`}
|
|
73
70
|
>
|
|
74
71
|
{header}
|
package/src/Dashboard/Layout.tsx
CHANGED
|
@@ -134,13 +134,3 @@ export const withRangeThresholds: Story = {
|
|
|
134
134
|
},
|
|
135
135
|
render: Template
|
|
136
136
|
};
|
|
137
|
-
|
|
138
|
-
export const RawValue: Story = {
|
|
139
|
-
args: {
|
|
140
|
-
data: dataLastWeek,
|
|
141
|
-
displayAsRaw: true,
|
|
142
|
-
thresholdTooltipLabels: ['Warning', 'Critical'],
|
|
143
|
-
thresholds: [0.5, 0.6]
|
|
144
|
-
},
|
|
145
|
-
render: Template
|
|
146
|
-
};
|
|
@@ -7,18 +7,11 @@ import { Metric } from '../common/timeSeries/models';
|
|
|
7
7
|
import ResponsiveGauge from './ResponsiveGauge';
|
|
8
8
|
|
|
9
9
|
interface Props {
|
|
10
|
-
baseColor?: string;
|
|
11
10
|
data?: LineChartData;
|
|
12
|
-
displayAsRaw?: boolean;
|
|
13
11
|
thresholds: Thresholds;
|
|
14
12
|
}
|
|
15
13
|
|
|
16
|
-
export const Gauge = ({
|
|
17
|
-
thresholds,
|
|
18
|
-
data,
|
|
19
|
-
displayAsRaw,
|
|
20
|
-
baseColor
|
|
21
|
-
}: Props): JSX.Element | null => {
|
|
14
|
+
export const Gauge = ({ thresholds, data }: Props): JSX.Element | null => {
|
|
22
15
|
if (!data) {
|
|
23
16
|
return null;
|
|
24
17
|
}
|
|
@@ -29,8 +22,6 @@ export const Gauge = ({
|
|
|
29
22
|
<Responsive.ParentSize>
|
|
30
23
|
{({ width, height }) => (
|
|
31
24
|
<ResponsiveGauge
|
|
32
|
-
baseColor={baseColor}
|
|
33
|
-
displayAsRaw={displayAsRaw}
|
|
34
25
|
height={height}
|
|
35
26
|
metric={metric}
|
|
36
27
|
thresholds={thresholds}
|
|
@@ -16,8 +16,7 @@ const PieData = ({
|
|
|
16
16
|
metric,
|
|
17
17
|
adaptedMaxValue,
|
|
18
18
|
thresholds,
|
|
19
|
-
radius
|
|
20
|
-
baseColor
|
|
19
|
+
radius
|
|
21
20
|
}: Omit<
|
|
22
21
|
GaugeProps,
|
|
23
22
|
'width' | 'height' | 'showTooltip' | 'hideTooltip' | 'thresholdTooltipLabels'
|
|
@@ -25,12 +24,13 @@ const PieData = ({
|
|
|
25
24
|
const theme = useTheme();
|
|
26
25
|
|
|
27
26
|
const pieData = [metric.data[0], adaptedMaxValue - metric.data[0]];
|
|
28
|
-
const pieColor =
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
27
|
+
const pieColor = !thresholds.enabled
|
|
28
|
+
? theme.palette.success.main
|
|
29
|
+
: getColorFromDataAndTresholds({
|
|
30
|
+
data: metric.data[0],
|
|
31
|
+
theme,
|
|
32
|
+
thresholds
|
|
33
|
+
});
|
|
34
34
|
|
|
35
35
|
const getDataColor = scaleOrdinal({
|
|
36
36
|
domain: pieData,
|
|
@@ -7,7 +7,7 @@ import { Tooltip } from '@visx/visx';
|
|
|
7
7
|
import { Box, Fade, useTheme } from '@mui/material';
|
|
8
8
|
|
|
9
9
|
import { Metric } from '../common/timeSeries/models';
|
|
10
|
-
import {
|
|
10
|
+
import { formatMetricValue } from '../common/timeSeries';
|
|
11
11
|
import { getColorFromDataAndTresholds } from '../common/utils';
|
|
12
12
|
import { margins } from '../common/margins';
|
|
13
13
|
|
|
@@ -15,8 +15,7 @@ import Thresholds from './Thresholds';
|
|
|
15
15
|
import PieData from './PieData';
|
|
16
16
|
import { GaugeProps } from './models';
|
|
17
17
|
|
|
18
|
-
interface Props extends Pick<GaugeProps, 'thresholds'
|
|
19
|
-
displayAsRaw?: boolean;
|
|
18
|
+
interface Props extends Pick<GaugeProps, 'thresholds'> {
|
|
20
19
|
height: number;
|
|
21
20
|
metric: Metric;
|
|
22
21
|
width: number;
|
|
@@ -31,9 +30,7 @@ const ResponsiveGauge = ({
|
|
|
31
30
|
width,
|
|
32
31
|
height,
|
|
33
32
|
thresholds,
|
|
34
|
-
metric
|
|
35
|
-
displayAsRaw,
|
|
36
|
-
baseColor
|
|
33
|
+
metric
|
|
37
34
|
}: Props): JSX.Element => {
|
|
38
35
|
const svgRef = useRef<SVGSVGElement>(null);
|
|
39
36
|
|
|
@@ -53,36 +50,28 @@ const ResponsiveGauge = ({
|
|
|
53
50
|
const centerY = innerHeight / 2;
|
|
54
51
|
const centerX = innerWidth / 2;
|
|
55
52
|
const radius = Math.min(innerWidth, innerHeight) / 2;
|
|
56
|
-
const thresholdValues =
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
])
|
|
61
|
-
: [0];
|
|
53
|
+
const thresholdValues = flatten([
|
|
54
|
+
pluck('value', thresholds.warning),
|
|
55
|
+
pluck('value', thresholds.critical)
|
|
56
|
+
]);
|
|
62
57
|
const adaptedMaxValue = Math.max(
|
|
63
58
|
metric.maximum_value || 0,
|
|
64
59
|
Math.max(...thresholdValues) * 1.1,
|
|
65
60
|
head(metric.data) as number
|
|
66
61
|
);
|
|
67
62
|
|
|
68
|
-
const pieColor =
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
63
|
+
const pieColor = !thresholds.enabled
|
|
64
|
+
? theme.palette.success.main
|
|
65
|
+
: getColorFromDataAndTresholds({
|
|
66
|
+
data: metric.data[0],
|
|
67
|
+
theme,
|
|
68
|
+
thresholds
|
|
69
|
+
});
|
|
74
70
|
|
|
75
71
|
const svgTop = svgRef.current?.getBoundingClientRect().top || 0;
|
|
76
72
|
const svgLeft = svgRef.current?.getBoundingClientRect().left || 0;
|
|
77
73
|
|
|
78
|
-
const
|
|
79
|
-
|
|
80
|
-
const gaugeValue = formatMetricValueWithUnit({
|
|
81
|
-
base: 1000,
|
|
82
|
-
isRaw: displayAsRaw,
|
|
83
|
-
unit: metric.unit,
|
|
84
|
-
value: metric.data[0]
|
|
85
|
-
});
|
|
74
|
+
const isSmallHeight = height < 250;
|
|
86
75
|
|
|
87
76
|
return (
|
|
88
77
|
<Box sx={{ position: 'relative' }}>
|
|
@@ -98,7 +87,6 @@ const ResponsiveGauge = ({
|
|
|
98
87
|
/>
|
|
99
88
|
<PieData
|
|
100
89
|
adaptedMaxValue={adaptedMaxValue}
|
|
101
|
-
baseColor={baseColor}
|
|
102
90
|
metric={metric}
|
|
103
91
|
radius={radius}
|
|
104
92
|
thresholds={thresholds}
|
|
@@ -109,15 +97,18 @@ const ResponsiveGauge = ({
|
|
|
109
97
|
style={{
|
|
110
98
|
fill: pieColor,
|
|
111
99
|
...theme.typography.h3,
|
|
112
|
-
fontSize:
|
|
113
|
-
Math.min(width, height) / 7 -
|
|
114
|
-
(isSmallWidget ? 0 : (gaugeValue?.length || 0) * 2)
|
|
100
|
+
fontSize: Math.min(width, height) / 7
|
|
115
101
|
}}
|
|
116
102
|
textAnchor="middle"
|
|
117
103
|
x="50%"
|
|
118
|
-
y={
|
|
104
|
+
y={isSmallHeight ? 140 : 100 + Math.min(width, height) / 3}
|
|
119
105
|
>
|
|
120
|
-
{
|
|
106
|
+
{formatMetricValue({
|
|
107
|
+
base: 1000,
|
|
108
|
+
unit: metric.unit,
|
|
109
|
+
value: metric.data[0]
|
|
110
|
+
})}{' '}
|
|
111
|
+
{metric.unit}
|
|
121
112
|
</text>
|
|
122
113
|
</svg>
|
|
123
114
|
<Fade in={tooltipOpen && thresholds.enabled}>
|
|
@@ -16,7 +16,7 @@ const Thresholds = ({
|
|
|
16
16
|
showTooltip,
|
|
17
17
|
hideTooltip,
|
|
18
18
|
metric
|
|
19
|
-
}: Omit<GaugeProps, 'width' | 'height'>): JSX.Element
|
|
19
|
+
}: Omit<GaugeProps, 'width' | 'height'>): JSX.Element => {
|
|
20
20
|
const theme = useTheme();
|
|
21
21
|
|
|
22
22
|
const criticalThresholdValues = pluck('value', thresholds.critical);
|
|
@@ -65,7 +65,30 @@ const Thresholds = ({
|
|
|
65
65
|
});
|
|
66
66
|
|
|
67
67
|
if (!thresholds.enabled) {
|
|
68
|
-
return
|
|
68
|
+
return (
|
|
69
|
+
<Pie
|
|
70
|
+
data={successThresholdArc}
|
|
71
|
+
endAngle={-Math.PI / 2}
|
|
72
|
+
innerRadius={radius - thresholdThickness}
|
|
73
|
+
outerRadius={radius}
|
|
74
|
+
pieSortValues={() => -1}
|
|
75
|
+
pieValue={(d) => d.value}
|
|
76
|
+
startAngle={Math.PI / 2}
|
|
77
|
+
>
|
|
78
|
+
{(pie) => (
|
|
79
|
+
<AnimatedPie<{ name: string; value: number }>
|
|
80
|
+
{...pie}
|
|
81
|
+
animate
|
|
82
|
+
getColor={(arc) => successThresholdScaleOrdinal(arc.data.name)}
|
|
83
|
+
getKey={(arc) => `${arc.data.name}_${arc.data.value}`}
|
|
84
|
+
hideTooltip={hideTooltip}
|
|
85
|
+
metric={metric}
|
|
86
|
+
showTooltip={showTooltip}
|
|
87
|
+
thresholds={thresholds}
|
|
88
|
+
/>
|
|
89
|
+
)}
|
|
90
|
+
</Pie>
|
|
91
|
+
);
|
|
69
92
|
}
|
|
70
93
|
|
|
71
94
|
const arcs = [
|
|
@@ -2,14 +2,14 @@ import { useMemo, useRef } from 'react';
|
|
|
2
2
|
|
|
3
3
|
import { Group, Tooltip } from '@visx/visx';
|
|
4
4
|
import { scaleLinear } from '@visx/scale';
|
|
5
|
-
import {
|
|
5
|
+
import { flatten, head, pluck } from 'ramda';
|
|
6
6
|
import { Bar } from '@visx/shape';
|
|
7
7
|
import { useSpring, animated } from '@react-spring/web';
|
|
8
8
|
|
|
9
9
|
import { alpha, Box, Fade, useTheme } from '@mui/material';
|
|
10
10
|
|
|
11
11
|
import {
|
|
12
|
-
|
|
12
|
+
formatMetricValue,
|
|
13
13
|
getMetricWithLatestData
|
|
14
14
|
} from '../common/timeSeries';
|
|
15
15
|
import { Metric } from '../common/timeSeries/models';
|
|
@@ -18,7 +18,7 @@ import { margins } from '../common/margins';
|
|
|
18
18
|
|
|
19
19
|
import { SingleBarProps } from './models';
|
|
20
20
|
import Thresholds, { groupMargin } from './Thresholds';
|
|
21
|
-
import {
|
|
21
|
+
import { barHeight, margin } from './ThresholdLine';
|
|
22
22
|
|
|
23
23
|
interface Props extends SingleBarProps {
|
|
24
24
|
height: number;
|
|
@@ -34,29 +34,25 @@ const ResponsiveSingleBar = ({
|
|
|
34
34
|
data,
|
|
35
35
|
thresholds,
|
|
36
36
|
width,
|
|
37
|
-
height
|
|
38
|
-
displayAsRaw,
|
|
39
|
-
baseColor,
|
|
40
|
-
size = 'medium',
|
|
41
|
-
showLabels = true
|
|
37
|
+
height
|
|
42
38
|
}: Props): JSX.Element => {
|
|
43
39
|
const theme = useTheme();
|
|
44
40
|
|
|
45
41
|
const metric = getMetricWithLatestData(data) as Metric;
|
|
46
42
|
const latestMetricData = head(metric.data) as number;
|
|
47
|
-
const thresholdValues =
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
])
|
|
52
|
-
: [0];
|
|
53
|
-
|
|
43
|
+
const thresholdValues = flatten([
|
|
44
|
+
pluck('value', thresholds.warning),
|
|
45
|
+
pluck('value', thresholds.critical)
|
|
46
|
+
]);
|
|
54
47
|
const adaptedMaxValue = Math.max(
|
|
55
48
|
metric.maximum_value || 0,
|
|
56
49
|
Math.max(...thresholdValues) * 1.1,
|
|
57
50
|
head(metric.data) as number
|
|
58
51
|
);
|
|
59
52
|
|
|
53
|
+
const innerHeight = height;
|
|
54
|
+
const centerY = innerHeight / 4;
|
|
55
|
+
|
|
60
56
|
const {
|
|
61
57
|
showTooltip,
|
|
62
58
|
hideTooltip,
|
|
@@ -70,7 +66,6 @@ const ResponsiveSingleBar = ({
|
|
|
70
66
|
const barColor = useMemo(
|
|
71
67
|
() =>
|
|
72
68
|
getColorFromDataAndTresholds({
|
|
73
|
-
baseColor,
|
|
74
69
|
data: latestMetricData,
|
|
75
70
|
theme,
|
|
76
71
|
thresholds
|
|
@@ -78,31 +73,20 @@ const ResponsiveSingleBar = ({
|
|
|
78
73
|
[latestMetricData, thresholds, theme]
|
|
79
74
|
);
|
|
80
75
|
|
|
81
|
-
const
|
|
82
|
-
|
|
83
|
-
const textStyle = isSmall
|
|
84
|
-
? {
|
|
85
|
-
...theme.typography.h6
|
|
86
|
-
}
|
|
87
|
-
: theme.typography.h3;
|
|
88
|
-
|
|
89
|
-
const text = showLabels && (
|
|
76
|
+
const text = (
|
|
90
77
|
<text
|
|
91
78
|
dominantBaseline="middle"
|
|
92
|
-
style={{
|
|
93
|
-
fill: barColor,
|
|
94
|
-
...textStyle
|
|
95
|
-
}}
|
|
79
|
+
style={{ fill: barColor, ...theme.typography.h3 }}
|
|
96
80
|
textAnchor="middle"
|
|
97
81
|
x="50%"
|
|
98
|
-
y={
|
|
82
|
+
y={25}
|
|
99
83
|
>
|
|
100
|
-
{
|
|
84
|
+
{formatMetricValue({
|
|
101
85
|
base: 1000,
|
|
102
|
-
isRaw: displayAsRaw,
|
|
103
86
|
unit: metric.unit,
|
|
104
87
|
value: metric.data[0]
|
|
105
|
-
})}
|
|
88
|
+
})}{' '}
|
|
89
|
+
{metric.unit}
|
|
106
90
|
</text>
|
|
107
91
|
);
|
|
108
92
|
|
|
@@ -129,32 +113,31 @@ const ResponsiveSingleBar = ({
|
|
|
129
113
|
return (
|
|
130
114
|
<Box sx={{ position: 'relative' }}>
|
|
131
115
|
<svg height={height} ref={svgRef} width={width}>
|
|
132
|
-
<Group.Group>
|
|
116
|
+
<Group.Group top={centerY - margins.bottom}>
|
|
133
117
|
{text}
|
|
134
118
|
<animated.rect
|
|
135
119
|
data-testid={`${latestMetricData}-bar-${barColor}`}
|
|
136
120
|
fill={barColor}
|
|
137
|
-
height={
|
|
121
|
+
height={barHeight}
|
|
138
122
|
rx={4}
|
|
139
123
|
style={springStyle}
|
|
140
124
|
x={0}
|
|
141
|
-
y={groupMargin +
|
|
125
|
+
y={groupMargin + margin}
|
|
142
126
|
/>
|
|
143
127
|
<Bar
|
|
144
128
|
fill="transparent"
|
|
145
|
-
height={
|
|
129
|
+
height={barHeight}
|
|
146
130
|
rx={4}
|
|
147
131
|
ry={4}
|
|
148
132
|
stroke={alpha(theme.palette.text.primary, 0.3)}
|
|
149
133
|
width={maxBarWidth}
|
|
150
134
|
x={0}
|
|
151
|
-
y={groupMargin +
|
|
135
|
+
y={groupMargin + margin}
|
|
152
136
|
/>
|
|
153
137
|
{thresholds.enabled && (
|
|
154
138
|
<Thresholds
|
|
155
139
|
hideTooltip={hideTooltip}
|
|
156
140
|
showTooltip={showTooltip}
|
|
157
|
-
size={size}
|
|
158
141
|
thresholds={thresholds}
|
|
159
142
|
xScale={xScale}
|
|
160
143
|
/>
|
|
@@ -168,8 +151,7 @@ const ResponsiveSingleBar = ({
|
|
|
168
151
|
...baseStyles,
|
|
169
152
|
backgroundColor: theme.palette.background.paper,
|
|
170
153
|
color: theme.palette.text.primary,
|
|
171
|
-
transform:
|
|
172
|
-
zIndex: theme.zIndex.tooltip
|
|
154
|
+
transform: 'translate(-50%, -20px)'
|
|
173
155
|
}}
|
|
174
156
|
top={tooltipTop}
|
|
175
157
|
>
|
|
@@ -156,49 +156,3 @@ export const rangeThresholds: Story = {
|
|
|
156
156
|
},
|
|
157
157
|
render: Template
|
|
158
158
|
};
|
|
159
|
-
|
|
160
|
-
export const RawValue: Story = {
|
|
161
|
-
args: {
|
|
162
|
-
data: dataLastWeek,
|
|
163
|
-
displayAsRaw: true,
|
|
164
|
-
thresholds: {
|
|
165
|
-
critical: [
|
|
166
|
-
{
|
|
167
|
-
label: 'Critical',
|
|
168
|
-
value: 0.6
|
|
169
|
-
}
|
|
170
|
-
],
|
|
171
|
-
enabled: false,
|
|
172
|
-
warning: [
|
|
173
|
-
{
|
|
174
|
-
label: 'Warning',
|
|
175
|
-
value: 0.5
|
|
176
|
-
}
|
|
177
|
-
]
|
|
178
|
-
}
|
|
179
|
-
},
|
|
180
|
-
render: Template
|
|
181
|
-
};
|
|
182
|
-
|
|
183
|
-
export const Small: Story = {
|
|
184
|
-
args: {
|
|
185
|
-
data: dataLastWeek,
|
|
186
|
-
size: 'small',
|
|
187
|
-
thresholds: {
|
|
188
|
-
critical: [
|
|
189
|
-
{
|
|
190
|
-
label: 'Critical',
|
|
191
|
-
value: 0.6
|
|
192
|
-
}
|
|
193
|
-
],
|
|
194
|
-
enabled: true,
|
|
195
|
-
warning: [
|
|
196
|
-
{
|
|
197
|
-
label: 'Warning',
|
|
198
|
-
value: 0.5
|
|
199
|
-
}
|
|
200
|
-
]
|
|
201
|
-
}
|
|
202
|
-
},
|
|
203
|
-
render: Template
|
|
204
|
-
};
|
|
@@ -2,26 +2,20 @@ import { equals } from 'ramda';
|
|
|
2
2
|
|
|
3
3
|
import { useTheme } from '@mui/material';
|
|
4
4
|
|
|
5
|
-
import { margins } from '../common/margins';
|
|
6
|
-
|
|
7
5
|
import { groupMargin } from './Thresholds';
|
|
8
6
|
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
7
|
+
const lineMargin = 10;
|
|
8
|
+
|
|
9
|
+
const thresholdLineHeight = 60 + 2 * lineMargin;
|
|
10
|
+
|
|
13
11
|
export const margin = 40;
|
|
14
12
|
|
|
15
|
-
const
|
|
16
|
-
medium: 10,
|
|
17
|
-
small: 5
|
|
18
|
-
};
|
|
13
|
+
export const barHeight = 50;
|
|
19
14
|
|
|
20
15
|
interface Props {
|
|
21
16
|
hideTooltip: () => void;
|
|
22
17
|
label: string;
|
|
23
18
|
showTooltip: (args) => void;
|
|
24
|
-
size: 'small' | 'medium';
|
|
25
19
|
thresholdType: string;
|
|
26
20
|
value: number;
|
|
27
21
|
xScale: (value: number) => number;
|
|
@@ -33,20 +27,13 @@ export const ThresholdLine = ({
|
|
|
33
27
|
xScale,
|
|
34
28
|
thresholdType,
|
|
35
29
|
showTooltip,
|
|
36
|
-
hideTooltip
|
|
37
|
-
size
|
|
30
|
+
hideTooltip
|
|
38
31
|
}: Props): JSX.Element => {
|
|
39
32
|
const theme = useTheme();
|
|
40
33
|
|
|
41
34
|
const scaledValue = xScale(value) || 0;
|
|
42
35
|
|
|
43
|
-
const
|
|
44
|
-
|
|
45
|
-
const thresholdLineHeight = barHeights[size] + 2 * lineMargin;
|
|
46
|
-
|
|
47
|
-
const isSmall = equals(size, 'small');
|
|
48
|
-
|
|
49
|
-
const bottom = barHeights[size] + margin * 2;
|
|
36
|
+
const bottom = barHeight + margin * 2;
|
|
50
37
|
|
|
51
38
|
const onMouseEnter = (left) => (): void =>
|
|
52
39
|
showTooltip({
|
|
@@ -64,20 +51,12 @@ export const ThresholdLine = ({
|
|
|
64
51
|
<line
|
|
65
52
|
data-testid={`${thresholdType}-line-${value}`}
|
|
66
53
|
stroke={lineColor}
|
|
67
|
-
strokeDasharray=
|
|
54
|
+
strokeDasharray={4}
|
|
68
55
|
strokeWidth={2}
|
|
69
56
|
x1={scaledValue}
|
|
70
57
|
x2={scaledValue}
|
|
71
|
-
y1={
|
|
72
|
-
|
|
73
|
-
? groupMargin - lineMargin
|
|
74
|
-
: groupMargin + lineMargin + margins.top
|
|
75
|
-
}
|
|
76
|
-
y2={
|
|
77
|
-
isSmall
|
|
78
|
-
? thresholdLineHeight + groupMargin - lineMargin
|
|
79
|
-
: thresholdLineHeight + groupMargin + lineMargin + margins.top
|
|
80
|
-
}
|
|
58
|
+
y1={groupMargin + 3 * lineMargin}
|
|
59
|
+
y2={thresholdLineHeight + groupMargin + 3 * lineMargin}
|
|
81
60
|
/>
|
|
82
61
|
<line
|
|
83
62
|
data-testid={`${thresholdType}-line-${value}-tooltip`}
|
|
@@ -85,16 +64,8 @@ export const ThresholdLine = ({
|
|
|
85
64
|
strokeWidth={5}
|
|
86
65
|
x1={scaledValue}
|
|
87
66
|
x2={scaledValue}
|
|
88
|
-
y1={
|
|
89
|
-
|
|
90
|
-
? groupMargin - lineMargin
|
|
91
|
-
: groupMargin + lineMargin + margins.top
|
|
92
|
-
}
|
|
93
|
-
y2={
|
|
94
|
-
isSmall
|
|
95
|
-
? thresholdLineHeight + groupMargin - lineMargin
|
|
96
|
-
: thresholdLineHeight + groupMargin + lineMargin + margins.top
|
|
97
|
-
}
|
|
67
|
+
y1={groupMargin + 3 * lineMargin}
|
|
68
|
+
y2={thresholdLineHeight + groupMargin + 3 * lineMargin}
|
|
98
69
|
onMouseEnter={onMouseEnter(scaledValue)}
|
|
99
70
|
onMouseLeave={hideTooltip}
|
|
100
71
|
/>
|
|
@@ -7,7 +7,6 @@ export const groupMargin = 25;
|
|
|
7
7
|
interface Props {
|
|
8
8
|
hideTooltip: () => void;
|
|
9
9
|
showTooltip: (args) => void;
|
|
10
|
-
size: 'small' | 'medium';
|
|
11
10
|
thresholds: Thresholds;
|
|
12
11
|
xScale: (value: number) => number;
|
|
13
12
|
}
|
|
@@ -16,8 +15,7 @@ const Thresholds = ({
|
|
|
16
15
|
xScale,
|
|
17
16
|
thresholds,
|
|
18
17
|
showTooltip,
|
|
19
|
-
hideTooltip
|
|
20
|
-
size
|
|
18
|
+
hideTooltip
|
|
21
19
|
}: Props): JSX.Element => (
|
|
22
20
|
<>
|
|
23
21
|
{thresholds.warning.map(({ value, label }) => (
|
|
@@ -26,7 +24,6 @@ const Thresholds = ({
|
|
|
26
24
|
key={`warning-${value.toString()}`}
|
|
27
25
|
label={label}
|
|
28
26
|
showTooltip={showTooltip}
|
|
29
|
-
size={size}
|
|
30
27
|
thresholdType="warning"
|
|
31
28
|
value={value}
|
|
32
29
|
xScale={xScale}
|
|
@@ -38,7 +35,6 @@ const Thresholds = ({
|
|
|
38
35
|
key={`critical-${value.toString()}`}
|
|
39
36
|
label={label}
|
|
40
37
|
showTooltip={showTooltip}
|
|
41
|
-
size={size}
|
|
42
38
|
thresholdType="critical"
|
|
43
39
|
value={value}
|
|
44
40
|
xScale={xScale}
|
|
@@ -52,16 +52,3 @@ export const critical: Story = {
|
|
|
52
52
|
},
|
|
53
53
|
render: Template
|
|
54
54
|
};
|
|
55
|
-
|
|
56
|
-
export const rawValue: Story = {
|
|
57
|
-
args: {
|
|
58
|
-
data: dataLastWeek,
|
|
59
|
-
displayAsRaw: true,
|
|
60
|
-
labels: {
|
|
61
|
-
critical: 'Critical',
|
|
62
|
-
warning: 'Warning'
|
|
63
|
-
},
|
|
64
|
-
thresholds: [0.5, 1.5]
|
|
65
|
-
},
|
|
66
|
-
render: Template
|
|
67
|
-
};
|