mirror of
https://github.com/IoTManagerProject/IoTManagerWeb.git
synced 2026-03-26 15:02:21 +03:00
обновление виджетов
This commit is contained in:
@@ -33,8 +33,8 @@
|
||||
|
||||
//****************************************************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;
|
||||
@@ -132,7 +132,6 @@
|
||||
sendCurrentPageName();
|
||||
}
|
||||
|
||||
//отправляем запрос данных для данной страницы и запрос данных для всех страниц - /all
|
||||
function sendCurrentPageName() {
|
||||
if (selectedWs !== undefined) {
|
||||
wsSendMsg(selectedWs, currentPageName);
|
||||
@@ -233,7 +232,7 @@
|
||||
if (data.includes("status")) {
|
||||
if (IsJsonParse(data)) {
|
||||
let statusJson = JSON.parse(data);
|
||||
udatelayoutJson(statusJson);
|
||||
udateStatusOfWidget(statusJson);
|
||||
wigetsUpdate();
|
||||
if (debug) console.log("✔", "statusJson parced");
|
||||
onParced("status");
|
||||
@@ -243,8 +242,8 @@
|
||||
if (data.includes("params")) {
|
||||
if (IsJsonParse(data)) {
|
||||
let paramsJson = JSON.parse(data);
|
||||
//udatelayoutJson(statusJson);
|
||||
//wigetsUpdate();
|
||||
udateStatusOfAllWidgets(paramsJson);
|
||||
wigetsUpdate();
|
||||
if (debug) console.log("✔", "paramsJson parced");
|
||||
onParced("params");
|
||||
}
|
||||
@@ -460,7 +459,7 @@
|
||||
return layout;
|
||||
}
|
||||
|
||||
function udatelayoutJson(newStatusJson) {
|
||||
function udateStatusOfWidget(newStatusJson) {
|
||||
for (let i = 0; i < layoutJson.length; i++) {
|
||||
let topic = layoutJson[i].topic;
|
||||
if (topic === newStatusJson.topic) {
|
||||
@@ -470,6 +469,20 @@
|
||||
}
|
||||
}
|
||||
|
||||
function udateStatusOfAllWidgets(paramsJson) {
|
||||
for (const [key, value] of Object.entries(paramsJson)) {
|
||||
for (let i = 0; i < layoutJson.length; i++) {
|
||||
let topic = layoutJson[i].topic;
|
||||
topic = topic.substring(topic.lastIndexOf("/") + 1, topic.length);
|
||||
if (key === topic) {
|
||||
console.log("[i]", "value " + topic + " updated");
|
||||
layoutJson[i].status = value;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function clearData() {
|
||||
configJson = [];
|
||||
configJsonBlob.clear();
|
||||
|
||||
@@ -108,6 +108,14 @@
|
||||
num: true,
|
||||
},
|
||||
},
|
||||
jse3: {
|
||||
1: {
|
||||
descr: "Ошибка json",
|
||||
color: "text-red-500",
|
||||
txt: "Ошибка чтения файла json с виджетами",
|
||||
cancel: true,
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
import Card from "../components/Card.svelte";
|
||||
|
||||
Reference in New Issue
Block a user