финальный дашбоард

This commit is contained in:
Dmitry Borisenko
2022-03-01 01:43:55 +01:00
parent 9be9a67567
commit 869fcdf97b
2 changed files with 34 additions and 51 deletions

View File

@@ -4,7 +4,7 @@
<meta charset='utf-8'> <meta charset='utf-8'>
<meta name='viewport' content='width=device-width,initial-scale=1'> <meta name='viewport' content='width=device-width,initial-scale=1'>
<title>IoT Manager 4.1.0</title> <title>IoT Manager 4.1.1</title>
<link rel='icon' type='image/png' href='/favicon.ico'> <link rel='icon' type='image/png' href='/favicon.ico'>
<link rel='stylesheet' href='/build/bundle.css'> <link rel='stylesheet' href='/build/bundle.css'>

View File

@@ -440,23 +440,10 @@
} }
//сборщик layoutJson пакетов======================================== //сборщик layoutJson пакетов========================================
if (data === "/st/layout.json") { if (data === "/st/layout.json") {
deviceList[ws].lp = false;
} }
if (data === "/end/layout.json") { if (data === "/end/layout.json") {
deviceList[ws].lp = true; dashReady = true;
for (let i = 0; i < deviceList.length; i++) { createLayoutUnderLoading(ws);
//выполняем только для устройств online
//if (deviceList[i].status) {
if (deviceList[i].lp === false || deviceList[i].lp === undefined) {
layoutJsonArrayParced = false;
break;
} else {
layoutJsonArrayParced = true;
}
//}
}
if (layoutJsonArrayParced) console.log("✔", "layoutJsonArray parced");
onParced();
} }
//сборщик paramsJson сообщений====================================== //сборщик paramsJson сообщений======================================
if (data.includes('"params":"')) { if (data.includes('"params":"')) {
@@ -466,19 +453,7 @@
...JSON.parse(data), ...JSON.parse(data),
}; };
paramsJson = paramsJson; paramsJson = paramsJson;
deviceList[ws].pp = true; if (paramsJsonParced) console.log("✔", "paramsJson parced", paramsJson);
for (let i = 0; i < deviceList.length; i++) {
//выполняем только для устройств online
//if (deviceList[i].status) {
if (deviceList[i].pp === false || deviceList[i].pp === undefined) {
paramsJsonParced = false;
break;
} else {
paramsJsonParced = true;
}
//}
}
if (paramsJsonParced) console.log("✔", "paramsJson parced");
onParced(); onParced();
} }
} }
@@ -519,28 +494,36 @@
} }
} }
async function createFinalLayout() { async function createLayoutUnderLoading(ws) {
var t0 = performance.now(); var bb = layoutJsonArray[ws].getBlob();
let length = layoutJsonArray.length; let reader = new FileReader();
for (let i = 0; i < length; i++) { reader.readAsText(bb);
var bb = layoutJsonArray[i].getBlob(); reader.onload = () => {
let reader = new FileReader(); let devLayout = JSON.parse(reader.result);
reader.readAsText(bb); udateStatusOfDevWidgets(devLayout);
reader.onload = () => { layoutJson = layoutJson.concat(devLayout);
layoutJson = layoutJson.concat(JSON.parse(reader.result)); sortingLayout();
if (i === length - 1) { };
sortingLayout();
console.log(paramsJson);
udateStatusOfAllWidgets();
dashReady = true;
var t1 = performance.now();
console.log("layout time: " + (t1 - t0) + " mls");
}
};
}
return layoutJson;
} }
function udateStatusOfDevWidgets(devLayout) {
for (const [key, value] of Object.entries(paramsJson)) {
for (let i = 0; i < devLayout.length; i++) {
let topic = devLayout[i].topic;
topic = topic.substring(topic.lastIndexOf("/") + 1, topic.length);
if (key === topic) {
console.log("[i]", "value " + topic + " updated");
devLayout[i].status = value;
break;
}
}
}
}
//var t0 = performance.now();
//var t1 = performance.now();
//console.log("layout time: " + (t1 - t0) + " mls");
function udateStatusOfAllWidgets() { function udateStatusOfAllWidgets() {
for (const [key, value] of Object.entries(paramsJson)) { for (const [key, value] of Object.entries(paramsJson)) {
for (let i = 0; i < layoutJson.length; i++) { for (let i = 0; i < layoutJson.length; i++) {
@@ -566,10 +549,10 @@
} }
async function onParced() { async function onParced() {
if (currentPageName === "/|" && layoutJsonArrayParced && paramsJsonParced) { if (currentPageName === "/|" && paramsJsonParced) {
clearParcedFlags(); clearParcedFlags();
if (debug) console.log("✔✔", "dashboard data parced"); if (debug) console.log("✔✔", "dashboard data parced");
createFinalLayout(); //createFinalLayout();
} }
if (currentPageName === "/config|" && itemsJsonParced && widgetsJsonParced && configJsonParced && settingsJsonParced && scenarioTxtParced) { if (currentPageName === "/config|" && itemsJsonParced && widgetsJsonParced && configJsonParced && settingsJsonParced && scenarioTxtParced) {
clearParcedFlags(); clearParcedFlags();