diff --git a/src/App.svelte b/src/App.svelte index 3f1068f..a709cf0 100644 --- a/src/App.svelte +++ b/src/App.svelte @@ -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); - delete item.num; - delete item.name; - configJson.push(item); - configJson = configJson; - itemsJsonBind = 0; - if (debug) console.log("[i]", "item added"); + 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 @@
+ {#if wigets === []} + + {/if} {#each pages as pagesName, i} {#each wigets as widget, i} @@ -781,7 +790,7 @@ {/if} {/each} - +
@@ -796,7 +805,7 @@ - {#each configJson as element} + {#each configJson as element, i} @@ -811,7 +820,7 @@ - + {#if !hideAllSubParams} {#each Object.entries(element) as [key, param]}
{element.subtype} (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"> 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">