mirror of
https://github.com/IoTManagerProject/IoTManagerWeb.git
synced 2026-03-26 23:12:34 +03:00
добавил удаление элементов
This commit is contained in:
@@ -184,8 +184,8 @@
|
||||
{
|
||||
name: "Устройство 1",
|
||||
id: "987654321",
|
||||
//ip: myip,
|
||||
ip: "192.168.88.235",
|
||||
ip: myip,
|
||||
//ip: "192.168.88.235",
|
||||
status: false,
|
||||
},
|
||||
];
|
||||
@@ -660,22 +660,28 @@
|
||||
//************************************************elements and presets dropdown************************************************************/
|
||||
|
||||
function elementsDropdownChange() {
|
||||
//костыльный вариант предотвкащающий binding
|
||||
let itemStr = JSON.stringify(getItem(itemsJsonBind));
|
||||
let item = JSON.parse(itemStr);
|
||||
for (let i = 0; i < itemsJson.length; i++) {
|
||||
let item = Object.assign({}, itemsJson[i]);
|
||||
if (itemsJsonBind === item.num) {
|
||||
delete item.num;
|
||||
delete item.name;
|
||||
configJson.push(item);
|
||||
configJson = configJson;
|
||||
itemsJsonBind = 0;
|
||||
if (debug) console.log("[i]", "item added");
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function getItem(num) {
|
||||
for (let i = 0; i < itemsJson.length; i++) {
|
||||
let item = itemsJson[i];
|
||||
if (num === item.num) {
|
||||
return item;
|
||||
function deleteLine(num) {
|
||||
if (debug) console.log("[i]", num);
|
||||
for (let i = 0; i < configJson.length; i++) {
|
||||
if (num === i) {
|
||||
configJson.splice(i, 1);
|
||||
configJson = configJson;
|
||||
if (debug) console.log("[i]", "item " + num + " deleted");
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -746,6 +752,9 @@
|
||||
<div class="bg-cover pt-0 px-4">
|
||||
<Route path="/">
|
||||
<div class="grd-3cols">
|
||||
{#if wigets === []}
|
||||
<Card title={"Ваша панель управления пуста, вначале добавьте новые элементы в конфигураторе!"} />
|
||||
{/if}
|
||||
{#each pages as pagesName, i}
|
||||
<Card title={pagesName.page}>
|
||||
{#each wigets as widget, i}
|
||||
@@ -781,7 +790,7 @@
|
||||
{/if}
|
||||
{/each}
|
||||
</select>
|
||||
<select class="slct-lg">{"Выберите пресет"}</select>
|
||||
<select class="slct-lg"><option>{"Выберите пресет"}</option></select>
|
||||
</div>
|
||||
<table class="table-fixed w-full select-none my-2 ">
|
||||
<thead class="bg-gray-100">
|
||||
@@ -796,7 +805,7 @@
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody class="bg-white">
|
||||
{#each configJson as element}
|
||||
{#each configJson as element, i}
|
||||
<tr class="tbl-txt-sz tbl-txt-p">
|
||||
<td class="tbl-bdy">{element.subtype}</td>
|
||||
<td class="tbl-bdy"><input bind:value={element.id} class="tbl-ipt w-full" type="text" /></td>
|
||||
@@ -811,7 +820,7 @@
|
||||
<td class="tbl-bdy"><input bind:value={element.page} class="tbl-ipt w-full" type="text" /></td>
|
||||
<td class="tbl-bdy"><input bind:value={element.descr} class="tbl-ipt w-full" type="text" /></td>
|
||||
<td class="tbl-bdy"><svg on:click={() => (hideAllSubParams = !hideAllSubParams)} class="h-6 w-6 text-green-400 cursor-pointer" width="24" height="24" viewBox="0 0 24 24" stroke-width="2" stroke="currentColor" fill="none" stroke-linecap="round" stroke-linejoin="round"> <path stroke="none" d="M0 0h24v24H0z" /> <circle cx="5" cy="12" r="1" /> <circle cx="12" cy="12" r="1" /> <circle cx="19" cy="12" r="1" /></svg></td>
|
||||
<td class="tbl-bdy"><svg class="h-6 w-6 text-red-400 cursor-pointer" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"> <line x1="18" y1="6" x2="6" y2="18" /> <line x1="6" y1="6" x2="18" y2="18" /></svg></td>
|
||||
<td class="tbl-bdy"><svg on:click={() => deleteLine(i)} class="h-6 w-6 text-red-400 cursor-pointer" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"> <line x1="18" y1="6" x2="6" y2="18" /> <line x1="6" y1="6" x2="18" y2="18" /></svg></td>
|
||||
</tr>
|
||||
{#if !hideAllSubParams}
|
||||
{#each Object.entries(element) as [key, param]}
|
||||
|
||||
Reference in New Issue
Block a user