2021-10-19 21:59:48 +08:00
|
|
|
<script>
|
2022-08-14 17:13:49 +02:00
|
|
|
import App from "../App.svelte";
|
2022-08-15 19:31:01 +02:00
|
|
|
import { onMount } from "svelte";
|
2022-08-16 00:11:38 +02:00
|
|
|
import { handle_promise } from "svelte/internal";
|
2022-08-15 19:31:01 +02:00
|
|
|
onMount(async () => {
|
|
|
|
|
setDefaultValue();
|
|
|
|
|
});
|
2021-10-19 21:59:48 +08:00
|
|
|
export let widget;
|
2022-08-15 19:31:01 +02:00
|
|
|
|
2022-02-06 23:02:20 +01:00
|
|
|
export let wsPush = (ws, topic, status) => {};
|
2022-08-15 19:31:01 +02:00
|
|
|
|
|
|
|
|
let st = false;
|
|
|
|
|
|
|
|
|
|
function setDefaultValue() {
|
|
|
|
|
if (widget.status == "1") {
|
|
|
|
|
st = true;
|
|
|
|
|
} else if (widget.status == "0") {
|
|
|
|
|
st = false;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function changeValue() {
|
|
|
|
|
if (st) {
|
|
|
|
|
widget.status = "1";
|
|
|
|
|
} else {
|
|
|
|
|
widget.status = "0";
|
|
|
|
|
}
|
|
|
|
|
}
|
2021-10-19 21:59:48 +08:00
|
|
|
</script>
|
|
|
|
|
|
2021-12-28 23:55:14 +01:00
|
|
|
<div class="crd-itm-psn">
|
2022-02-11 00:22:41 +01:00
|
|
|
<div class="w-2/3">
|
2021-10-19 21:59:48 +08:00
|
|
|
<!-- svelte-ignore a11y-label-has-associated-control -->
|
2021-12-28 23:55:14 +01:00
|
|
|
<label class="wgt-dscr-stl">{!widget.descr ? "" : widget.descr}</label>
|
2021-10-19 21:59:48 +08:00
|
|
|
</div>
|
2022-02-11 00:22:41 +01:00
|
|
|
<div class="flex justify-end w-1/3">
|
2021-10-25 16:50:31 +07:00
|
|
|
<label for={widget.topic} class="items-center cursor-pointer">
|
|
|
|
|
<div class="relative">
|
2022-08-15 19:31:01 +02:00
|
|
|
<input bind:checked={st} on:change={() => (changeValue(), wsPush(widget.ws, widget.topic, widget.status))} id={widget.topic} type="checkbox" class="sr-only" />
|
2021-10-27 05:11:28 +07:00
|
|
|
<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" />
|
2021-10-25 16:50:31 +07:00
|
|
|
</div>
|
|
|
|
|
</label>
|
2021-10-19 21:59:48 +08:00
|
|
|
</div>
|
|
|
|
|
</div>
|