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]);
const handleClose = (event: object, reason: 'backdropClick' | 'escapeKeyDown') => {
const handleClose = (_event, reason: 'backdropClick' | 'escapeKeyDown') => {
if (reason !== 'backdropClick') {
onClose();
}

View File

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

View File

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

View File

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

View File

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

View File

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