fix: allow 'reboot' to application when on on battery
Having to press the power button again to wake up the device is less annoying to the user than not being able to apply settings when the device is on battery. Signed-off-by: Matthias Blankertz <matthias@blankertz.org>
This commit is contained in:
@@ -167,7 +167,7 @@
|
|||||||
<div id="screen-config" class="screen">
|
<div id="screen-config" class="screen">
|
||||||
<h2>Configuration Editor</h2>
|
<h2>Configuration Editor</h2>
|
||||||
<div id="config-container">Loading…</div>
|
<div id="config-container">Loading…</div>
|
||||||
<button id="config-save-btn" disabled>Save</button>
|
<button id="config-save-btn" disabled>Save & Reboot</button>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<!-- PLAYLIST EDITOR SCREEN 1: list of playlists -->
|
<!-- PLAYLIST EDITOR SCREEN 1: list of playlists -->
|
||||||
@@ -316,7 +316,9 @@
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
alert("Configuration saved successfully!");
|
alert("Configuration saved successfully, device will now reboot/shutdown! " +
|
||||||
|
"On battery, press Power button after shutdown to restart.");
|
||||||
|
await fetch('/api/v1/reboot/application', {'method': 'POST'});
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
alert("Error saving configuration: " + err);
|
alert("Error saving configuration: " + err);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -269,10 +269,9 @@ async def audiofile_delete(request):
|
|||||||
|
|
||||||
@webapp.route('/api/v1/reboot/<method>', methods=['POST'])
|
@webapp.route('/api/v1/reboot/<method>', methods=['POST'])
|
||||||
async def reboot(request, method):
|
async def reboot(request, method):
|
||||||
if hwconfig.get_on_battery():
|
|
||||||
return 'not allowed: usb not connected', 403
|
|
||||||
|
|
||||||
if method == 'bootloader':
|
if method == 'bootloader':
|
||||||
|
if hwconfig.get_on_battery():
|
||||||
|
return 'not possible: connect USB first', 403
|
||||||
leds.set_state(LedManager.REBOOTING)
|
leds.set_state(LedManager.REBOOTING)
|
||||||
timer_manager.schedule(time.ticks_ms() + 1500, machine.bootloader)
|
timer_manager.schedule(time.ticks_ms() + 1500, machine.bootloader)
|
||||||
elif method == 'application':
|
elif method == 'application':
|
||||||
|
|||||||
Reference in New Issue
Block a user