@centreon/ui 25.2.3 → 25.2.5
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/Graph/BarChart/BarChart.cypress.spec.tsx +2 -2
- package/src/Graph/BarChart/ResponsiveBarChart.tsx +17 -4
- package/src/Graph/Chart/Chart.cypress.spec.tsx +13 -17
- package/src/Graph/Chart/Chart.tsx +50 -33
- package/src/Graph/Chart/InteractiveComponents/AnchorPoint/GuidingLines.tsx +3 -3
- package/src/Graph/Chart/InteractiveComponents/AnchorPoint/useTickGraph.ts +19 -6
- package/src/Graph/common/Axes/index.tsx +1 -1
- package/src/Graph/common/Axes/useAxisY.ts +8 -4
- package/src/Graph/common/BaseChart/ChartSvgWrapper.tsx +12 -4
- package/src/Graph/common/BaseChart/useComputeBaseChartDimensions.ts +6 -4
- package/src/Graph/common/BaseChart/useComputeYAxisMaxCharacters.ts +92 -0
- package/src/Graph/common/models.ts +7 -8
- package/src/Graph/common/timeSeries/index.test.ts +1 -1
- package/src/Graph/common/timeSeries/index.ts +1 -7
- package/src/Graph/common/utils.ts +49 -1
- package/src/Graph/mockedData/lastDayWithNullValues.json +46 -12
- package/src/InputField/Select/Autocomplete/Connected/Multi/index.test.tsx +20 -1
- package/src/InputField/Select/Autocomplete/Multi/index.stories.tsx +19 -0
- package/src/InputField/Select/Autocomplete/Multi/index.tsx +8 -5
- package/src/Listing/index.tsx +3 -1
- package/src/Graph/common/timeSeries/index.test.ts-E +0 -622
|
@@ -17,7 +17,9 @@ import {
|
|
|
17
17
|
|
|
18
18
|
import { Theme, darken, getLuminance, lighten } from '@mui/material';
|
|
19
19
|
|
|
20
|
-
import { Thresholds } from './models';
|
|
20
|
+
import { Threshold, Thresholds } from './models';
|
|
21
|
+
import { formatMetricValue } from './timeSeries';
|
|
22
|
+
import { Line, TimeValue } from './timeSeries/models';
|
|
21
23
|
|
|
22
24
|
interface GetColorFromDataAndThresholdsProps {
|
|
23
25
|
baseColor?: string;
|
|
@@ -179,3 +181,49 @@ export const commonTickLabelProps = {
|
|
|
179
181
|
fontSize: 10,
|
|
180
182
|
textAnchor: 'middle'
|
|
181
183
|
};
|
|
184
|
+
|
|
185
|
+
interface GetFormattedAxisValuesProps {
|
|
186
|
+
thresholdUnit?: string;
|
|
187
|
+
axisUnit: string;
|
|
188
|
+
base?: number;
|
|
189
|
+
timeSeries: Array<TimeValue>;
|
|
190
|
+
threshold: Array<Threshold>;
|
|
191
|
+
lines: Array<Line>;
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
export const getFormattedAxisValues = ({
|
|
195
|
+
thresholdUnit,
|
|
196
|
+
axisUnit,
|
|
197
|
+
timeSeries,
|
|
198
|
+
base = 1000,
|
|
199
|
+
lines,
|
|
200
|
+
threshold
|
|
201
|
+
}: GetFormattedAxisValuesProps): Array<string> => {
|
|
202
|
+
const metricId = (lines.find(({ unit }) => equals(unit, axisUnit)) as Line)
|
|
203
|
+
?.metric_id;
|
|
204
|
+
|
|
205
|
+
if (isNil(metricId)) {
|
|
206
|
+
return [];
|
|
207
|
+
}
|
|
208
|
+
const formattedData = timeSeries.map((data) =>
|
|
209
|
+
formatMetricValue({
|
|
210
|
+
value: data[metricId],
|
|
211
|
+
unit: axisUnit,
|
|
212
|
+
base
|
|
213
|
+
})
|
|
214
|
+
);
|
|
215
|
+
|
|
216
|
+
const formattedThresholdValues = equals(thresholdUnit, axisUnit)
|
|
217
|
+
? threshold.map(({ value }) =>
|
|
218
|
+
formatMetricValue({
|
|
219
|
+
value,
|
|
220
|
+
unit: axisUnit,
|
|
221
|
+
base
|
|
222
|
+
})
|
|
223
|
+
) || []
|
|
224
|
+
: [];
|
|
225
|
+
|
|
226
|
+
return formattedData
|
|
227
|
+
.concat(formattedThresholdValues)
|
|
228
|
+
.filter((v) => v) as Array<string>;
|
|
229
|
+
};
|
|
@@ -329,7 +329,20 @@
|
|
|
329
329
|
0.32339333333,
|
|
330
330
|
null
|
|
331
331
|
],
|
|
332
|
-
"prints": [
|
|
332
|
+
"prints": [
|
|
333
|
+
[
|
|
334
|
+
"Last:0.32"
|
|
335
|
+
],
|
|
336
|
+
[
|
|
337
|
+
"Min:0.03"
|
|
338
|
+
],
|
|
339
|
+
[
|
|
340
|
+
"Max:0.97"
|
|
341
|
+
],
|
|
342
|
+
[
|
|
343
|
+
"Average:0.51"
|
|
344
|
+
]
|
|
345
|
+
],
|
|
333
346
|
"last_value": 0.32,
|
|
334
347
|
"minimum_value": 0.03,
|
|
335
348
|
"maximum_value": 0.97,
|
|
@@ -654,10 +667,18 @@
|
|
|
654
667
|
null
|
|
655
668
|
],
|
|
656
669
|
"prints": [
|
|
657
|
-
[
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
[
|
|
670
|
+
[
|
|
671
|
+
"Last:87.27"
|
|
672
|
+
],
|
|
673
|
+
[
|
|
674
|
+
"Min:70.31"
|
|
675
|
+
],
|
|
676
|
+
[
|
|
677
|
+
"Max:88.03"
|
|
678
|
+
],
|
|
679
|
+
[
|
|
680
|
+
"Average:78.07"
|
|
681
|
+
]
|
|
661
682
|
],
|
|
662
683
|
"last_value": 87.27,
|
|
663
684
|
"minimum_value": 70.31,
|
|
@@ -974,15 +995,28 @@
|
|
|
974
995
|
0.32092,
|
|
975
996
|
0.23609333333,
|
|
976
997
|
0.45102333333,
|
|
977
|
-
|
|
978
|
-
|
|
979
|
-
|
|
980
|
-
|
|
981
|
-
|
|
982
|
-
|
|
998
|
+
null,
|
|
999
|
+
null,
|
|
1000
|
+
null,
|
|
1001
|
+
null,
|
|
1002
|
+
null,
|
|
1003
|
+
null,
|
|
983
1004
|
null
|
|
984
1005
|
],
|
|
985
|
-
"prints": [
|
|
1006
|
+
"prints": [
|
|
1007
|
+
[
|
|
1008
|
+
"Last:0.65"
|
|
1009
|
+
],
|
|
1010
|
+
[
|
|
1011
|
+
"Min:0.03"
|
|
1012
|
+
],
|
|
1013
|
+
[
|
|
1014
|
+
"Max:0.98"
|
|
1015
|
+
],
|
|
1016
|
+
[
|
|
1017
|
+
"Average:0.50"
|
|
1018
|
+
]
|
|
1019
|
+
],
|
|
986
1020
|
"last_value": 0.65,
|
|
987
1021
|
"minimum_value": 0.03,
|
|
988
1022
|
"maximum_value": 0.98,
|
|
@@ -13,7 +13,7 @@ import { baseEndpoint, getEndpoint, label, optionsData } from './utils';
|
|
|
13
13
|
|
|
14
14
|
import MultiConnectedAutocompleteField from '.';
|
|
15
15
|
|
|
16
|
-
const renderMultiAutocompleteField = (): RenderResult =>
|
|
16
|
+
const renderMultiAutocompleteField = (customRenderTags?): RenderResult =>
|
|
17
17
|
render(
|
|
18
18
|
<TestQueryProvider>
|
|
19
19
|
<MultiConnectedAutocompleteField
|
|
@@ -23,6 +23,7 @@ const renderMultiAutocompleteField = (): RenderResult =>
|
|
|
23
23
|
label={label}
|
|
24
24
|
placeholder="Type here..."
|
|
25
25
|
value={[optionsData.result[0]]}
|
|
26
|
+
customRenderTags={customRenderTags}
|
|
26
27
|
/>
|
|
27
28
|
</TestQueryProvider>
|
|
28
29
|
);
|
|
@@ -42,4 +43,22 @@ describe(MultiConnectedAutocompleteField, () => {
|
|
|
42
43
|
expect(getFetchCall(0)).toEqual(`${baseEndpoint}?page=1`);
|
|
43
44
|
});
|
|
44
45
|
});
|
|
46
|
+
|
|
47
|
+
it('display tags when customTagsRender is defined', async () => {
|
|
48
|
+
const customRender = (tags: React.ReactNode): React.ReactNode => (
|
|
49
|
+
<div data-testid="custom-tags-wrapper">
|
|
50
|
+
{tags}
|
|
51
|
+
</div>
|
|
52
|
+
);
|
|
53
|
+
|
|
54
|
+
const { getByLabelText, getByTestId } = renderMultiAutocompleteField(customRender);
|
|
55
|
+
|
|
56
|
+
fireEvent.click(getByLabelText('Open'));
|
|
57
|
+
|
|
58
|
+
await waitFor(() => {
|
|
59
|
+
const tagChip = getByTestId(`tag-option-chip-${optionsData.result[0].id}`);
|
|
60
|
+
expect(tagChip).toBeVisible();
|
|
61
|
+
expect(tagChip).toHaveTextContent(optionsData.result[0].name);
|
|
62
|
+
});
|
|
63
|
+
});
|
|
45
64
|
});
|
|
@@ -58,3 +58,22 @@ export const popoverWithoutInput = (): JSX.Element => {
|
|
|
58
58
|
/>
|
|
59
59
|
);
|
|
60
60
|
};
|
|
61
|
+
|
|
62
|
+
export const customRenderedTags = (): JSX.Element => {
|
|
63
|
+
const customRender = (tags: React.ReactNode): React.ReactNode => (
|
|
64
|
+
<div style={{ display: 'flex' }}>
|
|
65
|
+
{tags}
|
|
66
|
+
<span style={{ color: '#999' }}>Custom wrapper</span>
|
|
67
|
+
</div>
|
|
68
|
+
);
|
|
69
|
+
|
|
70
|
+
return (
|
|
71
|
+
<MultiAutocompleteField
|
|
72
|
+
label="Custom Tags Render"
|
|
73
|
+
options={options}
|
|
74
|
+
placeholder="Type here..."
|
|
75
|
+
value={[options[0], options[1]]}
|
|
76
|
+
customRenderTags={customRender}
|
|
77
|
+
/>
|
|
78
|
+
);
|
|
79
|
+
};
|
|
@@ -9,10 +9,6 @@ import { SelectEntry } from '../..';
|
|
|
9
9
|
import Option from '../../Option';
|
|
10
10
|
|
|
11
11
|
const useStyles = makeStyles()((theme) => ({
|
|
12
|
-
checkbox: {
|
|
13
|
-
marginRight: theme.spacing(1),
|
|
14
|
-
padding: 0
|
|
15
|
-
},
|
|
16
12
|
deleteIcon: {
|
|
17
13
|
height: theme.spacing(1.5),
|
|
18
14
|
width: theme.spacing(1.5)
|
|
@@ -37,6 +33,7 @@ export interface Props
|
|
|
37
33
|
getOptionTooltipLabel?: (option) => string;
|
|
38
34
|
getTagLabel?: (option) => string;
|
|
39
35
|
optionProperty?: string;
|
|
36
|
+
customRenderTags?: (tags: React.ReactNode) => React.ReactNode;
|
|
40
37
|
}
|
|
41
38
|
|
|
42
39
|
const MultiAutocompleteField = ({
|
|
@@ -48,6 +45,7 @@ const MultiAutocompleteField = ({
|
|
|
48
45
|
getTagLabel = (option): string => option[optionProperty],
|
|
49
46
|
getOptionTooltipLabel,
|
|
50
47
|
chipProps,
|
|
48
|
+
customRenderTags,
|
|
51
49
|
...props
|
|
52
50
|
}: Props): JSX.Element => {
|
|
53
51
|
const { classes } = useStyles();
|
|
@@ -65,6 +63,7 @@ const MultiAutocompleteField = ({
|
|
|
65
63
|
deleteIcon: classes.deleteIcon,
|
|
66
64
|
root: classes.tag
|
|
67
65
|
}}
|
|
66
|
+
data-testid={`tag-option-chip-${option.id}`}
|
|
68
67
|
label={getTagLabel(option)}
|
|
69
68
|
size="medium"
|
|
70
69
|
{...getTagProps({ index })}
|
|
@@ -106,7 +105,11 @@ const MultiAutocompleteField = ({
|
|
|
106
105
|
<Option checkboxSelected={selected}>{getOptionLabel(option)}</Option>
|
|
107
106
|
</li>
|
|
108
107
|
)}
|
|
109
|
-
renderTags={
|
|
108
|
+
renderTags={(renderedValue, getTagProps): React.ReactNode =>
|
|
109
|
+
customRenderTags
|
|
110
|
+
? customRenderTags(renderTags(renderedValue, getTagProps))
|
|
111
|
+
: renderTags(renderedValue, getTagProps)
|
|
112
|
+
}
|
|
110
113
|
value={value}
|
|
111
114
|
{...props}
|
|
112
115
|
/>
|
package/src/Listing/index.tsx
CHANGED