исправил множество багов

This commit is contained in:
Dmitry Borisenko
2022-02-24 00:59:10 +01:00
parent 474fae6d62
commit 3c2cddb0d3
5 changed files with 37 additions and 49 deletions

View File

@@ -29,11 +29,11 @@
//****************************************************constants section*********************************************************/ //****************************************************constants section*********************************************************/
//******************************************************************************************************************************/ //******************************************************************************************************************************/
let version = 408; let version = 410;
let debug = true; let debug = true;
let LOG_MAX_MESSAGES = 100; let LOG_MAX_MESSAGES = 100;
let reconnectTimeout = 20000; let reconnectTimeout = 20000;
let rebootingTimeout = 15000; let rebootingTimeout = 18000;
let updatingTimeout = 80000; let updatingTimeout = 80000;
let opened = false; let opened = false;
let preventMove = false; let preventMove = false;
@@ -48,6 +48,9 @@
let showInput = false; let showInput = false;
let showModalFlag = false; let showModalFlag = false;
let rebootingUpdatingInProgress = false;
const myTimeout = undefined;
let additionalParams = false; let additionalParams = false;
//dashboard //dashboard
@@ -119,7 +122,7 @@
let selectedDeviceData = undefined; let selectedDeviceData = undefined;
let selectedWs = 0; let selectedWs = 0;
let flag = true; let firstTime = true;
let newDevice = {}; let newDevice = {};
let coreMessages = []; let coreMessages = [];
@@ -669,18 +672,22 @@
function wsTestMsgTask() { function wsTestMsgTask() {
setTimeout(wsTestMsgTask, reconnectTimeout); setTimeout(wsTestMsgTask, reconnectTimeout);
if (debug) console.log("[i]", "----timer tick----"); if (!rebootingUpdatingInProgress) {
if (!flag) { if (debug) console.log("[i]", "----timer tick----");
deviceList.forEach((device) => { if (!firstTime) {
if (!getDeviceStatus(device.ws)) { deviceList.forEach((device) => {
wsConnect(device.ws); if (!getDeviceStatus(device.ws)) {
wsEventAdd(device.ws); wsConnect(device.ws);
} else { wsEventAdd(device.ws);
wsSendMsg(device.ws, "/tst|"); } else {
} wsSendMsg(device.ws, "/tst|");
}); }
});
}
firstTime = false;
} else {
if (debug) console.log("[i]", "----timer skipped----");
} }
flag = false;
} }
function wsSendMsg(ws, msg) { function wsSendMsg(ws, msg) {
@@ -960,13 +967,10 @@
wsSendMsg(selectedWs, "/scan|"); wsSendMsg(selectedWs, "/scan|");
} }
let rebootingInProgress = false;
const myTimeout = undefined;
function rebootEsp() { function rebootEsp() {
if (debug) console.log("[i]", "reboot..."); if (debug) console.log("[i]", "reboot...");
wsSendMsg(selectedWs, "/reboot|"); wsSendMsg(selectedWs, "/reboot|");
rebootingInProgress = true; rebootingUpdatingInProgress = true;
myTimeout = setTimeout(rebootingTask, rebootingTimeout); myTimeout = setTimeout(rebootingTask, rebootingTimeout);
} }
@@ -974,7 +978,7 @@
clearTimeout(myTimeout); clearTimeout(myTimeout);
clearData(); clearData();
connectToAllDevices(); connectToAllDevices();
rebootingInProgress = false; rebootingUpdatingInProgress = false;
} }
function cancelAlarm(alarmKey) { function cancelAlarm(alarmKey) {
@@ -1020,7 +1024,7 @@
wsSendMsg(selectedWs, '/rorre|{"chver":' + choosingVersion + "}"); wsSendMsg(selectedWs, '/rorre|{"chver":' + choosingVersion + "}");
//начнем обновление //начнем обновление
wsSendMsg(selectedWs, "/update|"); wsSendMsg(selectedWs, "/update|");
rebootingInProgress = true; rebootingUpdatingInProgress = true;
myTimeout = setTimeout(rebootingTask, updatingTimeout); myTimeout = setTimeout(rebootingTask, updatingTimeout);
} else { } else {
console.log("update canceled"); console.log("update canceled");
@@ -1036,7 +1040,7 @@
<!--{#if errorsJson.wscle === 1}--> <!--{#if errorsJson.wscle === 1}-->
<!--<Modal header={"Ошибка web sockets"} text={"Слишком много клиентов было открыто. Допускается не более четырех. Для исчезновения ошибки перезагрузите устройство"} />--> <!--<Modal header={"Ошибка web sockets"} text={"Слишком много клиентов было открыто. Допускается не более четырех. Для исчезновения ошибки перезагрузите устройство"} />-->
<!--{/if}--> <!--{/if}-->
{#if rebootingInProgress} {#if rebootingUpdatingInProgress}
<Progress /> <Progress />
{/if} {/if}
<header class="h-10 w-full bg-gray-100 overflow-auto shadow-md"> <header class="h-10 w-full bg-gray-100 overflow-auto shadow-md">
@@ -1057,7 +1061,8 @@
</header> </header>
<nav class="flex"> <nav class="flex">
<input bind:checked={opened} on:change={() => onCheck()} id="menu__toggle" type="checkbox" /> <input class="w-0 h-0" bind:checked={opened} on:change={() => onCheck()} id="menu__toggle" type="checkbox" />
<label class="menu__btn" for="menu__toggle"> <label class="menu__btn" for="menu__toggle">
<span /> <span />
</label> </label>
@@ -1078,15 +1083,6 @@
<li> <li>
<a class="menu__item" href="/system">{"Системные"}</a> <a class="menu__item" href="/system">{"Системные"}</a>
</li> </li>
<!--<li>-->
<!--<a class="menu__item" href="/utilities">{"Утилиты"}</a>-->
<!--</li>-->
<!--<li>-->
<!--<a class="menu__item" href="/log">{"Лог"}</a>-->
<!--</li>-->
<!--<li>-->
<!--<a class="menu__item" href="/about">{"О проекте"}</a>-->
<!--</li>-->
</ul> </ul>
</nav> </nav>
@@ -1111,16 +1107,6 @@
<Route path="/system"> <Route path="/system">
<SystemPage show={systemReady} errorsJson={errorsJson} settingsJson={settingsJson} saveSett={() => saveSett()} rebootEsp={() => rebootEsp()} cancelAlarm={(alarmKey) => cancelAlarm(alarmKey)} versionsList={versionsList} bind:choosingVersion startUpdate={() => startUpdate()} coreMessages={coreMessages} /> <SystemPage show={systemReady} errorsJson={errorsJson} settingsJson={settingsJson} saveSett={() => saveSett()} rebootEsp={() => rebootEsp()} cancelAlarm={(alarmKey) => cancelAlarm(alarmKey)} versionsList={versionsList} bind:choosingVersion startUpdate={() => startUpdate()} coreMessages={coreMessages} />
</Route> </Route>
<!--<Route path="/utilities">-->
<!--<UtilitiesPage />-->
<!--</Route>-->
<!--<Route path="/log">-->
<!--<LogPage coreMessages={coreMessages} />-->
<!--</Route>-->
<!--<Route path="/about">-->
<!--<AboutPage wigetsUpdate={wigetsUpdate} layoutJson={layoutJson} showModal={() => showModal()} syntaxHighlight={(json) => syntaxHighlight(json)} />-->
<!--</Route>-->
{/if} {/if}
</div> </div>
</ul> </ul>

View File

@@ -28,7 +28,7 @@
@layer components { @layer components {
.alm { .alm {
@apply mb-2 w-full p-2 sm:p-2 md:p-2 lg:p-2 xl:px-4 xl:py-2 2xl:px-4 2xl:py-2 bg-white shadow-md lg:shadow-lg border border-gray-200 rounded-lg; @apply mt-4 w-full p-2 sm:p-2 md:p-2 lg:p-2 xl:px-4 xl:py-2 2xl:px-4 2xl:py-2 bg-white shadow-md lg:shadow-lg border border-gray-200 rounded-lg;
} }
.alm-hdr { .alm-hdr {
@apply text-center text-base text-red-400 font-bold pb-0; @apply text-center text-base text-red-400 font-bold pb-0;

View File

@@ -19,7 +19,7 @@
@layer components { @layer components {
.crd { .crd {
@apply w-full mb-2 p-2 sm:p-2 md:p-2 lg:p-2 xl:px-4 xl:py-4 2xl:px-4 2xl:py-4 bg-white shadow-md lg:shadow-lg border border-gray-200 rounded-lg; @apply w-full mt-4 p-2 sm:p-2 md:p-2 lg:p-2 xl:px-4 xl:py-4 2xl:px-4 2xl:py-4 bg-white shadow-md lg:shadow-lg border border-gray-200 rounded-lg;
} }
.crd-hdr { .crd-hdr {
@apply text-center text-lg text-gray-500 font-bold pb-4; @apply text-center text-lg text-gray-500 font-bold pb-4;

View File

@@ -1,11 +1,13 @@
<script> <script>
</script> </script>
<div class="z-50"> <div class="fixed z-10 inset-0 overflow-y-auto" aria-labelledby="modal-title" role="dialog" aria-modal="true">
<div class="fixed inset-0 bg-gray-200 bg-opacity-75 transition-opacity" aria-hidden="true" /> <div class="flex items-end justify-center min-h-screen pt-4 px-4 pb-20 text-center sm:block sm:p-0">
<div class="flex h-screen justify-center items-center"> <div class="fixed inset-0 bg-gray-50 bg-opacity-75 transition-opacity" aria-hidden="true" />
<div class="m-auto"> <div class="flex h-screen justify-center items-center">
<div style="border-top-color:transparent" class="w-20 h-20 border-4 border-blue-400 border-solid rounded-full animate-spin" /> <div class="m-auto">
<div style="border-top-color:transparent" class="w-20 h-20 border-4 border-blue-400 border-solid rounded-full animate-spin" />
</div>
</div> </div>
</div> </div>
</div> </div>

View File

@@ -263,7 +263,7 @@
<button class="btn-lg" on:click={() => rebootEsp()}>{"Перезагрузить устройство"}</button> <button class="btn-lg" on:click={() => rebootEsp()}>{"Перезагрузить устройство"}</button>
</Card> </Card>
<!--LOG--> <!--LOG-->
<Card title="Лог"> <Card title="Лог" class="z-50">
<div class="h-80 overflow-y-auto"> <div class="h-80 overflow-y-auto">
{#each coreMessages as message, i} {#each coreMessages as message, i}
<div class={message.msg.toString().includes("[E]") ? "text-xs text-red-500" : "text-xs text-black"}>{message.msg}</div> <div class={message.msg.toString().includes("[E]") ? "text-xs text-red-500" : "text-xs text-black"}>{message.msg}</div>