mirror of
https://github.com/blakeblackshear/frigate.git
synced 2026-02-02 01:05:20 +03:00
improved user experience
This commit is contained in:
parent
f2eebf2a02
commit
8652b454bb
@ -6,17 +6,14 @@ import AutoAwesomeIcon from './icons/AutoAwesome';
|
||||
import LightModeIcon from './icons/LightMode';
|
||||
import DarkModeIcon from './icons/DarkMode';
|
||||
import FrigateRestartIcon from './icons/FrigateRestart';
|
||||
import Dialog from './components/Dialog';
|
||||
import DialogRestart from './components/DialogRestart';
|
||||
import { useDarkMode } from './context';
|
||||
import { useCallback, useRef, useState } from 'preact/hooks';
|
||||
import { useRestart } from './api/mqtt';
|
||||
|
||||
export default function AppBar() {
|
||||
const [showMoreMenu, setShowMoreMenu] = useState(false);
|
||||
const [showDialog, setShowDialog] = useState(false);
|
||||
const [showDialogWait, setShowDialogWait] = useState(false);
|
||||
const [showDialogRestart, setShowDialogRestart] = useState(false);
|
||||
const { setDarkMode } = useDarkMode();
|
||||
const { send: sendRestart } = useRestart();
|
||||
|
||||
const handleSelectDarkMode = useCallback(
|
||||
(value, label) => {
|
||||
@ -36,16 +33,6 @@ export default function AppBar() {
|
||||
setShowMoreMenu(false);
|
||||
}, [setShowMoreMenu]);
|
||||
|
||||
const handleClickRestartDialog = useCallback(() => {
|
||||
setShowDialog(false);
|
||||
setShowDialogWait(true);
|
||||
sendRestart();
|
||||
}, [setShowDialog]); // eslint-disable-line react-hooks/exhaustive-deps
|
||||
|
||||
const handleDismissRestartDialog = useCallback(() => {
|
||||
setShowDialog(false);
|
||||
}, [setShowDialog]);
|
||||
|
||||
const handleRestart = useCallback(() => {
|
||||
setShowMoreMenu(false);
|
||||
setShowDialog(true);
|
||||
@ -63,24 +50,8 @@ export default function AppBar() {
|
||||
<MenuSeparator />
|
||||
<MenuItem icon={FrigateRestartIcon} label="Restart Frigate" onSelect={handleRestart} />
|
||||
</Menu>
|
||||
) : null},
|
||||
{showDialog ? (
|
||||
<Dialog
|
||||
onDismiss={handleDismissRestartDialog}
|
||||
title="Restart Frigate"
|
||||
text="Are you sure?"
|
||||
actions={[
|
||||
{ text: 'Yes', color: 'red', onClick: handleClickRestartDialog },
|
||||
{ text: 'Cancel', onClick: handleDismissRestartDialog },
|
||||
]}
|
||||
/>
|
||||
) : null},
|
||||
{showDialogWait ? (
|
||||
<Dialog
|
||||
title="Restart in progress"
|
||||
text="Please wait a few seconds for the restart to complete before reloading the page."
|
||||
/>
|
||||
) : null}
|
||||
<DialogRestart showDialog={showDialogRestart} setShowDialog={setShowDialogRestart} />
|
||||
</Fragment>
|
||||
);
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user