Merge pull request #1901 from proddy/dev

updates to scheduler web
This commit is contained in:
Proddy
2024-07-28 19:50:29 +02:00
committed by GitHub
6 changed files with 45 additions and 42 deletions

View File

@@ -64,7 +64,7 @@ const CustomEntitiesDialog = ({
} }
}, [open, selectedItem]); }, [open, selectedItem]);
const handleClose = (event: object, reason: 'backdropClick' | 'escapeKeyDown') => { const handleClose = (_event, reason: 'backdropClick' | 'escapeKeyDown') => {
if (reason !== 'backdropClick') { if (reason !== 'backdropClick') {
onClose(); onClose();
} }

View File

@@ -54,7 +54,7 @@ const CustomizationDialog = ({
} }
}, [open, selectedItem]); }, [open, selectedItem]);
const handleClose = (event: object, reason: 'backdropClick' | 'escapeKeyDown') => { const handleClose = (_event, reason: 'backdropClick' | 'escapeKeyDown') => {
if (reason !== 'backdropClick') { if (reason !== 'backdropClick') {
onClose(); onClose();
} }

View File

@@ -219,27 +219,33 @@ const Scheduler: FC = () => {
<Box> <Box>
<Typography <Typography
sx={{ fontSize: 11 }} sx={{ fontSize: 11 }}
color={ color={(si.flags & flag) === flag ? 'primary' : 'grey'}
si.flags >= ScheduleFlag.SCHEDULE_TIMER && si.flags !== flag
? 'gray'
: (si.flags & flag) === flag
? 'primary'
: 'grey'
}
> >
{flag === ScheduleFlag.SCHEDULE_TIMER {dow[Math.log(flag) / Math.log(2)]}
? LL.TIMER(0)
: flag === ScheduleFlag.SCHEDULE_ONCHANGE
? 'On Change'
: flag === ScheduleFlag.SCHEDULE_CONDITION
? 'Condition'
: dow[Math.log(flag) / Math.log(2)]}
</Typography> </Typography>
</Box> </Box>
<Divider orientation="vertical" flexItem /> <Divider orientation="vertical" flexItem />
</> </>
); );
const scheduleType = (si: ScheduleItem) => (
<Box>
<Typography sx={{ fontSize: 11 }} color="primary">
{si.flags === ScheduleFlag.SCHEDULE_IMMEDIATE ? (
<>Immediate</>
) : si.flags === ScheduleFlag.SCHEDULE_TIMER ? (
<>Timer</>
) : si.flags === ScheduleFlag.SCHEDULE_CONDITION ? (
<>Condition</>
) : si.flags === ScheduleFlag.SCHEDULE_ONCHANGE ? (
<>On Change</>
) : (
<></>
)}
</Typography>
</Box>
);
useLayoutTitle(LL.SCHEDULER()); useLayoutTitle(LL.SCHEDULER());
return ( return (
@@ -283,9 +289,9 @@ const Scheduler: FC = () => {
<Cell stiff> <Cell stiff>
<Stack spacing={0.5} direction="row"> <Stack spacing={0.5} direction="row">
<Divider orientation="vertical" flexItem /> <Divider orientation="vertical" flexItem />
{si.flags === ScheduleFlag.SCHEDULE_IMMEDIATE ? ( {si.flags > 127 ? (
<></> scheduleType(si)
) : si.flags < ScheduleFlag.SCHEDULE_TIMER ? ( ) : (
<> <>
{dayBox(si, ScheduleFlag.SCHEDULE_MON)} {dayBox(si, ScheduleFlag.SCHEDULE_MON)}
{dayBox(si, ScheduleFlag.SCHEDULE_TUE)} {dayBox(si, ScheduleFlag.SCHEDULE_TUE)}
@@ -295,12 +301,6 @@ const Scheduler: FC = () => {
{dayBox(si, ScheduleFlag.SCHEDULE_SAT)} {dayBox(si, ScheduleFlag.SCHEDULE_SAT)}
{dayBox(si, ScheduleFlag.SCHEDULE_SUN)} {dayBox(si, ScheduleFlag.SCHEDULE_SUN)}
</> </>
) : (
<>
{dayBox(si, ScheduleFlag.SCHEDULE_TIMER)}
{dayBox(si, ScheduleFlag.SCHEDULE_ONCHANGE)}
{dayBox(si, ScheduleFlag.SCHEDULE_CONDITION)}
</>
)} )}
</Stack> </Stack>
</Cell> </Cell>

View File

@@ -144,7 +144,7 @@ const SchedulerDialog = ({
</Typography> </Typography>
); );
const handleClose = (event: object, reason: 'backdropClick' | 'escapeKeyDown') => { const handleClose = (_event, reason: 'backdropClick' | 'escapeKeyDown') => {
if (reason !== 'backdropClick') { if (reason !== 'backdropClick') {
onClose(); onClose();
} }
@@ -164,20 +164,23 @@ const SchedulerDialog = ({
exclusive exclusive
disabled={!creating} disabled={!creating}
onChange={(_event, flag: ScheduleFlag) => { onChange={(_event, flag: ScheduleFlag) => {
setScheduleType(flag); if (flag !== null) {
// wipe the time field when changing the schedule type setFieldErrors(undefined); // clear any validation errors
setEditItem({ ...editItem, time: '' }); setScheduleType(flag);
// set the flags based on type // wipe the time field when changing the schedule type
// 0-127 is day schedule setEditItem({ ...editItem, time: '' });
// 128 is timer // set the flags based on type
// 129 is on change // 0-127 is day schedule
// 130 is on condition // 128 is timer
// 132 is immediate // 129 is on change
setEditItem( // 130 is on condition
flag === ScheduleFlag.SCHEDULE_DAY // 132 is immediate
? { ...editItem, flags: 0 } setEditItem(
: { ...editItem, flags: flag } flag === ScheduleFlag.SCHEDULE_DAY
); ? { ...editItem, flags: 0 }
: { ...editItem, flags: flag }
);
}
}} }}
> >
<ToggleButton value={ScheduleFlag.SCHEDULE_DAY}> <ToggleButton value={ScheduleFlag.SCHEDULE_DAY}>

View File

@@ -57,7 +57,7 @@ const SensorsAnalogDialog = ({
} }
}, [open, selectedItem]); }, [open, selectedItem]);
const handleClose = (event: object, reason: 'backdropClick' | 'escapeKeyDown') => { const handleClose = (_event, reason: 'backdropClick' | 'escapeKeyDown') => {
if (reason !== 'backdropClick') { if (reason !== 'backdropClick') {
onClose(); onClose();
} }

View File

@@ -52,7 +52,7 @@ const SensorsTemperatureDialog = ({
} }
}, [open, selectedItem]); }, [open, selectedItem]);
const handleClose = (event: object, reason: 'backdropClick' | 'escapeKeyDown') => { const handleClose = (_event, reason: 'backdropClick' | 'escapeKeyDown') => {
if (reason !== 'backdropClick') { if (reason !== 'backdropClick') {
onClose(); onClose();
} }