-
Notifications
You must be signed in to change notification settings - Fork 400
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Introducing new Timer UI, including Idle Shutdown
- Loading branch information
Showing
7 changed files
with
183 additions
and
45 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
101 changes: 101 additions & 0 deletions
101
src/webapp/src/components/Settings/timers/set-timer-dialog.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,101 @@ | ||
import React, { useState } from 'react'; | ||
import { useTranslation } from 'react-i18next'; | ||
|
||
import { | ||
Box, | ||
Button, | ||
Dialog, | ||
DialogActions, | ||
DialogContent, | ||
DialogContentText, | ||
DialogTitle, | ||
Grid, | ||
} from '@mui/material'; | ||
import { useTheme } from '@mui/material/styles'; | ||
|
||
import { | ||
SliderTimer | ||
} from '../../general'; | ||
|
||
export default function SetTimerDialog({ | ||
type, | ||
enabled, | ||
setTimer, | ||
cancelTimer, | ||
waitSeconds, | ||
setWaitSeconds, | ||
}) { | ||
const { t } = useTranslation(); | ||
const theme = useTheme(); | ||
|
||
const [dialogOpen, setDialogOpen] = useState(false); | ||
|
||
const handleClickOpen = () => { | ||
setWaitSeconds(0); | ||
setDialogOpen(true); | ||
}; | ||
|
||
const handleCancel = () => { | ||
setDialogOpen(false); | ||
}; | ||
|
||
const handleSetTimer = () => { | ||
setTimer(waitSeconds) | ||
setDialogOpen(false); | ||
} | ||
|
||
return ( | ||
<Box sx={{ marginLeft: '10px' }}> | ||
{!enabled && | ||
<Button | ||
variant="outlined" | ||
onClick={handleClickOpen} | ||
> | ||
{t('settings.timers.set')} | ||
</Button> | ||
} | ||
{enabled && | ||
<Button | ||
variant="outlined" | ||
onClick={cancelTimer} | ||
> | ||
{t('settings.timers.cancel')} | ||
</Button> | ||
} | ||
<Dialog | ||
open={dialogOpen} | ||
onClose={handleCancel} | ||
aria-labelledby="alert-dialog-title" | ||
aria-describedby="alert-dialog-description" | ||
> | ||
<DialogTitle id="alert-dialog-title"> | ||
{t('settings.timers.dialog.title', { value: t(`settings.timers.${type}`)} )} | ||
</DialogTitle> | ||
<DialogContent> | ||
<DialogContentText id="alert-dialog-description"> | ||
{t('settings.timers.dialog.description')} | ||
</DialogContentText> | ||
<Grid item sx={{ padding: theme.spacing(1) }}> | ||
<SliderTimer | ||
value={waitSeconds || 0} | ||
onChangeCommitted={(evt, value) => { setWaitSeconds(value) }} | ||
/> | ||
</Grid> | ||
</DialogContent> | ||
<DialogActions> | ||
<Button onClick={handleCancel} color="secondary"> | ||
{t('settings.timers.dialog.cancel')} | ||
</Button> | ||
<Button | ||
onClick={handleSetTimer} | ||
color="primary" | ||
autoFocus | ||
disabled={waitSeconds === 0} | ||
> | ||
{t('settings.timers.dialog.start')} | ||
</Button> | ||
</DialogActions> | ||
</Dialog> | ||
</Box> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters