@centreon/ui 24.4.1-MON-38194-widgets-display-optimizations.2 → 24.4.1-MON-38194-widgets-display-optimizations-2.0

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.4.1-MON-38194-widgets-display-optimizations.2",
3
+ "version": "24.4.1-MON-38194-widgets-display-optimizations-2.0",
4
4
  "description": "Centreon UI Components",
5
5
  "scripts": {
6
6
  "update:deps": "pnpx npm-check-updates -i --format group",
@@ -76,11 +76,12 @@ export const useDashboardItemStyles = makeStyles<{ hasHeader: boolean }>()(
76
76
  border: 'none',
77
77
  borderRadius: theme.spacing(1),
78
78
  height: '100%',
79
- paddingBottom: theme.spacing(4),
80
79
  width: '100%'
81
80
  },
82
81
  widgetContent: {
83
- height: '100%'
82
+ height: hasHeader
83
+ ? `calc(100% - ${theme.spacing(3.5)} - ${theme.spacing(0.5)})`
84
+ : `calc(100% - ${theme.spacing(3.5)})`
84
85
  },
85
86
  widgetHeader: {
86
87
  '&:hover': {
@@ -92,19 +93,17 @@ export const useDashboardItemStyles = makeStyles<{ hasHeader: boolean }>()(
92
93
  '&[data-canMove="true"]': {
93
94
  cursor: 'move'
94
95
  },
95
- padding: theme.spacing(2.5, 2.5, 0.5),
96
+ padding: theme.spacing(0, 1.5),
96
97
  position: 'relative'
97
98
  },
98
99
  widgetHeaderDraggable: {
99
100
  height: '100%',
100
- left: 0,
101
101
  position: 'absolute',
102
- top: 0,
103
- width: '100%'
102
+ width: '95%'
104
103
  },
105
104
  widgetPadding: {
106
105
  overflowX: 'auto',
107
- padding: hasHeader ? theme.spacing(1, 2.5, 3) : theme.spacing(1, 2)
106
+ padding: theme.spacing(0.5, 1.5, 1.5)
108
107
  }
109
108
  })
110
109
  );
@@ -2,6 +2,8 @@ import { equals } from 'ramda';
2
2
 
3
3
  import { useTheme } from '@mui/material';
4
4
 
5
+ import { margin } from '../common';
6
+
5
7
  interface Props {
6
8
  hideTooltip: () => void;
7
9
  label: string;
@@ -28,7 +30,7 @@ export const ThresholdLine = ({
28
30
  const onMouseEnter = (): void =>
29
31
  showTooltip({
30
32
  tooltipData: label,
31
- tooltipLeft: 0,
33
+ tooltipLeft: -(margin.left + margin.right),
32
34
  tooltipTop: scaledValue
33
35
  });
34
36
 
@@ -70,7 +70,6 @@ interface CommonData {
70
70
 
71
71
  interface TimeShiftZonesData extends InteractedZone {
72
72
  graphInterval: GraphInterval;
73
- loading: boolean;
74
73
  }
75
74
 
76
75
  interface Props {
@@ -234,7 +233,7 @@ const InteractionWithGraph = ({
234
233
  value: timeValue?.[metric_id]
235
234
  }),
236
235
  linesData
237
- ).filter(({ value }) => value)
236
+ ).filter(({ value }) => !isNil(value))
238
237
  });
239
238
  };
240
239
 
@@ -6,7 +6,7 @@ interface MakeStylesProps {
6
6
  limitLegendRows?: boolean;
7
7
  }
8
8
 
9
- export const legendWidth = 25;
9
+ export const legendWidth = 21;
10
10
  const legendItemHeight = 5.25;
11
11
  const legendItemHeightCompact = 2;
12
12
 
