mirror of
https://github.com/mofeng-git/One-KVM.git
synced 2025-12-12 01:00:29 +08:00
granularity info and minor fixes
This commit is contained in:
parent
d4fb640418
commit
0fd1174bc5
@ -65,6 +65,15 @@ class InfoManager:
|
|||||||
])
|
])
|
||||||
|
|
||||||
async def poll_state(self) -> AsyncGenerator[dict, None]:
|
async def poll_state(self) -> AsyncGenerator[dict, None]:
|
||||||
|
# ==== Granularity table ====
|
||||||
|
# - system -- Partial
|
||||||
|
# - auth -- Partial
|
||||||
|
# - meta -- Partial, nullable
|
||||||
|
# - extras -- Partial, nullable
|
||||||
|
# - hw -- Partial
|
||||||
|
# - fan -- Partial
|
||||||
|
# ===========================
|
||||||
|
|
||||||
while True:
|
while True:
|
||||||
(field, value) = await self.__queue.get()
|
(field, value) = await self.__queue.get()
|
||||||
yield {field: value}
|
yield {field: value}
|
||||||
|
|||||||
@ -129,6 +129,11 @@ class Ocr:
|
|||||||
self.__notifier.notify()
|
self.__notifier.notify()
|
||||||
|
|
||||||
async def poll_state(self) -> AsyncGenerator[dict, None]:
|
async def poll_state(self) -> AsyncGenerator[dict, None]:
|
||||||
|
# ===== Granularity table =====
|
||||||
|
# - enabled -- Full
|
||||||
|
# - langs -- Partial
|
||||||
|
# =============================
|
||||||
|
|
||||||
while True:
|
while True:
|
||||||
await self.__notifier.wait()
|
await self.__notifier.wait()
|
||||||
yield (await self.get_state())
|
yield (await self.get_state())
|
||||||
|
|||||||
@ -287,6 +287,14 @@ class Streamer: # pylint: disable=too-many-instance-attributes
|
|||||||
self.__notifier.notify(self.__ST_FULL)
|
self.__notifier.notify(self.__ST_FULL)
|
||||||
|
|
||||||
async def poll_state(self) -> AsyncGenerator[dict, None]:
|
async def poll_state(self) -> AsyncGenerator[dict, None]:
|
||||||
|
# ==== Granularity table ====
|
||||||
|
# - features -- Full
|
||||||
|
# - limits -- Partial, paired with params
|
||||||
|
# - params -- Partial, paired with limits
|
||||||
|
# - streamer -- Partial, nullable
|
||||||
|
# - snapshot -- Partial
|
||||||
|
# ===========================
|
||||||
|
|
||||||
def signal_handler(*_: Any) -> None:
|
def signal_handler(*_: Any) -> None:
|
||||||
get_logger(0).info("Got SIGUSR2, checking the stream state ...")
|
get_logger(0).info("Got SIGUSR2, checking the stream state ...")
|
||||||
self.__notifier.notify(self.__ST_STREAMER)
|
self.__notifier.notify(self.__ST_STREAMER)
|
||||||
|
|||||||
@ -271,6 +271,12 @@ class UserGpio:
|
|||||||
self.__notifier.notify(1)
|
self.__notifier.notify(1)
|
||||||
|
|
||||||
async def poll_state(self) -> AsyncGenerator[dict, None]:
|
async def poll_state(self) -> AsyncGenerator[dict, None]:
|
||||||
|
# ==== Granularity table ====
|
||||||
|
# - model -- Full
|
||||||
|
# - state.inputs -- Partial
|
||||||
|
# - state.outputs -- Partial
|
||||||
|
# ===========================
|
||||||
|
|
||||||
prev: dict = {"inputs": {}, "outputs": {}}
|
prev: dict = {"inputs": {}, "outputs": {}}
|
||||||
while True: # pylint: disable=too-many-nested-blocks
|
while True: # pylint: disable=too-many-nested-blocks
|
||||||
if (await self.__notifier.wait()) > 0:
|
if (await self.__notifier.wait()) > 0:
|
||||||
|
|||||||
@ -52,6 +52,12 @@ class BaseAtx(BasePlugin):
|
|||||||
raise NotImplementedError
|
raise NotImplementedError
|
||||||
|
|
||||||
async def poll_state(self) -> AsyncGenerator[dict, None]:
|
async def poll_state(self) -> AsyncGenerator[dict, None]:
|
||||||
|
# ==== Granularity table ====
|
||||||
|
# - enabled -- Full
|
||||||
|
# - busy -- Partial
|
||||||
|
# - leds -- Partial
|
||||||
|
# ===========================
|
||||||
|
|
||||||
yield {}
|
yield {}
|
||||||
raise NotImplementedError
|
raise NotImplementedError
|
||||||
|
|
||||||
|
|||||||
@ -121,6 +121,18 @@ class BaseMsd(BasePlugin):
|
|||||||
raise NotImplementedError()
|
raise NotImplementedError()
|
||||||
|
|
||||||
async def poll_state(self) -> AsyncGenerator[dict, None]:
|
async def poll_state(self) -> AsyncGenerator[dict, None]:
|
||||||
|
# ==== Granularity table ====
|
||||||
|
# - enabled -- Full
|
||||||
|
# - online -- Partial
|
||||||
|
# - busy -- Partial
|
||||||
|
# - drive -- Partial, nullable
|
||||||
|
# - storage -- Partial, nullable
|
||||||
|
# - storage.parts -- Partial
|
||||||
|
# - storage.images -- Partial
|
||||||
|
# - storage.downloading -- Partial, nullable
|
||||||
|
# - storage.uploading -- Partial, nullable
|
||||||
|
# ===========================
|
||||||
|
|
||||||
if self is not None: # XXX: Vulture and pylint hack
|
if self is not None: # XXX: Vulture and pylint hack
|
||||||
raise NotImplementedError()
|
raise NotImplementedError()
|
||||||
yield
|
yield
|
||||||
|
|||||||
@ -32,6 +32,8 @@ export function Atx(__recorder) {
|
|||||||
|
|
||||||
/************************************************************************/
|
/************************************************************************/
|
||||||
|
|
||||||
|
var __state = null;
|
||||||
|
|
||||||
var __init__ = function() {
|
var __init__ = function() {
|
||||||
$("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";
|
||||||
@ -46,18 +48,38 @@ export function Atx(__recorder) {
|
|||||||
/************************************************************************/
|
/************************************************************************/
|
||||||
|
|
||||||
self.setState = function(state) {
|
self.setState = function(state) {
|
||||||
let buttons_enabled = false;
|
|
||||||
if (state) {
|
if (state) {
|
||||||
tools.feature.setEnabled($("atx-dropdown"), state.enabled);
|
if (!__state) {
|
||||||
$("atx-power-led").className = (state.busy ? "led-yellow" : (state.leds.power ? "led-green" : "led-gray"));
|
__state = {"leds": {}};
|
||||||
$("atx-hdd-led").className = (state.leds.hdd ? "led-red" : "led-gray");
|
}
|
||||||
buttons_enabled = !state.busy;
|
if (state.enabled !== undefined) {
|
||||||
|
tools.feature.setEnabled($("atx-dropdown"), state.enabled);
|
||||||
|
__state.enabled = state.enabled;
|
||||||
|
}
|
||||||
|
if (__state.enabled !== undefined) {
|
||||||
|
if (state.busy !== undefined) {
|
||||||
|
__updateButtons(!state.busy);
|
||||||
|
__state.busy = state.busy;
|
||||||
|
}
|
||||||
|
if (state.leds !== undefined) {
|
||||||
|
__state.leds = state.leds;
|
||||||
|
}
|
||||||
|
if (state.busy !== undefined || state.leds !== undefined) {
|
||||||
|
let busy = __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 {
|
||||||
$("atx-power-led").className = "led-gray";
|
__state = null;
|
||||||
$("atx-hdd-led").className = "led-gray";
|
__updateButtons(false);
|
||||||
}
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
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), buttons_enabled);
|
tools.el.setEnabled($(id), enabled);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@ -32,6 +32,8 @@ export function Ocr(__getGeometry) {
|
|||||||
|
|
||||||
/************************************************************************/
|
/************************************************************************/
|
||||||
|
|
||||||
|
var __enabled = null;
|
||||||
|
|
||||||
var __start_pos = null;
|
var __start_pos = null;
|
||||||
var __end_pos = null;
|
var __end_pos = null;
|
||||||
var __sel = null;
|
var __sel = null;
|
||||||
@ -71,8 +73,10 @@ export function Ocr(__getGeometry) {
|
|||||||
/************************************************************************/
|
/************************************************************************/
|
||||||
|
|
||||||
self.setState = function(state) {
|
self.setState = function(state) {
|
||||||
let enabled = (state && state.enabled && !tools.browser.is_mobile);
|
if (state.enabled !== undefined) {
|
||||||
if (enabled) {
|
__enabled = (state.enabled && !tools.browser.is_mobile);
|
||||||
|
}
|
||||||
|
if (__enabled) {
|
||||||
let el = $("stream-ocr-lang-selector");
|
let el = $("stream-ocr-lang-selector");
|
||||||
el.options.length = 0;
|
el.options.length = 0;
|
||||||
for (let lang of state.langs.available) {
|
for (let lang of state.langs.available) {
|
||||||
@ -80,8 +84,8 @@ export function Ocr(__getGeometry) {
|
|||||||
}
|
}
|
||||||
el.value = tools.storage.get("stream.ocr.lang", state.langs["default"]);
|
el.value = tools.storage.get("stream.ocr.lang", state.langs["default"]);
|
||||||
}
|
}
|
||||||
tools.feature.setEnabled($("stream-ocr"), enabled);
|
tools.feature.setEnabled($("stream-ocr"), __enabled);
|
||||||
$("stream-ocr-led").className = (enabled ? "led-gray" : "hidden");
|
$("stream-ocr-led").className = (__enabled ? "led-gray" : "hidden");
|
||||||
};
|
};
|
||||||
|
|
||||||
var __startSelection = function(event) {
|
var __startSelection = function(event) {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user