mirror of
https://github.com/IoTManagerProject/IoTManagerWeb.git
synced 2026-03-26 23:12:34 +03:00
toggle в процессе
This commit is contained in:
@@ -4,7 +4,7 @@
|
|||||||
<meta charset='utf-8'>
|
<meta charset='utf-8'>
|
||||||
<meta name='viewport' content='width=device-width,initial-scale=1'>
|
<meta name='viewport' content='width=device-width,initial-scale=1'>
|
||||||
|
|
||||||
<title>IoT Manager 4.1.2</title>
|
<title>IoT Manager 4.1.3</title>
|
||||||
|
|
||||||
<link rel='icon' type='image/png' href='/favicon.ico'>
|
<link rel='icon' type='image/png' href='/favicon.ico'>
|
||||||
<link rel='stylesheet' href='/build/bundle.css'>
|
<link rel='stylesheet' href='/build/bundle.css'>
|
||||||
|
|||||||
@@ -40,8 +40,8 @@
|
|||||||
|
|
||||||
//****************************************************variable section**********************************************************/
|
//****************************************************variable section**********************************************************/
|
||||||
//******************************************************************************************************************************/
|
//******************************************************************************************************************************/
|
||||||
let myip = document.location.hostname;
|
//let myip = document.location.hostname;
|
||||||
//let myip = "192.168.88.224";
|
let myip = "192.168.88.228";
|
||||||
|
|
||||||
//Flags
|
//Flags
|
||||||
let firstDevListRequest = true;
|
let firstDevListRequest = true;
|
||||||
@@ -497,16 +497,17 @@
|
|||||||
reader.readAsText(bb);
|
reader.readAsText(bb);
|
||||||
reader.onload = () => {
|
reader.onload = () => {
|
||||||
let devLayout = JSON.parse(reader.result);
|
let devLayout = JSON.parse(reader.result);
|
||||||
udateStatusOfDevWidgets(devLayout);
|
udateStatusOfDevWidgets(devLayout, ws);
|
||||||
layoutJson = layoutJson.concat(devLayout);
|
layoutJson = layoutJson.concat(devLayout);
|
||||||
sortingLayout();
|
sortingLayout();
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
function udateStatusOfDevWidgets(devLayout) {
|
function udateStatusOfDevWidgets(devLayout, ws) {
|
||||||
for (const [key, value] of Object.entries(paramsJson)) {
|
for (const [key, value] of Object.entries(paramsJson)) {
|
||||||
for (let i = 0; i < devLayout.length; i++) {
|
for (let i = 0; i < devLayout.length; i++) {
|
||||||
let topic = devLayout[i].topic;
|
let topic = devLayout[i].topic;
|
||||||
|
devLayout[i].ws = ws;
|
||||||
topic = topic.substring(topic.lastIndexOf("/") + 1, topic.length);
|
topic = topic.substring(topic.lastIndexOf("/") + 1, topic.length);
|
||||||
if (key === topic) {
|
if (key === topic) {
|
||||||
console.log("[i]", "value " + topic + " updated");
|
console.log("[i]", "value " + topic + " updated");
|
||||||
@@ -686,8 +687,12 @@
|
|||||||
|
|
||||||
function wsPush(ws, topic, status) {
|
function wsPush(ws, topic, status) {
|
||||||
let msg = topic + " " + status;
|
let msg = topic + " " + status;
|
||||||
if (debug) console.log("[i]", "send to ws msg:", msg);
|
if (debug) console.log("[i]", "ws: ", ws, msg);
|
||||||
wsSendMsg(ws, msg);
|
//if (ws) {
|
||||||
|
wsSendMsg(ws, "/control| " + status); // "/tst|"
|
||||||
|
//} else {
|
||||||
|
// console.log("[i]", "ws undefined");
|
||||||
|
//}
|
||||||
}
|
}
|
||||||
|
|
||||||
function wsTestMsgTask() {
|
function wsTestMsgTask() {
|
||||||
@@ -1117,6 +1122,7 @@
|
|||||||
<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={() => createFinalLayout()}>{"Test"}</button>-->
|
<!--<button class="btn-lg" on:click={() => createFinalLayout()}>{"Test"}</button>-->
|
||||||
|
<textarea value={JSON.stringify(layoutJson)} class="ipt-big h-40 w-full" />
|
||||||
</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()} />
|
||||||
|
|||||||
@@ -1,7 +1,11 @@
|
|||||||
<script>
|
<script>
|
||||||
|
import App from "../App.svelte";
|
||||||
|
|
||||||
export let widget;
|
export let widget;
|
||||||
export let value;
|
export let value;
|
||||||
|
|
||||||
value = value;
|
value = value;
|
||||||
|
|
||||||
export let wsPush = (ws, topic, status) => {};
|
export let wsPush = (ws, topic, status) => {};
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
@@ -13,10 +17,15 @@
|
|||||||
<div class="flex justify-end w-1/3">
|
<div class="flex justify-end w-1/3">
|
||||||
<label for={widget.topic} class="items-center cursor-pointer">
|
<label for={widget.topic} class="items-center cursor-pointer">
|
||||||
<div class="relative">
|
<div class="relative">
|
||||||
<input on:change={() => ((widget["send"] = true), wsPush(widget.ws, widget.topic, widget.status))} bind:value={widget.status} id={widget.topic} type="checkbox" class="sr-only" />
|
<input on:change={() => ((widget["send"] = true), wsPush(widget.ws, widget.topic, widget.status))} bind:checked={widget.status} id={widget.topic} type="checkbox" class="sr-only" />
|
||||||
<div class="block bg-gray-600 w-10 h-6 rounded-full" />
|
<div class="block bg-gray-600 w-10 h-6 rounded-full" />
|
||||||
<div class="dot {widget['send'] == true ? 'bg-red-400' : 'bg-white'} absolute left-1 top-1 w-4 h-4 rounded-full transition" />
|
<div class="dot {widget['send'] == true ? 'bg-red-400' : 'bg-white'} absolute left-1 top-1 w-4 h-4 rounded-full transition" />
|
||||||
</div>
|
</div>
|
||||||
|
{#if widget.status}
|
||||||
|
<p>yes</p>
|
||||||
|
{:else}
|
||||||
|
<p>no</p>
|
||||||
|
{/if}
|
||||||
</label>
|
</label>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
Reference in New Issue
Block a user