@centreon/ui 25.10.28 → 25.10.30
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 +3 -3
- package/public/mockServiceWorker.js +8 -31
- package/src/Dashboard/Item.tsx +142 -149
- package/src/Form/Inputs/ConnectedAutocomplete.tsx +2 -0
- package/src/Form/Inputs/Grid.tsx +2 -3
- package/src/Form/Inputs/models.ts +2 -0
- package/src/Form/Section/navigateToSection.ts +6 -6
- package/src/Graph/BarChart/BarChart.cypress.spec.tsx +55 -102
- package/src/Graph/BarChart/BarChart.stories.tsx +1 -51
- package/src/Graph/BarChart/BarChart.tsx +1 -1
- package/src/Graph/BarChart/BarGroup.tsx +32 -22
- package/src/Graph/BarChart/BarStack.tsx +26 -15
- package/src/Graph/BarChart/MemoizedGroup.tsx +18 -14
- package/src/Graph/BarChart/ResponsiveBarChart.tsx +6 -7
- package/src/Graph/BarChart/Tooltip/BarChartTooltip.tsx +2 -2
- package/src/Graph/Chart/BasicComponents/Lines/StackedLines/index.tsx +5 -4
- package/src/Graph/Chart/BasicComponents/Lines/StackedLines/useStackedLines.ts +45 -18
- package/src/Graph/Chart/BasicComponents/Lines/index.tsx +118 -124
- package/src/Graph/Chart/Chart.cypress.spec.tsx +6 -25
- package/src/Graph/Chart/Chart.stories.tsx +1 -43
- package/src/Graph/Chart/Chart.tsx +13 -9
- package/src/Graph/Chart/InteractiveComponents/GraphValueTooltip/useGraphValueTooltip.ts +4 -2
- package/src/Graph/Chart/Legend/index.tsx +2 -26
- package/src/Graph/Chart/index.tsx +45 -31
- package/src/Graph/Chart/models.ts +1 -6
- package/src/Graph/Chart/translatedLabels.ts +1 -0
- package/src/Graph/Chart/useChartData.ts +24 -3
- package/src/Graph/common/Axes/index.tsx +1 -1
- package/src/Graph/common/BaseChart/BaseChart.tsx +1 -6
- package/src/Graph/common/BaseChart/ChartSvgWrapper.tsx +23 -16
- package/src/Graph/common/Error/NoData.tsx +18 -0
- package/src/Graph/common/Grids/index.tsx +4 -4
- package/src/Graph/common/timeSeries/index.test.ts +4 -24
- package/src/Graph/common/timeSeries/index.ts +120 -184
- package/src/Graph/common/timeSeries/models.ts +1 -1
- package/src/Graph/common/utils.ts +4 -10
- package/src/Graph/index.ts +20 -20
- package/src/InputField/Select/Autocomplete/Connected/index.tsx +9 -9
- package/src/InputField/Select/Autocomplete/Multi/Listbox.tsx +11 -3
- package/src/InputField/Select/Autocomplete/Multi/Multi.tsx +3 -2
- package/src/InputField/Select/Autocomplete/index.tsx +28 -17
- package/src/InputField/Select/Option.tsx +3 -3
- package/src/InputField/Select/index.tsx +2 -1
- package/src/Listing/ActionBar/Pagination.tsx +2 -1
- package/src/Listing/ActionBar/index.tsx +113 -8
- package/src/Listing/index.tsx +19 -2
- package/src/Listing/translatedLabels.ts +4 -0
- package/src/Module/index.tsx +2 -8
- package/src/ThemeProvider/index.tsx +21 -30
- package/src/ThemeProvider/tailwindcss.css +12 -10
- package/src/TimePeriods/CustomTimePeriod/PopoverCustomTimePeriod/PickersStartEndDate.tsx +8 -5
- package/src/TimePeriods/CustomTimePeriod/PopoverCustomTimePeriod/models.ts +0 -1
- package/src/api/useGraphQuery/index.ts +7 -4
- package/src/components/Form/AccessRights/ShareInput/ShareInput.tsx +4 -3
- package/src/components/Form/AccessRights/ShareInput/useShareInput.tsx +15 -10
- package/src/components/Layout/PageLayout/PageLayout.tsx +3 -9
- package/src/components/Layout/PageLayout/PageLayoutActions.tsx +3 -5
- package/src/components/Layout/PageLayout/PageLayoutBody.tsx +3 -5
- package/src/components/Layout/PageLayout/PageLayoutHeader.tsx +3 -5
- package/src/components/Layout/PageLayout/PageQuickAccess.tsx +44 -25
- package/src/components/Layout/PageLayout/translatedLabels.ts +1 -0
- package/src/components/Menu/Button/MenuButton.styles.ts +27 -0
- package/src/components/Menu/Button/MenuButton.tsx +5 -8
- package/src/components/Menu/Menu.styles.ts +68 -0
- package/src/components/Menu/MenuDivider.tsx +5 -1
- package/src/components/Menu/MenuItem.tsx +5 -1
- package/src/components/Menu/MenuItems.tsx +4 -5
- package/src/components/Modal/Modal.styles.ts +2 -1
- package/src/components/Modal/ModalHeader.tsx +1 -5
- package/src/utils/useInfiniteScrollListing.ts +11 -7
- package/src/utils/useViewportIntersection.ts +3 -4
- package/src/Graph/mockedData/dataWithMissingPoint.json +0 -74
- package/src/Graph/mockedData/pingServiceWithStackedKeys.json +0 -205
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@centreon/ui",
|
|
3
|
-
"version": "25.10.
|
|
3
|
+
"version": "25.10.30",
|
|
4
4
|
"description": "Centreon UI Components",
|
|
5
5
|
"scripts": {
|
|
6
6
|
"update:deps": "pnpx npm-check-updates -i --format group",
|
|
@@ -28,8 +28,8 @@
|
|
|
28
28
|
"url": "git+https://github.com/centreon/centreon.git"
|
|
29
29
|
},
|
|
30
30
|
"keywords": [
|
|
31
|
-
"
|
|
32
|
-
"
|
|
31
|
+
"react",
|
|
32
|
+
"centreon"
|
|
33
33
|
],
|
|
34
34
|
"author": {
|
|
35
35
|
"name": "centreon@centreon.com"
|
|
@@ -8,8 +8,8 @@
|
|
|
8
8
|
* - Please do NOT serve this file on production.
|
|
9
9
|
*/
|
|
10
10
|
|
|
11
|
-
const PACKAGE_VERSION = '2.
|
|
12
|
-
const INTEGRITY_CHECKSUM = '
|
|
11
|
+
const PACKAGE_VERSION = '2.2.14'
|
|
12
|
+
const INTEGRITY_CHECKSUM = '26357c79639bfa20d64c0efca2a87423'
|
|
13
13
|
const IS_MOCKED_RESPONSE = Symbol('isMockedResponse')
|
|
14
14
|
const activeClientIds = new Set()
|
|
15
15
|
|
|
@@ -62,12 +62,7 @@ self.addEventListener('message', async function (event) {
|
|
|
62
62
|
|
|
63
63
|
sendToClient(client, {
|
|
64
64
|
type: 'MOCKING_ENABLED',
|
|
65
|
-
payload:
|
|
66
|
-
client: {
|
|
67
|
-
id: client.id,
|
|
68
|
-
frameType: client.frameType,
|
|
69
|
-
},
|
|
70
|
-
},
|
|
65
|
+
payload: true,
|
|
71
66
|
})
|
|
72
67
|
break
|
|
73
68
|
}
|
|
@@ -160,10 +155,6 @@ async function handleRequest(event, requestId) {
|
|
|
160
155
|
async function resolveMainClient(event) {
|
|
161
156
|
const client = await self.clients.get(event.clientId)
|
|
162
157
|
|
|
163
|
-
if (activeClientIds.has(event.clientId)) {
|
|
164
|
-
return client
|
|
165
|
-
}
|
|
166
|
-
|
|
167
158
|
if (client?.frameType === 'top-level') {
|
|
168
159
|
return client
|
|
169
160
|
}
|
|
@@ -192,26 +183,12 @@ async function getResponse(event, client, requestId) {
|
|
|
192
183
|
const requestClone = request.clone()
|
|
193
184
|
|
|
194
185
|
function passthrough() {
|
|
195
|
-
|
|
196
|
-
// so the headers can be manipulated with.
|
|
197
|
-
const headers = new Headers(requestClone.headers)
|
|
198
|
-
|
|
199
|
-
// Remove the "accept" header value that marked this request as passthrough.
|
|
200
|
-
// This prevents request alteration and also keeps it compliant with the
|
|
201
|
-
// user-defined CORS policies.
|
|
202
|
-
const acceptHeader = headers.get('accept')
|
|
203
|
-
if (acceptHeader) {
|
|
204
|
-
const values = acceptHeader.split(',').map((value) => value.trim())
|
|
205
|
-
const filteredValues = values.filter(
|
|
206
|
-
(value) => value !== 'msw/passthrough',
|
|
207
|
-
)
|
|
186
|
+
const headers = Object.fromEntries(requestClone.headers.entries())
|
|
208
187
|
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
}
|
|
214
|
-
}
|
|
188
|
+
// Remove internal MSW request header so the passthrough request
|
|
189
|
+
// complies with any potential CORS preflight checks on the server.
|
|
190
|
+
// Some servers forbid unknown request headers.
|
|
191
|
+
delete headers['x-msw-intention']
|
|
215
192
|
|
|
216
193
|
return fetch(requestClone, { headers })
|
|
217
194
|
}
|
package/src/Dashboard/Item.tsx
CHANGED
|
@@ -1,28 +1,29 @@
|
|
|
1
|
+
import { Card, useTheme } from '@mui/material';
|
|
2
|
+
|
|
3
|
+
import { useAtomValue } from 'jotai';
|
|
4
|
+
import { equals, isNil, omit, type } from 'ramda';
|
|
1
5
|
import {
|
|
2
|
-
CSSProperties,
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
forwardRef,
|
|
6
|
+
type CSSProperties,
|
|
7
|
+
type MouseEvent,
|
|
8
|
+
type ReactElement,
|
|
9
|
+
RefObject,
|
|
7
10
|
useEffect,
|
|
8
11
|
useMemo
|
|
9
12
|
} from 'react';
|
|
10
13
|
|
|
11
|
-
import { useAtomValue } from 'jotai';
|
|
12
|
-
import { equals, isNil, omit, type } from 'ramda';
|
|
13
|
-
|
|
14
|
-
import { Card, useTheme } from '@mui/material';
|
|
15
|
-
import LoadingSkeleton from '../LoadingSkeleton';
|
|
16
14
|
import ExpandableContainer from '../components/ExpandableContainer';
|
|
17
|
-
import { Parameters } from '../components/ExpandableContainer/models';
|
|
15
|
+
import type { Parameters } from '../components/ExpandableContainer/models';
|
|
18
16
|
import { useMemoComponent, useViewportIntersection } from '../utils';
|
|
19
|
-
import { useDashboardItemStyles } from './Dashboard.styles';
|
|
20
17
|
import { isResizingItemAtom } from './atoms';
|
|
18
|
+
import { useDashboardItemStyles } from './Dashboard.styles';
|
|
21
19
|
|
|
22
20
|
interface DashboardItemProps {
|
|
23
21
|
additionalMemoProps?: Array<unknown>;
|
|
24
22
|
canMove?: boolean;
|
|
25
|
-
children:
|
|
23
|
+
children: Array<
|
|
24
|
+
| ReactElement
|
|
25
|
+
| (({ isInViewport }: { isInViewport: boolean }) => ReactElement)
|
|
26
|
+
>;
|
|
26
27
|
className?: string;
|
|
27
28
|
disablePadding?: boolean;
|
|
28
29
|
header?: ReactElement | ((params: Parameters) => ReactElement);
|
|
@@ -31,148 +32,140 @@ interface DashboardItemProps {
|
|
|
31
32
|
onMouseUp?: (e: MouseEvent<HTMLDivElement>) => void;
|
|
32
33
|
onTouchEnd?: (e) => void;
|
|
33
34
|
style?: CSSProperties;
|
|
35
|
+
ref?: RefObject<HTMLDivElement>;
|
|
34
36
|
}
|
|
35
37
|
|
|
36
|
-
const Item =
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
)
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
)
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
data-padding={!disablePadding}
|
|
123
|
-
>
|
|
124
|
-
{childrenHeader && (
|
|
125
|
-
<div
|
|
126
|
-
className={classes.widgetHeader}
|
|
127
|
-
data-can-move={canControl}
|
|
128
|
-
>
|
|
129
|
-
{canControl && (
|
|
130
|
-
<div
|
|
131
|
-
{...listeners}
|
|
132
|
-
className={classes.widgetHeaderDraggable}
|
|
133
|
-
data-testid={`${id}_move_panel`}
|
|
134
|
-
/>
|
|
135
|
-
)}
|
|
136
|
-
{childrenHeader}
|
|
137
|
-
</div>
|
|
138
|
-
)}
|
|
38
|
+
const Item = ({
|
|
39
|
+
children,
|
|
40
|
+
style,
|
|
41
|
+
className,
|
|
42
|
+
header,
|
|
43
|
+
onMouseDown,
|
|
44
|
+
onMouseUp,
|
|
45
|
+
onTouchEnd,
|
|
46
|
+
id,
|
|
47
|
+
disablePadding = false,
|
|
48
|
+
canMove = false,
|
|
49
|
+
additionalMemoProps = [],
|
|
50
|
+
ref
|
|
51
|
+
}: DashboardItemProps): ReactElement => {
|
|
52
|
+
const { isInViewport, setElement } = useViewportIntersection({
|
|
53
|
+
rootMargin: '140px 0px 140px 0px'
|
|
54
|
+
});
|
|
55
|
+
const hasHeader = !isNil(header);
|
|
56
|
+
|
|
57
|
+
const { classes, cx } = useDashboardItemStyles({ hasHeader });
|
|
58
|
+
const theme = useTheme();
|
|
59
|
+
|
|
60
|
+
const isResizingItem = useAtomValue(isResizingItemAtom);
|
|
61
|
+
|
|
62
|
+
const isResizing = useMemo(
|
|
63
|
+
() => equals(id, isResizingItem),
|
|
64
|
+
[isResizingItem, id]
|
|
65
|
+
);
|
|
66
|
+
|
|
67
|
+
const sanitizedReactGridLayoutClassName = useMemo(
|
|
68
|
+
() => (isResizing ? className : className?.replace(' resizing ', '')),
|
|
69
|
+
[className, isResizing]
|
|
70
|
+
);
|
|
71
|
+
|
|
72
|
+
const listeners = {
|
|
73
|
+
onMouseDown,
|
|
74
|
+
onMouseUp,
|
|
75
|
+
onTouchEnd
|
|
76
|
+
};
|
|
77
|
+
|
|
78
|
+
const cardContainerListeners = !hasHeader ? listeners : {};
|
|
79
|
+
|
|
80
|
+
useEffect(() => {
|
|
81
|
+
if (isNil(ref?.current)) {
|
|
82
|
+
return;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
setElement(ref.current);
|
|
86
|
+
}, [ref, setElement]);
|
|
87
|
+
|
|
88
|
+
const newTransform =
|
|
89
|
+
style?.transform &&
|
|
90
|
+
`translate3d(${style.transform.match(/translate\(([a-z0-9 ,-]+)\)/)?.[1]}, 0px)`;
|
|
91
|
+
|
|
92
|
+
return useMemoComponent({
|
|
93
|
+
Component: (
|
|
94
|
+
<div
|
|
95
|
+
{...cardContainerListeners}
|
|
96
|
+
className={sanitizedReactGridLayoutClassName}
|
|
97
|
+
ref={ref}
|
|
98
|
+
style={{
|
|
99
|
+
...omit(['transform'], style || {}),
|
|
100
|
+
transform: newTransform
|
|
101
|
+
}}
|
|
102
|
+
>
|
|
103
|
+
<ExpandableContainer>
|
|
104
|
+
{({ isExpanded, label, key, ...rest }) => {
|
|
105
|
+
const canControl = isExpanded ? false : canMove;
|
|
106
|
+
|
|
107
|
+
const childrenHeader = equals(type(header), 'Function')
|
|
108
|
+
? (header as (params: Parameters) => ReactElement)({
|
|
109
|
+
isExpanded,
|
|
110
|
+
key,
|
|
111
|
+
label,
|
|
112
|
+
ref: ref as RefObject<HTMLDivElement>,
|
|
113
|
+
...rest
|
|
114
|
+
})
|
|
115
|
+
: (header as ReactElement);
|
|
116
|
+
|
|
117
|
+
return (
|
|
118
|
+
<div className={classes.widgetSubContainer} key={key}>
|
|
119
|
+
<Card
|
|
120
|
+
className={classes.widgetContainer}
|
|
121
|
+
data-padding={!disablePadding}
|
|
122
|
+
>
|
|
123
|
+
{childrenHeader && (
|
|
139
124
|
<div
|
|
140
|
-
className={
|
|
141
|
-
|
|
142
|
-
!disablePadding && classes.widgetPadding
|
|
143
|
-
)}
|
|
125
|
+
className={classes.widgetHeader}
|
|
126
|
+
data-can-move={canControl}
|
|
144
127
|
>
|
|
145
|
-
{
|
|
146
|
-
<
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
width="100%"
|
|
128
|
+
{canControl && (
|
|
129
|
+
<div
|
|
130
|
+
{...listeners}
|
|
131
|
+
className={classes.widgetHeaderDraggable}
|
|
132
|
+
data-testid={`${id}_move_panel`}
|
|
151
133
|
/>
|
|
152
|
-
) : (
|
|
153
|
-
children
|
|
154
134
|
)}
|
|
135
|
+
{childrenHeader}
|
|
155
136
|
</div>
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
137
|
+
)}
|
|
138
|
+
<div
|
|
139
|
+
className={cx(
|
|
140
|
+
classes.widgetContent,
|
|
141
|
+
!disablePadding && classes.widgetPadding
|
|
142
|
+
)}
|
|
143
|
+
>
|
|
144
|
+
{children.map((child) =>
|
|
145
|
+
typeof child === 'function'
|
|
146
|
+
? child({ isInViewport })
|
|
147
|
+
: child
|
|
148
|
+
)}
|
|
149
|
+
</div>
|
|
150
|
+
</Card>
|
|
151
|
+
</div>
|
|
152
|
+
);
|
|
153
|
+
}}
|
|
154
|
+
</ExpandableContainer>
|
|
155
|
+
</div>
|
|
156
|
+
),
|
|
157
|
+
memoProps: isInViewport
|
|
158
|
+
? [
|
|
159
|
+
style,
|
|
160
|
+
className,
|
|
161
|
+
header,
|
|
162
|
+
theme.palette.mode,
|
|
163
|
+
canMove,
|
|
164
|
+
isInViewport,
|
|
165
|
+
...additionalMemoProps
|
|
166
|
+
]
|
|
167
|
+
: [isInViewport, theme.palette.mode, style]
|
|
168
|
+
});
|
|
169
|
+
};
|
|
177
170
|
|
|
178
171
|
export default Item;
|
|
@@ -137,6 +137,8 @@ const ConnectedAutocomplete = ({
|
|
|
137
137
|
getEndpoint={getEndpoint}
|
|
138
138
|
decoder={connectedAutocomplete?.decoder}
|
|
139
139
|
getRenderedOptionText={connectedAutocomplete?.getRenderedOptionText}
|
|
140
|
+
getOptionLabel={connectedAutocomplete?.getOptionLabel}
|
|
141
|
+
optionProperty={connectedAutocomplete?.optionProperty}
|
|
140
142
|
initialPage={1}
|
|
141
143
|
isOptionEqualToValue={isOptionEqualToValue}
|
|
142
144
|
label={t(label)}
|
package/src/Form/Inputs/Grid.tsx
CHANGED
|
@@ -21,9 +21,8 @@ const Grid = ({
|
|
|
21
21
|
<div
|
|
22
22
|
className={`${className} grid gap-3`}
|
|
23
23
|
style={{
|
|
24
|
-
gridTemplateColumns:
|
|
25
|
-
? grid?.gridTemplateColumns || undefined
|
|
26
|
-
: grid?.gridTemplateColumns ||
|
|
24
|
+
gridTemplateColumns:
|
|
25
|
+
className ? grid?.gridTemplateColumns || undefined : grid?.gridTemplateColumns ||
|
|
27
26
|
`repeat(${grid?.columns.length || 1}, 1fr)`,
|
|
28
27
|
alignItems: grid?.alignItems || 'flex-start'
|
|
29
28
|
}}
|
|
@@ -62,6 +62,8 @@ export interface InputProps {
|
|
|
62
62
|
endpoint?: string;
|
|
63
63
|
filterKey?: string;
|
|
64
64
|
getRenderedOptionText?: (option) => string | JSX.Element;
|
|
65
|
+
getOptionLabel?: (option) => string;
|
|
66
|
+
optionProperty?: string;
|
|
65
67
|
disableSelectAll?: boolean;
|
|
66
68
|
limitTags?: number;
|
|
67
69
|
decoder?;
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
export const useNavigateToSection = () => {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
2
|
+
return (sectionName: string) => {
|
|
3
|
+
const section = document.querySelector(
|
|
4
|
+
`[data-section-group-form-id="${sectionName}"]`
|
|
5
|
+
);
|
|
6
6
|
|
|
7
|
-
|
|
8
|
-
|
|
7
|
+
section?.scrollIntoView({ behavior: 'smooth' });
|
|
8
|
+
};
|
|
9
9
|
};
|
|
@@ -4,12 +4,10 @@ import { useAtomValue } from 'jotai';
|
|
|
4
4
|
|
|
5
5
|
import { userAtom } from '@centreon/ui-context';
|
|
6
6
|
|
|
7
|
-
import dataMissingPoint from '../mockedData/dataWithMissingPoint.json';
|
|
8
7
|
import dataLastWeek from '../mockedData/lastWeek.json';
|
|
9
8
|
import dataPingService from '../mockedData/pingService.json';
|
|
10
9
|
import dataPingServiceMixedStacked from '../mockedData/pingServiceMixedStacked.json';
|
|
11
10
|
import dataPingServiceStacked from '../mockedData/pingServiceStacked.json';
|
|
12
|
-
import dataPingServiceLinesStackKeys from '../mockedData/pingServiceWithStackedKeys.json';
|
|
13
11
|
|
|
14
12
|
import BarChart, { BarChartProps } from './BarChart';
|
|
15
13
|
|
|
@@ -86,6 +84,61 @@ const checkWidth = (orientation): void => {
|
|
|
86
84
|
};
|
|
87
85
|
|
|
88
86
|
describe('Bar chart', () => {
|
|
87
|
+
it('displays a tooltip when a single bar is hovered', () => {
|
|
88
|
+
initialize({
|
|
89
|
+
orientation: 'horizontal'
|
|
90
|
+
});
|
|
91
|
+
|
|
92
|
+
checkWidth('horizontal');
|
|
93
|
+
cy.contains('0 ms').should('be.visible');
|
|
94
|
+
cy.contains('20').should('be.visible');
|
|
95
|
+
cy.contains(':40 AM').should('be.visible');
|
|
96
|
+
|
|
97
|
+
cy.findByTestId('stacked-bar-10-0-7650.368581547736').realHover();
|
|
98
|
+
|
|
99
|
+
cy.contains('06/19/2024').should('be.visible');
|
|
100
|
+
cy.contains('Centreon-Server: Round-Trip Maximum Time').should(
|
|
101
|
+
'be.visible'
|
|
102
|
+
);
|
|
103
|
+
cy.contains('7.47 KiB').should('be.visible');
|
|
104
|
+
|
|
105
|
+
cy.makeSnapshot();
|
|
106
|
+
});
|
|
107
|
+
|
|
108
|
+
it('displays a tooltip when a stacked bar is hovered', () => {
|
|
109
|
+
initialize({
|
|
110
|
+
data: dataPingServiceStacked,
|
|
111
|
+
orientation: 'horizontal',
|
|
112
|
+
tooltip: {
|
|
113
|
+
mode: 'all',
|
|
114
|
+
sortOrder: 'ascending'
|
|
115
|
+
}
|
|
116
|
+
});
|
|
117
|
+
|
|
118
|
+
checkWidth('horizontal');
|
|
119
|
+
cy.contains('0 ms').should('be.visible');
|
|
120
|
+
cy.contains('20').should('be.visible');
|
|
121
|
+
cy.contains(':40 AM').should('be.visible');
|
|
122
|
+
|
|
123
|
+
cy.findByTestId('stacked-bar-1-0-0.05296').realHover();
|
|
124
|
+
|
|
125
|
+
cy.contains('06/19/2024').should('be.visible');
|
|
126
|
+
cy.contains('Centreon-Server: Round-Trip Maximum Time').should(
|
|
127
|
+
'be.visible'
|
|
128
|
+
);
|
|
129
|
+
cy.contains('Centreon-Server: Round-Trip Average Time').should(
|
|
130
|
+
'be.visible'
|
|
131
|
+
);
|
|
132
|
+
cy.contains('Centreon-Server: Round-Trip Minimum Time').should(
|
|
133
|
+
'be.visible'
|
|
134
|
+
);
|
|
135
|
+
cy.contains('0.05 ms').should('be.visible');
|
|
136
|
+
cy.contains('0.02 ms').should('be.visible');
|
|
137
|
+
cy.contains('0.11 ms').should('be.visible');
|
|
138
|
+
|
|
139
|
+
cy.findByTestId('stacked-bar-3-0-0.16196').should('be.visible');
|
|
140
|
+
});
|
|
141
|
+
|
|
89
142
|
['horizontal', 'vertical'].forEach((orientation) => {
|
|
90
143
|
it(`displays the bar chart ${orientation}ly`, () => {
|
|
91
144
|
initialize({ orientation });
|
|
@@ -185,27 +238,6 @@ describe('Bar chart', () => {
|
|
|
185
238
|
});
|
|
186
239
|
});
|
|
187
240
|
|
|
188
|
-
it('displays a tooltip when a single bar is hovered', () => {
|
|
189
|
-
initialize({
|
|
190
|
-
orientation: 'horizontal'
|
|
191
|
-
});
|
|
192
|
-
|
|
193
|
-
checkWidth('horizontal');
|
|
194
|
-
cy.contains('0 ms').should('be.visible');
|
|
195
|
-
cy.contains('20').should('be.visible');
|
|
196
|
-
cy.contains(':40 AM').should('be.visible');
|
|
197
|
-
|
|
198
|
-
cy.findByTestId('stacked-bar-10-0-7650.368581547736').realHover();
|
|
199
|
-
|
|
200
|
-
cy.contains('06/19/2024').should('be.visible');
|
|
201
|
-
cy.contains('Centreon-Server: Round-Trip Maximum Time').should(
|
|
202
|
-
'be.visible'
|
|
203
|
-
);
|
|
204
|
-
cy.contains('7.47 KB').should('be.visible');
|
|
205
|
-
|
|
206
|
-
cy.makeSnapshot();
|
|
207
|
-
});
|
|
208
|
-
|
|
209
241
|
it('does not display a tooltip when a bar is hovered and a props is set', () => {
|
|
210
242
|
initialize({
|
|
211
243
|
data: dataPingServiceStacked,
|
|
@@ -230,68 +262,6 @@ describe('Bar chart', () => {
|
|
|
230
262
|
cy.makeSnapshot();
|
|
231
263
|
});
|
|
232
264
|
|
|
233
|
-
it('displays a tooltip when a stacked bar is hovered', () => {
|
|
234
|
-
initialize({
|
|
235
|
-
data: dataPingServiceStacked,
|
|
236
|
-
orientation: 'horizontal',
|
|
237
|
-
tooltip: {
|
|
238
|
-
mode: 'all',
|
|
239
|
-
sortOrder: 'ascending'
|
|
240
|
-
}
|
|
241
|
-
});
|
|
242
|
-
|
|
243
|
-
checkWidth('horizontal');
|
|
244
|
-
cy.contains('0 ms').should('be.visible');
|
|
245
|
-
cy.contains('20').should('be.visible');
|
|
246
|
-
cy.contains(':40 AM').should('be.visible');
|
|
247
|
-
|
|
248
|
-
cy.findByTestId('stacked-bar-1-0-0.05296').realHover();
|
|
249
|
-
|
|
250
|
-
cy.contains('06/19/2024').should('be.visible');
|
|
251
|
-
cy.contains('Centreon-Server: Round-Trip Maximum Time').should(
|
|
252
|
-
'be.visible'
|
|
253
|
-
);
|
|
254
|
-
cy.contains('Centreon-Server: Round-Trip Average Time').should(
|
|
255
|
-
'be.visible'
|
|
256
|
-
);
|
|
257
|
-
cy.contains('Centreon-Server: Round-Trip Minimum Time').should(
|
|
258
|
-
'be.visible'
|
|
259
|
-
);
|
|
260
|
-
cy.contains('0.05 ms').should('be.visible');
|
|
261
|
-
cy.contains('0.02 ms').should('be.visible');
|
|
262
|
-
cy.contains('0.11 ms').should('be.visible');
|
|
263
|
-
|
|
264
|
-
cy.findByTestId('stacked-bar-3-0-0.16196').should('be.visible');
|
|
265
|
-
});
|
|
266
|
-
|
|
267
|
-
it('displays a tooltip with a single metric when a stacked bar is hovered and a prop is set', () => {
|
|
268
|
-
initialize({
|
|
269
|
-
data: dataPingServiceStacked,
|
|
270
|
-
orientation: 'horizontal',
|
|
271
|
-
tooltip: {
|
|
272
|
-
mode: 'single',
|
|
273
|
-
sortOrder: 'descending'
|
|
274
|
-
}
|
|
275
|
-
});
|
|
276
|
-
|
|
277
|
-
checkWidth('horizontal');
|
|
278
|
-
cy.contains('0 ms').should('be.visible');
|
|
279
|
-
cy.contains('20').should('be.visible');
|
|
280
|
-
cy.contains(':40 AM').should('be.visible');
|
|
281
|
-
|
|
282
|
-
cy.findByTestId('stacked-bar-1-0-0.05296').realHover();
|
|
283
|
-
|
|
284
|
-
cy.contains('06/19/2024').should('be.visible');
|
|
285
|
-
cy.contains('Centreon-Server: Round-Trip Average Time').should(
|
|
286
|
-
'be.visible'
|
|
287
|
-
);
|
|
288
|
-
cy.contains('0.05 ms').should('be.visible');
|
|
289
|
-
|
|
290
|
-
cy.findByTestId('stacked-bar-3-0-0.16196').should('be.visible');
|
|
291
|
-
|
|
292
|
-
cy.makeSnapshot();
|
|
293
|
-
});
|
|
294
|
-
|
|
295
265
|
it('displays the bottom axis correctly when data starts from several days ago', () => {
|
|
296
266
|
initialize({
|
|
297
267
|
data: dataLastWeek,
|
|
@@ -314,21 +284,4 @@ describe('Bar chart', () => {
|
|
|
314
284
|
cy.contains('1 s').should('be.visible');
|
|
315
285
|
cy.contains('1%').should('be.visible');
|
|
316
286
|
});
|
|
317
|
-
|
|
318
|
-
it('displays the stacked bar chart correctly when a point is missing compare to the time serie', () => {
|
|
319
|
-
initialize({ data: dataMissingPoint });
|
|
320
|
-
|
|
321
|
-
cy.findByTestId('stacked-bar-2-0-139').should('be.visible');
|
|
322
|
-
|
|
323
|
-
cy.makeSnapshot();
|
|
324
|
-
});
|
|
325
|
-
|
|
326
|
-
it('displays the stacked bar chart with bars stacked together', () => {
|
|
327
|
-
initialize({ data: dataPingServiceLinesStackKeys });
|
|
328
|
-
|
|
329
|
-
cy.findByTestId('stacked-bar-3-0-0.05336').should('be.visible');
|
|
330
|
-
cy.findByTestId('stacked-bar-4-0-0.06684').should('be.visible');
|
|
331
|
-
|
|
332
|
-
cy.makeSnapshot();
|
|
333
|
-
});
|
|
334
287
|
});
|