pikvm/pikvm#1518: web: switch: Toggle to disable MSD warning

This commit is contained in:
Maxim Devaev
2025-06-03 04:59:29 +03:00
parent 54cb364c2e
commit 37e8aa2cec
4 changed files with 47 additions and 23 deletions

View File

@@ -46,6 +46,7 @@ export function Switch() {
tools.el.setOnClick($("switch-edid-copy-data-button"), __clickCopyEdidDataButton);
tools.storage.bindSimpleSwitch($("switch-atx-ask-switch"), "switch.atx.ask", true);
tools.storage.bindSimpleSwitch($("switch-msd-ask-switch"), "switch.msd.ask", true);
for (let role of ["inactive", "active", "flashing", "beacon", "bootloader"]) {
let el_brightness = $(`switch-color-${role}-brightness-slider`);
@@ -563,13 +564,24 @@ export function Switch() {
};
var __switchActivePort = function(port) {
let switch_port = () => __sendPost("api/switch/set_active", {"port": port});
if (__msd_connected) {
wm.error(`
Oops! Before port switching, please disconnect an active Mass Storage Drive image first.
Otherwise, it will break a current USB operation (OS installation, Live CD, or whatever).
`);
if ($("switch-msd-ask-switch").checked) {
wm.confirm(`
The Mass Storage Drive is active.<br><br>
If you switch the port now, it will break a current USB disk operation<br>
(OS installation, Live CD, or whatever).<br><br>
Are you sure you want to continue a port switching?
`).then(function(ok) {
if (ok) {
switch_port();
}
});
} else {
switch_port();
}
} else {
__sendPost("api/switch/set_active", {"port": port});
switch_port();
}
};
@@ -592,9 +604,7 @@ export function Switch() {
};
var __atxClick = function(port, button) {
let click_button = function() {
__sendPost("api/switch/atx/click", {"port": port, "button": button});
};
let click_button = () => __sendPost("api/switch/atx/click", {"port": port, "button": button});
if ($("switch-atx-ask-switch").checked) {
wm.confirm(`
Are you sure you want to press the <b>${tools.escape(button)}</b> button?<br>