Skip to content

Commit

Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Show a toast when restarting the device
Browse files Browse the repository at this point in the history
mairas committed Aug 13, 2024
1 parent fb6b9ec commit f0545e1
Showing 2 changed files with 1,908 additions and 1,899 deletions.
11 changes: 10 additions & 1 deletion frontend/src/pages/System/index.tsx
Original file line number Diff line number Diff line change
@@ -319,6 +319,7 @@ function AuthCard(): JSX.Element {
*/
function RestartCard(): JSX.Element {
const [httpErrorText, setHttpErrorText] = useState("");
const [showRestartToast, setShowRestartToast] = useState(false);

const id = useId();

@@ -336,6 +337,7 @@ function RestartCard(): JSX.Element {
setTimeout(() => {
window.location.reload();
}, 5000);
setShowRestartToast(true);
} catch (e) {
setHttpErrorText(`Error restarting the device: ${e}`);
}
@@ -344,12 +346,19 @@ function RestartCard(): JSX.Element {
return (
<>
<ToastMessage
color="text-bg-warning"
color="text-bg-danger"
show={httpErrorText !== ""}
onHide={() => setHttpErrorText("")}
>
<p>Failed to restart: {httpErrorText}</p>
</ToastMessage>
<ToastMessage
color="text-bg-warning"
show={showRestartToast}
onHide={() => {setShowRestartToast(false)}}
>
<p>Restarting the device...</p>
</ToastMessage>
<ButtonCard
title="Restart the device"
buttonText="Restart"
3,796 changes: 1,898 additions & 1,898 deletions src/sensesp/net/web/autogen/frontend_files.h

Large diffs are not rendered by default.

0 comments on commit f0545e1

Please sign in to comment.