From b0d66cb7769de9640bcea42931773b88989acfdb Mon Sep 17 00:00:00 2001 From: Dmitry Borisenko <67171972+IoTManagerProject@users.noreply.github.com> Date: Tue, 8 Feb 2022 16:47:26 +0100 Subject: [PATCH] =?UTF-8?q?=D0=B4=D0=BE=D0=B1=D0=B0=D0=B2=D0=BB=D0=B5?= =?UTF-8?q?=D0=BD=D0=B0=20=D0=BA=D0=BD=D0=BE=D0=BF=D0=BA=D0=B0=20=D0=BF?= =?UTF-8?q?=D0=B5=D1=80=D0=B5=D0=B7=D0=B0=D0=B3=D1=80=D1=83=D0=B7=D0=BA?= =?UTF-8?q?=D0=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/App.svelte | 85 ++++++++++++++++++++++++++-------- src/components/Modal.svelte | 9 ++-- src/components/Progress.svelte | 12 +++-- src/pages/Connection.svelte | 11 ++++- 4 files changed, 90 insertions(+), 27 deletions(-) diff --git a/src/App.svelte b/src/App.svelte index 1a76ef1..fd895cc 100644 --- a/src/App.svelte +++ b/src/App.svelte @@ -6,7 +6,7 @@ router.mode.hash(); import Alarm from "./components/Alarm.svelte"; - //import Progress from "./components/Progress.svelte"; + import Progress from "./components/Progress.svelte"; import Modal from "./components/Modal.svelte"; import DashboardPage from "./pages/Dashboard.svelte"; @@ -24,13 +24,14 @@ let debug = true; let LOG_MAX_MESSAGES = 10; let reconnectTimeout = 30000; + let rebootingTimeout = 20000; let opened = false; let preventMove = false; //****************************************************variable section**********************************************************/ //******************************************************************************************************************************/ - //let myip = document.location.hostname; - let myip = "192.168.88.235"; + let myip = document.location.hostname; + //let myip = "192.168.88.235"; //Flags let showInput = false; @@ -62,6 +63,9 @@ let settingsJsonFlag = false; let settingsJsonParced = false; + let errorsJson = {}; + let errorsJsonParced = false; + let ssidJson = {}; let ssidJsonParced = false; @@ -130,9 +134,11 @@ sendCurrentPageName(); } + //отправляем запрос данных для данной страницы и запрос данных для всех страниц - /all function sendCurrentPageName() { if (selectedWs !== undefined) { wsSendMsg(selectedWs, currentPageName); + wsSendMsg(selectedWs, "/all"); } } @@ -232,7 +238,7 @@ let statusJson = JSON.parse(data); udatelayoutJson(statusJson); wigetsUpdate(); - if (debug) console.log("[i]", "statusJson parced: ", statusJson); + if (debug) console.log("✔", "statusJson parced"); } } //сборщик paramsJson сообщений====================================== @@ -241,7 +247,7 @@ let paramsJson = JSON.parse(data); //udatelayoutJson(statusJson); //wigetsUpdate(); - if (debug) console.log("[i]", "paramsJson parced: ", paramsJson); + if (debug) console.log("✔", "paramsJson parced"); } } //сборщик ssidJson сообщений====================================== @@ -251,7 +257,7 @@ delete ssidJson.ssid; ssidJson = ssidJson; ssidJsonParced = true; - if (debug) console.log("[i]", "ssidJson parced"); + if (debug) console.log("✔", "ssidJson parced"); } } //сборщик deviceList сообщений====================================== @@ -265,7 +271,18 @@ deviceList = deviceList; whenDeviceListWasUpdated(); connectToAllDevices(); - if (debug) console.log("[i]", "incDeviceList json parced", incDeviceList); + if (debug) console.log("✔", "incDeviceList json parced"); + } + } + //сборщик errorsJson сообщений====================================== + if (data.includes("errors")) { + if (IsJsonParse(data)) { + errorsJson = JSON.parse(data); + delete errorsJson.errors; + errorsJson = errorsJson; + errorsJsonParced = true; + handleErrors(); + if (debug) console.log("✔", "errorsJson json parced"); } } //сборщик configJson пакетов======================================== @@ -285,7 +302,7 @@ configJson = JSON.parse(configJsonResult); configJson = configJson; configJsonParced = true; - if (debug) console.log("[ii]", "configJson parced!"); + if (debug) console.log("✔", "configJson parced"); } }; } @@ -306,7 +323,7 @@ widgetsJson = JSON.parse(widgetsJsonResult); widgetsJson = widgetsJson; widgetsJsonParced = true; - if (debug) console.log("[ii]", "widgetsJson parced!"); + if (debug) console.log("✔", "widgetsJson parced"); } }; } @@ -327,7 +344,7 @@ itemsJson = JSON.parse(itemsJsonResult); itemsJson = itemsJson; itemsJsonParced = true; - if (debug) console.log("[ii]", "itemsJson parced!"); + if (debug) console.log("✔", "itemsJson parced"); } }; } @@ -349,7 +366,7 @@ layoutJson = layoutJson; wigetsUpdate(); layoutJsonParced = true; - if (debug) console.log("[ii]", "layoutJson parced!"); + if (debug) console.log("✔", "layoutJson parced"); } }; } @@ -372,7 +389,7 @@ wigetsUpdate(); settingsJsonParced = true; updateThisDeviceInList(); - if (debug) console.log("[ii]", "settingsJson parced!"); + if (debug) console.log("✔", "settingsJson parced"); } }; } @@ -406,6 +423,7 @@ } function saveSettings() { + console.log("[i]", settingsJson); wsSendMsg(selectedWs, "/cennoc" + JSON.stringify(settingsJson)); clearData(); sendCurrentPageName(); @@ -464,6 +482,8 @@ settingsJson = {}; settingsJsonBlob.clear(); + errorsJson = {}; + configJsonParced = false; widgetsJsonParced = false; itemsJsonParced = false; @@ -749,6 +769,29 @@ wsSendMsg(selectedWs, "/scan"); } + let wsClientsError = false; + + function handleErrors() { + if (errorsJson.wscle === 1) { + wsClientsError = true; + } + } + + let rebootingInProgress = false; + const myTimeout = undefined; + + function rebootEsp() { + if (debug) console.log("[i]", "reboot..."); + wsSendMsg(selectedWs, "/reboot"); + rebootingInProgress = true; + myTimeout = setTimeout(rebootingTask, rebootingTimeout); + } + + function rebootingTask() { + clearTimeout(myTimeout); + connectToAllDevices(); + rebootingInProgress = false; + } //*******************************************************initialisation********************************************************************/ onMount(async () => { console.log("[i]", "mounted"); @@ -760,11 +803,15 @@