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 layoutJson = [];
|
||||||
let layoutJsonFlag = false;
|
let layoutJsonFlag = false;
|
||||||
let layoutJsonParced = false;
|
let layoutJsonParced = false;
|
||||||
|
let layoutJsonArrayParced = [];
|
||||||
|
|
||||||
let settingsJson = {};
|
let settingsJson = {};
|
||||||
let settingsJsonParced = false;
|
let settingsJsonParced = false;
|
||||||
@@ -157,10 +158,9 @@
|
|||||||
var widgetsJsonBlob = new MyBlobBuilder();
|
var widgetsJsonBlob = new MyBlobBuilder();
|
||||||
var itemsJsonBlob = new MyBlobBuilder();
|
var itemsJsonBlob = new MyBlobBuilder();
|
||||||
var layoutJsonBlob = new MyBlobBuilder();
|
var layoutJsonBlob = new MyBlobBuilder();
|
||||||
var layoutJsonBlob = new MyBlobBuilder();
|
|
||||||
var scenarioTxtBlob = new MyBlobBuilder();
|
var scenarioTxtBlob = new MyBlobBuilder();
|
||||||
|
|
||||||
//var blobArr = new MyBlobBuilder()[10];
|
var layoutJsonArray = [];
|
||||||
|
|
||||||
router.subscribe(handleNavigation);
|
router.subscribe(handleNavigation);
|
||||||
|
|
||||||
@@ -275,10 +275,13 @@
|
|||||||
if (debug) console.log("[i]", ip, ws, "completed connecting");
|
if (debug) console.log("[i]", ip, ws, "completed connecting");
|
||||||
markDeviceStatus(ws, true);
|
markDeviceStatus(ws, true);
|
||||||
if (firstDevListRequest) wsSendMsg(0, "/list|");
|
if (firstDevListRequest) wsSendMsg(0, "/list|");
|
||||||
//отправим запрос только выбранному устройству
|
if (currentPageName === "/|") {
|
||||||
|
wsSendMsg(ws, currentPageName);
|
||||||
|
} else {
|
||||||
if (ws === selectedWs) {
|
if (ws === selectedWs) {
|
||||||
sendCurrentPageName();
|
sendCurrentPageName();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
});
|
});
|
||||||
socket[ws].addEventListener("message", function (event) {
|
socket[ws].addEventListener("message", function (event) {
|
||||||
if (typeof event.data === "string") {
|
if (typeof event.data === "string") {
|
||||||
@@ -456,11 +459,14 @@
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
}
|
||||||
//сборщик layoutJson пакетов========================================
|
//сборщик layoutJson пакетов========================================
|
||||||
if (data === "/st/layout.json") {
|
if (data === "/st/layout.json") {
|
||||||
|
//layoutJsonArrayParced[ws] = false;
|
||||||
layoutJsonFlag = true;
|
layoutJsonFlag = true;
|
||||||
}
|
}
|
||||||
if (data === "/end/layout.json") {
|
if (data === "/end/layout.json") {
|
||||||
|
layoutJsonArrayParced[ws] = true;
|
||||||
layoutJsonFlag = false;
|
layoutJsonFlag = false;
|
||||||
var bb = layoutJsonBlob.getBlob();
|
var bb = layoutJsonBlob.getBlob();
|
||||||
let layoutJsonReader = new FileReader();
|
let layoutJsonReader = new FileReader();
|
||||||
@@ -478,7 +484,6 @@
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
if (event.data instanceof Blob) {
|
if (event.data instanceof Blob) {
|
||||||
//принимаем данные только для выбранного устройства
|
//принимаем данные только для выбранного устройства
|
||||||
if (ws === selectedWs) {
|
if (ws === selectedWs) {
|
||||||
@@ -488,6 +493,11 @@
|
|||||||
if (layoutJsonFlag) layoutJsonBlob.append(event.data);
|
if (layoutJsonFlag) layoutJsonBlob.append(event.data);
|
||||||
if (scenarioTxtFlag) scenarioTxtBlob.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) => {
|
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() {
|
function onParced() {
|
||||||
if (currentPageName === "/|" && layoutJsonParced && paramsJsonParced) {
|
if (currentPageName === "/|" && layoutJsonParced && paramsJsonParced) {
|
||||||
clearParcedFlags();
|
clearParcedFlags();
|
||||||
@@ -1037,9 +1059,6 @@
|
|||||||
</script>
|
</script>
|
||||||
|
|
||||||
<div class="flex flex-col h-screen bg-gray-50">
|
<div class="flex flex-col h-screen bg-gray-50">
|
||||||
<!--{#if errorsJson.wscle === 1}-->
|
|
||||||
<!--<Modal header={"Ошибка web sockets"} text={"Слишком много клиентов было открыто. Допускается не более четырех. Для исчезновения ошибки перезагрузите устройство"} />-->
|
|
||||||
<!--{/if}-->
|
|
||||||
{#if rebootingUpdatingInProgress}
|
{#if rebootingUpdatingInProgress}
|
||||||
<Progress />
|
<Progress />
|
||||||
{/if}
|
{/if}
|
||||||
@@ -1094,6 +1113,7 @@
|
|||||||
{:else}
|
{:else}
|
||||||
<Route path="/">
|
<Route path="/">
|
||||||
<DashboardPage show={dashReady} layoutJson={layoutJson} pages={pages} wsPush={(ws, topic, status) => wsPush(ws, topic, status)} />
|
<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>
|
||||||
<Route path="/config">
|
<Route path="/config">
|
||||||
<ConfigPage show={configReady} configJson={configJson} widgetsJson={widgetsJson} itemsJson={itemsJson} bind:scenarioTxt saveConfig={() => saveConfig()} rebootEsp={() => rebootEsp()} />
|
<ConfigPage show={configReady} configJson={configJson} widgetsJson={widgetsJson} itemsJson={itemsJson} bind:scenarioTxt saveConfig={() => saveConfig()} rebootEsp={() => rebootEsp()} />
|
||||||
|
|||||||
Reference in New Issue
Block a user