mirror of
https://github.com/lumapu/ahoy.git
synced 2025-05-18 11:26:10 +02:00
fix setup for multiple inverters
This commit is contained in:
parent
35d8fdcab2
commit
f2a794d518
4 changed files with 31 additions and 3 deletions
|
@ -47,7 +47,7 @@
|
|||
<fieldset>
|
||||
<legend class="des">Inverter</legend>
|
||||
<div id="inverter"></div><br/>
|
||||
<input type="button" name="btnAdd" value="Add Inverter"/>
|
||||
<input type="button" id="btnAdd" value="Add Inverter"/>
|
||||
<p class="subdes">General</p>
|
||||
<label for="invInterval">Interval [s]</label>
|
||||
<input type="text" class="text" name="invInterval"/>
|
||||
|
@ -132,8 +132,8 @@
|
|||
|
||||
const re = /11[2,4,6]1.*/;
|
||||
|
||||
document.getElementsByName("btnAdd")[0].addEventListener("click", function() {
|
||||
if(highestId < (maxInv-1))
|
||||
document.getElementById("btnAdd").addEventListener("click", function() {
|
||||
if(highestId <= (maxInv-1))
|
||||
ivHtml(JSON.parse('{"name":"","serial":"","channels":4,"ch_max_power":[0,0,0,0],"ch_name":["","","",""]}'), highestId + 1);
|
||||
});
|
||||
|
||||
|
@ -174,6 +174,14 @@
|
|||
getAjax("/api/setup", apiCbMqtt, "POST", JSON.stringify(obj));
|
||||
}
|
||||
|
||||
function delIv() {
|
||||
var id = this.id.substring(0,4);
|
||||
var e = document.getElementsByName(id + "Addr")[0];
|
||||
e.value = "";
|
||||
e.dispatchEvent(new Event("keyup"));
|
||||
document.getElementsByName(id + "Name")[0].value = "";
|
||||
}
|
||||
|
||||
function ivHtml(obj, id) {
|
||||
highestId = id;
|
||||
if(highestId == (maxInv - 1))
|
||||
|
@ -182,6 +190,7 @@
|
|||
iv.appendChild(des("Inverter " + id));
|
||||
id = "inv" + id;
|
||||
|
||||
|
||||
iv.appendChild(lbl(id + "Addr", "Address*"));
|
||||
var addr = inp(id + "Addr", obj["serial"], 12)
|
||||
iv.appendChild(addr);
|
||||
|
@ -226,6 +235,11 @@
|
|||
}
|
||||
iv.appendChild(d);
|
||||
}
|
||||
iv.appendChild(br());
|
||||
iv.appendChild(lbl(id + "lbldel", "Delete"));
|
||||
var del = inp(id+"del", "X", 0, ["btn", "btnDel"], id+"del", "button");
|
||||
iv.appendChild(del);
|
||||
del.addEventListener("click", delIv);
|
||||
}
|
||||
|
||||
function ivGlob(obj) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue