mirror of
https://github.com/emsesp/EMS-ESP32.git
synced 2025-12-08 00:39:50 +03:00
minor improvements to add dialog
This commit is contained in:
@@ -13,7 +13,10 @@ import {
|
|||||||
MenuItem,
|
MenuItem,
|
||||||
ToggleButtonGroup,
|
ToggleButtonGroup,
|
||||||
Checkbox,
|
Checkbox,
|
||||||
TextField
|
TextField,
|
||||||
|
Radio,
|
||||||
|
RadioGroup,
|
||||||
|
FormControlLabel
|
||||||
} from '@mui/material';
|
} from '@mui/material';
|
||||||
|
|
||||||
import { useTheme } from '@table-library/react-table-library/theme';
|
import { useTheme } from '@table-library/react-table-library/theme';
|
||||||
@@ -38,18 +41,17 @@ import {
|
|||||||
BlockNavigation
|
BlockNavigation
|
||||||
} from 'components';
|
} from 'components';
|
||||||
|
|
||||||
import * as EMSESP from './api';
|
|
||||||
|
|
||||||
import { extractErrorMessage, updateValue } from 'utils';
|
import { extractErrorMessage, updateValue } from 'utils';
|
||||||
|
|
||||||
import { validate } from 'validators';
|
import { validate } from 'validators';
|
||||||
import { schedulerItemValidation } from './validators';
|
import { schedulerItemValidation } from './validators';
|
||||||
|
import { ValidateFieldsError } from 'async-validator';
|
||||||
|
|
||||||
import { ScheduleItem, ScheduleFlag } from './types';
|
import { ScheduleItem, ScheduleFlag } from './types';
|
||||||
|
|
||||||
import Schema, { ValidateFieldsError } from 'async-validator';
|
|
||||||
|
|
||||||
import { useI18nContext } from 'i18n/i18n-react';
|
import { useI18nContext } from 'i18n/i18n-react';
|
||||||
|
|
||||||
|
import * as EMSESP from './api';
|
||||||
export const APIURL = window.location.origin + '/api/';
|
export const APIURL = window.location.origin + '/api/';
|
||||||
|
|
||||||
const SettingsScheduler: FC = () => {
|
const SettingsScheduler: FC = () => {
|
||||||
@@ -444,6 +446,26 @@ const SettingsScheduler: FC = () => {
|
|||||||
LL.SCHEDULE()}
|
LL.SCHEDULE()}
|
||||||
</DialogTitle>
|
</DialogTitle>
|
||||||
<DialogContent dividers>
|
<DialogContent dividers>
|
||||||
|
{creating && (
|
||||||
|
<RadioGroup
|
||||||
|
row
|
||||||
|
name="schedule-type"
|
||||||
|
onChange={(event) => {
|
||||||
|
if ((event.target as HTMLInputElement).value === 't') {
|
||||||
|
scheduleItem.flags = ScheduleFlag.SCHEDULE_TIMER;
|
||||||
|
scheduleItem.time = '01:00';
|
||||||
|
} else {
|
||||||
|
scheduleItem.flags = 0;
|
||||||
|
}
|
||||||
|
updateValue(setScheduleItem);
|
||||||
|
setFlags(['']); // refresh screen
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<FormControlLabel value="w" control={<Radio />} label={LL.WEEKLY()} />
|
||||||
|
<FormControlLabel value="t" control={<Radio />} label={LL.TIMER()} />
|
||||||
|
</RadioGroup>
|
||||||
|
)}
|
||||||
|
|
||||||
<TextField
|
<TextField
|
||||||
name="description"
|
name="description"
|
||||||
label={LL.DESCRIPTION()}
|
label={LL.DESCRIPTION()}
|
||||||
@@ -457,6 +479,7 @@ const SettingsScheduler: FC = () => {
|
|||||||
control={<Checkbox checked={scheduleItem.active} onChange={updateValue(setScheduleItem)} name="active" />}
|
control={<Checkbox checked={scheduleItem.active} onChange={updateValue(setScheduleItem)} name="active" />}
|
||||||
label={LL.ACTIVE()}
|
label={LL.ACTIVE()}
|
||||||
/>
|
/>
|
||||||
|
|
||||||
{(scheduleItem.flags & ScheduleFlag.SCHEDULE_TIMER) === ScheduleFlag.SCHEDULE_TIMER ? (
|
{(scheduleItem.flags & ScheduleFlag.SCHEDULE_TIMER) === ScheduleFlag.SCHEDULE_TIMER ? (
|
||||||
<TextField
|
<TextField
|
||||||
name="time"
|
name="time"
|
||||||
@@ -482,6 +505,7 @@ const SettingsScheduler: FC = () => {
|
|||||||
onChange={updateValue(setScheduleItem)}
|
onChange={updateValue(setScheduleItem)}
|
||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
|
|
||||||
<ValidatedTextField
|
<ValidatedTextField
|
||||||
fieldErrors={fieldErrors}
|
fieldErrors={fieldErrors}
|
||||||
name="cmd"
|
name="cmd"
|
||||||
|
|||||||
Reference in New Issue
Block a user