Delaying reboot/shutdown with asyncio sleep to give API time to shut down.

This commit is contained in:
Roland 2023-08-18 11:55:14 -06:00
parent 5ffb8bee8d
commit 4cc00a9cb1
No known key found for this signature in database
GPG key ID: 9D6DBD3ACF11AB93
9 changed files with 71 additions and 49 deletions

View file

@ -32,6 +32,14 @@ function handleEvents(events) {
eventToast('Refresh completed', 'Files have been refreshed.');
}
if (event === 'shutdown') {
eventToast('Shutdown', message, 'warning');
}
if (event === 'shutdown_failed') {
eventToast('Shutdown Failed', message, 'error');
}
if (event === 'downloads_disabled') {
eventToast('Downloads Disabled', message, 'info');
}

View file

@ -21,6 +21,13 @@ export function ShutdownButton() {
time: 5000,
type: "error",
})
} else if (response && response['code'] === 'NATIVE_ONLY') {
toast({
title: 'Shutdown Failed',
description: 'Cannot shutdown while running in Docker',
time: 5000,
type: "error",
})
} else if (response !== null) {
toast({
title: 'Shutdown Failed',
@ -58,13 +65,20 @@ export function RestartButton() {
const handleRestart = async () => {
try {
const response = await postRestart();
if (response && response['code'] === 'RESTART_FAILED') {
if (response && response['code'] === 'SHUTDOWN_FAILED') {
toast({
title: 'Restart Failed',
description: response['error'],
time: 5000,
type: "error",
})
} else if (response && response['code'] === 'NATIVE_ONLY') {
toast({
title: 'Restart Failed',
description: 'Cannot restart while running in Docker',
time: 5000,
type: "error",
})
} else if (response !== null) {
toast({
title: 'Restart Failed',