@centreon/ui 24.10.3 → 24.10.4
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 +4 -3
- package/src/Dashboard/Grid.tsx +17 -11
- package/src/Dashboard/Layout.tsx +56 -27
- package/src/Graph/BarChart/BarChart.tsx +4 -1
- package/src/Graph/BarChart/ResponsiveBarChart.tsx +3 -2
- package/src/Graph/Chart/Chart.tsx +3 -2
- package/src/Graph/Chart/index.tsx +1 -0
- package/src/Graph/Chart/models.ts +1 -0
- package/src/components/Layout/PageLayout/PageLayout.styles.ts +5 -1
- package/src/components/Layout/PageLayout/PageLayoutBody.tsx +1 -0
package/package.json
CHANGED
|
@@ -40,7 +40,7 @@ export const useDashboardLayoutStyles = makeStyles<boolean>()(
|
|
|
40
40
|
width: theme.spacing(1)
|
|
41
41
|
},
|
|
42
42
|
'& .react-resizable-handle.react-resizable-handle-s': {
|
|
43
|
-
bottom:
|
|
43
|
+
bottom: 4,
|
|
44
44
|
cursor: 'ns-resize',
|
|
45
45
|
height: theme.spacing(1),
|
|
46
46
|
left: 0,
|
|
@@ -49,7 +49,7 @@ export const useDashboardLayoutStyles = makeStyles<boolean>()(
|
|
|
49
49
|
width: `calc(100% - ${theme.spacing(3)})`
|
|
50
50
|
},
|
|
51
51
|
'& .react-resizable-handle.react-resizable-handle-se': {
|
|
52
|
-
bottom:
|
|
52
|
+
bottom: 4,
|
|
53
53
|
cursor: 'nwse-resize',
|
|
54
54
|
height: theme.spacing(2),
|
|
55
55
|
right: 0,
|
|
@@ -62,7 +62,8 @@ export const useDashboardLayoutStyles = makeStyles<boolean>()(
|
|
|
62
62
|
'& .react-resizable-handle:hover': {
|
|
63
63
|
opacity: 1
|
|
64
64
|
},
|
|
65
|
-
position: 'relative'
|
|
65
|
+
position: 'relative',
|
|
66
|
+
height: '100%',
|
|
66
67
|
}
|
|
67
68
|
})
|
|
68
69
|
);
|
package/src/Dashboard/Grid.tsx
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ReactElement, useMemo } from 'react';
|
|
1
|
+
import { MutableRefObject, ReactElement, useMemo } from 'react';
|
|
2
2
|
|
|
3
3
|
import { scaleLinear } from '@visx/scale';
|
|
4
4
|
import { Grid as VisxGrid } from '@visx/visx';
|
|
@@ -13,9 +13,15 @@ interface Props {
|
|
|
13
13
|
columns: number;
|
|
14
14
|
height: number;
|
|
15
15
|
width: number;
|
|
16
|
+
containerRef: MutableRefObject<HTMLDivElement | null>;
|
|
16
17
|
}
|
|
17
18
|
|
|
18
|
-
const Grid = ({
|
|
19
|
+
const Grid = ({
|
|
20
|
+
width,
|
|
21
|
+
height,
|
|
22
|
+
columns,
|
|
23
|
+
containerRef
|
|
24
|
+
}: Props): ReactElement => {
|
|
19
25
|
const theme = useTheme();
|
|
20
26
|
|
|
21
27
|
const xScale = useMemo(
|
|
@@ -44,19 +50,19 @@ const Grid = ({ width, height, columns }: Props): ReactElement => {
|
|
|
44
50
|
.fill(0)
|
|
45
51
|
.map((_, index) => index * tick);
|
|
46
52
|
|
|
53
|
+
const yTickValues = Array(numberOfRows)
|
|
54
|
+
.fill(0)
|
|
55
|
+
.map((_, index) => index);
|
|
56
|
+
|
|
47
57
|
return useMemoComponent({
|
|
48
58
|
Component: (
|
|
49
59
|
<svg style={{ height, position: 'absolute', width }}>
|
|
50
|
-
<VisxGrid.
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
stroke={theme.palette.divider}
|
|
54
|
-
tickValues={xTickValues}
|
|
55
|
-
width={width}
|
|
56
|
-
/>
|
|
57
|
-
<VisxGrid.GridRows
|
|
60
|
+
<VisxGrid.Grid
|
|
61
|
+
columnTickValues={xTickValues}
|
|
62
|
+
rowTickValues={yTickValues}
|
|
58
63
|
height={height}
|
|
59
|
-
|
|
64
|
+
yScale={yScale}
|
|
65
|
+
xScale={xScale}
|
|
60
66
|
stroke={theme.palette.divider}
|
|
61
67
|
top={-10}
|
|
62
68
|
width={width}
|
package/src/Dashboard/Layout.tsx
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { useCallback, useEffect, useState } from 'react';
|
|
1
|
+
import { useCallback, useEffect, useMemo, useRef, useState } from 'react';
|
|
2
2
|
|
|
3
3
|
import { useSetAtom } from 'jotai';
|
|
4
4
|
import GridLayout, { Layout, WidthProvider } from 'react-grid-layout';
|
|
@@ -6,10 +6,10 @@ import 'react-grid-layout/css/styles.css';
|
|
|
6
6
|
|
|
7
7
|
import {
|
|
8
8
|
ParentSize,
|
|
9
|
-
Responsive as ResponsiveHeight,
|
|
10
9
|
useMemoComponent
|
|
11
10
|
} from '..';
|
|
12
11
|
|
|
12
|
+
import { Box } from '@mui/material';
|
|
13
13
|
import { useDashboardLayoutStyles } from './Dashboard.styles';
|
|
14
14
|
import Grid from './Grid';
|
|
15
15
|
import { isResizingItemAtom } from './atoms';
|
|
@@ -26,6 +26,18 @@ interface DashboardLayoutProps<T> {
|
|
|
26
26
|
layout: Array<T>;
|
|
27
27
|
}
|
|
28
28
|
|
|
29
|
+
const bottom = (layout: Array<Layout>): number => {
|
|
30
|
+
let max = 0;
|
|
31
|
+
let bottomY = 0;
|
|
32
|
+
|
|
33
|
+
layout.forEach((panel) => {
|
|
34
|
+
bottomY = panel.y + panel.h;
|
|
35
|
+
if (bottomY > max) max = bottomY;
|
|
36
|
+
})
|
|
37
|
+
|
|
38
|
+
return max;
|
|
39
|
+
}
|
|
40
|
+
|
|
29
41
|
const DashboardLayout = <T extends Layout>({
|
|
30
42
|
children,
|
|
31
43
|
changeLayout,
|
|
@@ -34,6 +46,8 @@ const DashboardLayout = <T extends Layout>({
|
|
|
34
46
|
isStatic = false,
|
|
35
47
|
additionalMemoProps = []
|
|
36
48
|
}: DashboardLayoutProps<T>): JSX.Element => {
|
|
49
|
+
const dashboardContainerRef = useRef<HTMLDivElement | null>(null);
|
|
50
|
+
|
|
37
51
|
const { classes } = useDashboardLayoutStyles(isStatic);
|
|
38
52
|
|
|
39
53
|
const [columns, setColumns] = useState(getColumnsFromScreenSize());
|
|
@@ -52,6 +66,16 @@ const DashboardLayout = <T extends Layout>({
|
|
|
52
66
|
setIsResizingItem(null);
|
|
53
67
|
}, []);
|
|
54
68
|
|
|
69
|
+
const containerHeight = useMemo((): number | undefined => {
|
|
70
|
+
const nbRow = bottom(getLayout(layout));
|
|
71
|
+
const containerPaddingY = 4
|
|
72
|
+
return (
|
|
73
|
+
nbRow * rowHeight +
|
|
74
|
+
(nbRow - 1) * 20 +
|
|
75
|
+
containerPaddingY * 2
|
|
76
|
+
);
|
|
77
|
+
}, [layout, rowHeight])
|
|
78
|
+
|
|
55
79
|
useEffect(() => {
|
|
56
80
|
window.addEventListener('resize', resize);
|
|
57
81
|
|
|
@@ -62,31 +86,36 @@ const DashboardLayout = <T extends Layout>({
|
|
|
62
86
|
|
|
63
87
|
return useMemoComponent({
|
|
64
88
|
Component: (
|
|
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
|
-
|
|
89
|
+
<Box ref={dashboardContainerRef} sx={{ overflowY: 'auto', overflowX: 'hidden' }}>
|
|
90
|
+
<ParentSize>
|
|
91
|
+
{({ width, height }): JSX.Element => (
|
|
92
|
+
<Box className={classes.container}>
|
|
93
|
+
{displayGrid && (
|
|
94
|
+
<Grid
|
|
95
|
+
columns={columns}
|
|
96
|
+
height={(containerHeight || 0) > height ? containerHeight : height}
|
|
97
|
+
width={width}
|
|
98
|
+
containerRef={dashboardContainerRef}
|
|
99
|
+
/>
|
|
100
|
+
)}
|
|
101
|
+
<ReactGridLayout
|
|
102
|
+
cols={columns}
|
|
103
|
+
containerPadding={[4, 0]}
|
|
104
|
+
layout={getLayout(layout)}
|
|
105
|
+
margin={[20, 20]}
|
|
106
|
+
resizeHandles={['s', 'e', 'se']}
|
|
107
|
+
rowHeight={rowHeight}
|
|
108
|
+
width={width}
|
|
109
|
+
onLayoutChange={changeLayout}
|
|
110
|
+
onResizeStart={startResize}
|
|
111
|
+
onResizeStop={stopResize}
|
|
112
|
+
>
|
|
113
|
+
{children}
|
|
114
|
+
</ReactGridLayout>
|
|
115
|
+
</Box>
|
|
116
|
+
)}
|
|
117
|
+
</ParentSize>
|
|
118
|
+
</Box>
|
|
90
119
|
),
|
|
91
120
|
memoProps: [columns, layout, displayGrid, isStatic, ...additionalMemoProps]
|
|
92
121
|
});
|
|
@@ -38,6 +38,7 @@ export interface BarChartProps
|
|
|
38
38
|
start: string;
|
|
39
39
|
thresholdUnit?: string;
|
|
40
40
|
thresholds?: Thresholds;
|
|
41
|
+
skipIntersectionObserver?: boolean;
|
|
41
42
|
}
|
|
42
43
|
|
|
43
44
|
const BarChart = ({
|
|
@@ -57,7 +58,8 @@ const BarChart = ({
|
|
|
57
58
|
barStyle = {
|
|
58
59
|
opacity: 1,
|
|
59
60
|
radius: 0.2
|
|
60
|
-
}
|
|
61
|
+
},
|
|
62
|
+
skipIntersectionObserver
|
|
61
63
|
}: BarChartProps): JSX.Element => {
|
|
62
64
|
const { adjustedData } = useChartData({ data, end, start });
|
|
63
65
|
const lineChartRef = useRef<HTMLDivElement | null>(null);
|
|
@@ -93,6 +95,7 @@ const BarChart = ({
|
|
|
93
95
|
thresholds={thresholds}
|
|
94
96
|
tooltip={tooltip}
|
|
95
97
|
width={width}
|
|
98
|
+
skipIntersectionObserver={skipIntersectionObserver}
|
|
96
99
|
/>
|
|
97
100
|
)}
|
|
98
101
|
</ParentSize>
|
|
@@ -54,7 +54,8 @@ const ResponsiveBarChart = ({
|
|
|
54
54
|
limitLegend,
|
|
55
55
|
orientation,
|
|
56
56
|
tooltip,
|
|
57
|
-
barStyle
|
|
57
|
+
barStyle,
|
|
58
|
+
skipIntersectionObserver
|
|
58
59
|
}: Props): JSX.Element => {
|
|
59
60
|
const { title, timeSeries, baseAxis, lines } = graphData;
|
|
60
61
|
|
|
@@ -149,7 +150,7 @@ const ResponsiveBarChart = ({
|
|
|
149
150
|
[axis?.showGridLines]
|
|
150
151
|
);
|
|
151
152
|
|
|
152
|
-
if (!isInViewport) {
|
|
153
|
+
if (!isInViewport && !skipIntersectionObserver) {
|
|
153
154
|
return (
|
|
154
155
|
<Skeleton
|
|
155
156
|
height={graphSvgRef?.current?.clientHeight ?? graphHeight}
|
|
@@ -97,7 +97,8 @@ const Chart = ({
|
|
|
97
97
|
},
|
|
98
98
|
thresholds,
|
|
99
99
|
thresholdUnit,
|
|
100
|
-
limitLegend
|
|
100
|
+
limitLegend,
|
|
101
|
+
skipIntersectionObserver
|
|
101
102
|
}: Props): JSX.Element => {
|
|
102
103
|
const { classes } = useChartStyles();
|
|
103
104
|
|
|
@@ -219,7 +220,7 @@ const Chart = ({
|
|
|
219
220
|
[axis?.showGridLines]
|
|
220
221
|
);
|
|
221
222
|
|
|
222
|
-
if (!isInViewport) {
|
|
223
|
+
if (!isInViewport && !skipIntersectionObserver) {
|
|
223
224
|
return (
|
|
224
225
|
<Skeleton
|
|
225
226
|
height={graphSvgRef?.current?.clientHeight ?? graphHeight}
|
|
@@ -2,6 +2,7 @@ import { makeStyles } from 'tss-react/mui';
|
|
|
2
2
|
|
|
3
3
|
export const useStyles = makeStyles()((theme) => ({
|
|
4
4
|
pageLayout: {
|
|
5
|
+
height: '100%',
|
|
5
6
|
display: 'grid',
|
|
6
7
|
gridTemplateRows: 'min-content',
|
|
7
8
|
overflow: 'hidden'
|
|
@@ -22,8 +23,11 @@ export const useStyles = makeStyles()((theme) => ({
|
|
|
22
23
|
'&[data-has-background="true"]': {
|
|
23
24
|
backgroundColor: theme.palette.layout.body.background
|
|
24
25
|
},
|
|
26
|
+
'&[data-has-actions="true"]': {
|
|
27
|
+
gridTemplateRows: 'min-content auto',
|
|
28
|
+
},
|
|
25
29
|
display: 'grid',
|
|
26
|
-
gridTemplateRows: '
|
|
30
|
+
gridTemplateRows: 'auto',
|
|
27
31
|
overflow: 'hidden',
|
|
28
32
|
padding: theme.spacing(1.5, 3, 5)
|
|
29
33
|
},
|