summaryrefslogtreecommitdiff
path: root/web/share/js/kvm/gpio.js
diff options
context:
space:
mode:
authorShantur Rathore <[email protected]>2021-09-20 01:22:48 +0100
committerGitHub <[email protected]>2021-09-20 03:22:48 +0300
commitf160fb561fa5bdcc7e35d35d16f66cc9150a0859 (patch)
treeb143c46ba4748d07da0b877d43152a7444a91c13 /web/share/js/kvm/gpio.js
parente38c65f18187163292c9e35957ac0b62efb04b19 (diff)
Implement macro recording for gpio (#65)
Diffstat (limited to 'web/share/js/kvm/gpio.js')
-rw-r--r--web/share/js/kvm/gpio.js20
1 files changed, 17 insertions, 3 deletions
diff --git a/web/share/js/kvm/gpio.js b/web/share/js/kvm/gpio.js
index 85f6070b..bd9e5dd7 100644
--- a/web/share/js/kvm/gpio.js
+++ b/web/share/js/kvm/gpio.js
@@ -27,7 +27,7 @@ import {tools, $, $$$} from "../tools.js";
import {wm} from "../wm.js";
-export function Gpio() {
+export function Gpio(__recordWsEvent) {
var self = this;
/************************************************************************/
@@ -167,7 +167,14 @@ export function Gpio() {
if (to === "0" && el.hasAttribute("data-confirm-off")) {
confirm = el.getAttribute("data-confirm-off");
}
- let act = () => __sendPost(`/api/gpio/switch?channel=${channel}&state=${to}`);
+ let event = {
+ "event_type": "gpio_switch",
+ "event": {"channel": channel, "state": to, "wait": 0},
+ };
+ let act = () => {
+ __sendPost(`/api/gpio/switch?channel=${channel}&state=${to}`);
+ __recordWsEvent(event);
+ };
if (confirm) {
wm.confirm(confirm).then(function(ok) {
if (ok) {
@@ -184,7 +191,14 @@ export function Gpio() {
var __pulseChannel = function(el) {
let channel = el.getAttribute("data-channel");
let confirm = el.getAttribute("data-confirm");
- let act = () => __sendPost(`/api/gpio/pulse?channel=${channel}`);
+ let event = {
+ "event_type": "gpio_pulse",
+ "event": {"channel": channel, "delay": 0, "wait": 0},
+ };
+ let act = () => {
+ __sendPost(`/api/gpio/pulse?channel=${channel}`);
+ __recordWsEvent(event);
+ };
if (confirm) {
wm.confirm(confirm).then(function(ok) { if (ok) act(); });
} else {