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",
|
name: "Устройство 1",
|
||||||
id: "987654321",
|
id: "987654321",
|
||||||
//ip: myip,
|
ip: myip,
|
||||||
ip: "192.168.88.235",
|
//ip: "192.168.88.235",
|
||||||
status: false,
|
status: false,
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
@@ -660,22 +660,28 @@
|
|||||||
//************************************************elements and presets dropdown************************************************************/
|
//************************************************elements and presets dropdown************************************************************/
|
||||||
|
|
||||||
function elementsDropdownChange() {
|
function elementsDropdownChange() {
|
||||||
//костыльный вариант предотвкащающий binding
|
for (let i = 0; i < itemsJson.length; i++) {
|
||||||
let itemStr = JSON.stringify(getItem(itemsJsonBind));
|
let item = Object.assign({}, itemsJson[i]);
|
||||||
let item = JSON.parse(itemStr);
|
if (itemsJsonBind === item.num) {
|
||||||
delete item.num;
|
delete item.num;
|
||||||
delete item.name;
|
delete item.name;
|
||||||
configJson.push(item);
|
configJson.push(item);
|
||||||
configJson = configJson;
|
configJson = configJson;
|
||||||
itemsJsonBind = 0;
|
itemsJsonBind = 0;
|
||||||
if (debug) console.log("[i]", "item added");
|
if (debug) console.log("[i]", "item added");
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function getItem(num) {
|
function deleteLine(num) {
|
||||||
for (let i = 0; i < itemsJson.length; i++) {
|
if (debug) console.log("[i]", num);
|
||||||
let item = itemsJson[i];
|
for (let i = 0; i < configJson.length; i++) {
|
||||||
if (num === item.num) {
|
if (num === i) {
|
||||||
return item;
|
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">
|
<div class="bg-cover pt-0 px-4">
|
||||||
<Route path="/">
|
<Route path="/">
|
||||||
<div class="grd-3cols">
|
<div class="grd-3cols">
|
||||||
|
{#if wigets === []}
|
||||||
|
<Card title={"Ваша панель управления пуста, вначале добавьте новые элементы в конфигураторе!"} />
|
||||||
|
{/if}
|
||||||
{#each pages as pagesName, i}
|
{#each pages as pagesName, i}
|
||||||
<Card title={pagesName.page}>
|
<Card title={pagesName.page}>
|
||||||
{#each wigets as widget, i}
|
{#each wigets as widget, i}
|
||||||
@@ -781,7 +790,7 @@
|
|||||||
{/if}
|
{/if}
|
||||||
{/each}
|
{/each}
|
||||||
</select>
|
</select>
|
||||||
<select class="slct-lg">{"Выберите пресет"}</select>
|
<select class="slct-lg"><option>{"Выберите пресет"}</option></select>
|
||||||
</div>
|
</div>
|
||||||
<table class="table-fixed w-full select-none my-2 ">
|
<table class="table-fixed w-full select-none my-2 ">
|
||||||
<thead class="bg-gray-100">
|
<thead class="bg-gray-100">
|
||||||
@@ -796,7 +805,7 @@
|
|||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
<tbody class="bg-white">
|
<tbody class="bg-white">
|
||||||
{#each configJson as element}
|
{#each configJson as element, i}
|
||||||
<tr class="tbl-txt-sz tbl-txt-p">
|
<tr class="tbl-txt-sz tbl-txt-p">
|
||||||
<td class="tbl-bdy">{element.subtype}</td>
|
<td class="tbl-bdy">{element.subtype}</td>
|
||||||
<td class="tbl-bdy"><input bind:value={element.id} class="tbl-ipt w-full" type="text" /></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.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"><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 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>
|
</tr>
|
||||||
{#if !hideAllSubParams}
|
{#if !hideAllSubParams}
|
||||||
{#each Object.entries(element) as [key, param]}
|
{#each Object.entries(element) as [key, param]}
|
||||||
|
|||||||
Reference in New Issue
Block a user