Files
IoTManagerWeb/src/widgets/Input.svelte

67 lines
1.9 KiB
Svelte
Raw Normal View History

2021-09-16 02:00:52 +08:00
<script context="module">
2021-10-17 17:48:59 +08:00
import { WSpush } from "../App.svelte";
2021-09-16 02:00:52 +08:00
</script>
<script>
2021-10-16 21:27:57 +08:00
export let widget;
2021-09-16 02:00:52 +08:00
</script>
2021-09-17 23:18:06 +08:00
<div class="card-items">
2021-10-19 21:59:48 +08:00
<div class="w-full md:w-2/3 lg:w-2/3 2xl:w-2/3">
2021-09-17 23:18:06 +08:00
<!-- svelte-ignore a11y-label-has-associated-control -->
2021-10-19 21:59:48 +08:00
<label class="widget-descr-gray"
2021-10-18 03:31:36 +08:00
>{!widget.descr ? "" : widget.descr}</label>
2021-09-17 23:18:06 +08:00
</div>
2021-10-19 21:59:48 +08:00
<div class="w-full md:w-1/3 lg:w-1/3 2xl:w-1/3">
2021-10-16 21:27:57 +08:00
{#if widget.type == "number"}
2021-10-18 03:31:36 +08:00
<input
class={widget["send"] == true
? "widget-input border-red-500"
: "widget-input focus:border-indigo-500"}
on:change={() => (
(widget["send"] = true),
WSpush(widget.ws, widget.topic, widget.status)
)}
2021-10-18 03:37:06 +08:00
bind:value={widget.status}
2021-10-18 03:31:36 +08:00
step="0.1"
type="number" />
2021-09-17 23:18:06 +08:00
{/if}
2021-10-16 21:27:57 +08:00
{#if widget.type == "text"}
2021-10-18 03:31:36 +08:00
<input
class={widget["send"] == true
? "widget-input border-red-500"
: "widget-input focus:border-indigo-500"}
on:change={() => (
(widget["send"] = true),
WSpush(widget.ws, widget.topic, widget.status)
)}
2021-10-18 03:37:06 +08:00
bind:value={widget.status}
2021-10-18 03:31:36 +08:00
type="text" />
2021-09-17 23:18:06 +08:00
{/if}
2021-10-16 21:27:57 +08:00
{#if widget.type == "date"}
2021-10-18 03:31:36 +08:00
<input
class={widget["send"] == true
? "widget-input border-red-500"
: "widget-input focus:border-indigo-500"}
on:change={() => (
(widget["send"] = true),
WSpush(widget.ws, widget.topic, widget.status)
)}
2021-10-18 03:37:06 +08:00
bind:value={widget.status}
2021-10-18 03:31:36 +08:00
type="date" />
2021-09-17 23:18:06 +08:00
{/if}
2021-10-16 21:27:57 +08:00
{#if widget.type == "time"}
2021-10-18 03:31:36 +08:00
<input
class={widget["send"] == true
? "widget-input border-red-500"
: "widget-input focus:border-indigo-500"}
on:change={() => (
(widget["send"] = true),
WSpush(widget.ws, widget.topic, widget.status)
)}
2021-10-18 03:37:06 +08:00
bind:value={widget.status}
2021-10-18 03:31:36 +08:00
type="time" />
2021-09-17 23:18:06 +08:00
{/if}
2021-09-16 02:00:52 +08:00
</div>
</div>