@centreon/ui 23.10.1-MON-20803-RS-add-basic-filter.11 → 23.10.1-MON-22310-text-alignment-description.0
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 +11 -2
- package/src/Dashboard/Item.tsx +7 -3
- package/src/Dashboard/Layout.tsx +9 -6
- package/src/Form/Inputs/Radio.tsx +15 -4
- package/src/Form/Inputs/models.ts +1 -1
- package/src/Graph/Gauge/Gauge.stories.tsx +10 -0
- package/src/Graph/Gauge/Gauge.tsx +13 -5
- package/src/Graph/Gauge/PieData.tsx +8 -8
- package/src/Graph/Gauge/ResponsiveGauge.tsx +41 -25
- package/src/Graph/Gauge/Thresholds.tsx +2 -25
- package/src/Graph/Gauge/models.ts +1 -0
- package/src/Graph/LineChart/BasicComponents/Axes/index.tsx +1 -1
- package/src/Graph/LineChart/BasicComponents/Lines/RegularLines/index.tsx +13 -8
- package/src/Graph/LineChart/BasicComponents/Lines/StackedLines/index.tsx +5 -3
- package/src/Graph/LineChart/BasicComponents/Lines/Threshold/useScaleThreshold.ts +3 -3
- package/src/Graph/LineChart/BasicComponents/Lines/index.tsx +5 -5
- package/src/Graph/LineChart/InteractiveComponents/AnchorPoint/RegularAnchorPoint.tsx +5 -5
- package/src/Graph/LineChart/InteractiveComponents/AnchorPoint/models.ts +1 -1
- package/src/Graph/LineChart/Legend/index.tsx +7 -7
- package/src/Graph/LineChart/Legend/useInteractiveValues.ts +10 -10
- package/src/Graph/LineChart/Legend/useLegend.ts +16 -18
- package/src/Graph/LineChart/index.tsx +4 -3
- package/src/Graph/SingleBar/ResponsiveSingleBar.tsx +83 -51
- package/src/Graph/SingleBar/SingleBar.stories.tsx +46 -0
- package/src/Graph/SingleBar/ThresholdLine.tsx +41 -12
- package/src/Graph/SingleBar/Thresholds.tsx +5 -1
- package/src/Graph/SingleBar/models.ts +4 -0
- package/src/Graph/Text/Text.stories.tsx +13 -0
- package/src/Graph/Text/Text.tsx +19 -12
- package/src/Graph/common/timeSeries/index.test.ts +144 -26
- package/src/Graph/common/timeSeries/index.ts +86 -21
- package/src/Graph/common/timeSeries/models.ts +9 -4
- package/src/Graph/common/utils.ts +4 -2
- package/src/InputField/Select/Autocomplete/Connected/index.tsx +7 -2
- package/src/InputField/Select/Autocomplete/Multi/index.tsx +20 -11
- package/src/InputField/Select/Autocomplete/index.tsx +4 -1
- package/src/InputField/Select/index.tsx +1 -0
- package/src/InputField/Text/index.tsx +10 -7
- package/src/Listing/Cell/DataCell.tsx +1 -1
- package/src/Listing/Cell/index.tsx +2 -2
- package/src/ParentSize/ParentSize.tsx +24 -0
- package/src/ParentSize/index.ts +1 -0
- package/src/PopoverMenu/index.tsx +4 -14
- package/src/RichTextEditor/ContentEditable.tsx +15 -7
- package/src/RichTextEditor/RichTextEditor.cypress.spec.tsx +28 -13
- package/src/RichTextEditor/RichTextEditor.tsx +5 -2
- package/src/RichTextEditor/index.stories.tsx +9 -0
- package/src/RichTextEditor/plugins/AutoLinkPlugin/index.tsx +40 -1
- package/src/RichTextEditor/plugins/FloatingLinkEditorPlugin.tsx +33 -8
- package/src/RichTextEditor/plugins/ToolbarPlugin/AlignPicker.tsx +115 -0
- package/src/RichTextEditor/plugins/ToolbarPlugin/MacrosButton.tsx +1 -2
- package/src/RichTextEditor/plugins/ToolbarPlugin/ToolbarPlugin.styles.ts +15 -0
- package/src/RichTextEditor/plugins/ToolbarPlugin/index.tsx +12 -4
- package/src/ThemeProvider/index.tsx +6 -4
- package/src/ThemeProvider/palettes.ts +5 -2
- package/src/TimePeriods/CustomTimePeriod/PopoverCustomTimePeriod/PickersStartEndDate.tsx +9 -6
- package/src/TimePeriods/CustomTimePeriod/SimpleCustomTimePeriod.tsx +28 -0
- package/src/TimePeriods/index.stories.tsx +15 -0
- package/src/TimePeriods/index.tsx +4 -3
- package/src/TopCounterElements/ResourceSubMenu.tsx +3 -1
- package/src/TopCounterElements/TopCounterLayout.tsx +1 -1
- package/src/api/buildListingEndpoint/getSearchQueryParameterValue.ts +4 -2
- package/src/api/buildListingEndpoint/index.ts +1 -1
- package/src/api/useFetchQuery/index.ts +10 -8
- package/src/api/useGraphQuery/index.ts +67 -32
- package/src/api/useGraphQuery/models.ts +9 -8
- package/src/api/useMutationQuery/index.ts +16 -11
- package/src/components/DataTable/DataTable.styles.ts +1 -1
- package/src/components/DataTable/Item/DataTableItem.styles.ts +3 -9
- package/src/components/DataTable/Item/DataTableItem.tsx +3 -1
- package/src/components/Form/Dashboard/Dashboard.resource.ts +5 -0
- package/src/components/Form/Dashboard/DashboardForm.styles.ts +10 -2
- package/src/components/Form/Dashboard/DashboardForm.tsx +34 -1
- package/src/components/Form/Dashboard/GlobalRefreshFieldOption.tsx +59 -0
- package/src/components/Form/Dashboard/translatedLabels.ts +3 -0
- package/src/components/Inputs/Switch/Switch.stories.tsx +22 -0
- package/src/components/Inputs/Switch/Switch.styles.ts +13 -0
- package/src/components/Inputs/Switch/Switch.tsx +18 -0
- package/src/components/Inputs/index.ts +1 -0
- package/src/components/Layout/PageLayout/PageLayout.styles.ts +4 -2
- package/src/components/Layout/PageLayout/PageLayoutActions.tsx +13 -4
- package/src/components/Menu/Button/MenuButton.tsx +3 -0
- package/src/components/Menu/Menu.styles.ts +6 -8
- package/src/components/Modal/Modal.styles.ts +5 -2
- package/src/components/Modal/ModalHeader.tsx +1 -1
- package/src/components/index.ts +1 -0
- package/src/index.ts +5 -4
- package/src/utils/centreonBaseURL.ts +4 -0
- package/src/utils/index.ts +1 -0
- package/src/utils/useDebounce.ts +2 -7
- package/src/utils/useRefreshInterval.ts +19 -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-22310-text-alignment-description.0",
|
|
4
4
|
"description": "Centreon UI Components",
|
|
5
5
|
"scripts": {
|
|
6
6
|
"eslint": "eslint ./src --ext .js,.jsx,.ts,.tsx --max-warnings 0",
|
|
@@ -69,7 +69,11 @@ export const useDashboardLayoutStyles = makeStyles<boolean>()(
|
|
|
69
69
|
export const useDashboardItemStyles = makeStyles<{ hasHeader: boolean }>()(
|
|
70
70
|
(theme, { hasHeader }) => ({
|
|
71
71
|
widgetContainer: {
|
|
72
|
+
background: theme.palette.background.widget,
|
|
73
|
+
border: 'none',
|
|
74
|
+
borderRadius: theme.spacing(1),
|
|
72
75
|
height: '100%',
|
|
76
|
+
paddingBottom: theme.spacing(2),
|
|
73
77
|
width: '100%'
|
|
74
78
|
},
|
|
75
79
|
widgetContent: {
|
|
@@ -79,12 +83,17 @@ export const useDashboardItemStyles = makeStyles<{ hasHeader: boolean }>()(
|
|
|
79
83
|
'&:hover': {
|
|
80
84
|
backgroundColor: theme.palette.action.hover
|
|
81
85
|
},
|
|
82
|
-
|
|
86
|
+
'&[data-canMove="false"]': {
|
|
87
|
+
cursor: 'default'
|
|
88
|
+
},
|
|
89
|
+
'&[data-canMove="true"]': {
|
|
90
|
+
cursor: 'move'
|
|
91
|
+
},
|
|
83
92
|
padding: theme.spacing(0.5, 2)
|
|
84
93
|
},
|
|
85
94
|
widgetPadding: {
|
|
86
95
|
overflowX: 'auto',
|
|
87
|
-
padding: hasHeader ? theme.spacing(1, 2,
|
|
96
|
+
padding: hasHeader ? theme.spacing(1, 2, 0) : theme.spacing(1, 2)
|
|
88
97
|
}
|
|
89
98
|
})
|
|
90
99
|
);
|
package/src/Dashboard/Item.tsx
CHANGED
|
@@ -8,13 +8,14 @@ import {
|
|
|
8
8
|
|
|
9
9
|
import { isNil } from 'ramda';
|
|
10
10
|
|
|
11
|
-
import { Card } from '@mui/material';
|
|
11
|
+
import { Card, useTheme } from '@mui/material';
|
|
12
12
|
|
|
13
13
|
import { useMemoComponent } from '../utils';
|
|
14
14
|
|
|
15
15
|
import { useDashboardItemStyles } from './Dashboard.styles';
|
|
16
16
|
|
|
17
17
|
interface DashboardItemProps {
|
|
18
|
+
canMove?: boolean;
|
|
18
19
|
children: ReactElement;
|
|
19
20
|
className?: string;
|
|
20
21
|
disablePadding?: boolean;
|
|
@@ -37,13 +38,15 @@ const Item = forwardRef(
|
|
|
37
38
|
onMouseUp,
|
|
38
39
|
onTouchEnd,
|
|
39
40
|
id,
|
|
40
|
-
disablePadding = false
|
|
41
|
+
disablePadding = false,
|
|
42
|
+
canMove = false
|
|
41
43
|
}: DashboardItemProps,
|
|
42
44
|
ref: ForwardedRef<HTMLDivElement>
|
|
43
45
|
): ReactElement => {
|
|
44
46
|
const hasHeader = !isNil(header);
|
|
45
47
|
|
|
46
48
|
const { classes, cx } = useDashboardItemStyles({ hasHeader });
|
|
49
|
+
const theme = useTheme();
|
|
47
50
|
|
|
48
51
|
const listeners = {
|
|
49
52
|
onMouseDown,
|
|
@@ -66,6 +69,7 @@ const Item = forwardRef(
|
|
|
66
69
|
<div
|
|
67
70
|
{...listeners}
|
|
68
71
|
className={classes.widgetHeader}
|
|
72
|
+
data-canMove={canMove}
|
|
69
73
|
data-testid={`${id}_move_panel`}
|
|
70
74
|
>
|
|
71
75
|
{header}
|
|
@@ -82,7 +86,7 @@ const Item = forwardRef(
|
|
|
82
86
|
</Card>
|
|
83
87
|
</div>
|
|
84
88
|
),
|
|
85
|
-
memoProps: [style, className, header]
|
|
89
|
+
memoProps: [style, className, header, theme.palette.mode, canMove]
|
|
86
90
|
});
|
|
87
91
|
}
|
|
88
92
|
);
|
package/src/Dashboard/Layout.tsx
CHANGED
|
@@ -1,10 +1,13 @@
|
|
|
1
1
|
import { useEffect, useState } from 'react';
|
|
2
2
|
|
|
3
|
-
import { Responsive } from '@visx/visx';
|
|
4
3
|
import GridLayout, { Layout, WidthProvider } from 'react-grid-layout';
|
|
5
4
|
import 'react-grid-layout/css/styles.css';
|
|
6
5
|
|
|
7
|
-
import {
|
|
6
|
+
import {
|
|
7
|
+
Responsive as ResponsiveHeight,
|
|
8
|
+
ParentSize,
|
|
9
|
+
useMemoComponent
|
|
10
|
+
} from '..';
|
|
8
11
|
|
|
9
12
|
import { useDashboardLayoutStyles } from './Dashboard.styles';
|
|
10
13
|
import { getColumnsFromScreenSize, getLayout, rowHeight } from './utils';
|
|
@@ -45,8 +48,8 @@ const Layout = <T extends Layout>({
|
|
|
45
48
|
|
|
46
49
|
return useMemoComponent({
|
|
47
50
|
Component: (
|
|
48
|
-
<ResponsiveHeight>
|
|
49
|
-
<
|
|
51
|
+
<ResponsiveHeight margin={40}>
|
|
52
|
+
<ParentSize>
|
|
50
53
|
{({ width, height }): JSX.Element => (
|
|
51
54
|
<div className={classes.container}>
|
|
52
55
|
{displayGrid && (
|
|
@@ -66,10 +69,10 @@ const Layout = <T extends Layout>({
|
|
|
66
69
|
</ReactGridLayout>
|
|
67
70
|
</div>
|
|
68
71
|
)}
|
|
69
|
-
</
|
|
72
|
+
</ParentSize>
|
|
70
73
|
</ResponsiveHeight>
|
|
71
74
|
),
|
|
72
|
-
memoProps: [columns, layout, displayGrid]
|
|
75
|
+
memoProps: [columns, layout, displayGrid, isStatic]
|
|
73
76
|
});
|
|
74
77
|
};
|
|
75
78
|
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { FormikValues, useFormikContext } from 'formik';
|
|
2
|
-
import { equals, includes, path, split } from 'ramda';
|
|
2
|
+
import { equals, includes, path, split, type } from 'ramda';
|
|
3
3
|
import { useTranslation } from 'react-i18next';
|
|
4
4
|
|
|
5
5
|
import {
|
|
@@ -73,12 +73,23 @@ const Radio = ({
|
|
|
73
73
|
disabled={disabled}
|
|
74
74
|
id={getNormalizedId(`${dataTestId}${optionLabel}`)}
|
|
75
75
|
inputProps={{
|
|
76
|
-
'aria-label':
|
|
76
|
+
'aria-label':
|
|
77
|
+
(equals(type(optionLabel), 'String') &&
|
|
78
|
+
t(optionLabel as string)) ||
|
|
79
|
+
''
|
|
77
80
|
}}
|
|
78
81
|
/>
|
|
79
82
|
}
|
|
80
|
-
key={
|
|
81
|
-
|
|
83
|
+
key={
|
|
84
|
+
equals(type(optionLabel), 'String')
|
|
85
|
+
? (optionLabel as string)
|
|
86
|
+
: `${optionValue}`
|
|
87
|
+
}
|
|
88
|
+
label={
|
|
89
|
+
equals(type(optionLabel), 'String')
|
|
90
|
+
? (t(optionLabel as string) as string)
|
|
91
|
+
: optionLabel
|
|
92
|
+
}
|
|
82
93
|
value={optionValue}
|
|
83
94
|
/>
|
|
84
95
|
))}
|
|
@@ -134,3 +134,13 @@ 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
|
+
};
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
1
|
+
import { ParentSize } from '../..';
|
|
3
2
|
import { LineChartData, Thresholds } from '../common/models';
|
|
4
3
|
import { getMetricWithLatestData } from '../common/timeSeries';
|
|
5
4
|
import { Metric } from '../common/timeSeries/models';
|
|
@@ -7,11 +6,18 @@ import { Metric } from '../common/timeSeries/models';
|
|
|
7
6
|
import ResponsiveGauge from './ResponsiveGauge';
|
|
8
7
|
|
|
9
8
|
interface Props {
|
|
9
|
+
baseColor?: string;
|
|
10
10
|
data?: LineChartData;
|
|
11
|
+
displayAsRaw?: boolean;
|
|
11
12
|
thresholds: Thresholds;
|
|
12
13
|
}
|
|
13
14
|
|
|
14
|
-
export const Gauge = ({
|
|
15
|
+
export const Gauge = ({
|
|
16
|
+
thresholds,
|
|
17
|
+
data,
|
|
18
|
+
displayAsRaw,
|
|
19
|
+
baseColor
|
|
20
|
+
}: Props): JSX.Element | null => {
|
|
15
21
|
if (!data) {
|
|
16
22
|
return null;
|
|
17
23
|
}
|
|
@@ -19,15 +25,17 @@ export const Gauge = ({ thresholds, data }: Props): JSX.Element | null => {
|
|
|
19
25
|
const metric = getMetricWithLatestData(data) as Metric;
|
|
20
26
|
|
|
21
27
|
return (
|
|
22
|
-
<
|
|
28
|
+
<ParentSize>
|
|
23
29
|
{({ width, height }) => (
|
|
24
30
|
<ResponsiveGauge
|
|
31
|
+
baseColor={baseColor}
|
|
32
|
+
displayAsRaw={displayAsRaw}
|
|
25
33
|
height={height}
|
|
26
34
|
metric={metric}
|
|
27
35
|
thresholds={thresholds}
|
|
28
36
|
width={width}
|
|
29
37
|
/>
|
|
30
38
|
)}
|
|
31
|
-
</
|
|
39
|
+
</ParentSize>
|
|
32
40
|
);
|
|
33
41
|
};
|
|
@@ -16,7 +16,8 @@ const PieData = ({
|
|
|
16
16
|
metric,
|
|
17
17
|
adaptedMaxValue,
|
|
18
18
|
thresholds,
|
|
19
|
-
radius
|
|
19
|
+
radius,
|
|
20
|
+
baseColor
|
|
20
21
|
}: Omit<
|
|
21
22
|
GaugeProps,
|
|
22
23
|
'width' | 'height' | 'showTooltip' | 'hideTooltip' | 'thresholdTooltipLabels'
|
|
@@ -24,13 +25,12 @@ const PieData = ({
|
|
|
24
25
|
const theme = useTheme();
|
|
25
26
|
|
|
26
27
|
const pieData = [metric.data[0], adaptedMaxValue - metric.data[0]];
|
|
27
|
-
const pieColor =
|
|
28
|
-
|
|
29
|
-
:
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
});
|
|
28
|
+
const pieColor = getColorFromDataAndTresholds({
|
|
29
|
+
baseColor,
|
|
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 { formatMetricValueWithUnit } from '../common/timeSeries';
|
|
11
11
|
import { getColorFromDataAndTresholds } from '../common/utils';
|
|
12
12
|
import { margins } from '../common/margins';
|
|
13
13
|
|
|
@@ -15,7 +15,8 @@ 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'> {
|
|
18
|
+
interface Props extends Pick<GaugeProps, 'thresholds' | 'baseColor'> {
|
|
19
|
+
displayAsRaw?: boolean;
|
|
19
20
|
height: number;
|
|
20
21
|
metric: Metric;
|
|
21
22
|
width: number;
|
|
@@ -30,7 +31,9 @@ const ResponsiveGauge = ({
|
|
|
30
31
|
width,
|
|
31
32
|
height,
|
|
32
33
|
thresholds,
|
|
33
|
-
metric
|
|
34
|
+
metric,
|
|
35
|
+
displayAsRaw,
|
|
36
|
+
baseColor
|
|
34
37
|
}: Props): JSX.Element => {
|
|
35
38
|
const svgRef = useRef<SVGSVGElement>(null);
|
|
36
39
|
|
|
@@ -50,31 +53,46 @@ const ResponsiveGauge = ({
|
|
|
50
53
|
const centerY = innerHeight / 2;
|
|
51
54
|
const centerX = innerWidth / 2;
|
|
52
55
|
const radius = Math.min(innerWidth, innerHeight) / 2;
|
|
53
|
-
const thresholdValues =
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
56
|
+
const thresholdValues = thresholds.enabled
|
|
57
|
+
? flatten([
|
|
58
|
+
pluck('value', thresholds.warning),
|
|
59
|
+
pluck('value', thresholds.critical)
|
|
60
|
+
])
|
|
61
|
+
: [0];
|
|
57
62
|
const adaptedMaxValue = Math.max(
|
|
58
63
|
metric.maximum_value || 0,
|
|
59
64
|
Math.max(...thresholdValues) * 1.1,
|
|
60
65
|
head(metric.data) as number
|
|
61
66
|
);
|
|
62
67
|
|
|
63
|
-
const pieColor =
|
|
64
|
-
|
|
65
|
-
:
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
});
|
|
68
|
+
const pieColor = getColorFromDataAndTresholds({
|
|
69
|
+
baseColor,
|
|
70
|
+
data: metric.data[0],
|
|
71
|
+
theme,
|
|
72
|
+
thresholds
|
|
73
|
+
});
|
|
70
74
|
|
|
71
75
|
const svgTop = svgRef.current?.getBoundingClientRect().top || 0;
|
|
72
76
|
const svgLeft = svgRef.current?.getBoundingClientRect().left || 0;
|
|
73
77
|
|
|
74
|
-
const
|
|
78
|
+
const isSmallWidget = height < 240;
|
|
79
|
+
|
|
80
|
+
const gaugeValue = formatMetricValueWithUnit({
|
|
81
|
+
base: 1000,
|
|
82
|
+
isRaw: displayAsRaw,
|
|
83
|
+
unit: metric.unit,
|
|
84
|
+
value: metric.data[0]
|
|
85
|
+
});
|
|
75
86
|
|
|
76
87
|
return (
|
|
77
|
-
<Box
|
|
88
|
+
<Box
|
|
89
|
+
sx={{
|
|
90
|
+
height: '100%',
|
|
91
|
+
overflow: 'hidden',
|
|
92
|
+
position: 'relative',
|
|
93
|
+
width: '100%'
|
|
94
|
+
}}
|
|
95
|
+
>
|
|
78
96
|
<svg height={height} ref={svgRef} width={width}>
|
|
79
97
|
<Group left={centerX + margins.left} top={centerY + height / 6}>
|
|
80
98
|
<Thresholds
|
|
@@ -87,6 +105,7 @@ const ResponsiveGauge = ({
|
|
|
87
105
|
/>
|
|
88
106
|
<PieData
|
|
89
107
|
adaptedMaxValue={adaptedMaxValue}
|
|
108
|
+
baseColor={baseColor}
|
|
90
109
|
metric={metric}
|
|
91
110
|
radius={radius}
|
|
92
111
|
thresholds={thresholds}
|
|
@@ -97,18 +116,15 @@ const ResponsiveGauge = ({
|
|
|
97
116
|
style={{
|
|
98
117
|
fill: pieColor,
|
|
99
118
|
...theme.typography.h3,
|
|
100
|
-
fontSize:
|
|
119
|
+
fontSize:
|
|
120
|
+
Math.min(width, height) / 7 -
|
|
121
|
+
(isSmallWidget ? 0 : (gaugeValue?.length || 0) * 2)
|
|
101
122
|
}}
|
|
102
123
|
textAnchor="middle"
|
|
103
124
|
x="50%"
|
|
104
|
-
y={
|
|
125
|
+
y={isSmallWidget ? 130 : height - height / 2.3}
|
|
105
126
|
>
|
|
106
|
-
{
|
|
107
|
-
base: 1000,
|
|
108
|
-
unit: metric.unit,
|
|
109
|
-
value: metric.data[0]
|
|
110
|
-
})}{' '}
|
|
111
|
-
{metric.unit}
|
|
127
|
+
{gaugeValue}
|
|
112
128
|
</text>
|
|
113
129
|
</svg>
|
|
114
130
|
<Fade in={tooltipOpen && thresholds.enabled}>
|
|
@@ -118,7 +134,7 @@ const ResponsiveGauge = ({
|
|
|
118
134
|
...baseStyles,
|
|
119
135
|
backgroundColor: theme.palette.background.paper,
|
|
120
136
|
color: theme.palette.text.primary,
|
|
121
|
-
transform: 'translate(-50%,
|
|
137
|
+
transform: 'translate(-50%, -24px)'
|
|
122
138
|
}}
|
|
123
139
|
top={(tooltipTop || 0) - svgTop + 20}
|
|
124
140
|
>
|
|
@@ -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 | null => {
|
|
20
20
|
const theme = useTheme();
|
|
21
21
|
|
|
22
22
|
const criticalThresholdValues = pluck('value', thresholds.critical);
|
|
@@ -65,30 +65,7 @@ const Thresholds = ({
|
|
|
65
65
|
});
|
|
66
66
|
|
|
67
67
|
if (!thresholds.enabled) {
|
|
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
|
-
);
|
|
68
|
+
return null;
|
|
92
69
|
}
|
|
93
70
|
|
|
94
71
|
const arcs = [
|
|
@@ -38,7 +38,7 @@ const Axes = ({
|
|
|
38
38
|
|
|
39
39
|
const [firstUnit, secondUnit, thirdUnit] = getUnits(lines);
|
|
40
40
|
|
|
41
|
-
const xTickCount = Math.ceil(width / 82);
|
|
41
|
+
const xTickCount = Math.min(Math.ceil(width / 82), 12);
|
|
42
42
|
|
|
43
43
|
const tickFormat =
|
|
44
44
|
data?.axisX?.xAxisTickFormat ?? getXAxisTickFormat(graphInterval);
|
|
@@ -16,7 +16,7 @@ interface Props {
|
|
|
16
16
|
graphHeight: number;
|
|
17
17
|
highlight?: boolean;
|
|
18
18
|
lineColor: string;
|
|
19
|
-
|
|
19
|
+
metric_id: number;
|
|
20
20
|
shapeAreaClosed?: Record<string, unknown>;
|
|
21
21
|
shapeLinePath?: Record<string, unknown>;
|
|
22
22
|
timeSeries: Array<TimeValue>;
|
|
@@ -30,7 +30,7 @@ const RegularLine = ({
|
|
|
30
30
|
filled,
|
|
31
31
|
timeSeries,
|
|
32
32
|
highlight,
|
|
33
|
-
|
|
33
|
+
metric_id,
|
|
34
34
|
lineColor,
|
|
35
35
|
unit,
|
|
36
36
|
yScale,
|
|
@@ -43,13 +43,13 @@ const RegularLine = ({
|
|
|
43
43
|
const props = {
|
|
44
44
|
curve,
|
|
45
45
|
data: timeSeries,
|
|
46
|
-
defined: (value): boolean => !isNil(value[
|
|
46
|
+
defined: (value): boolean => !isNil(value[metric_id]),
|
|
47
47
|
opacity: 1,
|
|
48
48
|
stroke: lineColor,
|
|
49
49
|
strokeWidth: !highlight ? 1 : 2,
|
|
50
50
|
unit,
|
|
51
51
|
x: (timeValue): number => xScale(getTime(timeValue)) as number,
|
|
52
|
-
y: (timeValue): number => yScale(prop(
|
|
52
|
+
y: (timeValue): number => yScale(prop(metric_id, timeValue)) ?? null
|
|
53
53
|
};
|
|
54
54
|
|
|
55
55
|
if (filled) {
|
|
@@ -57,7 +57,7 @@ const RegularLine = ({
|
|
|
57
57
|
<Shape.AreaClosed<TimeValue>
|
|
58
58
|
fill={getFillColor({ areaColor, transparency })}
|
|
59
59
|
fillRule="nonzero"
|
|
60
|
-
key={
|
|
60
|
+
key={metric_id}
|
|
61
61
|
y0={Math.min(yScale(0), graphHeight)}
|
|
62
62
|
yScale={yScale}
|
|
63
63
|
{...props}
|
|
@@ -73,22 +73,27 @@ export default memo(RegularLine, (prevProps, nextProps) => {
|
|
|
73
73
|
timeSeries: prevTimeSeries,
|
|
74
74
|
graphHeight: prevGraphHeight,
|
|
75
75
|
highlight: prevHighlight,
|
|
76
|
-
xScale: prevXScale
|
|
76
|
+
xScale: prevXScale,
|
|
77
|
+
yScale: prevYScale
|
|
77
78
|
} = prevProps;
|
|
78
79
|
const {
|
|
79
80
|
timeSeries: nextTimeSeries,
|
|
80
81
|
graphHeight: nextGraphHeight,
|
|
81
82
|
highlight: nextHighlight,
|
|
82
|
-
xScale: nextXScale
|
|
83
|
+
xScale: nextXScale,
|
|
84
|
+
yScale: nextYScale
|
|
83
85
|
} = nextProps;
|
|
84
86
|
|
|
85
87
|
const prevXScaleRange = prevXScale.range();
|
|
86
88
|
const nextXScaleRange = nextXScale.range();
|
|
89
|
+
const prevYScaleDomain = prevYScale.domain();
|
|
90
|
+
const nextYScaleDomain = nextYScale.domain();
|
|
87
91
|
|
|
88
92
|
return (
|
|
89
93
|
equals(prevTimeSeries, nextTimeSeries) &&
|
|
90
94
|
equals(prevGraphHeight, nextGraphHeight) &&
|
|
91
95
|
equals(prevHighlight, nextHighlight) &&
|
|
92
|
-
equals(prevXScaleRange, nextXScaleRange)
|
|
96
|
+
equals(prevXScaleRange, nextXScaleRange) &&
|
|
97
|
+
equals(prevYScaleDomain, nextYScaleDomain)
|
|
93
98
|
);
|
|
94
99
|
});
|
|
@@ -32,11 +32,13 @@ const StackLines = ({
|
|
|
32
32
|
data={timeSeries}
|
|
33
33
|
defined={(d): boolean => {
|
|
34
34
|
return pipe(
|
|
35
|
-
map(prop('
|
|
36
|
-
|
|
35
|
+
map(prop('metric_id')) as unknown as (
|
|
36
|
+
displayedLines
|
|
37
|
+
) => Array<string>,
|
|
38
|
+
all((metric_id) => pipe(path(['data', metric_id]), isNil, not)(d))
|
|
37
39
|
)(lines);
|
|
38
40
|
}}
|
|
39
|
-
keys={map(prop('
|
|
41
|
+
keys={map(prop('metric_id'), lines)}
|
|
40
42
|
x={(d): number => xScale(getTime(d.data)) ?? 0}
|
|
41
43
|
y0={(d): number => yScale(d[0]) ?? 0}
|
|
42
44
|
y1={(d): number => yScale(d[1]) ?? 0}
|
|
@@ -53,21 +53,21 @@ const useScaleThreshold = ({
|
|
|
53
53
|
const [, secondUnit, thirdUnit] = getUnits(lines);
|
|
54
54
|
|
|
55
55
|
const {
|
|
56
|
-
|
|
56
|
+
metric_id: metricY1,
|
|
57
57
|
unit: unitY1,
|
|
58
58
|
invert: invertY1,
|
|
59
59
|
lineColor: lineColorY1
|
|
60
60
|
} = lineUpper;
|
|
61
61
|
|
|
62
62
|
const {
|
|
63
|
-
|
|
63
|
+
metric_id: metricY0,
|
|
64
64
|
unit: unitY0,
|
|
65
65
|
invert: invertY0,
|
|
66
66
|
lineColor: lineColorY0
|
|
67
67
|
} = lineLower;
|
|
68
68
|
|
|
69
69
|
const {
|
|
70
|
-
|
|
70
|
+
metric_id: metricOrigin,
|
|
71
71
|
unit: unitYOrigin,
|
|
72
72
|
invert: invertYOrigin
|
|
73
73
|
} = lineOrigin;
|
|
@@ -129,14 +129,14 @@ const Lines = ({
|
|
|
129
129
|
{displayAreaRegularLines
|
|
130
130
|
? regularLines.map(
|
|
131
131
|
({
|
|
132
|
-
metric,
|
|
133
132
|
areaColor,
|
|
134
133
|
transparency,
|
|
135
134
|
lineColor,
|
|
136
135
|
filled,
|
|
137
136
|
unit,
|
|
138
137
|
highlight,
|
|
139
|
-
invert
|
|
138
|
+
invert,
|
|
139
|
+
metric_id
|
|
140
140
|
}) => {
|
|
141
141
|
const [, secondUnit, thirdUnit] = getUnits(
|
|
142
142
|
regularLines as Array<Line>
|
|
@@ -151,12 +151,12 @@ const Lines = ({
|
|
|
151
151
|
});
|
|
152
152
|
|
|
153
153
|
return (
|
|
154
|
-
<g key={
|
|
154
|
+
<g key={metric_id}>
|
|
155
155
|
{displayGuidingLines && (
|
|
156
156
|
<RegularAnchorPoint
|
|
157
157
|
areaColor={areaColor}
|
|
158
158
|
lineColor={lineColor}
|
|
159
|
-
|
|
159
|
+
metric_id={metric_id}
|
|
160
160
|
timeSeries={timeSeries}
|
|
161
161
|
transparency={transparency}
|
|
162
162
|
xScale={xScale}
|
|
@@ -170,7 +170,7 @@ const Lines = ({
|
|
|
170
170
|
graphHeight={height}
|
|
171
171
|
highlight={highlight}
|
|
172
172
|
lineColor={lineColor}
|
|
173
|
-
|
|
173
|
+
metric_id={metric_id}
|
|
174
174
|
timeSeries={timeSeries}
|
|
175
175
|
transparency={transparency}
|
|
176
176
|
unit={unit}
|
|
@@ -11,7 +11,7 @@ import AnchorPoint from '.';
|
|
|
11
11
|
|
|
12
12
|
interface Props {
|
|
13
13
|
lineColor: string;
|
|
14
|
-
|
|
14
|
+
metric_id: number;
|
|
15
15
|
timeSeries: Array<TimeValue>;
|
|
16
16
|
xScale: ScaleTime<number, number>;
|
|
17
17
|
yScale: ScaleLinear<number, number>;
|
|
@@ -21,18 +21,18 @@ const getYAnchorPoint = ({
|
|
|
21
21
|
timeTick,
|
|
22
22
|
timeSeries,
|
|
23
23
|
yScale,
|
|
24
|
-
|
|
24
|
+
metric_id
|
|
25
25
|
}: GetYAnchorPoint): number => {
|
|
26
26
|
const index = bisectDate(getDates(timeSeries), timeTick);
|
|
27
27
|
const timeValue = timeSeries[index];
|
|
28
28
|
|
|
29
|
-
return yScale(prop(
|
|
29
|
+
return yScale(prop(metric_id, timeValue) as number);
|
|
30
30
|
};
|
|
31
31
|
|
|
32
32
|
const RegularAnchorPoint = ({
|
|
33
33
|
xScale,
|
|
34
34
|
yScale,
|
|
35
|
-
|
|
35
|
+
metric_id,
|
|
36
36
|
timeSeries,
|
|
37
37
|
lineColor
|
|
38
38
|
}: Props): JSX.Element | null => {
|
|
@@ -48,7 +48,7 @@ const RegularAnchorPoint = ({
|
|
|
48
48
|
const xAnchorPoint = xScale(timeTick);
|
|
49
49
|
|
|
50
50
|
const yAnchorPoint = getYAnchorPoint({
|
|
51
|
-
|
|
51
|
+
metric_id,
|
|
52
52
|
timeSeries,
|
|
53
53
|
timeTick,
|
|
54
54
|
yScale
|