@centreon/ui 23.10.18-MON-17793-create-graph-component-centreon-ui.8 → 23.10.18-MON-17793-create-graph-component-centreon-ui.9
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": "23.10.18-MON-17793-create-graph-component-centreon-ui.
|
|
3
|
+
"version": "23.10.18-MON-17793-create-graph-component-centreon-ui.9",
|
|
4
4
|
"description": "Centreon UI Components",
|
|
5
5
|
"scripts": {
|
|
6
6
|
"eslint": "eslint ./src --ext .js,.jsx,.ts,.tsx --max-warnings 0",
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { useAtomValue } from 'jotai';
|
|
2
|
+
import { useTranslation } from 'react-i18next';
|
|
2
3
|
|
|
3
4
|
import AccessTimeIcon from '@mui/icons-material/AccessTime';
|
|
4
5
|
import { Button, Typography } from '@mui/material';
|
|
@@ -6,6 +7,11 @@ import { Button, Typography } from '@mui/material';
|
|
|
6
7
|
import { dateTimeFormat, useLocaleDateTimeFormat } from '@centreon/ui';
|
|
7
8
|
|
|
8
9
|
import { customTimePeriodAtom } from '../timePeriodsAtoms';
|
|
10
|
+
import {
|
|
11
|
+
labelCompactTimePeriod,
|
|
12
|
+
labelFrom,
|
|
13
|
+
labelTo
|
|
14
|
+
} from '../translatedLabels';
|
|
9
15
|
|
|
10
16
|
import useStyles from './CompactCustomTimePeriod.styles';
|
|
11
17
|
|
|
@@ -19,6 +25,7 @@ const CompactCustomTimePeriod = ({
|
|
|
19
25
|
disabled = false
|
|
20
26
|
}: Props): JSX.Element => {
|
|
21
27
|
const { classes } = useStyles();
|
|
28
|
+
const { t } = useTranslation();
|
|
22
29
|
|
|
23
30
|
const { format } = useLocaleDateTimeFormat();
|
|
24
31
|
|
|
@@ -27,10 +34,10 @@ const CompactCustomTimePeriod = ({
|
|
|
27
34
|
return (
|
|
28
35
|
<div>
|
|
29
36
|
<Button
|
|
30
|
-
aria-label=
|
|
37
|
+
aria-label={t(labelCompactTimePeriod) as string}
|
|
31
38
|
className={classes.button}
|
|
32
39
|
color="primary"
|
|
33
|
-
data-testid=
|
|
40
|
+
data-testid={labelCompactTimePeriod}
|
|
34
41
|
disabled={disabled}
|
|
35
42
|
variant="outlined"
|
|
36
43
|
onClick={onClick}
|
|
@@ -44,7 +51,7 @@ const CompactCustomTimePeriod = ({
|
|
|
44
51
|
component="div"
|
|
45
52
|
variant="caption"
|
|
46
53
|
>
|
|
47
|
-
|
|
54
|
+
{t(labelFrom)}:
|
|
48
55
|
</Typography>
|
|
49
56
|
|
|
50
57
|
<Typography
|
|
@@ -64,7 +71,7 @@ const CompactCustomTimePeriod = ({
|
|
|
64
71
|
component="div"
|
|
65
72
|
variant="caption"
|
|
66
73
|
>
|
|
67
|
-
|
|
74
|
+
{t(labelTo)}:
|
|
68
75
|
</Typography>
|
|
69
76
|
|
|
70
77
|
<Typography
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { useAtomValue, useSetAtom } from 'jotai';
|
|
2
2
|
import { T, always, cond, equals, lte, map, pick } from 'ramda';
|
|
3
3
|
import { makeStyles } from 'tss-react/mui';
|
|
4
|
+
import { useTranslation } from 'react-i18next';
|
|
4
5
|
|
|
5
6
|
import { Button, ButtonGroup, Tooltip, useTheme } from '@mui/material';
|
|
6
7
|
|
|
@@ -35,7 +36,7 @@ const SelectedTimePeriod = ({
|
|
|
35
36
|
}: Props): JSX.Element => {
|
|
36
37
|
const { classes } = useStyles();
|
|
37
38
|
const theme = useTheme();
|
|
38
|
-
|
|
39
|
+
const { t } = useTranslation();
|
|
39
40
|
const selectedTimePeriodData = useAtomValue(selectedTimePeriodAtom);
|
|
40
41
|
|
|
41
42
|
const changeSelectedTimePeriod = useSetAtom(
|
|
@@ -52,6 +53,12 @@ const SelectedTimePeriod = ({
|
|
|
52
53
|
currentTimePeriods
|
|
53
54
|
);
|
|
54
55
|
|
|
56
|
+
const translatedTimePeriodOptions = timePeriodOptions.map((timePeriod) => ({
|
|
57
|
+
...timePeriod,
|
|
58
|
+
largeName: t(timePeriod.largeName),
|
|
59
|
+
name: t(timePeriod.name)
|
|
60
|
+
}));
|
|
61
|
+
|
|
55
62
|
return (
|
|
56
63
|
<ButtonGroup
|
|
57
64
|
className={classes.buttonGroup}
|
|
@@ -86,7 +93,7 @@ const SelectedTimePeriod = ({
|
|
|
86
93
|
</Button>
|
|
87
94
|
</Tooltip>
|
|
88
95
|
),
|
|
89
|
-
|
|
96
|
+
translatedTimePeriodOptions
|
|
90
97
|
)}
|
|
91
98
|
</ButtonGroup>
|
|
92
99
|
);
|
|
@@ -1,5 +1,14 @@
|
|
|
1
1
|
import dayjs from 'dayjs';
|
|
2
2
|
|
|
3
|
+
import {
|
|
4
|
+
labelLastDay,
|
|
5
|
+
label1Day,
|
|
6
|
+
label7Days,
|
|
7
|
+
label31Days,
|
|
8
|
+
labelLast7Days,
|
|
9
|
+
labelLast31Days
|
|
10
|
+
} from './translatedLabels';
|
|
11
|
+
|
|
3
12
|
export const dateFormat = 'L';
|
|
4
13
|
export const timeFormat = 'LT';
|
|
5
14
|
export const dateTimeFormat = `${dateFormat} ${timeFormat}`;
|
|
@@ -18,13 +27,6 @@ export interface TimePeriod {
|
|
|
18
27
|
timelineEventsLimit: number;
|
|
19
28
|
}
|
|
20
29
|
|
|
21
|
-
export const label1Day = '1 day';
|
|
22
|
-
export const label7Days = '7 days';
|
|
23
|
-
export const label31Days = '31 days';
|
|
24
|
-
export const labelLastDay = 'Last day';
|
|
25
|
-
export const labelLast7Days = 'Last 7 days';
|
|
26
|
-
export const labelLast31Days = 'Last 31 days';
|
|
27
|
-
|
|
28
30
|
export const lastDayPeriod: TimePeriod = {
|
|
29
31
|
dateTimeFormat: timeFormat,
|
|
30
32
|
getStart: (): Date => dayjs(Date.now()).subtract(24, 'hour').toDate(),
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export const label1Day = '1 day';
|
|
2
|
+
export const label7Days = '7 days';
|
|
3
|
+
export const label31Days = '31 days';
|
|
4
|
+
export const labelLastDay = 'Last day';
|
|
5
|
+
export const labelLast7Days = 'Last 7 days';
|
|
6
|
+
export const labelLast31Days = 'Last 31 days';
|
|
7
|
+
export const labelFrom = 'From';
|
|
8
|
+
export const labelTo = 'To';
|
|
9
|
+
export const labelCompactTimePeriod = 'Compact time period';
|