mirror of
https://github.com/IoTManagerProject/IoTManagerWeb.git
synced 2026-03-26 23:12:34 +03:00
first widget
This commit is contained in:
1676
examples/Dashboard.svelte
Normal file
1676
examples/Dashboard.svelte
Normal file
File diff suppressed because it is too large
Load Diff
@@ -5,10 +5,41 @@
|
|||||||
//router.mode.memory(); // enables in-memory navigation method
|
//router.mode.memory(); // enables in-memory navigation method
|
||||||
import Card from "./Card.svelte";
|
import Card from "./Card.svelte";
|
||||||
import Input from "./Input.svelte";
|
import Input from "./Input.svelte";
|
||||||
//
|
|
||||||
let incommingText = "";
|
let wigets = [];
|
||||||
function handleMessage(event) {
|
|
||||||
incommingText = event.detail.text;
|
wigets = [
|
||||||
|
{
|
||||||
|
widget: "input",
|
||||||
|
status: "30",
|
||||||
|
type: "",
|
||||||
|
page: "",
|
||||||
|
order: "1",
|
||||||
|
descr: "Temperature1",
|
||||||
|
topic: "/prefix/00000-00000/temp1",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
widget: "input",
|
||||||
|
status: "31",
|
||||||
|
type: "",
|
||||||
|
page: "",
|
||||||
|
order: "1",
|
||||||
|
descr: "Temperature2",
|
||||||
|
topic: "/prefix/00000-00000/temp2",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
widget: "input",
|
||||||
|
status: "32",
|
||||||
|
type: "",
|
||||||
|
page: "",
|
||||||
|
order: "1",
|
||||||
|
descr: "Temperature3",
|
||||||
|
topic: "/prefix/00000-00000/temp3",
|
||||||
|
},
|
||||||
|
];
|
||||||
|
|
||||||
|
function WSpush(ws, uri, val) {
|
||||||
|
console.log(ws + " " + uri + " " + val);
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
@@ -51,7 +82,13 @@
|
|||||||
<ul class="menu__main">
|
<ul class="menu__main">
|
||||||
<div class="bg-cover bg-gray-50 pt-16">
|
<div class="bg-cover bg-gray-50 pt-16">
|
||||||
<Route path="/">
|
<Route path="/">
|
||||||
<Card title="Здесь будет dashboard" />
|
<Card title="Testing card1">
|
||||||
|
{#each wigets as widget, i}
|
||||||
|
{#if widget.widget === "input"}
|
||||||
|
<Input title={widget.descr} value={widget.status} />
|
||||||
|
{/if}
|
||||||
|
{/each}
|
||||||
|
</Card>
|
||||||
</Route>
|
</Route>
|
||||||
|
|
||||||
<Route path="/config">
|
<Route path="/config">
|
||||||
@@ -146,12 +183,7 @@
|
|||||||
</Card>
|
</Card>
|
||||||
</Route>
|
</Route>
|
||||||
|
|
||||||
<Route path="/test">
|
<Route path="/test" />
|
||||||
<Card title="Testing card1">
|
|
||||||
<Input on:msg1={handleMessage} title="Input text1" />
|
|
||||||
<h1>{incommingText}</h1>
|
|
||||||
</Card>
|
|
||||||
</Route>
|
|
||||||
</div>
|
</div>
|
||||||
</ul>
|
</ul>
|
||||||
</main>
|
</main>
|
||||||
|
|||||||
@@ -1,11 +1,7 @@
|
|||||||
<script>
|
<script>
|
||||||
export let title;
|
export let title;
|
||||||
let text;
|
export let value;
|
||||||
import { createEventDispatcher } from "svelte";
|
//on:input={sendInputText}
|
||||||
const dispatch = createEventDispatcher();
|
|
||||||
function sendInputText() {
|
|
||||||
dispatch("msg1", { text: text });
|
|
||||||
}
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<div class="container">
|
<div class="container">
|
||||||
@@ -14,7 +10,7 @@
|
|||||||
<label class="block text-gray-500 font-bold md:text-right mb-1 md:mb-0 pr-4" for="inline-full-name">{title}</label>
|
<label class="block text-gray-500 font-bold md:text-right mb-1 md:mb-0 pr-4" for="inline-full-name">{title}</label>
|
||||||
</div>
|
</div>
|
||||||
<div class="md:w-2/3">
|
<div class="md:w-2/3">
|
||||||
<input bind:value={text} on:input={sendInputText} class="bg-gray-200 appearance-none border-2 border-gray-200 rounded w-full py-2 px-4 text-gray-700 leading-tight focus:outline-none focus:bg-white focus:border-purple-500" id="inline-full-name" type="text" />
|
<input bind:value class="bg-gray-200 appearance-none border-2 border-gray-200 rounded w-full py-2 px-4 text-gray-700 leading-tight focus:outline-none focus:bg-white focus:border-purple-500" id="inline-full-name" type="text" />
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
Reference in New Issue
Block a user