From 2f17080ff3a3847fecc7a10a2576da2ec2bd087c Mon Sep 17 00:00:00 2001 From: Patrick Amrhein Date: Fri, 1 Mar 2024 00:50:35 +0100 Subject: [PATCH] zero-0.8.850023 --- src/config/settings.h | 8 ++++---- src/defines.h | 2 +- src/web/RestApi.h | 4 ++-- src/web/html/setup.html | 40 +++++++++++++++------------------------- 4 files changed, 22 insertions(+), 32 deletions(-) diff --git a/src/config/settings.h b/src/config/settings.h index 1259d41a..50a21ab0 100644 --- a/src/config/settings.h +++ b/src/config/settings.h @@ -234,8 +234,8 @@ typedef enum { typedef struct { bool enabled; - uint8_t id; - uint8_t target; + int8_t id; + int8_t target; bool twoPercent; uint16_t powerMax; @@ -908,9 +908,9 @@ class settings { if (obj.containsKey(F("enabled"))) getVal(obj, F("enabled"), &mCfg.plugin.zeroExport.groups[group].inverters[inv].enabled); if (obj.containsKey(F("id"))) - getVal(obj, F("id"), &mCfg.plugin.zeroExport.groups[group].inverters[inv].id); + getVal(obj, F("id"), &mCfg.plugin.zeroExport.groups[group].inverters[inv].id); if (obj.containsKey(F("target"))) - getVal(obj, F("target"), &mCfg.plugin.zeroExport.groups[group].inverters[inv].target); + getVal(obj, F("target"), &mCfg.plugin.zeroExport.groups[group].inverters[inv].target); if (obj.containsKey(F("twoPercent"))) getVal(obj, F("twoPercent"), &mCfg.plugin.zeroExport.groups[group].inverters[inv].twoPercent); if (obj.containsKey(F("powerMax"))) diff --git a/src/defines.h b/src/defines.h index 0de67262..054e884c 100644 --- a/src/defines.h +++ b/src/defines.h @@ -13,7 +13,7 @@ //------------------------------------- #define VERSION_MAJOR 0 #define VERSION_MINOR 8 -#define VERSION_PATCH 850021 +#define VERSION_PATCH 850023 //------------------------------------- typedef struct { diff --git a/src/web/RestApi.h b/src/web/RestApi.h index e7a2b34b..1246851d 100644 --- a/src/web/RestApi.h +++ b/src/web/RestApi.h @@ -736,8 +736,8 @@ class RestApi { for(uint8_t inv = 0; inv < ZEROEXPORT_GROUP_MAX_INVERTERS; inv++) { JsonObject objGroupInv = arrInv.createNestedObject(); objGroupInv[F("enabled")] = (bool)mConfig->plugin.zeroExport.groups[group].inverters[inv].enabled; - objGroupInv[F("id")] = (uint8_t)mConfig->plugin.zeroExport.groups[group].inverters[inv].id; - objGroupInv[F("target")] = (uint8_t)mConfig->plugin.zeroExport.groups[group].inverters[inv].target; + objGroupInv[F("id")] = (int8_t)mConfig->plugin.zeroExport.groups[group].inverters[inv].id; + objGroupInv[F("target")] = (int8_t)mConfig->plugin.zeroExport.groups[group].inverters[inv].target; objGroupInv[F("twoPercent")] = (bool)mConfig->plugin.zeroExport.groups[group].inverters[inv].twoPercent; objGroupInv[F("powerMax")] = (uint16_t)mConfig->plugin.zeroExport.groups[group].inverters[inv].powerMax; } diff --git a/src/web/html/setup.html b/src/web/html/setup.html index b83f777d..7feeb02e 100644 --- a/src/web/html/setup.html +++ b/src/web/html/setup.html @@ -1176,25 +1176,7 @@ /*IF_PLUGIN_ZEROEXPORT*/ // Plugin ZeroExport - function parseZeroExportGroup_Modal_Iv(root) { - - if (root == null) - return; - - var invMax = document.getElementById("invMax").value; - - for (var inv = 0; inv < invMax; inv++) { - var e = document.getElementById("invId"+inv); - selDelAllOpt(e); -// e.appendChild(opt(-1, "---")); -// TODO: Verhindert die Funktion des selects egal ob -1 oder "-1" - for (var i = 0; i < root.inverter.length; i++) { - e.appendChild(opt((root.inverter[i].id), (root.inverter[i].name))); - } - } - } - - function ZeroExportGroup_Modal(obj) { + function ZeroExportGroup_Modal(obj, ivObj) { // Tab_General var cbEnabled = ml("input", {name: "enabled", type: "checkbox"}, null); @@ -1331,17 +1313,18 @@ e.checked = (obj.inverters[inv].enabled); } // - InverterId - getAjax("/api/inverter/list", parseZeroExportGroup_Modal_Iv); for (var inv = 0; inv < maxInv; inv++) { var e = document.getElementById("invId"+inv); -console.log(e); + selDelAllOpt(e); + e.appendChild(opt("-1", "---")); +// TODO: Verhindert die Funktion des selects egal ob -1 oder "-1" + for (var i = 0; i < ivObj.inverter.length; i++) { + e.appendChild(opt((ivObj.inverter[i].id), (ivObj.inverter[i].name))); + } //e.selectedIndex = (obj.inverters[inv].id); -console.log(e.length) for (var i = 0; i < (e.length); i++) { -console.log(i); if (e.options[i].value == obj.inverters[inv].id) { e.selectedIndex = i; -console.log(i); } } } @@ -1349,6 +1332,7 @@ console.log(i); for (var inv = 0; inv < maxInv; inv++) { var e = document.getElementById("invTarget"+inv); selDelAllOpt(e); + e.appendChild(opt("-1", "---")); e.appendChild(opt("0", "Sum")); e.appendChild(opt("1", "L1")); e.appendChild(opt("2", "L2")); @@ -1515,7 +1499,13 @@ console.log(i); ml("td", {style: "text-align: center;", }, String(obj.groups[group].id)), ml("td", {style: "text-align: left;", }, String(obj.groups[group].name)), ml("td", {style: "text-align: right;", id: "groupPowerTotal"+group}, "n/a"), - ml("td", {style: "text-align: center;", onclick: function() {ZeroExportGroup_Modal(obj.groups[group]);}}, svg(iconGear, 25, 25, "icon icon-fg pointer")), +// ml("td", {style: "text-align: center;", onclick: function() {ZeroExportGroup_Modal(obj.groups[group]);}}, svg(iconGear, 25, 25, "icon icon-fg pointer")), + ml("td", {style: "text-align: center;", onclick: function() { + function zeroGetIvList(ivObj) { + ZeroExportGroup_Modal(obj.groups[group], ivObj) + } + getAjax("/api/inverter/list", zeroGetIvList) + }}, svg(iconGear, 25, 25, "icon icon-fg pointer")), ml("td", {style: "text-align: center;", onclick: function() {ZeroExportGroup_Del(obj.groups[group]);}}, svg(iconDel, 25, 25, "icon icon-fg pointer")) ])); }