mirror of
https://github.com/mofeng-git/One-KVM.git
synced 2025-12-12 17:20:30 +08:00
atx confirmation
This commit is contained in:
parent
ba22978d63
commit
d5b59043de
@ -235,8 +235,20 @@
|
|||||||
</div>
|
</div>
|
||||||
</li>
|
</li>
|
||||||
<li class="right feature-disabled" id="atx-dropdown"><a class="menu-button" href="#"><img class="led-gray" data-dont-hide-menu id="atx-power-led" src="/share/svg/led-atx-power.svg"><img class="led-gray" data-dont-hide-menu id="atx-hdd-led" src="/share/svg/led-atx-hdd.svg">ATX</a>
|
<li class="right feature-disabled" id="atx-dropdown"><a class="menu-button" href="#"><img class="led-gray" data-dont-hide-menu id="atx-power-led" src="/share/svg/led-atx-power.svg"><img class="led-gray" data-dont-hide-menu id="atx-hdd-led" src="/share/svg/led-atx-hdd.svg">ATX</a>
|
||||||
<div class="menu">
|
<div class="menu" data-dont-hide-menu>
|
||||||
<div class="text"><b>Control the server's power<br></b><sub>Use the short click for ACPI shutdown</sub></div>
|
<div class="text"><b>Control the server's power<br></b><sub>Use the short click for ACPI shutdown</sub></div>
|
||||||
|
<hr>
|
||||||
|
<table class="kv">
|
||||||
|
<tr>
|
||||||
|
<td>Ask click confirmation:</td>
|
||||||
|
<td align="right">
|
||||||
|
<div class="switch-box">
|
||||||
|
<input checked type="checkbox" id="atx-ask-switch">
|
||||||
|
<label for="atx-ask-switch"><span class="switch-inner"></span><span class="switch"></span></label>
|
||||||
|
</div>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
</table>
|
||||||
<hr>
|
<hr>
|
||||||
<div class="buttons">
|
<div class="buttons">
|
||||||
<button disabled id="atx-power-button">• Click Power <sup><i>short</i></sup></button>
|
<button disabled id="atx-power-button">• Click Power <sup><i>short</i></sup></button>
|
||||||
|
|||||||
@ -3,11 +3,13 @@ li(id="atx-dropdown" class="right feature-disabled")
|
|||||||
+navbar_led("atx-power-led", "led-atx-power")
|
+navbar_led("atx-power-led", "led-atx-power")
|
||||||
+navbar_led("atx-hdd-led", "led-atx-hdd")
|
+navbar_led("atx-hdd-led", "led-atx-hdd")
|
||||||
| ATX
|
| ATX
|
||||||
div(class="menu")
|
div(data-dont-hide-menu class="menu")
|
||||||
div(class="text")
|
div(class="text")
|
||||||
b Control the server's power#[br]
|
b Control the server's power#[br]
|
||||||
sub Use the short click for ACPI shutdown
|
sub Use the short click for ACPI shutdown
|
||||||
hr
|
hr
|
||||||
|
+menu_switch("atx-ask-switch", "Ask click confirmation", true, true)
|
||||||
|
hr
|
||||||
div(class="buttons")
|
div(class="buttons")
|
||||||
button(disabled id="atx-power-button") • Click Power #[sup #[i short]]
|
button(disabled id="atx-power-button") • Click Power #[sup #[i short]]
|
||||||
button(disabled id="atx-power-button-long") • Click Power #[sup #[i long]]
|
button(disabled id="atx-power-button-long") • Click Power #[sup #[i long]]
|
||||||
|
|||||||
@ -36,6 +36,12 @@ export function Atx() {
|
|||||||
$("atx-power-led").title = "Power Led";
|
$("atx-power-led").title = "Power Led";
|
||||||
$("atx-hdd-led").title = "Disk Activity Led";
|
$("atx-hdd-led").title = "Disk Activity Led";
|
||||||
|
|
||||||
|
$("atx-ask-switch").checked = parseInt(tools.storage.get("atx.ask", "1"));
|
||||||
|
tools.el.setOnClick($("atx-ask-switch"), function() {
|
||||||
|
tools.storage.set("atx.ask", ($("atx-ask-switch").checked ? 1 : 0));
|
||||||
|
}, false);
|
||||||
|
|
||||||
|
|
||||||
for (let args of [
|
for (let args of [
|
||||||
["atx-power-button", "power", "Are you sure you want to press the power button?"],
|
["atx-power-button", "power", "Are you sure you want to press the power button?"],
|
||||||
["atx-power-button-long", "power_long", `
|
["atx-power-button-long", "power_long", `
|
||||||
@ -70,19 +76,27 @@ export function Atx() {
|
|||||||
};
|
};
|
||||||
|
|
||||||
var __clickButton = function(button, confirm_msg) {
|
var __clickButton = function(button, confirm_msg) {
|
||||||
wm.confirm(confirm_msg).then(function(ok) {
|
let click_button = function() {
|
||||||
if (ok) {
|
let http = tools.makeRequest("POST", `/api/atx/click?button=${button}`, function() {
|
||||||
let http = tools.makeRequest("POST", `/api/atx/click?button=${button}`, function() {
|
if (http.readyState === 4) {
|
||||||
if (http.readyState === 4) {
|
if (http.status === 409) {
|
||||||
if (http.status === 409) {
|
wm.error("Performing another ATX operation for other client.<br>Please try again later");
|
||||||
wm.error("Performing another ATX operation for other client.<br>Please try again later");
|
} else if (http.status !== 200) {
|
||||||
} else if (http.status !== 200) {
|
wm.error("Click error:<br>", http.responseText);
|
||||||
wm.error("Click error:<br>", http.responseText);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
});
|
}
|
||||||
}
|
});
|
||||||
});
|
};
|
||||||
|
|
||||||
|
if ($("atx-ask-switch").checked) {
|
||||||
|
wm.confirm(confirm_msg).then(function(ok) {
|
||||||
|
if (ok) {
|
||||||
|
click_button();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
click_button();
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
__init__();
|
__init__();
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user