@centreon/ui 24.10.3 → 24.10.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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@centreon/ui",
3
- "version": "24.10.3",
3
+ "version": "24.10.5",
4
4
  "description": "Centreon UI Components",
5
5
  "scripts": {
6
6
  "update:deps": "pnpx npm-check-updates -i --format group",
@@ -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: 0,
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: 0,
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
  );
@@ -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 = ({ width, height, columns }: Props): ReactElement => {
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.GridColumns
51
- height={height}
52
- scale={xScale}
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
- scale={yScale}
64
+ yScale={yScale}
65
+ xScale={xScale}
60
66
  stroke={theme.palette.divider}
61
67
  top={-10}
62
68
  width={width}
@@ -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
- <ResponsiveHeight margin={40}>
66
- <ParentSize>
67
- {({ width, height }): JSX.Element => (
68
- <div className={classes.container}>
69
- {displayGrid && (
70
- <Grid columns={columns} height={height} width={width} />
71
- )}
72
- <ReactGridLayout
73
- cols={columns}
74
- containerPadding={[4, 0]}
75
- layout={getLayout(layout)}
76
- margin={[20, 20]}
77
- resizeHandles={['s', 'e', 'se']}
78
- rowHeight={rowHeight}
79
- width={width}
80
- onLayoutChange={changeLayout}
81
- onResizeStart={startResize}
82
- onResizeStop={stopResize}
83
- >
84
- {children}
85
- </ReactGridLayout>
86
- </div>
87
- )}
88
- </ParentSize>
89
- </ResponsiveHeight>
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}
@@ -120,6 +120,7 @@ const WrapperChart = ({
120
120
  tooltip={tooltip}
121
121
  width={width ?? responsiveWidth}
122
122
  zoomPreview={zoomPreview}
123
+ skipIntersectionObserver={rest.skipIntersectionObserver}
123
124
  />
124
125
  );
125
126
  }}
@@ -120,6 +120,7 @@ export interface LineChartProps {
120
120
  tooltip?: Tooltip;
121
121
  width: number;
122
122
  zoomPreview?: InteractedZone;
123
+ skipIntersectionObserver?: boolean;
123
124
  }
124
125
 
125
126
  export interface Area {
@@ -157,7 +157,7 @@ declare module '@mui/material/Badge' {
157
157
 
158
158
  export const lightPalette: PaletteOptions = {
159
159
  action: {
160
- acknowledged: '#67532C',
160
+ acknowledged: '#745F35',
161
161
  acknowledgedBackground: '#DFD2B9',
162
162
  activatedOpacity: 0.12,
163
163
  active: '#666666',
@@ -167,7 +167,7 @@ export const lightPalette: PaletteOptions = {
167
167
  focusOpacity: 0.12,
168
168
  hover: 'rgba(0, 0, 0, 0.06)',
169
169
  hoverOpacity: 0.06,
170
- inDowntime: '#4B2352',
170
+ inDowntime: '#512980',
171
171
  inDowntimeBackground: '#E5D8F3',
172
172
  selected: 'rgba(102, 102, 102, 0.3)',
173
173
  selectedOpacity: 0.3
@@ -297,7 +297,7 @@ export const lightPalette: PaletteOptions = {
297
297
 
298
298
  export const darkPalette: PaletteOptions = {
299
299
  action: {
300
- acknowledged: '#67532C',
300
+ acknowledged: '#DFD2B9',
301
301
  acknowledgedBackground: '#745F35',
302
302
  activatedOpacity: 0.3,
303
303
  active: '#B5B5B5',
@@ -307,7 +307,7 @@ export const darkPalette: PaletteOptions = {
307
307
  focusOpacity: 0.3,
308
308
  hover: 'rgba(255, 255, 255, 0.16)',
309
309
  hoverOpacity: 0.16,
310
- inDowntime: '#4B2352',
310
+ inDowntime: '#E5D8F3',
311
311
  inDowntimeBackground: '#512980',
312
312
  selected: 'rgba(255, 255, 255, 0.5)',
313
313
  selectedOpacity: 0.5
@@ -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: 'min-content',
30
+ gridTemplateRows: 'auto',
27
31
  overflow: 'hidden',
28
32
  padding: theme.spacing(1.5, 3, 5)
29
33
  },
@@ -17,6 +17,7 @@ export const PageLayoutBody = ({
17
17
  <section
18
18
  className={classes.pageLayoutBody}
19
19
  data-has-background={hasBackground}
20
+ data-has-actions={!!children?.length}
20
21
  id="page-body"
21
22
  >
22
23
  {children}