mirror of
https://github.com/mofeng-git/One-KVM.git
synced 2025-12-12 01:00:29 +08:00
minor partial state fixes
This commit is contained in:
parent
d93639ba8d
commit
7ef2e16b51
@ -394,7 +394,7 @@
|
|||||||
<td>Connect main USB to Server:</td>
|
<td>Connect main USB to Server:</td>
|
||||||
<td align="right">
|
<td align="right">
|
||||||
<div class="switch-box">
|
<div class="switch-box">
|
||||||
<input class="__gpio-switch-__v3_usb_breaker__ gpio-switch" disabled type="checkbox" id="__gpio-switch-__v3_usb_breaker__" data-channel="__v3_usb_breaker__" data-confirm-off="Turning off this switch will disconnect the main USB<br>from the server. Are you sure you want to continue?">
|
<input class="__gpio-switch-__v3_usb_breaker__ gpio-switch" disabled type="checkbox" id="__gpio-switch-__v3_usb_breaker__" data-channel="__v3_usb_breaker__" data-confirm-off="Turning off this switch will disconnect the main USB from the server. Are you sure you want to continue?">
|
||||||
<label for="__gpio-switch-__v3_usb_breaker__"><span class="switch-inner"></span><span class="switch"></span></label>
|
<label for="__gpio-switch-__v3_usb_breaker__"><span class="switch-inner"></span><span class="switch"></span></label>
|
||||||
</div>
|
</div>
|
||||||
</td>
|
</td>
|
||||||
|
|||||||
@ -122,7 +122,7 @@ li(id="system-dropdown" class="right")
|
|||||||
+menu_switch_notable("hid-mute-switch", "Mute HID input events", true, false)
|
+menu_switch_notable("hid-mute-switch", "Mute HID input events", true, false)
|
||||||
tr(id="v3-usb-breaker" class="feature-disabled")
|
tr(id="v3-usb-breaker" class="feature-disabled")
|
||||||
+menu_switch_notable_gpio("__v3_usb_breaker__", "Connect main USB to Server",
|
+menu_switch_notable_gpio("__v3_usb_breaker__", "Connect main USB to Server",
|
||||||
"Turning off this switch will disconnect the main USB<br>from the server. Are you sure you want to continue?")
|
"Turning off this switch will disconnect the main USB from the server. Are you sure you want to continue?")
|
||||||
tr(id="v4-locator" class="feature-disabled")
|
tr(id="v4-locator" class="feature-disabled")
|
||||||
+menu_switch_notable_gpio("__v4_locator__", "Enable locator LED")
|
+menu_switch_notable_gpio("__v4_locator__", "Enable locator LED")
|
||||||
tr
|
tr
|
||||||
|
|||||||
@ -53,30 +53,33 @@ export function Atx(__recorder) {
|
|||||||
__state = {"leds": {}};
|
__state = {"leds": {}};
|
||||||
}
|
}
|
||||||
if (state.enabled !== undefined) {
|
if (state.enabled !== undefined) {
|
||||||
tools.feature.setEnabled($("atx-dropdown"), state.enabled);
|
|
||||||
__state.enabled = state.enabled;
|
__state.enabled = state.enabled;
|
||||||
|
tools.feature.setEnabled($("atx-dropdown"), __state.enabled);
|
||||||
}
|
}
|
||||||
if (__state.enabled !== undefined) {
|
if (__state.enabled !== undefined) {
|
||||||
if (state.busy !== undefined) {
|
if (state.busy !== undefined) {
|
||||||
__updateButtons(!state.busy);
|
|
||||||
__state.busy = state.busy;
|
__state.busy = state.busy;
|
||||||
|
__updateButtons(!__state.busy);
|
||||||
}
|
}
|
||||||
if (state.leds !== undefined) {
|
if (state.leds !== undefined) {
|
||||||
__state.leds = state.leds;
|
__state.leds = state.leds;
|
||||||
}
|
}
|
||||||
if (state.busy !== undefined || state.leds !== undefined) {
|
if (state.busy !== undefined || state.leds !== undefined) {
|
||||||
let busy = __state.busy;
|
__updateLeds(__state.leds.power, __state.leds.hdd, __state.busy);
|
||||||
let leds = __state.leds;
|
|
||||||
$("atx-power-led").className = (busy ? "led-yellow" : (leds.power ? "led-green" : "led-gray"));
|
|
||||||
$("atx-hdd-led").className = (leds.hdd ? "led-red" : "led-gray");
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
__state = null;
|
__state = null;
|
||||||
|
__updateLeds(false, false, false);
|
||||||
__updateButtons(false);
|
__updateButtons(false);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
var __updateLeds = function(power, hdd, busy) {
|
||||||
|
$("atx-power-led").className = (busy ? "led-yellow" : (power ? "led-green" : "led-gray"));
|
||||||
|
$("atx-hdd-led").className = (hdd ? "led-red" : "led-gray");
|
||||||
|
};
|
||||||
|
|
||||||
var __updateButtons = function(enabled) {
|
var __updateButtons = function(enabled) {
|
||||||
for (let id of ["atx-power-button", "atx-power-button-long", "atx-reset-button"]) {
|
for (let id of ["atx-power-button", "atx-power-button-long", "atx-reset-button"]) {
|
||||||
tools.el.setEnabled($(id), enabled);
|
tools.el.setEnabled($(id), enabled);
|
||||||
|
|||||||
@ -38,14 +38,20 @@ export function Gpio(__recorder) {
|
|||||||
|
|
||||||
self.setState = function(state) {
|
self.setState = function(state) {
|
||||||
if (state) {
|
if (state) {
|
||||||
if (state.model) {
|
if (state.model !== undefined) {
|
||||||
__applyModel(state.model);
|
|
||||||
__has_model = true;
|
__has_model = true;
|
||||||
|
__updateModel(state.model);
|
||||||
}
|
}
|
||||||
if (__has_model && state.state) {
|
if (__has_model && state.state !== undefined) {
|
||||||
__applyState(state.state);
|
if (state.state.inputs !== undefined) {
|
||||||
|
__updateInputs(state.state.inputs);
|
||||||
|
}
|
||||||
|
if (state.state.outputs !== undefined) {
|
||||||
|
__updateOutputs(state.state.outputs);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
__has_model = false;
|
||||||
for (let el of $$("__gpio-led")) {
|
for (let el of $$("__gpio-led")) {
|
||||||
__setLedState(el, false);
|
__setLedState(el, false);
|
||||||
}
|
}
|
||||||
@ -54,33 +60,31 @@ export function Gpio(__recorder) {
|
|||||||
tools.el.setEnabled(el, false);
|
tools.el.setEnabled(el, false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
__has_model = false;
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
var __applyState = function(state) {
|
var __updateInputs = function(inputs) {
|
||||||
if (state.inputs) {
|
for (let ch in inputs) {
|
||||||
for (let ch in state.inputs) {
|
for (let el of $$(`__gpio-led-${ch}`)) {
|
||||||
for (let el of $$(`__gpio-led-${ch}`)) {
|
__setLedState(el, inputs[ch].state);
|
||||||
__setLedState(el, state.inputs[ch].state);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (state.outputs) {
|
|
||||||
for (let ch in state.outputs) {
|
|
||||||
for (let type of ["switch", "button"]) {
|
|
||||||
for (let el of $$(`__gpio-${type}-${ch}`)) {
|
|
||||||
tools.el.setEnabled(el, state.outputs[ch].online && !state.outputs[ch].busy);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
for (let el of $$(`__gpio-switch-${ch}`)) {
|
|
||||||
el.checked = state.outputs[ch].state;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
var __applyModel = function(model) {
|
var __updateOutputs = function(outputs) {
|
||||||
|
for (let ch in outputs) {
|
||||||
|
for (let type of ["switch", "button"]) {
|
||||||
|
for (let el of $$(`__gpio-${type}-${ch}`)) {
|
||||||
|
tools.el.setEnabled(el, (outputs[ch].online && !outputs[ch].busy));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
for (let el of $$(`__gpio-switch-${ch}`)) {
|
||||||
|
el.checked = outputs[ch].state;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
var __updateModel = function(model) {
|
||||||
tools.feature.setEnabled($("gpio-dropdown"), model.view.table.length);
|
tools.feature.setEnabled($("gpio-dropdown"), model.view.table.length);
|
||||||
if (model.view.table.length) {
|
if (model.view.table.length) {
|
||||||
let title = [];
|
let title = [];
|
||||||
|
|||||||
@ -66,12 +66,11 @@ export function Msd() {
|
|||||||
self.setState = function(state) {
|
self.setState = function(state) {
|
||||||
if (state) {
|
if (state) {
|
||||||
if (!__state) {
|
if (!__state) {
|
||||||
__state = {};
|
__state = {"storage": {}};
|
||||||
__state.storage = {};
|
|
||||||
}
|
}
|
||||||
if (state.enabled !== undefined) {
|
if (state.enabled !== undefined) {
|
||||||
tools.feature.setEnabled($("msd-dropdown"), state.enabled);
|
|
||||||
__state.enabled = state.enabled;
|
__state.enabled = state.enabled;
|
||||||
|
tools.feature.setEnabled($("msd-dropdown"), __state.enabled);
|
||||||
}
|
}
|
||||||
if (__state.enabled !== undefined) {
|
if (__state.enabled !== undefined) {
|
||||||
if (state.online !== undefined) {
|
if (state.online !== undefined) {
|
||||||
@ -80,31 +79,27 @@ export function Msd() {
|
|||||||
if (state.busy !== undefined) {
|
if (state.busy !== undefined) {
|
||||||
__state.busy = state.busy;
|
__state.busy = state.busy;
|
||||||
}
|
}
|
||||||
if (state.drive !== undefined || (state.storage && state.storage.images !== undefined)) {
|
if (state.drive) { // Null on offline, ignore
|
||||||
let drive = (state.drive !== undefined ? state.drive : __state.drive);
|
__state.drive = state.drive;
|
||||||
let images = (
|
}
|
||||||
state.storage && state.storage.images !== undefined
|
if (state.storage) { // Null on offline, ignore
|
||||||
? state.storage.images
|
if (state.storage.parts !== undefined) {
|
||||||
: __state.storage && __state.storage.images !== undefined
|
__state.storage.parts = state.storage.parts;
|
||||||
? __state.storage.images
|
__updateParts(__state.storage.parts);
|
||||||
: null
|
}
|
||||||
);
|
if (state.storage.uploading !== undefined) {
|
||||||
if (drive && images) {
|
__state.storage.uploading = state.storage.uploading;
|
||||||
__updateImageSelector(drive, images);
|
__updateUploading(__state.storage.uploading);
|
||||||
|
}
|
||||||
|
if (state.storage.downloading !== undefined) {
|
||||||
|
__state.storage.downloading = state.storage.downloading;
|
||||||
|
}
|
||||||
|
if (state.storage.images !== undefined) {
|
||||||
|
__state.storage.images = state.storage.images;
|
||||||
}
|
}
|
||||||
__state.drive = drive;
|
|
||||||
__state.storage.images = images;
|
|
||||||
}
|
}
|
||||||
if (state.storage && state.storage.parts !== undefined) {
|
if (state.drive || (state.storage && state.storage.images !== undefined)) {
|
||||||
__updateParts(state.storage.parts);
|
__updateImageSelector(__state.drive, __state.storage.images);
|
||||||
__state.storage.parts = state.storage.parts;
|
|
||||||
}
|
|
||||||
if (state.storage && state.storage.uploading !== undefined) {
|
|
||||||
__updateUploading(state.storage.uploading);
|
|
||||||
__state.storage.uploading = state.storage.uploading;
|
|
||||||
}
|
|
||||||
if (state.storage && state.storage.downloading !== undefined) {
|
|
||||||
__state.storage.downloading = state.storage.downloading;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@ -403,10 +398,12 @@ export function Msd() {
|
|||||||
let file = tools.input.getFile(el);
|
let file = tools.input.getFile(el);
|
||||||
if (file) {
|
if (file) {
|
||||||
$("msd-new-url").value = "";
|
$("msd-new-url").value = "";
|
||||||
let part = __state.storage.parts[$("msd-new-part-selector").value];
|
if (__state && __state.storage && __state.storage.parts) {
|
||||||
if (file.size > part.size) {
|
let part = __state.storage.parts[$("msd-new-part-selector").value];
|
||||||
wm.error(`The new image is too big for the Mass Storage partition.<br>Maximum: ${tools.formatSize(part.size)}`);
|
if (part && (file.size > part.size)) {
|
||||||
el.value = "";
|
wm.error(`The new image is too big for the Mass Storage partition.<br>Maximum: ${tools.formatSize(part.size)}`);
|
||||||
|
el.value = "";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
__refreshControls();
|
__refreshControls();
|
||||||
|
|||||||
@ -76,20 +76,26 @@ export function Ocr(__getGeometry) {
|
|||||||
if (state) {
|
if (state) {
|
||||||
if (state.enabled !== undefined) {
|
if (state.enabled !== undefined) {
|
||||||
__enabled = (state.enabled && !tools.browser.is_mobile);
|
__enabled = (state.enabled && !tools.browser.is_mobile);
|
||||||
|
tools.feature.setEnabled($("stream-ocr"), __enabled);
|
||||||
|
$("stream-ocr-led").className = (__enabled ? "led-gray" : "hidden");
|
||||||
|
}
|
||||||
|
if (__enabled && state.langs !== undefined) {
|
||||||
|
__updateLangs(state.langs);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
__enabled = false;
|
__enabled = false;
|
||||||
|
tools.feature.setEnabled($("stream-ocr"), false);
|
||||||
|
$("stream-ocr-led").className = "hidden";
|
||||||
}
|
}
|
||||||
if (__enabled) {
|
};
|
||||||
let el = $("stream-ocr-lang-selector");
|
|
||||||
el.options.length = 0;
|
var __updateLangs = function(langs) {
|
||||||
for (let lang of state.langs.available) {
|
let el = $("stream-ocr-lang-selector");
|
||||||
tools.selector.addOption(el, lang, lang);
|
el.options.length = 0;
|
||||||
}
|
for (let lang of langs.available) {
|
||||||
el.value = tools.storage.get("stream.ocr.lang", state.langs["default"]);
|
tools.selector.addOption(el, lang, lang);
|
||||||
}
|
}
|
||||||
tools.feature.setEnabled($("stream-ocr"), __enabled);
|
el.value = tools.storage.get("stream.ocr.lang", langs["default"]);
|
||||||
$("stream-ocr-led").className = (__enabled ? "led-gray" : "hidden");
|
|
||||||
};
|
};
|
||||||
|
|
||||||
var __startSelection = function(event) {
|
var __startSelection = function(event) {
|
||||||
|
|||||||
@ -138,17 +138,17 @@ export function Streamer() {
|
|||||||
if (!__state) {
|
if (!__state) {
|
||||||
__state = {};
|
__state = {};
|
||||||
}
|
}
|
||||||
if (state.features) {
|
if (state.features !== undefined) {
|
||||||
__state.features = state.features;
|
__state.features = state.features;
|
||||||
__state.limits = state.limits; // Following together with features
|
__state.limits = state.limits; // Following together with features
|
||||||
}
|
}
|
||||||
if (__state.features && state.streamer !== undefined) {
|
if (__state.features !== undefined && state.streamer !== undefined) {
|
||||||
__setControlsEnabled(!!state.streamer);
|
|
||||||
__state.streamer = state.streamer;
|
__state.streamer = state.streamer;
|
||||||
|
__setControlsEnabled(!!state.streamer);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
__setControlsEnabled(false);
|
|
||||||
__state = null;
|
__state = null;
|
||||||
|
__setControlsEnabled(false);
|
||||||
}
|
}
|
||||||
let visible = wm.isWindowVisible($("stream-window"));
|
let visible = wm.isWindowVisible($("stream-window"));
|
||||||
__applyState((visible && __state && __state.features) ? state : null);
|
__applyState((visible && __state && __state.features) ? state : null);
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user