From 08facab09f83f6ccf94c12c6352063c1508b69e4 Mon Sep 17 00:00:00 2001 From: Dmitry Borisenko <49808844+DmitryBorisenko33@users.noreply.github.com> Date: Sun, 14 Aug 2022 17:13:49 +0200 Subject: [PATCH] =?UTF-8?q?toggle=20=D0=B2=20=D0=BF=D1=80=D0=BE=D1=86?= =?UTF-8?q?=D0=B5=D1=81=D1=81=D0=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- public/index.html | 2 +- src/App.svelte | 18 ++++++++++++------ src/widgets/Toggle.svelte | 11 ++++++++++- 3 files changed, 23 insertions(+), 8 deletions(-) diff --git a/public/index.html b/public/index.html index 1fee065..92bec14 100644 --- a/public/index.html +++ b/public/index.html @@ -4,7 +4,7 @@ - IoT Manager 4.1.2 + IoT Manager 4.1.3 diff --git a/src/App.svelte b/src/App.svelte index b3ab781..2f02591 100644 --- a/src/App.svelte +++ b/src/App.svelte @@ -40,8 +40,8 @@ //****************************************************variable section**********************************************************/ //******************************************************************************************************************************/ - let myip = document.location.hostname; - //let myip = "192.168.88.224"; + //let myip = document.location.hostname; + let myip = "192.168.88.228"; //Flags let firstDevListRequest = true; @@ -497,16 +497,17 @@ reader.readAsText(bb); reader.onload = () => { let devLayout = JSON.parse(reader.result); - udateStatusOfDevWidgets(devLayout); + udateStatusOfDevWidgets(devLayout, ws); layoutJson = layoutJson.concat(devLayout); sortingLayout(); }; } - function udateStatusOfDevWidgets(devLayout) { + function udateStatusOfDevWidgets(devLayout, ws) { for (const [key, value] of Object.entries(paramsJson)) { for (let i = 0; i < devLayout.length; i++) { let topic = devLayout[i].topic; + devLayout[i].ws = ws; topic = topic.substring(topic.lastIndexOf("/") + 1, topic.length); if (key === topic) { console.log("[i]", "value " + topic + " updated"); @@ -686,8 +687,12 @@ function wsPush(ws, topic, status) { let msg = topic + " " + status; - if (debug) console.log("[i]", "send to ws msg:", msg); - wsSendMsg(ws, msg); + if (debug) console.log("[i]", "ws: ", ws, msg); + //if (ws) { + wsSendMsg(ws, "/control| " + status); // "/tst|" + //} else { + // console.log("[i]", "ws undefined"); + //} } function wsTestMsgTask() { @@ -1117,6 +1122,7 @@ wsPush(ws, topic, status)} /> +