change function

This commit is contained in:
Dmitry Borisenko
2021-09-13 18:59:30 +08:00
parent cb7fad76f4
commit ba3f94d15f
2 changed files with 12 additions and 9 deletions

View File

@@ -1,6 +1,6 @@
<script context="module"> <script context="module">
export function WSpush(arg) { export function WSpush(ws, topic, value) {
console.log(arg); console.log(ws, topic, value);
} }
</script> </script>
@@ -15,7 +15,7 @@
import Myinput from "./Myinput.svelte"; import Myinput from "./Myinput.svelte";
onMount(async () => { onMount(async () => {
WSpush("mounted"); console.log("mounted");
}); });
const syntaxHighlight = (json) => { const syntaxHighlight = (json) => {
@@ -45,7 +45,7 @@
page: "", page: "",
order: "1", order: "1",
descr: "Boiler temperature", descr: "Boiler temperature",
topic: "/prefix/00000-00000/temp1", topic: "/prefix/00000-00001/temp1",
}, },
{ {
widget: "input", widget: "input",
@@ -54,7 +54,7 @@
page: "", page: "",
order: "1", order: "1",
descr: "Room temperature", descr: "Room temperature",
topic: "/prefix/00000-00000/temp2", topic: "/prefix/00000-00002/temp2",
}, },
{ {
widget: "input", widget: "input",
@@ -63,7 +63,7 @@
page: "", page: "",
order: "1", order: "1",
descr: "Body temperature", descr: "Body temperature",
topic: "/prefix/00000-00000/temp3", topic: "/prefix/00000-00003/temp3",
}, },
]; ];
</script> </script>
@@ -113,7 +113,7 @@
<Card title="Dashboard"> <Card title="Dashboard">
{#each wigets as widget, i} {#each wigets as widget, i}
{#if widget.widget === "input"} {#if widget.widget === "input"}
<Myinput title={widget.descr} bind:value={widget.status} /> <Myinput ws={"ws"} topic={widget.topic} title={widget.descr} bind:value={widget.status} />
{/if} {/if}
{/each} {/each}
</Card> </Card>

View File

@@ -5,6 +5,8 @@
<script> <script>
export let title; export let title;
export let value; export let value;
export let topic;
export let ws;
</script> </script>
<div class="container"> <div class="container">
@@ -14,10 +16,11 @@
<label class="descr-gray-left">{title}</label> <label class="descr-gray-left">{title}</label>
</div> </div>
<div class="md:w-3/3"> <div class="md:w-3/3">
<input bind:value on:change={WSpush(value)} class="input-indigo" type="text" /> <!-- on:change={WSpush(ws, topic, value)} -->
<input bind:value class="input-indigo" type="text" />
</div> </div>
<div class="md:w-3/3"> <div class="md:w-3/3">
<button on:click={WSpush(value)} class="btn-indigo" type="button">Set</button> <button on:click={WSpush(ws, topic, value)} class="btn-indigo" type="button">Set</button>
</div> </div>
</div> </div>
</div> </div>