Browse Source

Merge pull request #11 from DanielR92/patch-6

add JS for formular Powermeter-DropDown
pull/1615/head
tictrick 8 months ago
committed by GitHub
parent
commit
1cf836fbfc
No known key found for this signature in database GPG Key ID: B5690EEEBB952194
  1. 52
      src/web/html/setup.html
  2. 5
      src/web/lang.json

52
src/web/html/setup.html

@ -1288,6 +1288,7 @@
} }
/*IF_PLUGIN_ZEROEXPORT*/ /*IF_PLUGIN_ZEROEXPORT*/
function apiCbBattOnOff(obj) { function apiCbBattOnOff(obj) {
// var e = document.getElementById("battSwitch"); // var e = document.getElementById("battSwitch");
// e.value = "88"; // e.value = "88";
@ -1382,13 +1383,16 @@
]), ]),
// Powermeter // Powermeter
ml("div", {id: "div{#ZE_GROUP_TAB_POWERMETER}", class: "tab-content hide"}, [ ml("div", {id: "div{#ZE_GROUP_TAB_POWERMETER}", class: "tab-content hide"}, [
divRow("{#ZE_GROUP_TAB_POWERMETER_REFRESH}",
ml("input", {name: "pm_refresh", class: "text", type: "number", min: "1", max: "30", step: "1", value: obj.pm_refresh}, null),
),
divRow("{#ZE_GROUP_TAB_POWERMETER_TYPE}", divRow("{#ZE_GROUP_TAB_POWERMETER_TYPE}",
ml("select", {name: "pm_type", class: "text", id: "pm_type"}, null), ml("select", {name: "pm_type", class: "text", id: "pm_type"}, null),
), ),
divRow("{#ZE_GROUP_TAB_POWERMETER_REFRESH}",
ml("input", {name: "pm_refresh", class: "text", type: "number", min: "1", max: "30", step: "1", value: obj.pm_refresh}, null),
),
// TODO: URL -> IP // TODO: URL -> IP
divRow("{#ZE_GROUP_TAB_POWERMETER_TARGET}",
ml("select", {name: "pm_target", class: "text", id: "pm_target"}, null),
),
divRow("{#ZE_GROUP_TAB_POWERMETER_IP}", [ divRow("{#ZE_GROUP_TAB_POWERMETER_IP}", [
ml("input", {name: "pm_url", class: "text", type: "text", value: obj.pm_url, maxlength: "100"}, null), ml("input", {name: "pm_url", class: "text", type: "text", value: obj.pm_url, maxlength: "100"}, null),
]), ]),
@ -1401,8 +1405,8 @@
divRow("{#ZE_GROUP_TAB_POWERMETER_PASS}", divRow("{#ZE_GROUP_TAB_POWERMETER_PASS}",
ml("input", {name: "pm_pass", class: "text", type: "password", value: "****"}, null), ml("input", {name: "pm_pass", class: "text", type: "password", value: "****"}, null),
), ),
divRow("{#ZE_GROUP_TAB_POWERMETER_TARGET}", divRow("{#ZE_GROUP_TAB_POWERMETER_TOPIC}",
ml("select", {name: "pm_target", class: "text", id: "pm_target"}, null), ml("input", {id: 3, name: "pm_topic", class: "text", type: "text", value: ""}, null),
), ),
// TODO: Uebersetzen mit lang.json und auf die entsprechende Dokuseite verlinken // TODO: Uebersetzen mit lang.json und auf die entsprechende Dokuseite verlinken
divRow("Hinweis: ", divRow("Hinweis: ",
@ -1482,7 +1486,6 @@
// Inhalt fuer pm_type aus config laden und in eine Funktion ausgliedern // Inhalt fuer pm_type aus config laden und in eine Funktion ausgliedern
var e = document.getElementById("pm_type"); var e = document.getElementById("pm_type");
selDelAllOpt(e); selDelAllOpt(e);
// TODO: uebersetzen?
e.appendChild(opt("0", "---")); e.appendChild(opt("0", "---"));
e.appendChild(opt("1", "Shelly")); e.appendChild(opt("1", "Shelly"));
//e.appendChild(opt("2", "Tasmota")); //e.appendChild(opt("2", "Tasmota"));
@ -1495,6 +1498,7 @@
e.selectedIndex = i; e.selectedIndex = i;
} }
} }
// - pm_target // - pm_target
var e = document.getElementById("pm_target"); var e = document.getElementById("pm_target");
selDelAllOpt(e); selDelAllOpt(e);
@ -1508,6 +1512,14 @@
} }
} }
// add addEventListener
const selectElement = document.querySelector("#pm_type");
//selectElement.addEventListener("change", (event) => { pm_type_dropdown() });
selectElement.addEventListener("change", (event) => { pm_type_dropdown() });
// run event one time
pm_type_dropdown();
// Tab_Inverters // Tab_Inverters
// - Enabled // - Enabled
for (var inv = 0; inv < maxInv; inv++) { for (var inv = 0; inv < maxInv; inv++) {
@ -1559,6 +1571,33 @@
} }
} }
function pm_type_dropdown()
{
var e = document.getElementsByName("pm_type")[0];
var value = e.options[e.selectedIndex].text;
var divsToHide = document.getElementById("divPowermeter");
// Formular for Powermeter-DropDown
// show all DIVs and remove only what is not necessary
for(var i = 0; i < divsToHide.childElementCount; i++) divsToHide.childNodes[i].style.display = '';
if(value == "---") for(var i = 1; i < divsToHide.childElementCount; i++) divsToHide.childNodes[i].style.display = 'none';
else if(value == "Shelly") {
divsToHide.childNodes[7].style.display = 'none';
}
else if(value == "Mqtt") {
divsToHide.childNodes[3].style.display = 'none';
divsToHide.childNodes[4].style.display = 'none';
divsToHide.childNodes[5].style.display = 'none';
divsToHide.childNodes[6].style.display = 'none';
}
else if(value == "Tibber") {
divsToHide.childNodes[4].style.display = 'none';
divsToHide.childNodes[7].style.display = 'none';
}
}
function save() { function save() {
var o = new Object(); var o = new Object();
o.cmd = "ze_save_group" o.cmd = "ze_save_group"
@ -1567,6 +1606,7 @@
o.id = obj.id o.id = obj.id
o.enabled = document.getElementsByName("enabled")[0].checked; o.enabled = document.getElementsByName("enabled")[0].checked;
o.name = document.getElementsByName("name")[0].value; o.name = document.getElementsByName("name")[0].value;
// Powermeter // Powermeter
o.pm_refresh = document.getElementsByName("pm_refresh")[0].value; o.pm_refresh = document.getElementsByName("pm_refresh")[0].value;
var e = document.getElementsByName("pm_type")[0]; var e = document.getElementsByName("pm_type")[0];

5
src/web/lang.json

@ -913,6 +913,11 @@
"en": "Password:", "en": "Password:",
"de": "Passwort:" "de": "Passwort:"
}, },
{
"token": "ZE_GROUP_TAB_POWERMETER_TOPIC",
"en": "Topic:",
"de": "Topic:"
},
{ {
"token": "ZE_GROUP_TAB_POWERMETER_TARGET", "token": "ZE_GROUP_TAB_POWERMETER_TARGET",
"en": "Target:", "en": "Target:",

Loading…
Cancel
Save