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

@ -962,18 +962,28 @@
</div>
<hr>
</div>
<table class="kv">
<tr>
<td>Ask ATX click confirmation:
</td>
<td align="right">
<div class="switch-box">
<input checked type="checkbox" id="switch-atx-ask-switch">
<label for="switch-atx-ask-switch"><span class="switch-inner"></span><span class="switch"></span></label>
</div>
</td>
</tr>
</table>
<table class="kv">
<tr>
<td>Ask ATX click confirmation:
</td>
<td align="right">
<div class="switch-box">
<input checked type="checkbox" id="switch-atx-ask-switch">
<label for="switch-atx-ask-switch"><span class="switch-inner"></span><span class="switch"></span></label>
</div>
</td>
</tr>
<tr>
<td>Confirm switching when the Drive is connected:
</td>
<td align="right">
<div class="switch-box">
<input checked type="checkbox" id="switch-msd-ask-switch">
<label for="switch-msd-ask-switch"><span class="switch-inner"></span><span class="switch"></span></label>
</div>
</td>
</tr>
</table>
<hr>
<table class="kv" id="switch-chain"></table>
</div>

View File

@ -22,7 +22,11 @@ li.right.feature-disabled#switch-dropdown
| when you decide to install it.
hr
+menu_switch_table("switch-atx-ask-switch", true, true) Ask ATX click confirmation:
table.kv
tr
+menu_switch_td2("switch-atx-ask-switch", true, true) Ask ATX click confirmation:
tr
+menu_switch_td2("switch-msd-ask-switch", true, true) Confirm switching when the Drive is connected:
hr
table.kv#switch-chain

View File

@ -56,8 +56,8 @@ div.modal div.modal-window div.modal-header {
}
div.modal div.modal-window div.modal-content {
max-width: 500px;
max-height: 500px;
max-width: 600px;
max-height: 600px;
padding: 16px 9px 16px 9px;
}

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>