@centreon/ui 24.4.1-MON-24235-Filter-App-token.28 → 24.4.1-MON-34407-implement-the-status-chart-widget.13
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/BarStack/BarStack.stories.tsx +5 -5
- package/src/Graph/BarStack/BarStack.styles.ts +1 -1
- package/src/Graph/BarStack/ResponsiveBarStack.tsx +41 -27
- package/src/Graph/BarStack/models.ts +1 -0
- package/src/Graph/BarStack/useResponsiveBarStack.ts +2 -4
- package/src/Graph/PieChart/ResponsivePie.tsx +6 -4
- package/src/Graph/PieChart/models.ts +1 -0
- package/src/InputField/Select/Autocomplete/Multi/index.tsx +2 -4
- package/src/InputField/Select/Autocomplete/index.tsx +1 -2
- package/src/PopoverMenu/index.tsx +5 -7
- package/src/components/List/Item/ListItem.tsx +3 -3
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@centreon/ui",
|
|
3
|
-
"version": "24.4.1-MON-
|
|
3
|
+
"version": "24.4.1-MON-34407-implement-the-status-chart-widget.13",
|
|
4
4
|
"description": "Centreon UI Components",
|
|
5
5
|
"scripts": {
|
|
6
6
|
"eslint": "eslint ./src --ext .js,.jsx,.ts,.tsx --max-warnings 0",
|
|
@@ -58,11 +58,6 @@ export const WithoutTitle: Story = {
|
|
|
58
58
|
render: Template
|
|
59
59
|
};
|
|
60
60
|
|
|
61
|
-
export const WithPencentage: Story = {
|
|
62
|
-
args: { data, title: 'hosts', unit: 'percentage' },
|
|
63
|
-
render: Template
|
|
64
|
-
};
|
|
65
|
-
|
|
66
61
|
export const WithoutLegend: Story = {
|
|
67
62
|
args: { data, displayLegend: false, title: 'hosts' },
|
|
68
63
|
|
|
@@ -74,6 +69,11 @@ export const withDisplayedValues: Story = {
|
|
|
74
69
|
render: Template
|
|
75
70
|
};
|
|
76
71
|
|
|
72
|
+
export const WithPencentage: Story = {
|
|
73
|
+
args: { data, displayValues: true, title: 'hosts', unit: 'percentage' },
|
|
74
|
+
render: Template
|
|
75
|
+
};
|
|
76
|
+
|
|
77
77
|
export const WithTooltip: Story = {
|
|
78
78
|
args: { TooltipContent, data, title: 'hosts' },
|
|
79
79
|
render: Template
|
|
@@ -16,7 +16,7 @@ export const useBarStackStyles = makeStyles()((theme) => ({
|
|
|
16
16
|
svgContainer: {
|
|
17
17
|
alignItems: 'center',
|
|
18
18
|
backgroundColor: theme.palette.background.panelGroups,
|
|
19
|
-
borderRadius: theme.
|
|
19
|
+
borderRadius: theme.spacing(1.25),
|
|
20
20
|
display: 'flex',
|
|
21
21
|
justifyContent: 'center'
|
|
22
22
|
},
|
|
@@ -5,6 +5,7 @@ import { Group } from '@visx/group';
|
|
|
5
5
|
import numeral from 'numeral';
|
|
6
6
|
import { Text } from '@visx/text';
|
|
7
7
|
import { useTranslation } from 'react-i18next';
|
|
8
|
+
import { equals } from 'ramda';
|
|
8
9
|
|
|
9
10
|
import { Typography } from '@mui/material';
|
|
10
11
|
|
|
@@ -12,7 +13,7 @@ import { Tooltip } from '../../components';
|
|
|
12
13
|
import { LegendProps } from '../Legend/models';
|
|
13
14
|
import { Legend as LegendComponent } from '../Legend';
|
|
14
15
|
import { getValueByUnit } from '../common/utils';
|
|
15
|
-
import { labelNoDataFound } from '../translatedLabels';
|
|
16
|
+
import { labelNoDataFound as defaultlabelNoDataFound } from '../translatedLabels';
|
|
16
17
|
|
|
17
18
|
import { BarStackProps } from './models';
|
|
18
19
|
import { useBarStackStyles } from './BarStack.styles';
|
|
@@ -35,7 +36,8 @@ const BarStack = ({
|
|
|
35
36
|
unit = 'number',
|
|
36
37
|
displayValues,
|
|
37
38
|
variant = 'vertical',
|
|
38
|
-
legendDirection = 'column'
|
|
39
|
+
legendDirection = 'column',
|
|
40
|
+
labelNoDataFound = defaultlabelNoDataFound
|
|
39
41
|
}: BarStackProps & { height: number; width: number }): JSX.Element => {
|
|
40
42
|
const { t } = useTranslation();
|
|
41
43
|
const { classes } = useBarStackStyles();
|
|
@@ -90,7 +92,7 @@ const BarStack = ({
|
|
|
90
92
|
>
|
|
91
93
|
{title && (
|
|
92
94
|
<div className={classes.title} data-testid="Title" ref={titleRef}>
|
|
93
|
-
{`${numeral(total).format('0a').toUpperCase()} `} {title}
|
|
95
|
+
{`${numeral(total).format('0a').toUpperCase()} `} {t(title)}
|
|
94
96
|
</div>
|
|
95
97
|
)}
|
|
96
98
|
<div
|
|
@@ -117,6 +119,20 @@ const BarStack = ({
|
|
|
117
119
|
{(barStacks) =>
|
|
118
120
|
barStacks.map((barStack) =>
|
|
119
121
|
barStack.bars.map((bar) => {
|
|
122
|
+
const shouldDisplayValues = (): boolean => {
|
|
123
|
+
if (bar.height < 10) {
|
|
124
|
+
return false;
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
return (
|
|
128
|
+
(equals(unit, 'number') && bar.width > 10) ||
|
|
129
|
+
(equals(unit, 'percentage') && bar.width > 25)
|
|
130
|
+
);
|
|
131
|
+
};
|
|
132
|
+
|
|
133
|
+
const TextX = bar.x + bar.width / 2;
|
|
134
|
+
const TextY = bar.y + bar.height / 2;
|
|
135
|
+
|
|
120
136
|
const onClick = (): void => {
|
|
121
137
|
onSingleBarClick?.(bar);
|
|
122
138
|
};
|
|
@@ -144,40 +160,38 @@ const BarStack = ({
|
|
|
144
160
|
isVerticalBar ? 'right-start' : 'bottom-start'
|
|
145
161
|
}
|
|
146
162
|
>
|
|
147
|
-
<g data-testid={bar.key}>
|
|
163
|
+
<g data-testid={bar.key} onClick={onClick}>
|
|
148
164
|
<rect
|
|
165
|
+
cursor="pointer"
|
|
149
166
|
fill={bar.color}
|
|
150
167
|
height={
|
|
151
168
|
isVerticalBar ? bar.height - 1 : bar.height
|
|
152
169
|
}
|
|
153
170
|
key={`bar-stack-${barStack.index}-${bar.index}`}
|
|
154
|
-
ry={
|
|
171
|
+
ry={10}
|
|
155
172
|
width={isVerticalBar ? bar.width : bar.width - 1}
|
|
156
173
|
x={bar.x}
|
|
157
174
|
y={bar.y}
|
|
158
|
-
onClick={onClick}
|
|
159
175
|
/>
|
|
160
|
-
{displayValues &&
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
</Text>
|
|
180
|
-
)}
|
|
176
|
+
{displayValues && shouldDisplayValues() && (
|
|
177
|
+
<Text
|
|
178
|
+
cursor="pointer"
|
|
179
|
+
data-testid="value"
|
|
180
|
+
fill="#000"
|
|
181
|
+
fontSize={12}
|
|
182
|
+
fontWeight={600}
|
|
183
|
+
textAnchor="middle"
|
|
184
|
+
verticalAnchor="middle"
|
|
185
|
+
x={TextX}
|
|
186
|
+
y={TextY}
|
|
187
|
+
>
|
|
188
|
+
{getValueByUnit({
|
|
189
|
+
total,
|
|
190
|
+
unit,
|
|
191
|
+
value: barStack.bars[0].bar.data[barStack.key]
|
|
192
|
+
})}
|
|
193
|
+
</Text>
|
|
194
|
+
)}
|
|
181
195
|
</g>
|
|
182
196
|
</Tooltip>
|
|
183
197
|
);
|
|
@@ -72,8 +72,7 @@ const useResponsiveBarStack = ({
|
|
|
72
72
|
|
|
73
73
|
const yScale = isVerticalBar
|
|
74
74
|
? scaleLinear({
|
|
75
|
-
domain: [0, total]
|
|
76
|
-
nice: true
|
|
75
|
+
domain: [0, total]
|
|
77
76
|
})
|
|
78
77
|
: scaleBand({
|
|
79
78
|
domain: [0, 0],
|
|
@@ -86,8 +85,7 @@ const useResponsiveBarStack = ({
|
|
|
86
85
|
padding: 0
|
|
87
86
|
})
|
|
88
87
|
: scaleLinear({
|
|
89
|
-
domain: [0, total]
|
|
90
|
-
nice: true
|
|
88
|
+
domain: [0, total]
|
|
91
89
|
});
|
|
92
90
|
|
|
93
91
|
const keys = pluck('label', data);
|
|
@@ -13,7 +13,7 @@ import { Tooltip } from '../../components';
|
|
|
13
13
|
import { Legend as LegendComponent } from '../Legend';
|
|
14
14
|
import { LegendProps } from '../Legend/models';
|
|
15
15
|
import { getValueByUnit } from '../common/utils';
|
|
16
|
-
import { labelNoDataFound } from '../translatedLabels';
|
|
16
|
+
import { labelNoDataFound as defaultlabelNoDataFound } from '../translatedLabels';
|
|
17
17
|
|
|
18
18
|
import { PieProps } from './models';
|
|
19
19
|
import { usePieStyles } from './PieChart.styles';
|
|
@@ -54,7 +54,8 @@ const ResponsivePie = ({
|
|
|
54
54
|
onArcClick,
|
|
55
55
|
displayValues,
|
|
56
56
|
TooltipContent,
|
|
57
|
-
legendDirection = 'column'
|
|
57
|
+
legendDirection = 'column',
|
|
58
|
+
labelNoDataFound = defaultlabelNoDataFound
|
|
58
59
|
}: PieProps & { height: number; width: number }): JSX.Element => {
|
|
59
60
|
const { t } = useTranslation();
|
|
60
61
|
const theme = useTheme();
|
|
@@ -109,7 +110,7 @@ const ResponsivePie = ({
|
|
|
109
110
|
>
|
|
110
111
|
{equals(variant, 'pie') && title && (
|
|
111
112
|
<div className={classes.title} data-testid="Title" ref={titleRef}>
|
|
112
|
-
{`${numeral(total).format('0a').toUpperCase()} `} {title}
|
|
113
|
+
{`${numeral(total).format('0a').toUpperCase()} `} {t(title)}
|
|
113
114
|
</div>
|
|
114
115
|
)}
|
|
115
116
|
<div
|
|
@@ -178,6 +179,7 @@ const ResponsivePie = ({
|
|
|
178
179
|
>
|
|
179
180
|
<g data-testid={arc.data.label} onClick={onClick}>
|
|
180
181
|
<path
|
|
182
|
+
cursor="pointer"
|
|
181
183
|
d={pie.path(arc) as string}
|
|
182
184
|
fill={arc.data.color}
|
|
183
185
|
/>
|
|
@@ -224,7 +226,7 @@ const ResponsivePie = ({
|
|
|
224
226
|
fill={theme.palette.text.primary}
|
|
225
227
|
textAnchor="middle"
|
|
226
228
|
>
|
|
227
|
-
{title}
|
|
229
|
+
{t(title)}
|
|
228
230
|
</Text>
|
|
229
231
|
</>
|
|
230
232
|
)}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { includes, map, prop, reject
|
|
1
|
+
import { includes, map, prop, reject } from 'ramda';
|
|
2
2
|
import { makeStyles } from 'tss-react/mui';
|
|
3
3
|
|
|
4
4
|
import { Chip, ChipProps, Tooltip } from '@mui/material';
|
|
@@ -85,11 +85,9 @@ const MultiAutocompleteField = ({
|
|
|
85
85
|
return includes(id, valueIds);
|
|
86
86
|
};
|
|
87
87
|
|
|
88
|
-
const sortByName = sortBy(compose(toLower, prop(optionProperty)));
|
|
89
|
-
|
|
90
88
|
const autocompleteOptions = disableSortedOptions
|
|
91
89
|
? options
|
|
92
|
-
:
|
|
90
|
+
: [...values, ...reject(isOptionSelected, options)];
|
|
93
91
|
|
|
94
92
|
return (
|
|
95
93
|
<Autocomplete
|
|
@@ -222,8 +222,7 @@ const AutocompleteField = React.forwardRef(
|
|
|
222
222
|
...params.inputProps,
|
|
223
223
|
'aria-label': label,
|
|
224
224
|
'data-testid': dataTestId || label,
|
|
225
|
-
id: getNormalizedId(label || '')
|
|
226
|
-
...autocompleteProps?.inputProps
|
|
225
|
+
id: getNormalizedId(label || '')
|
|
227
226
|
}}
|
|
228
227
|
label={label}
|
|
229
228
|
placeholder={isNil(placeholder) ? t(searchLabel) : placeholder}
|
|
@@ -6,16 +6,14 @@ import {
|
|
|
6
6
|
ClickAwayListener,
|
|
7
7
|
Paper,
|
|
8
8
|
Popper,
|
|
9
|
-
PopperPlacementType
|
|
9
|
+
PopperPlacementType,
|
|
10
|
+
useTheme
|
|
10
11
|
} from '@mui/material';
|
|
11
12
|
import { PopperProps } from '@mui/material/Popper';
|
|
12
13
|
|
|
13
14
|
import { IconButton } from '..';
|
|
14
15
|
|
|
15
|
-
const useStyles = makeStyles()((
|
|
16
|
-
popover: {
|
|
17
|
-
zIndex: theme.zIndex.tooltip
|
|
18
|
-
},
|
|
16
|
+
const useStyles = makeStyles()(() => ({
|
|
19
17
|
popoverIconButton: {
|
|
20
18
|
padding: 0,
|
|
21
19
|
width: '100%'
|
|
@@ -54,7 +52,7 @@ const PopoverMenu = ({
|
|
|
54
52
|
getPopoverData,
|
|
55
53
|
popperProps
|
|
56
54
|
}: Props): JSX.Element => {
|
|
57
|
-
|
|
55
|
+
const theme = useTheme();
|
|
58
56
|
const { classes, cx } = useStyles();
|
|
59
57
|
const [anchorEl, setAnchorEl] = useState<HTMLElement | undefined>();
|
|
60
58
|
const isOpen = Boolean(anchorEl);
|
|
@@ -107,9 +105,9 @@ const PopoverMenu = ({
|
|
|
107
105
|
<Popper
|
|
108
106
|
open
|
|
109
107
|
anchorEl={anchorEl}
|
|
110
|
-
className={classes.popover}
|
|
111
108
|
nonce={undefined}
|
|
112
109
|
placement={popperPlacement}
|
|
110
|
+
style={{ zIndex: theme.zIndex.tooltip }}
|
|
113
111
|
onResize={(): undefined => undefined}
|
|
114
112
|
onResizeCapture={(): undefined => undefined}
|
|
115
113
|
{...popperProps}
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { ForwardedRef, forwardRef, ReactElement, ReactNode } from 'react';
|
|
2
2
|
|
|
3
|
-
import {
|
|
3
|
+
import { ListItem as MuiListItem } from '@mui/material';
|
|
4
4
|
|
|
5
5
|
import { useStyles } from './ListItem.styles';
|
|
6
6
|
|
|
7
|
-
type
|
|
7
|
+
type ListItemProps = {
|
|
8
8
|
action?: ReactElement;
|
|
9
9
|
children: ReactNode | Array<ReactNode>;
|
|
10
10
|
className?: string;
|
|
@@ -12,7 +12,7 @@ type Props = {
|
|
|
12
12
|
|
|
13
13
|
export const ListItem = forwardRef(
|
|
14
14
|
(
|
|
15
|
-
{ action, children, className, ...attr }:
|
|
15
|
+
{ action, children, className, ...attr }: ListItemProps,
|
|
16
16
|
ref?: ForwardedRef<HTMLLIElement>
|
|
17
17
|
) => {
|
|
18
18
|
const { classes, cx } = useStyles();
|