mirror of
https://github.com/IoTManagerProject/IoTManagerWeb.git
synced 2026-03-30 20:09:24 +03:00
парсинг данных страниц
This commit is contained in:
127
src/App.svelte
127
src/App.svelte
@@ -45,25 +45,57 @@
|
||||
//dashboard
|
||||
let pages = [];
|
||||
|
||||
//ready flags
|
||||
let dashReady = false;
|
||||
let configReady = false;
|
||||
let connectionReady = false;
|
||||
let listReady = false;
|
||||
let systemReady = false;
|
||||
|
||||
//configuration
|
||||
let configJson = [];
|
||||
let configJsonFlag = false;
|
||||
let configJsonParced = false;
|
||||
|
||||
let widgetsJson = [];
|
||||
let widgetsJsonFlag = false;
|
||||
let widgetsJsonParced = false;
|
||||
|
||||
let itemsJson = [];
|
||||
let itemsJsonFlag = false;
|
||||
let itemsJsonParced = false;
|
||||
|
||||
let layoutJson = [];
|
||||
let layoutJsonFlag = false;
|
||||
let layoutJsonParced = false;
|
||||
|
||||
let settingsJson = {};
|
||||
let settingsJsonFlag = false;
|
||||
let settingsJsonParced = false;
|
||||
|
||||
let errorsJson = {};
|
||||
let errorsJsonParced = false;
|
||||
|
||||
let ssidJson = {};
|
||||
let ssidJsonParced = false;
|
||||
|
||||
let paramsJson = {};
|
||||
let paramsJsonParced = false;
|
||||
|
||||
let statusJsonParced = false;
|
||||
|
||||
let incDeviceList = [];
|
||||
let incDeviceListParced = false;
|
||||
|
||||
let deviceList = [];
|
||||
deviceList = [
|
||||
{
|
||||
name: "--",
|
||||
id: "--",
|
||||
ip: myip,
|
||||
status: false,
|
||||
},
|
||||
];
|
||||
|
||||
//web sockets
|
||||
let socket = [];
|
||||
@@ -77,19 +109,6 @@
|
||||
|
||||
let oneOfJsonPackageError = false;
|
||||
|
||||
let deviceList = [];
|
||||
deviceList = [
|
||||
{
|
||||
name: "--",
|
||||
id: "--",
|
||||
ip: myip,
|
||||
status: false,
|
||||
},
|
||||
];
|
||||
|
||||
let incDeviceList = [];
|
||||
let incDeviceListParced = false;
|
||||
|
||||
//***********************************************************blob**************************************************************/
|
||||
var MyBlobBuilder = function () {
|
||||
this.parts = [];
|
||||
@@ -235,16 +254,16 @@
|
||||
udateStatusOfWidget(statusJson);
|
||||
wigetsUpdate();
|
||||
if (debug) console.log("✔", "statusJson parced");
|
||||
statusJsonParced = true;
|
||||
onParced("status");
|
||||
}
|
||||
}
|
||||
//сборщик paramsJson сообщений======================================
|
||||
if (data.includes("params")) {
|
||||
if (IsJsonParse(data)) {
|
||||
let paramsJson = JSON.parse(data);
|
||||
udateStatusOfAllWidgets(paramsJson);
|
||||
wigetsUpdate();
|
||||
paramsJson = JSON.parse(data);
|
||||
if (debug) console.log("✔", "paramsJson parced");
|
||||
paramsJsonParced = true;
|
||||
onParced("params");
|
||||
}
|
||||
}
|
||||
@@ -254,6 +273,7 @@
|
||||
ssidJson = JSON.parse(data);
|
||||
ssidJson = ssidJson;
|
||||
if (debug) console.log("✔", "ssidJson parced");
|
||||
ssidJsonParced = true;
|
||||
onParced("ssid");
|
||||
}
|
||||
}
|
||||
@@ -267,6 +287,7 @@
|
||||
deviceList = deviceList;
|
||||
whenDeviceListWasUpdated();
|
||||
connectToAllDevices();
|
||||
|
||||
if (debug) console.log("✔", "incDeviceList json parced");
|
||||
onParced("devicelist");
|
||||
}
|
||||
@@ -276,8 +297,8 @@
|
||||
if (IsJsonParse(data)) {
|
||||
errorsJson = JSON.parse(data);
|
||||
errorsJson = errorsJson;
|
||||
errorsJsonParced = true;
|
||||
if (debug) console.log("✔", "errorsJson json parced");
|
||||
//dataReceived();
|
||||
onParced("errors");
|
||||
}
|
||||
}
|
||||
@@ -295,6 +316,7 @@
|
||||
if (IsJsonParse(configJsonResult)) {
|
||||
configJson = JSON.parse(configJsonResult);
|
||||
configJson = configJson;
|
||||
configJsonParced = true;
|
||||
if (debug) console.log("✔", "configJson parced");
|
||||
onParced("config");
|
||||
}
|
||||
@@ -314,6 +336,7 @@
|
||||
if (IsJsonParse(widgetsJsonResult)) {
|
||||
widgetsJson = JSON.parse(widgetsJsonResult);
|
||||
widgetsJson = widgetsJson;
|
||||
widgetsJsonParced = true;
|
||||
if (debug) console.log("✔", "widgetsJson parced");
|
||||
onParced("widgets");
|
||||
}
|
||||
@@ -333,6 +356,7 @@
|
||||
if (IsJsonParse(itemsJsonResult)) {
|
||||
itemsJson = JSON.parse(itemsJsonResult);
|
||||
itemsJson = itemsJson;
|
||||
itemsJsonParced = true;
|
||||
if (debug) console.log("✔", "itemsJson parced");
|
||||
onParced("items");
|
||||
}
|
||||
@@ -353,6 +377,7 @@
|
||||
layoutJson = JSON.parse(layoutJsonResult);
|
||||
layoutJson = layoutJson;
|
||||
wigetsUpdate();
|
||||
layoutJsonParced = true;
|
||||
if (debug) console.log("✔", "layoutJson parced");
|
||||
onParced("layout");
|
||||
}
|
||||
@@ -374,6 +399,7 @@
|
||||
settingsJson = settingsJson;
|
||||
wigetsUpdate();
|
||||
updateThisDeviceInList();
|
||||
settingsJsonParced = true;
|
||||
if (debug) console.log("✔", "settingsJson parced");
|
||||
onParced("settings");
|
||||
}
|
||||
@@ -401,6 +427,36 @@
|
||||
}
|
||||
}
|
||||
|
||||
function onParced(file) {
|
||||
if (currentPageName === "/|" && layoutJsonParced && paramsJsonParced) {
|
||||
clearParcedFlags();
|
||||
if (debug) console.log("✔✔", "dashboard data parced");
|
||||
udateStatusOfAllWidgets(paramsJson);
|
||||
wigetsUpdate();
|
||||
dashReady = true;
|
||||
}
|
||||
if (currentPageName === "/config|" && itemsJsonParced && widgetsJsonParced && configJsonParced && settingsJsonParced) {
|
||||
clearParcedFlags();
|
||||
if (debug) console.log("✔✔", "config data parced");
|
||||
configReady = true;
|
||||
}
|
||||
if (currentPageName === "/connection|" && ssidJsonParced && settingsJsonParced && errorsJsonParced) {
|
||||
clearParcedFlags();
|
||||
if (debug) console.log("✔✔", "connection data parced");
|
||||
connectionReady = true;
|
||||
}
|
||||
if (currentPageName === "/list|" && incDeviceListParced) {
|
||||
clearParcedFlags();
|
||||
if (debug) console.log("✔✔", "list data parced");
|
||||
listReady = true;
|
||||
}
|
||||
if (currentPageName === "/system|" && errorsJsonParced) {
|
||||
clearParcedFlags();
|
||||
if (debug) console.log("✔✔", "system data parced");
|
||||
systemReady = true;
|
||||
}
|
||||
}
|
||||
|
||||
function saveConfig() {
|
||||
wsSendMsg(selectedWs, "/tuoyal|" + JSON.stringify(generateLayout()));
|
||||
wsSendMsg(selectedWs, "/gifnoc|" + JSON.stringify(configJson));
|
||||
@@ -501,9 +557,30 @@
|
||||
|
||||
errorsJson = {};
|
||||
|
||||
dashReady = false;
|
||||
configReady = false;
|
||||
connectionReady = false;
|
||||
listReady = false;
|
||||
systemReady = false;
|
||||
|
||||
clearParcedFlags();
|
||||
|
||||
if (debug) console.log("[i]", "all app data cleared");
|
||||
}
|
||||
|
||||
function clearParcedFlags() {
|
||||
configJsonParced = false;
|
||||
widgetsJsonParced = false;
|
||||
itemsJsonParced = false;
|
||||
layoutJsonParced = false;
|
||||
settingsJsonParced = false;
|
||||
errorsJsonParced = false;
|
||||
ssidJsonParced = false;
|
||||
paramsJsonParced = false;
|
||||
statusJsonParced = false;
|
||||
incDeviceListParced = false;
|
||||
}
|
||||
|
||||
function wsPush(ws, topic, status) {
|
||||
let msg = topic + " " + status;
|
||||
if (debug) console.log("[i]", "send to ws msg:", msg);
|
||||
@@ -802,8 +879,6 @@
|
||||
wsSendMsg(selectedWs, '/rorre|{"' + alarmKey + '":0}');
|
||||
}
|
||||
|
||||
function onParced(file) {}
|
||||
|
||||
//*******************************************************initialisation********************************************************************/
|
||||
onMount(async () => {
|
||||
console.log("[i]", "mounted");
|
||||
@@ -879,16 +954,19 @@
|
||||
<Alarm title="Нет соединения" />
|
||||
{:else}
|
||||
<Route path="/">
|
||||
<DashboardPage 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)} />
|
||||
</Route>
|
||||
<Route path="/config">
|
||||
<ConfigPage configJson={configJson} widgetsJson={widgetsJson} itemsJson={itemsJson} saveConfig={() => saveConfig()} />
|
||||
<ConfigPage show={configReady} configJson={configJson} widgetsJson={widgetsJson} itemsJson={itemsJson} saveConfig={() => saveConfig()} />
|
||||
</Route>
|
||||
<Route path="/connection">
|
||||
<ConnectionPage rebootEsp={() => rebootEsp()} ssidClick={() => ssidClick()} saveSett={() => saveSett()} saveMqtt={() => saveMqtt()} settingsJson={settingsJson} errorsJson={errorsJson} ssidJson={ssidJson} />
|
||||
<ConnectionPage show={connectionReady} rebootEsp={() => rebootEsp()} ssidClick={() => ssidClick()} saveSett={() => saveSett()} saveMqtt={() => saveMqtt()} settingsJson={settingsJson} errorsJson={errorsJson} ssidJson={ssidJson} />
|
||||
</Route>
|
||||
<Route path="/list">
|
||||
<ListPage show={listReady} deviceList={deviceList} showInput={showInput} addDevInList={() => addDevInList()} newDevice={newDevice} />
|
||||
</Route>
|
||||
<Route path="/system">
|
||||
<SystemPage settingsJson={settingsJson} errorsJson={errorsJson} rebootEsp={() => rebootEsp()} cancelAlarm={(alarmKey) => cancelAlarm(alarmKey)} version={version} />
|
||||
<SystemPage show={systemReady} settingsJson={settingsJson} errorsJson={errorsJson} rebootEsp={() => rebootEsp()} cancelAlarm={(alarmKey) => cancelAlarm(alarmKey)} version={version} />
|
||||
</Route>
|
||||
|
||||
<!--<Route path="/utilities">-->
|
||||
@@ -901,9 +979,6 @@
|
||||
<!--<AboutPage wigetsUpdate={wigetsUpdate} layoutJson={layoutJson} showModal={() => showModal()} syntaxHighlight={(json) => syntaxHighlight(json)} />-->
|
||||
<!--</Route>-->
|
||||
{/if}
|
||||
<Route path="/list">
|
||||
<ListPage deviceList={deviceList} showInput={showInput} addDevInList={() => addDevInList()} newDevice={newDevice} />
|
||||
</Route>
|
||||
</div>
|
||||
</ul>
|
||||
</main>
|
||||
|
||||
@@ -2,11 +2,14 @@
|
||||
import Card from "../components/Card.svelte";
|
||||
import CrossIcon from "../svg/Cross.svelte";
|
||||
import OpenIcon from "../svg/Open.svelte";
|
||||
import Alarm from "../components/Alarm.svelte";
|
||||
|
||||
export let configJson;
|
||||
export let widgetsJson;
|
||||
export let itemsJson;
|
||||
|
||||
export let show;
|
||||
|
||||
let itemsJsonBind = 0;
|
||||
let debug = true;
|
||||
|
||||
@@ -41,8 +44,8 @@
|
||||
}
|
||||
</script>
|
||||
|
||||
<!--{#if itemsJsonParced && widgetsJsonParced && configJsonParced && settingsJsonParced}-->
|
||||
<div class="grd-1col1">
|
||||
{#if show}
|
||||
<div class="grd-1col1">
|
||||
<Card>
|
||||
<div class="grd-2col2">
|
||||
<select class="slct-lg" bind:value={itemsJsonBind} on:change={() => elementsDropdownChange()}>
|
||||
@@ -112,9 +115,7 @@
|
||||
</table>
|
||||
<button class="btn-lg" on:click={() => saveConfig()}>{"Сохранить"}</button>
|
||||
</Card>
|
||||
</div>
|
||||
<!--{:else if !itemsJsonParced && !widgetsJsonParced && !configJsonParced && !settingsJsonParced}-->
|
||||
<!--<div class="flex 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>-->
|
||||
<!--{/if}-->
|
||||
</div>
|
||||
{:else}
|
||||
<Alarm title="Загрузка..." />
|
||||
{/if}
|
||||
|
||||
@@ -6,13 +6,16 @@
|
||||
export let errorsJson;
|
||||
export let ssidJson;
|
||||
|
||||
export let show;
|
||||
|
||||
export let ssidClick = () => {};
|
||||
export let saveSett = () => {};
|
||||
export let saveMqtt = () => {};
|
||||
export let rebootEsp = () => {};
|
||||
</script>
|
||||
|
||||
<div class="grd-2col1">
|
||||
{#if show}
|
||||
<div class="grd-2col1">
|
||||
<Card title="Подключение к WiFi">
|
||||
<div class="crd-itm-psn">
|
||||
<div class="w-4/6">
|
||||
@@ -128,9 +131,12 @@
|
||||
</div>
|
||||
<button class="btn-lg" on:click={() => saveMqtt()}>{"Сохранить"}</button>
|
||||
</Card>
|
||||
</div>
|
||||
<div class="grd-1col1">
|
||||
</div>
|
||||
<div class="grd-1col1">
|
||||
<Card>
|
||||
<button class="btn-lg" on:click={() => rebootEsp()}>{"Перезагрузить устройство"}</button>
|
||||
</Card>
|
||||
</div>
|
||||
</div>
|
||||
{:else}
|
||||
<Alarm title="Загрузка..." />
|
||||
{/if}
|
||||
|
||||
@@ -3,14 +3,18 @@
|
||||
import Input from "../widgets/Input.svelte";
|
||||
import Toggle from "../widgets/Toggle.svelte";
|
||||
import Anydata from "../widgets/Anydata.svelte";
|
||||
import Alarm from "../components/Alarm.svelte";
|
||||
|
||||
export let layoutJson;
|
||||
export let pages;
|
||||
|
||||
export let show;
|
||||
|
||||
export let wsPush = (ws, topic, status) => {};
|
||||
</script>
|
||||
|
||||
<div class="grd-3col1">
|
||||
{#if show}
|
||||
<div class="grd-3col1">
|
||||
{#if layoutJson === []}
|
||||
<Card title={"Ваша панель управления пуста, вначале добавьте новые элементы в конфигураторе!"} />
|
||||
{/if}
|
||||
@@ -31,4 +35,7 @@
|
||||
{/each}
|
||||
</Card>
|
||||
{/each}
|
||||
</div>
|
||||
</div>
|
||||
{:else}
|
||||
<Alarm title="Загрузка..." />
|
||||
{/if}
|
||||
|
||||
@@ -5,6 +5,8 @@
|
||||
import CrossIcon from "../svg/Cross.svelte";
|
||||
import OpenIcon from "../svg/Open.svelte";
|
||||
|
||||
export let show;
|
||||
|
||||
export let deviceList;
|
||||
export let showInput;
|
||||
export let newDevice = {};
|
||||
@@ -25,7 +27,8 @@
|
||||
}
|
||||
</script>
|
||||
|
||||
<div class="grd-1col1">
|
||||
{#if show}
|
||||
<div class="grd-1col1">
|
||||
<Card title={"Список устройств"}>
|
||||
<table class="tbl">
|
||||
<thead class="bg-gray-100">
|
||||
@@ -62,4 +65,7 @@
|
||||
<Alarm>
|
||||
<p>Список устройств будет обновляться автоматически. Подключенные к одному роутеру устройства будут появляться в списке в течении двух минут. Ручное добавление сделано в целях проверки для разработчика.</p>
|
||||
</Alarm>
|
||||
</div>
|
||||
</div>
|
||||
{:else}
|
||||
<Alarm title="Загрузка..." />
|
||||
{/if}
|
||||
|
||||
@@ -124,10 +124,13 @@
|
||||
export let errorsJson;
|
||||
export let rebootEsp = () => {};
|
||||
|
||||
export let show;
|
||||
|
||||
export let cancelAlarm = (alarmKey) => {};
|
||||
</script>
|
||||
|
||||
<div class="grd-2col1">
|
||||
{#if show}
|
||||
<div class="grd-2col1">
|
||||
<Card title="Системная информация">
|
||||
<div class="crd-itm-psn">
|
||||
<div class="w-3/4">
|
||||
@@ -213,9 +216,12 @@
|
||||
{/each}
|
||||
</div>
|
||||
</Card>
|
||||
</div>
|
||||
<div class="grd-1col1">
|
||||
</div>
|
||||
<div class="grd-1col1">
|
||||
<Card>
|
||||
<button class="btn-lg" on:click={() => rebootEsp()}>{"Перезагрузить устройство"}</button>
|
||||
</Card>
|
||||
</div>
|
||||
</div>
|
||||
{:else}
|
||||
<Alarm title="Загрузка..." />
|
||||
{/if}
|
||||
|
||||
Reference in New Issue
Block a user