@centreon/ui 23.10.18-MON-17793-create-graph-component-centreon-ui.0 → 23.10.18
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 -2
- package/src/Graph/Axes/UnitLabel.tsx +0 -20
- package/src/Graph/Axes/index.tsx +0 -99
- package/src/Graph/Axes/models.ts +0 -26
- package/src/Graph/Axes/useAxisY.ts +0 -100
- package/src/Graph/Graph.tsx +0 -231
- package/src/Graph/Grids/index.tsx +0 -20
- package/src/Graph/Header/index.tsx +0 -34
- package/src/Graph/InteractionWithGraph/AnchorPoint/RegularAnchorPoint.tsx +0 -88
- package/src/Graph/InteractionWithGraph/AnchorPoint/StackedAnchorPoint.tsx +0 -97
- package/src/Graph/InteractionWithGraph/AnchorPoint/index.tsx +0 -56
- package/src/Graph/InteractionWithGraph/AnchorPoint/models.ts +0 -25
- package/src/Graph/InteractionWithGraph/AnchorPoint/useAnchorPoint.ts +0 -109
- package/src/Graph/InteractionWithGraph/Bar.tsx +0 -21
- package/src/Graph/InteractionWithGraph/ZoomPreview/index.tsx +0 -38
- package/src/Graph/InteractionWithGraph/ZoomPreview/models.ts +0 -17
- package/src/Graph/InteractionWithGraph/ZoomPreview/useZoomPreview.ts +0 -101
- package/src/Graph/InteractionWithGraph/ZoomPreview/zoomPreviewAtoms.ts +0 -5
- package/src/Graph/InteractionWithGraph/index.tsx +0 -93
- package/src/Graph/InteractionWithGraph/interactionWithGraphAtoms.ts +0 -7
- package/src/Graph/InteractionWithGraph/mouseTimeValueAtoms.ts +0 -49
- package/src/Graph/Lines/RegularLines/index.tsx +0 -99
- package/src/Graph/Lines/RegularLines/useRegularLines.ts +0 -15
- package/src/Graph/Lines/StackedLines/index.tsx +0 -74
- package/src/Graph/Lines/StackedLines/useStackedLines.ts +0 -39
- package/src/Graph/Lines/index.tsx +0 -153
- package/src/Graph/Lines/models.ts +0 -32
- package/src/Graph/LoadingProgress.tsx +0 -46
- package/src/Graph/common/index.ts +0 -33
- package/src/Graph/data.json +0 -1338
- package/src/Graph/helpers/doc.ts +0 -323
- package/src/Graph/helpers/index.ts +0 -15
- package/src/Graph/index.stories.tsx +0 -30
- package/src/Graph/index.tsx +0 -66
- package/src/Graph/models.ts +0 -68
- package/src/Graph/timeSeries/index.test.ts +0 -484
- package/src/Graph/timeSeries/index.ts +0 -512
- package/src/Graph/timeSeries/models.ts +0 -119
- package/src/Graph/useGraphData.ts +0 -117
- package/src/TimePeriods/CustomTimePeriod/CompactCustomTimePeriod.styles.ts +0 -57
- package/src/TimePeriods/CustomTimePeriod/CompactCustomTimePeriod.tsx +0 -78
- package/src/TimePeriods/CustomTimePeriod/PopoverCustomTimePeriod/ErrorText.tsx +0 -14
- package/src/TimePeriods/CustomTimePeriod/PopoverCustomTimePeriod/PickersStartEndDate.tsx +0 -169
- package/src/TimePeriods/CustomTimePeriod/PopoverCustomTimePeriod/index.tsx +0 -76
- package/src/TimePeriods/CustomTimePeriod/PopoverCustomTimePeriod/models.ts +0 -61
- package/src/TimePeriods/CustomTimePeriod/PopoverCustomTimePeriod/usePickersStartEndDate.ts +0 -91
- package/src/TimePeriods/CustomTimePeriod/index.tsx +0 -63
- package/src/TimePeriods/DateTimePickerInput.tsx +0 -99
- package/src/TimePeriods/SelectedTimePeriod.tsx +0 -99
- package/src/TimePeriods/TimePeriods.cypress.spec.tsx +0 -497
- package/src/TimePeriods/helpers/index.ts +0 -25
- package/src/TimePeriods/index.stories.tsx +0 -74
- package/src/TimePeriods/index.tsx +0 -77
- package/src/TimePeriods/models.ts +0 -103
- package/src/TimePeriods/timePeriods.styles.ts +0 -20
- package/src/TimePeriods/timePeriodsAtoms.ts +0 -113
- package/src/TimePeriods/useDateTimePickerAdapter.ts +0 -329
- package/src/TimePeriods/useSortTimePeriods.ts +0 -24
|
@@ -1,63 +0,0 @@
|
|
|
1
|
-
import { MouseEvent, useState } from 'react';
|
|
2
|
-
|
|
3
|
-
import { useAtomValue, useSetAtom } from 'jotai';
|
|
4
|
-
|
|
5
|
-
import {
|
|
6
|
-
changeCustomTimePeriodDerivedAtom,
|
|
7
|
-
customTimePeriodAtom
|
|
8
|
-
} from '../timePeriodsAtoms';
|
|
9
|
-
|
|
10
|
-
import CompactCustomTimePeriod from './CompactCustomTimePeriod';
|
|
11
|
-
import PopoverCustomTimePeriod from './PopoverCustomTimePeriod';
|
|
12
|
-
|
|
13
|
-
interface Props {
|
|
14
|
-
disabled?: boolean;
|
|
15
|
-
width: number;
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
const CustomTimePeriod = ({ width, disabled = false }: Props): JSX.Element => {
|
|
19
|
-
const [anchorEl, setAnchorEl] = useState<HTMLButtonElement>();
|
|
20
|
-
|
|
21
|
-
const customTimePeriod = useAtomValue(customTimePeriodAtom);
|
|
22
|
-
const changeCustomTimePeriod = useSetAtom(changeCustomTimePeriodDerivedAtom);
|
|
23
|
-
|
|
24
|
-
const acceptDate = ({ property, date }): void =>
|
|
25
|
-
changeCustomTimePeriod({ date, property });
|
|
26
|
-
|
|
27
|
-
const onClickCompactCustomTimePeriod = (
|
|
28
|
-
event: MouseEvent<HTMLButtonElement>
|
|
29
|
-
): void => {
|
|
30
|
-
setAnchorEl(event.currentTarget);
|
|
31
|
-
};
|
|
32
|
-
|
|
33
|
-
const closePopover = (): void => {
|
|
34
|
-
setAnchorEl(undefined);
|
|
35
|
-
};
|
|
36
|
-
|
|
37
|
-
return (
|
|
38
|
-
<>
|
|
39
|
-
<CompactCustomTimePeriod
|
|
40
|
-
disabled={disabled}
|
|
41
|
-
width={width}
|
|
42
|
-
onClick={onClickCompactCustomTimePeriod}
|
|
43
|
-
/>
|
|
44
|
-
<PopoverCustomTimePeriod
|
|
45
|
-
pickersData={{
|
|
46
|
-
acceptDate,
|
|
47
|
-
customTimePeriod,
|
|
48
|
-
isDisabledEndPicker: disabled,
|
|
49
|
-
isDisabledStartPicker: disabled,
|
|
50
|
-
rangeEndDate: { min: customTimePeriod.start },
|
|
51
|
-
rangeStartDate: { max: customTimePeriod.end }
|
|
52
|
-
}}
|
|
53
|
-
popoverData={{
|
|
54
|
-
anchorEl,
|
|
55
|
-
onClose: closePopover,
|
|
56
|
-
open: Boolean(anchorEl)
|
|
57
|
-
}}
|
|
58
|
-
/>
|
|
59
|
-
</>
|
|
60
|
-
);
|
|
61
|
-
};
|
|
62
|
-
|
|
63
|
-
export default CustomTimePeriod;
|
|
@@ -1,99 +0,0 @@
|
|
|
1
|
-
import { useState } from 'react';
|
|
2
|
-
|
|
3
|
-
import dayjs from 'dayjs';
|
|
4
|
-
|
|
5
|
-
import { TextFieldProps } from '@mui/material';
|
|
6
|
-
import { DesktopDateTimePicker } from '@mui/x-date-pickers';
|
|
7
|
-
|
|
8
|
-
import { TextField } from '@centreon/ui';
|
|
9
|
-
|
|
10
|
-
import { DateTimePickerInputModel } from './models';
|
|
11
|
-
import useDateTimePickerAdapter from './useDateTimePickerAdapter';
|
|
12
|
-
|
|
13
|
-
const renderDateTimePickerTextField =
|
|
14
|
-
(blur: () => void) =>
|
|
15
|
-
({ inputRef, inputProps, InputProps }: TextFieldProps): JSX.Element => {
|
|
16
|
-
return (
|
|
17
|
-
<TextField
|
|
18
|
-
// eslint-disable-next-line react/no-unstable-nested-components
|
|
19
|
-
EndAdornment={(): JSX.Element => <div>{InputProps?.endAdornment}</div>}
|
|
20
|
-
dataTestId="calendar"
|
|
21
|
-
inputProps={{
|
|
22
|
-
...inputProps,
|
|
23
|
-
ref: inputRef,
|
|
24
|
-
style: { padding: 8 }
|
|
25
|
-
}}
|
|
26
|
-
onBlur={blur}
|
|
27
|
-
/>
|
|
28
|
-
);
|
|
29
|
-
};
|
|
30
|
-
|
|
31
|
-
const DateTimePickerInput = ({
|
|
32
|
-
date,
|
|
33
|
-
maxDate,
|
|
34
|
-
minDate,
|
|
35
|
-
property,
|
|
36
|
-
changeDate,
|
|
37
|
-
setDate,
|
|
38
|
-
onClosePicker,
|
|
39
|
-
disabled = false
|
|
40
|
-
}: DateTimePickerInputModel): JSX.Element => {
|
|
41
|
-
const [isOpen, setIsOpen] = useState(false);
|
|
42
|
-
|
|
43
|
-
const { getDestinationAndConfiguredTimezoneOffset, formatKeyboardValue } =
|
|
44
|
-
useDateTimePickerAdapter();
|
|
45
|
-
|
|
46
|
-
const changeTime = (
|
|
47
|
-
newValue: dayjs.Dayjs | null,
|
|
48
|
-
keyBoardValue: string | undefined
|
|
49
|
-
): void => {
|
|
50
|
-
if (isOpen) {
|
|
51
|
-
changeDate({ date: dayjs(newValue).toDate(), property });
|
|
52
|
-
|
|
53
|
-
return;
|
|
54
|
-
}
|
|
55
|
-
const value = dayjs(formatKeyboardValue(keyBoardValue))
|
|
56
|
-
.add(
|
|
57
|
-
dayjs.duration({ hours: getDestinationAndConfiguredTimezoneOffset() })
|
|
58
|
-
)
|
|
59
|
-
.toDate();
|
|
60
|
-
|
|
61
|
-
setDate(value);
|
|
62
|
-
};
|
|
63
|
-
|
|
64
|
-
const blur = (): void => {
|
|
65
|
-
changeDate({ date, property });
|
|
66
|
-
};
|
|
67
|
-
const close = (): void => {
|
|
68
|
-
setIsOpen(false);
|
|
69
|
-
onClosePicker?.(true);
|
|
70
|
-
};
|
|
71
|
-
|
|
72
|
-
const open = (): void => {
|
|
73
|
-
setIsOpen(true);
|
|
74
|
-
onClosePicker?.(false);
|
|
75
|
-
};
|
|
76
|
-
|
|
77
|
-
return (
|
|
78
|
-
<DesktopDateTimePicker<dayjs.Dayjs>
|
|
79
|
-
hideTabs
|
|
80
|
-
PopperProps={{
|
|
81
|
-
open: isOpen
|
|
82
|
-
}}
|
|
83
|
-
dayOfWeekFormatter={(day: string): string =>
|
|
84
|
-
day.substring(0, 2).toUpperCase()
|
|
85
|
-
}
|
|
86
|
-
disabled={disabled}
|
|
87
|
-
maxDate={maxDate && dayjs(maxDate)}
|
|
88
|
-
minDate={minDate && dayjs(minDate)}
|
|
89
|
-
open={isOpen}
|
|
90
|
-
renderInput={renderDateTimePickerTextField(blur)}
|
|
91
|
-
value={date as dayjs.Dayjs}
|
|
92
|
-
onChange={changeTime}
|
|
93
|
-
onClose={close}
|
|
94
|
-
onOpen={open}
|
|
95
|
-
/>
|
|
96
|
-
);
|
|
97
|
-
};
|
|
98
|
-
|
|
99
|
-
export default DateTimePickerInput;
|
|
@@ -1,99 +0,0 @@
|
|
|
1
|
-
import { useAtomValue, useSetAtom } from 'jotai';
|
|
2
|
-
import { T, always, cond, equals, lte, map, pick } from 'ramda';
|
|
3
|
-
import { makeStyles } from 'tss-react/mui';
|
|
4
|
-
|
|
5
|
-
import { Button, ButtonGroup, Tooltip, useTheme } from '@mui/material';
|
|
6
|
-
|
|
7
|
-
import { TimePeriod, timePeriods } from './models';
|
|
8
|
-
import {
|
|
9
|
-
changeSelectedTimePeriodDerivedAtom,
|
|
10
|
-
selectedTimePeriodAtom
|
|
11
|
-
} from './timePeriodsAtoms';
|
|
12
|
-
import useSortTimePeriods from './useSortTimePeriods';
|
|
13
|
-
|
|
14
|
-
const useStyles = makeStyles()((theme) => ({
|
|
15
|
-
button: {
|
|
16
|
-
fontSize: theme.typography.body2.fontSize,
|
|
17
|
-
pointerEvents: 'all'
|
|
18
|
-
},
|
|
19
|
-
buttonGroup: {
|
|
20
|
-
alignSelf: 'center',
|
|
21
|
-
height: '100%'
|
|
22
|
-
}
|
|
23
|
-
}));
|
|
24
|
-
|
|
25
|
-
interface Props {
|
|
26
|
-
disabled?: boolean;
|
|
27
|
-
extraTimePeriods?: Array<TimePeriod>;
|
|
28
|
-
width: number;
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
const SelectedTimePeriod = ({
|
|
32
|
-
width,
|
|
33
|
-
disabled = false,
|
|
34
|
-
extraTimePeriods = []
|
|
35
|
-
}: Props): JSX.Element => {
|
|
36
|
-
const { classes } = useStyles();
|
|
37
|
-
const theme = useTheme();
|
|
38
|
-
|
|
39
|
-
const selectedTimePeriodData = useAtomValue(selectedTimePeriodAtom);
|
|
40
|
-
|
|
41
|
-
const changeSelectedTimePeriod = useSetAtom(
|
|
42
|
-
changeSelectedTimePeriodDerivedAtom
|
|
43
|
-
);
|
|
44
|
-
|
|
45
|
-
const currentTimePeriods = useSortTimePeriods([
|
|
46
|
-
...timePeriods,
|
|
47
|
-
...extraTimePeriods
|
|
48
|
-
]);
|
|
49
|
-
|
|
50
|
-
const timePeriodOptions = map(
|
|
51
|
-
pick(['id', 'name', 'largeName']),
|
|
52
|
-
currentTimePeriods
|
|
53
|
-
);
|
|
54
|
-
|
|
55
|
-
return (
|
|
56
|
-
<div>
|
|
57
|
-
<ButtonGroup
|
|
58
|
-
className={classes.buttonGroup}
|
|
59
|
-
color="primary"
|
|
60
|
-
component="span"
|
|
61
|
-
disabled={disabled}
|
|
62
|
-
size="small"
|
|
63
|
-
>
|
|
64
|
-
{map(
|
|
65
|
-
({ id, name, largeName }) => (
|
|
66
|
-
<Tooltip key={name} placement="top" title={largeName}>
|
|
67
|
-
<Button
|
|
68
|
-
className={classes.button}
|
|
69
|
-
component="span"
|
|
70
|
-
data-testid={id}
|
|
71
|
-
variant={
|
|
72
|
-
equals(selectedTimePeriodData?.id, id)
|
|
73
|
-
? 'contained'
|
|
74
|
-
: 'outlined'
|
|
75
|
-
}
|
|
76
|
-
onClick={(): void =>
|
|
77
|
-
changeSelectedTimePeriod({
|
|
78
|
-
id,
|
|
79
|
-
timePeriods: currentTimePeriods
|
|
80
|
-
})
|
|
81
|
-
}
|
|
82
|
-
>
|
|
83
|
-
{
|
|
84
|
-
cond<number, string>([
|
|
85
|
-
[lte(theme.breakpoints.values.md), always(largeName)],
|
|
86
|
-
[T, always(name)]
|
|
87
|
-
])(width) as string
|
|
88
|
-
}
|
|
89
|
-
</Button>
|
|
90
|
-
</Tooltip>
|
|
91
|
-
),
|
|
92
|
-
timePeriodOptions
|
|
93
|
-
)}
|
|
94
|
-
</ButtonGroup>
|
|
95
|
-
</div>
|
|
96
|
-
);
|
|
97
|
-
};
|
|
98
|
-
|
|
99
|
-
export default SelectedTimePeriod;
|