mirror of
https://github.com/IoTManagerProject/IoTManagerWeb.git
synced 2026-03-26 23:12:34 +03:00
dashboard закончил
This commit is contained in:
@@ -125,8 +125,6 @@
|
|||||||
let newDevice = {};
|
let newDevice = {};
|
||||||
let coreMessages = [];
|
let coreMessages = [];
|
||||||
|
|
||||||
let oneOfJsonPackageError = false;
|
|
||||||
|
|
||||||
//***********************************************************blob**************************************************************/
|
//***********************************************************blob**************************************************************/
|
||||||
var MyBlobBuilder = function () {
|
var MyBlobBuilder = function () {
|
||||||
this.parts = [];
|
this.parts = [];
|
||||||
@@ -286,12 +284,11 @@
|
|||||||
socket[ws].addEventListener("message", function (event) {
|
socket[ws].addEventListener("message", function (event) {
|
||||||
if (typeof event.data === "string") {
|
if (typeof event.data === "string") {
|
||||||
let data = event.data;
|
let data = event.data;
|
||||||
//if (debug) console.log("[i]", getIP(ws), "msg received", data); //
|
//if (debug) console.log("[i]", getIP(ws), "msg received", data);//
|
||||||
|
|
||||||
if (ws === selectedWs) {
|
if (ws === selectedWs) {
|
||||||
//STRING============================================================
|
//STRING============================================================
|
||||||
//сборщик deviceList сообщений======================================
|
//сборщик deviceList сообщений======================================
|
||||||
if (data.includes("devicelist")) {
|
if (data.includes('devicelist":"')) {
|
||||||
if (IsJsonParse(data)) {
|
if (IsJsonParse(data)) {
|
||||||
incDeviceList = JSON.parse(data);
|
incDeviceList = JSON.parse(data);
|
||||||
incDeviceList = incDeviceList;
|
incDeviceList = incDeviceList;
|
||||||
@@ -323,7 +320,7 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
//сборщик ssidJson сообщений======================================
|
//сборщик ssidJson сообщений======================================
|
||||||
if (data.includes("ssid")) {
|
if (data.includes('ssid":"')) {
|
||||||
if (IsJsonParse(data)) {
|
if (IsJsonParse(data)) {
|
||||||
ssidJson = JSON.parse(data);
|
ssidJson = JSON.parse(data);
|
||||||
ssidJson = ssidJson;
|
ssidJson = ssidJson;
|
||||||
@@ -333,7 +330,7 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
//сборщик errorsJson сообщений======================================
|
//сборщик errorsJson сообщений======================================
|
||||||
if (data.includes("errors")) {
|
if (data.includes('errors":"')) {
|
||||||
if (IsJsonParse(data)) {
|
if (IsJsonParse(data)) {
|
||||||
errorsJson = JSON.parse(data);
|
errorsJson = JSON.parse(data);
|
||||||
errorsJson = errorsJson;
|
errorsJson = errorsJson;
|
||||||
@@ -343,7 +340,7 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
//сборщик settingsJson сообщений======================================
|
//сборщик settingsJson сообщений======================================
|
||||||
if (data.includes("settings")) {
|
if (data.includes('settings":"')) {
|
||||||
if (IsJsonParse(data)) {
|
if (IsJsonParse(data)) {
|
||||||
settingsJson = JSON.parse(data);
|
settingsJson = JSON.parse(data);
|
||||||
settingsJson = settingsJson;
|
settingsJson = settingsJson;
|
||||||
@@ -459,7 +456,7 @@
|
|||||||
onParced();
|
onParced();
|
||||||
}
|
}
|
||||||
//сборщик paramsJson сообщений======================================
|
//сборщик paramsJson сообщений======================================
|
||||||
if (data.includes("params")) {
|
if (data.includes('"params":"')) {
|
||||||
if (IsJsonParse(data)) {
|
if (IsJsonParse(data)) {
|
||||||
paramsJson = {
|
paramsJson = {
|
||||||
...paramsJson,
|
...paramsJson,
|
||||||
@@ -485,7 +482,7 @@
|
|||||||
let statusJson = JSON.parse(data);
|
let statusJson = JSON.parse(data);
|
||||||
udateStatusOfWidget(statusJson);
|
udateStatusOfWidget(statusJson);
|
||||||
sortingLayout();
|
sortingLayout();
|
||||||
if (debug) console.log("[i]", statusJson);
|
//if (debug) console.log("[i]", statusJson);
|
||||||
statusJsonParced = true;
|
statusJsonParced = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -517,21 +514,30 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
async function createFinalLayout() {
|
async function createFinalLayout() {
|
||||||
console.log("[i]", "create Final Layout");
|
var t0 = performance.now();
|
||||||
for (let i = 0; i < layoutJsonArray.length; i++) {
|
let length = layoutJsonArray.length;
|
||||||
|
for (let i = 0; i < length; i++) {
|
||||||
var bb = layoutJsonArray[i].getBlob();
|
var bb = layoutJsonArray[i].getBlob();
|
||||||
let reader = new FileReader();
|
let reader = new FileReader();
|
||||||
reader.readAsText(bb);
|
reader.readAsText(bb);
|
||||||
reader.onload = () => {
|
reader.onload = () => {
|
||||||
layoutJson = layoutJson.concat(JSON.parse(reader.result));
|
layoutJson = layoutJson.concat(JSON.parse(reader.result));
|
||||||
|
if (i === length - 1) {
|
||||||
|
sortingLayout();
|
||||||
|
console.log(paramsJson);
|
||||||
|
udateStatusOfAllWidgets();
|
||||||
|
dashReady = true;
|
||||||
|
var t1 = performance.now();
|
||||||
|
console.log("layout time: " + (t1 - t0) + " mls");
|
||||||
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
console.log("[i]", "creating Final Layout done: ", layoutJson);
|
|
||||||
return layoutJson;
|
return layoutJson;
|
||||||
}
|
}
|
||||||
|
|
||||||
function udateStatusOfAllWidgets() {
|
function udateStatusOfAllWidgets() {
|
||||||
console.log("[i]", "udate Status Of All Widgets");
|
console.log("[i]", "udate Status Of All Widgets");
|
||||||
|
|
||||||
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++) {
|
||||||
let topic = layoutJson[i].topic;
|
let topic = layoutJson[i].topic;
|
||||||
@@ -559,11 +565,7 @@
|
|||||||
if (currentPageName === "/|" && layoutJsonArrayParced && paramsJsonParced) {
|
if (currentPageName === "/|" && layoutJsonArrayParced && paramsJsonParced) {
|
||||||
clearParcedFlags();
|
clearParcedFlags();
|
||||||
if (debug) console.log("✔✔", "dashboard data parced");
|
if (debug) console.log("✔✔", "dashboard data parced");
|
||||||
await createFinalLayout();
|
createFinalLayout();
|
||||||
sortingLayout();
|
|
||||||
console.log(paramsJson);
|
|
||||||
udateStatusOfAllWidgets();
|
|
||||||
dashReady = true;
|
|
||||||
}
|
}
|
||||||
if (currentPageName === "/config|" && itemsJsonParced && widgetsJsonParced && configJsonParced && settingsJsonParced && scenarioTxtParced) {
|
if (currentPageName === "/config|" && itemsJsonParced && widgetsJsonParced && configJsonParced && settingsJsonParced && scenarioTxtParced) {
|
||||||
clearParcedFlags();
|
clearParcedFlags();
|
||||||
@@ -885,11 +887,9 @@
|
|||||||
try {
|
try {
|
||||||
JSON.parse(str);
|
JSON.parse(str);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
oneOfJsonPackageError = true;
|
if (debug) console.log("[e]", "json parce error: ", str);
|
||||||
if (debug) console.log("[e]", "json parce error");
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
oneOfJsonPackageError = false;
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user