@@ -28,10 +28,11 @@ export const useStyles = makeStyles<MakeStylesProps>()(
28
28
  columnGap: theme.spacing(3),
29
29
  display: 'grid',
30
30
  gridAutoRows: theme.spacing(legendItemHeight),
31
- gridTemplateColumns: `repeat(auto-fit, ${theme.spacing(legendWidth)})`,
31
+ gridTemplateColumns: `repeat(auto-fit, minmax(${theme.spacing(legendWidth)}, 1fr))`,
32
32
  maxHeight: limitLegendRows
33
33
  ? theme.spacing(legendItemHeight * 2 + 1)
34
34
  : 'unset',
35
+ overflowX: 'hidden',
35
36
  overflowY: 'auto',
36
37
  rowGap: theme.spacing(1),
37
38
  width: '100%'
@@ -62,6 +63,9 @@ interface StylesProps {
62
63
 
63
64
  export const useLegendHeaderStyles = makeStyles<StylesProps>()(
64
65
  (theme, { color }) => ({
66
+ container: {
67
+ width: '100%'
68
+ },
65
69
  disabled: {
66
70
  color: theme.palette.text.disabled
67
71
  },
@@ -72,6 +76,9 @@ export const useLegendHeaderStyles = makeStyles<StylesProps>()(
72
76
  minWidth: theme.spacing(1.5),
73
77
  width: theme.spacing(1.5)
74
78
  },
79
+ legendName: {
80
+ maxWidth: '95%'
81
+ },
75
82
  markerAndLegendName: {
76
83
  alignItems: 'center',
77
84
  display: 'flex',
@@ -85,7 +92,8 @@ export const useLegendHeaderStyles = makeStyles<StylesProps>()(
85
92
  whiteSpace: 'nowrap'
86
93
  },
87
94
  text: {
88
- fontWeight: theme.typography.fontWeightBold,
95
+ fontSize: '0.75rem',
96
+ fontWeight: theme.typography.fontWeightMedium,
89
97
  lineHeight: 1
90
98
  }
91
99
  })
@@ -29,52 +29,52 @@ const LegendHeader = ({
29
29
  }: Props): JSX.Element => {
30
30
  const { classes, cx } = useLegendHeaderStyles({ color });
31
31
 
32
- const { unit, name, legend } = line;
32
+ const { name, legend } = line;
33
33
 
34
34
  const metricName = formatMetricName({ legend, name });
35
35
 
36
36
  const legendName = legend || name;
37
- const unitName = `(${unit})`;
38
37
 
39
38
  return (
40
- <Tooltip
41
- followCursor={false}
42
- label={
43
- minMaxAvg ? (
44
- <div>
45
- <Typography>{`${legendName} ${unitName}`}</Typography>
46
- <div className={classes.minMaxAvgContainer}>
47
- {minMaxAvg.map(({ label, value: subValue }) => (
48
- <LegendContent
49
- data={formatMetricValue({
50
- unit: line.unit,
51
- value: subValue
52
- })}
53
- key={label}
54
- label={label}
55
- />
56
- ))}
39
+ <div className={classes.container}>
40
+ <Tooltip
41
+ followCursor={false}
42
+ label={
43
+ minMaxAvg ? (
44
+ <div>
45
+ <Typography>{legendName}</Typography>
46
+ <div className={classes.minMaxAvgContainer}>
47
+ {minMaxAvg.map(({ label, value: subValue }) => (
48
+ <LegendContent
49
+ data={formatMetricValue({
50
+ unit: line.unit,
51
+ value: subValue
52
+ })}
53
+ key={label}
54
+ label={label}
55
+ />
56
+ ))}
57
+ </div>
57
58
  </div>
58
- </div>
59
- ) : (
60
- `${legendName} ${unitName}`
61
- )
62
- }
63
- placement="top"
64
- >
65
- <div className={classes.markerAndLegendName}>
66
- <div className={cx(classes.icon, { [classes.disabled]: disabled })} />
67
- <EllipsisTypography
68
- className={classes.text}
69
- data-mode={
70
- value ? LegendDisplayMode.Compact : LegendDisplayMode.Normal
71
- }
72
- variant="body2"
73
- >
74
- {metricName}
75
- </EllipsisTypography>
76
- </div>
77
- </Tooltip>
59
+ ) : (
60
+ legendName
61
+ )
62
+ }
63
+ placement="top"
64
+ >
65
+ <div className={classes.markerAndLegendName}>
66
+ <div className={cx(classes.icon, { [classes.disabled]: disabled })} />
67
+ <EllipsisTypography
68
+ className={cx(classes.text, classes.legendName)}
69
+ data-mode={
70
+ value ? LegendDisplayMode.Compact : LegendDisplayMode.Normal
71
+ }
72
+ >
73
+ {metricName}
74
+ </EllipsisTypography>
75
+ </div>
76
+ </Tooltip>
77
+ </div>
78
78
  );
79
79
  };
80
80
 
@@ -14,7 +14,6 @@ import Axes from './BasicComponents/Axes';
14
14
  import Grids from './BasicComponents/Grids';
15
15
  import Lines from './BasicComponents/Lines';
16
16
  import { canDisplayThreshold } from './BasicComponents/Lines/Threshold/models';
17
- import LoadingProgress from './BasicComponents/LoadingProgress';
18
17
  import useFilterLines from './BasicComponents/useFilterLines';
19
18
  import { useStyles } from './LineChart.styles';
20
19
  import Header from './Header';
@@ -45,7 +44,6 @@ interface Props extends LineChartProps {
45
44
  graphRef: MutableRefObject<HTMLDivElement | null>;
46
45
  legend?: LegendModel;
47
46
  limitLegend?: false | number;
48
- marginBottom: number;
49
47
  shapeLines?: GlobalAreaLines;
50
48
  thresholdUnit?: string;
51
49
  thresholds?: ThresholdsModel;
@@ -63,7 +61,6 @@ const LineChart = ({
63
61
  shapeLines,
64
62
  axis,
65
63
  displayAnchor,
66
- loading,
67
64
  zoomPreview,
68
65
  graphInterval,
69
66
  timeShiftZones,
@@ -73,7 +70,6 @@ const LineChart = ({
73
70
  graphRef,
74
71
  header,
75
72
  curve,
76
- marginBottom,
77
73
  thresholds,
78
74
  thresholdUnit,
79
75
  limitLegend
@@ -104,8 +100,7 @@ const LineChart = ({
104
100
  (height || 0) > 0
105
101
  ? (height || 0) -
106
102
  margin.top -
107
- margin.bottom -
108
- marginBottom -
103
+ 5 -
109
104
  (legendRef.current?.getBoundingClientRect().height || 0)
110
105
  : 0;
111
106
 
@@ -196,11 +191,6 @@ const LineChart = ({
196
191
  title={<GraphValueTooltip base={baseAxis} />}
197
192
  >
198
193
  <div className={classes.container}>
199
- <LoadingProgress
200
- display={loading}
201
- height={graphHeight}
202
- width={width}
203
- />
204
194
  <svg
205
195
  height={graphHeight + margin.top}
206
196
  ref={graphSvgRef}
@@ -259,8 +249,7 @@ const LineChart = ({
259
249
  }}
260
250
  timeShiftZonesData={{
261
251
  ...timeShiftZones,
262
- graphInterval,
263
- loading
252
+ graphInterval
264
253
  }}
265
254
  zoomData={{ ...zoomPreview }}
266
255
  />
@@ -13,8 +13,8 @@ const useSkeletonStyles = makeStyles<Props>()(
13
13
  display: 'grid',
14
14
  gridGap: theme.spacing(1),
15
15
  gridTemplateRows: `${
16
- displayTitleSkeleton ? '1fr' : ''
17
- } ${graphHeight}px ${theme.spacing(7)}`,
16
+ displayTitleSkeleton ? '0.8fr' : ''
17
+ } ${graphHeight}px ${theme.spacing(2)}`,
18
18
  height: '100%'
19
19
  },
20
20
  loadingSkeletonLine: {
@@ -30,7 +30,6 @@ interface Props extends Partial<LineChartProps> {
30
30
  legend: LegendModel;
31
31
  limitLegend?: false | number;
32
32
  loading: boolean;
33
- marginBottom?: number;
34
33
  shapeLines?: GlobalAreaLines;
35
34
  start: string;
36
35
  thresholdUnit?: string;
@@ -54,7 +53,6 @@ const WrapperLineChart = ({
54
53
  legend,
55
54
  header,
56
55
  curve = Curve.curveLinear,
57
- marginBottom = 0,
58
56
  thresholds,
59
57
  thresholdUnit,
60
58
  limitLegend
@@ -65,7 +63,7 @@ const WrapperLineChart = ({
65
63
  if (loading && !adjustedData) {
66
64
  return (
67
65
  <LoadingSkeleton
68
- displayTitleSkeleton={header?.displayTitle ?? true}
66
+ displayTitleSkeleton={header?.displayTitle ?? false}
69
67
  graphHeight={height || 200}
70
68
  />
71
69
  );
@@ -78,7 +76,7 @@ const WrapperLineChart = ({
78
76
  return (
79
77
  <div
80
78
  ref={lineChartRef as MutableRefObject<HTMLDivElement>}
81
- style={{ height: '100%', overflowY: 'hidden', width: '100%' }}
79
+ style={{ height: '100%', overflow: 'hidden', width: '100%' }}
82
80
  >
83
81
  <ParentSize>
84
82
  {({
@@ -98,8 +96,6 @@ const WrapperLineChart = ({
98
96
  height={height || responsiveHeight}
99
97
  legend={legend}
100
98
  limitLegend={limitLegend}
101
- loading={loading}
102
- marginBottom={marginBottom}
103
99
  shapeLines={shapeLines}
104
100
  thresholdUnit={thresholdUnit}
105
101
  thresholds={thresholds}
@@ -88,7 +88,6 @@ export interface LineChartProps {
88
88
  displayAnchor?: DisplayAnchor;
89
89
  header?: LineChartHeader;
90
90
  height?: number | null;
91
- loading: boolean;
92
91
  timeShiftZones?: InteractedZone;
93
92
  tooltip?: Tooltip;
94
93
  width: number;
@@ -1,6 +1,9 @@
1
1
  import { makeStyles } from 'tss-react/mui';
2
2
 
3
3
  export const useTextStyles = makeStyles()((theme) => ({
4
+ critical: {
5
+ color: theme.palette.error.main
6
+ },
4
7
  graphText: {
5
8
  alignItems: 'center',
6
9
  display: 'flex',
@@ -9,9 +12,17 @@ export const useTextStyles = makeStyles()((theme) => ({
9
12
  height: '100%',
10
13
  justifyContent: 'center'
11
14
  },
15
+ threshold: {
16
+ textAlign: 'center'
17
+ },
12
18
  thresholds: {
13
19
  display: 'flex',
14
20
  flexDirection: 'row',
15
- gap: theme.spacing(5)
21
+ gap: theme.spacing(5),
22
+ whiteSpace: 'nowrap',
23
+ width: '100%'
24
+ },
25
+ warning: {
26
+ color: theme.palette.warning.main
16
27
  }
17
28
  }));
@@ -2,6 +2,7 @@ import { isNil } from 'ramda';
2
2
 
3
3
  import { Typography, useTheme } from '@mui/material';
4
4
 
5
+ import FluidTypography from '../../Typography/FluidTypography';
5
6
  import { LineChartData, Thresholds } from '../common/models';
6
7
  import {
7
8
  formatMetricValueWithUnit,
@@ -30,7 +31,7 @@ export const Text = ({
30
31
  baseColor
31
32
  }: Props): JSX.Element | null => {
32
33
  const theme = useTheme();
33
- const { classes } = useTextStyles();
34
+ const { classes, cx } = useTextStyles();
34
35
 
35
36
  if (isNil(data)) {
36
37
  return null;
@@ -74,16 +75,20 @@ export const Text = ({
74
75
  </Typography>
75
76
  {thresholds.enabled && (
76
77
  <div className={classes.thresholds}>
77
- <Typography sx={{ color: 'warning.main' }} variant="h5">
78
- {labels.warning}
79
- {': '}
80
- {warningThresholdLabels.join(' - ')}
81
- </Typography>
82
- <Typography sx={{ color: 'error.main' }} variant="h5">
83
- {labels.critical}
84
- {': '}
85
- {criticalThresholdLabels.join(' - ')}
86
- </Typography>
78
+ <FluidTypography
79
+ containerClassName={cx(classes.threshold, classes.warning)}
80
+ max="30px"
81
+ pref={14}
82
+ text={`${labels.warning}: ${warningThresholdLabels.join(' - ')}`}
83
+ variant="h5"
84
+ />
85
+ <FluidTypography
86
+ containerClassName={cx(classes.threshold, classes.critical)}
87
+ max="30px"
88
+ pref={14}
89
+ text={`${labels.critical}: ${criticalThresholdLabels.join(' - ')}`}
90
+ variant="h5"
91
+ />
87
92
  </div>
88
93
  )}
89
94
  </div>
@@ -283,7 +283,6 @@ export const getTheme = (mode: ThemeMode): ThemeOptions => ({
283
283
  fontSize: '0.75rem'
284
284
  },
285
285
  button: {
286
- fontSize: '0.8125rem',
287
286
  textTransform: 'none'
288
287
  },
289
288
  caption: {
@@ -13,7 +13,7 @@ const useStyles = makeStyles()((theme) => ({
13
13
  paddingLeft: theme.spacing(2),
14
14
  paddingRight: theme.spacing(2)
15
15
  },
16
- fontSize: theme.typography.button.fontSize,
16
+ fontSize: '14px',
17
17
  height: 'unset',
18
18
  lineHeight: '22px'
19
19
  },
@@ -36,7 +36,7 @@ const useStyles = makeStyles()((theme) => ({
36
36
  color: theme.palette.primary.main
37
37
  },
38
38
 
39
- textWrap: 'nowrap',
39
+ textWrap: 'noWrap',
40
40
  transition: 'unset'
41
41
  }
42
42
  }));