2022-02-06 23:02:20 +01:00
< script >
import Card from "../components/Card.svelte";
2022-02-07 23:40:00 +01:00
import Alarm from "../components/Alarm.svelte";
2022-02-06 23:02:20 +01:00
2022-02-07 16:36:43 +01:00
import CrossIcon from "../svg/Cross.svelte";
import OpenIcon from "../svg/Open.svelte";
2022-02-06 23:02:20 +01:00
export let deviceList;
export let showInput;
2022-02-07 02:08:21 +01:00
export let newDevice = {} ;
2022-02-06 23:02:20 +01:00
export let devListSave = () => {} ;
2022-02-07 16:36:43 +01:00
let debug = true;
function deleteLineFromDevlist(num) {
for (let i = 0; i < deviceList.length ; i ++) {
if (num === i) {
deviceList.splice(i, 1);
deviceList = deviceList;
if (debug) console.log("[i]", "item " + num + " deleted from dev list");
break;
}
}
}
2022-02-06 23:02:20 +01:00
< / script >
2022-02-07 16:36:43 +01:00
< div class = "grd-1col1" >
2022-02-07 02:08:21 +01:00
< Card title = { "Список устройств" } >
< table class = "tbl" >
< thead class = "bg-gray-100" >
2022-02-07 16:36:43 +01:00
< tr class = "txt-sz txt-pad" >
2022-02-07 02:08:21 +01:00
< th class = "tbl-hd" > Название устройства< / th >
< th class = "tbl-hd" > IP адрес< / th >
< th class = "tbl-hd" > Идентификатор< / th >
< th class = "tbl-hd" > Состояние< / th >
< th class = "tbl-hd w-7" / >
2022-02-06 23:02:20 +01:00
< / tr >
2022-02-07 02:08:21 +01:00
< / thead >
< tbody class = "bg-white" >
{ #each deviceList as device , i }
2022-02-07 16:36:43 +01:00
< tr class = "txt-sz txt-pad" >
< td class = "tbl-bdy-lg ipt-lg w-full" > { device . name } </ td >
< td class = "tbl-bdy-lg ipt-lg w-full" >< a href = { "http://" + device . ip } > { device . ip } </a ></ td >
< td class = "tbl-bdy-lg ipt-lg w-full" > { device . id } </ td >
< td class = "tbl-bdy-lg ipt-lg w-full { device . status ? 'bg-green-50' : 'bg-red-50' } " > { device . status ? "online" : "offline" } </ td >
< td class = "tbl-bdy-lg" >< CrossIcon i = { i } click= {( i ) => deleteLineFromDevlist ( i )} /></ td >
2022-02-07 02:08:21 +01:00
< / tr >
{ /each }
{ #if showInput }
2022-02-07 16:36:43 +01:00
< tr class = "txt-sz txt-pad" >
< td class = "tbl-bdy-lg" >< input bind:value = { newDevice . name } class="ipt-lg w-full " type = "text" /></ td >
< td class = "tbl-bdy-lg" >< input bind:value = { newDevice . ip } class="ipt-lg w-full " type = "text" /></ td >
< td class = "tbl-bdy-lg" >< input bind:value = { newDevice . id } class="ipt-lg w-full " type = "text" /></ td >
< td class = "tbl-bdy-lg" / >
2022-02-07 02:08:21 +01:00
< / tr >
{ /if }
< / tbody >
< / table >
< button class = "btn-lg" on:click = {() => (( showInput = ! showInput ), devListSave ())} > { showInput ? "Сохранить" : "Добавить устройство" } </button >
< / Card >
2022-02-07 23:40:00 +01:00
< Alarm >
< p > Список устройств будет обновляться автоматически. Подключенные к одному роутеру устройства будут появляться в списке в течении двух минут. Ручное добавление сделано в целях проверки для разработчика.< / p >
< / Alarm >
2022-02-07 02:08:21 +01:00
< / div >