From 701df3c76fff0679c6b1b05c067fe05c3b9f5e38 Mon Sep 17 00:00:00 2001 From: Maxim Devaev Date: Mon, 20 Sep 2021 06:14:13 +0300 Subject: [PATCH] rewrited #65 --- kvmd/apps/kvmd/api/ugpio.py | 27 +-------------------------- web/kvm/index.html | 2 +- web/kvm/navbar-macro.pug | 2 +- web/share/js/kvm/gpio.js | 14 +++----------- web/share/js/kvm/recorder.js | 35 +++++++++++++++++++++++++++++++++-- web/share/js/kvm/session.js | 2 +- 6 files changed, 40 insertions(+), 42 deletions(-) diff --git a/kvmd/apps/kvmd/api/ugpio.py b/kvmd/apps/kvmd/api/ugpio.py index ddff00f7..444ec83e 100644 --- a/kvmd/apps/kvmd/api/ugpio.py +++ b/kvmd/apps/kvmd/api/ugpio.py @@ -19,11 +19,9 @@ # # # ========================================================================== # -from typing import Dict from aiohttp.web import Request from aiohttp.web import Response -from aiohttp.web import WebSocketResponse from ....validators.basic import valid_bool from ....validators.basic import valid_float_f0 @@ -32,7 +30,6 @@ from ....validators.ugpio import valid_ugpio_channel from ..ugpio import UserGpio from ..http import exposed_http -from ..http import exposed_ws from ..http import make_json_response @@ -41,7 +38,7 @@ class UserGpioApi: def __init__(self, user_gpio: UserGpio) -> None: self.__user_gpio = user_gpio - # ===== Http + # ===== @exposed_http("GET", "/gpio") async def __state_handler(self, _: Request) -> Response: @@ -65,25 +62,3 @@ class UserGpioApi: wait = valid_bool(request.query.get("wait", "0")) await self.__user_gpio.pulse(channel, delay, wait) return make_json_response() - - # ===== Websocket - - @exposed_ws("gpio_switch") - async def __ws_gpio_switch_handler(self, _: WebSocketResponse, event: Dict) -> None: - try: - channel = valid_ugpio_channel(event["channel"]) - state = valid_bool(event["state"]) - wait = valid_bool(event["wait"]) - except Exception: - return - await self.__user_gpio.switch(channel, state, wait) - - @exposed_ws("gpio_pulse") - async def __ws_gpio_pulse_handler(self, _: WebSocketResponse, event: Dict) -> None: - try: - channel = valid_ugpio_channel(event["channel"]) - delay = valid_float_f0(event["delay"]) - wait = valid_bool(event["wait"]) - except Exception: - return - await self.__user_gpio.pulse(channel, delay, wait) diff --git a/web/kvm/index.html b/web/kvm/index.html index 2ec36fd7..7d6a097f 100644 --- a/web/kvm/index.html +++ b/web/kvm/index.html @@ -437,7 +437,7 @@
  • Macro