diff options
author | Devaev Maxim <[email protected]> | 2021-01-14 23:29:52 +0300 |
---|---|---|
committer | Devaev Maxim <[email protected]> | 2021-01-14 23:29:52 +0300 |
commit | 8a45ce9146df3aa7c53b75c08ae0a4655e013ce2 (patch) | |
tree | fbef16bc6a3438417b38822f9dd6df1fb1bc3fda /web/share/js | |
parent | 1799e34fd009c1316c5e6a5281bba09b44b3134d (diff) |
v3 usb breaker
Diffstat (limited to 'web/share/js')
-rw-r--r-- | web/share/js/kvm/gpio.js | 18 |
1 files changed, 12 insertions, 6 deletions
diff --git a/web/share/js/kvm/gpio.js b/web/share/js/kvm/gpio.js index e874c81d..9a339da6 100644 --- a/web/share/js/kvm/gpio.js +++ b/web/share/js/kvm/gpio.js @@ -104,6 +104,8 @@ export function Gpio() { } } + tools.featureSetEnabled($("v3-usb-breaker"), ("__v3_usb_breaker__" in model.scheme.outputs)); + self.setState(__state); }; @@ -121,11 +123,12 @@ export function Gpio() { `; } else if (item.type === "output") { let controls = []; + let confirm = (item.confirm ? "Are you sure to act this control?" : ""); if (item.scheme["switch"]) { controls.push(` <td><div class="switch-box"> <input disabled type="checkbox" id="gpio-switch-${item.channel}" class="gpio-switch" - data-channel="${item.channel}" data-confirm="${Number(item.confirm)}" /> + data-channel="${item.channel}" data-confirm="${confirm}" /> <label for="gpio-switch-${item.channel}"> <span class="switch-inner"></span> <span class="switch"></span> @@ -136,7 +139,7 @@ export function Gpio() { if (item.scheme.pulse.delay) { controls.push(` <td><button disabled id="gpio-button-${item.channel}" class="gpio-button" - data-channel="${item.channel}" data-confirm="${Number(item.confirm)}">${item.text}</button></td> + data-channel="${item.channel}" data-confirm="${confirm}">${item.text}</button></td> `); } return `<table><tr>${controls.join("<td> </td>")}</tr></table>`; @@ -158,11 +161,14 @@ export function Gpio() { var __switchChannel = function(el) { let channel = el.getAttribute("data-channel"); - let confirm = parseInt(el.getAttribute("data-confirm")); + let confirm = el.getAttribute("data-confirm"); let to = ($(`gpio-switch-${channel}`).checked ? "1" : "0"); + if (to === "0" && el.hasAttribute("data-confirm-off")) { + confirm = el.getAttribute("data-confirm-off"); + } let act = () => __sendPost(`/api/gpio/switch?channel=${channel}&state=${to}`); if (confirm) { - wm.confirm("Are you sure to act this switch?").then(function(ok) { + wm.confirm(confirm).then(function(ok) { if (ok) { act(); } else { @@ -176,10 +182,10 @@ export function Gpio() { var __pulseChannel = function(el) { let channel = el.getAttribute("data-channel"); - let confirm = parseInt(el.getAttribute("data-confirm")); + let confirm = el.getAttribute("data-confirm"); let act = () => __sendPost(`/api/gpio/pulse?channel=${channel}`); if (confirm) { - wm.confirm("Are you sure to click this button?").then(function(ok) { if (ok) act(); }); + wm.confirm(confirm).then(function(ok) { if (ok) act(); }); } else { act(); } |