From 436b10a87bafaea2376a6629ab0f8c92ff4c2c4c Mon Sep 17 00:00:00 2001 From: ElMoribond Date: Mon, 21 Jun 2021 17:11:09 +0200 Subject: [PATCH] Add ability to restart --- web/src/AppBar.jsx | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) diff --git a/web/src/AppBar.jsx b/web/src/AppBar.jsx index 6a3ff2a72..12da10cf6 100644 --- a/web/src/AppBar.jsx +++ b/web/src/AppBar.jsx @@ -5,12 +5,18 @@ import Menu, { MenuItem, MenuSeparator } from './components/Menu'; 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 { 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 { setDarkMode } = useDarkMode(); + const { send: sendRestart } = useRestart(); const handleSelectDarkMode = useCallback( (value, label) => { @@ -30,6 +36,21 @@ export default function AppBar() { setShowMoreMenu(false); }, [setShowMoreMenu]); + const handleClickRestartDialog = useCallback(() => { + setShowDialog(false); + setShowDialogWait(true); + sendRestart(); + }, [setShowDialog]); + + const handleDismissRestartDialog = () => { + setShowDialog(false); + }; + + const handleRestart = useCallback(() => { + setShowMoreMenu(false); + setShowDialog(true); + }); + return ( @@ -39,7 +60,26 @@ export default function AppBar() { + + + ) : null}, + {showDialog ? ( + + ) : null}, + {showDialogWait ? ( + ) : null} );