mirror of
https://github.com/IoTManagerProject/IoTManagerWeb.git
synced 2026-03-26 23:12:34 +03:00
промежуточный вариант
This commit is contained in:
@@ -83,6 +83,7 @@
|
||||
let layoutJson = [];
|
||||
let layoutJsonFlag = false;
|
||||
let layoutJsonParced = false;
|
||||
let layoutJsonArrayParced = [];
|
||||
|
||||
let settingsJson = {};
|
||||
let settingsJsonParced = false;
|
||||
@@ -157,10 +158,9 @@
|
||||
var widgetsJsonBlob = new MyBlobBuilder();
|
||||
var itemsJsonBlob = new MyBlobBuilder();
|
||||
var layoutJsonBlob = new MyBlobBuilder();
|
||||
var layoutJsonBlob = new MyBlobBuilder();
|
||||
var scenarioTxtBlob = new MyBlobBuilder();
|
||||
|
||||
//var blobArr = new MyBlobBuilder()[10];
|
||||
var layoutJsonArray = [];
|
||||
|
||||
router.subscribe(handleNavigation);
|
||||
|
||||
@@ -275,10 +275,13 @@
|
||||
if (debug) console.log("[i]", ip, ws, "completed connecting");
|
||||
markDeviceStatus(ws, true);
|
||||
if (firstDevListRequest) wsSendMsg(0, "/list|");
|
||||
//отправим запрос только выбранному устройству
|
||||
if (currentPageName === "/|") {
|
||||
wsSendMsg(ws, currentPageName);
|
||||
} else {
|
||||
if (ws === selectedWs) {
|
||||
sendCurrentPageName();
|
||||
}
|
||||
}
|
||||
});
|
||||
socket[ws].addEventListener("message", function (event) {
|
||||
if (typeof event.data === "string") {
|
||||
@@ -456,11 +459,14 @@
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
//сборщик layoutJson пакетов========================================
|
||||
if (data === "/st/layout.json") {
|
||||
//layoutJsonArrayParced[ws] = false;
|
||||
layoutJsonFlag = true;
|
||||
}
|
||||
if (data === "/end/layout.json") {
|
||||
layoutJsonArrayParced[ws] = true;
|
||||
layoutJsonFlag = false;
|
||||
var bb = layoutJsonBlob.getBlob();
|
||||
let layoutJsonReader = new FileReader();
|
||||
@@ -478,7 +484,6 @@
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
if (event.data instanceof Blob) {
|
||||
//принимаем данные только для выбранного устройства
|
||||
if (ws === selectedWs) {
|
||||
@@ -488,6 +493,11 @@
|
||||
if (layoutJsonFlag) layoutJsonBlob.append(event.data);
|
||||
if (scenarioTxtFlag) scenarioTxtBlob.append(event.data);
|
||||
}
|
||||
if (!layoutJsonArray[ws]) layoutJsonArray[ws] = new MyBlobBuilder();
|
||||
layoutJsonArray[ws].append(event.data);
|
||||
if (layoutJsonArrayParced.every(Boolean) === true) {
|
||||
if (debug) console.log("✔", "!!! !!!");
|
||||
}
|
||||
}
|
||||
});
|
||||
socket[ws].addEventListener("close", (event) => {
|
||||
@@ -503,6 +513,18 @@
|
||||
}
|
||||
}
|
||||
|
||||
function testBlob() {
|
||||
for (let i = 0; i < layoutJsonArray.length; i++) {
|
||||
var bb = layoutJsonArray[i].getBlob();
|
||||
let reader = new FileReader();
|
||||
reader.readAsText(bb);
|
||||
reader.onload = () => {
|
||||
console.log(i, reader.result);
|
||||
};
|
||||
}
|
||||
layoutJsonArray = [];
|
||||
}
|
||||
|
||||
function onParced() {
|
||||
if (currentPageName === "/|" && layoutJsonParced && paramsJsonParced) {
|
||||
clearParcedFlags();
|
||||
@@ -1037,9 +1059,6 @@
|
||||
</script>
|
||||
|
||||
<div class="flex flex-col h-screen bg-gray-50">
|
||||
<!--{#if errorsJson.wscle === 1}-->
|
||||
<!--<Modal header={"Ошибка web sockets"} text={"Слишком много клиентов было открыто. Допускается не более четырех. Для исчезновения ошибки перезагрузите устройство"} />-->
|
||||
<!--{/if}-->
|
||||
{#if rebootingUpdatingInProgress}
|
||||
<Progress />
|
||||
{/if}
|
||||
@@ -1094,6 +1113,7 @@
|
||||
{:else}
|
||||
<Route path="/">
|
||||
<DashboardPage show={dashReady} layoutJson={layoutJson} pages={pages} wsPush={(ws, topic, status) => wsPush(ws, topic, status)} />
|
||||
<button class="btn-lg" on:click={() => testBlob()}>{"Test"}</button>
|
||||
</Route>
|
||||
<Route path="/config">
|
||||
<ConfigPage show={configReady} configJson={configJson} widgetsJson={widgetsJson} itemsJson={itemsJson} bind:scenarioTxt saveConfig={() => saveConfig()} rebootEsp={() => rebootEsp()} />
|
||||
|
||||
Reference in New Issue
Block a user