From 388cd8976c67e51e8fd928cd17ecc4c91bd461f4 Mon Sep 17 00:00:00 2001 From: lumapu Date: Thu, 18 Apr 2024 00:50:31 +0200 Subject: [PATCH] 0.8.111 * merge PR: Disable upload and import buttons when no file is selected #1586 #1519 --- src/CHANGES.md | 1 + src/hm/hmInverter.h | 38 +++++++++++++++++++++----------------- src/hm/hmSystem.h | 1 + src/web/Protection.h | 2 +- src/web/html/setup.html | 10 +++------- src/web/html/update.html | 11 +++-------- 6 files changed, 30 insertions(+), 33 deletions(-) diff --git a/src/CHANGES.md b/src/CHANGES.md index 77a03b4a..135fe0fc 100644 --- a/src/CHANGES.md +++ b/src/CHANGES.md @@ -4,6 +4,7 @@ * fix MqTT discovery field `ALARM_MES_ID` #1591 * fix Wifi reconnect for ESP32 #1589 #1575 * open link from `index.html` in new tab #1588 #1587 +* merge PR: Disable upload and import buttons when no file is selected #1586 #1519 ## 0.8.110 - 2024-04-11 * revert CMT2300A changes #1553 diff --git a/src/hm/hmInverter.h b/src/hm/hmInverter.h index 9053c19f..9ac1cacf 100644 --- a/src/hm/hmInverter.h +++ b/src/hm/hmInverter.h @@ -33,28 +33,28 @@ // prototypes template -static T calcYieldTotalCh0(Inverter<> *iv, uint8_t arg0); +T calcYieldTotalCh0(Inverter<> *iv, uint8_t arg0); template -static T calcYieldDayCh0(Inverter<> *iv, uint8_t arg0); +T calcYieldDayCh0(Inverter<> *iv, uint8_t arg0); template -static T calcUdcCh(Inverter<> *iv, uint8_t arg0); +T calcUdcCh(Inverter<> *iv, uint8_t arg0); template -static T calcPowerDcCh0(Inverter<> *iv, uint8_t arg0); +T calcPowerDcCh0(Inverter<> *iv, uint8_t arg0); template -static T calcEffiencyCh0(Inverter<> *iv, uint8_t arg0); +T calcEffiencyCh0(Inverter<> *iv, uint8_t arg0); template -static T calcIrradiation(Inverter<> *iv, uint8_t arg0); +T calcIrradiation(Inverter<> *iv, uint8_t arg0); template -static T calcMaxPowerAcCh0(Inverter<> *iv, uint8_t arg0); +T calcMaxPowerAcCh0(Inverter<> *iv, uint8_t arg0); template -static T calcMaxPowerDc(Inverter<> *iv, uint8_t arg0); +T calcMaxPowerDc(Inverter<> *iv, uint8_t arg0); template using func_t = T (Inverter<> *, uint8_t); @@ -270,7 +270,8 @@ class Inverter { if(InverterStatus::OFF != status) { mDevControlRequest = true; devControlCmd = cmd; - //app->triggerTickSend(); // done in RestApi.h, because of "chicken-and-egg problem ;-)" + //assert(App); + //App->triggerTickSend(0); } return (InverterStatus::OFF != status); } @@ -818,6 +819,7 @@ class Inverter { public: static uint32_t *timestamp; // system timestamp static cfgInst_t *generalConfig; // general inverter configuration from setup + static IApp *App; uint16_t mDtuRxCnt = 0; uint16_t mDtuTxCnt = 0; @@ -838,6 +840,8 @@ template uint32_t *Inverter::timestamp {0}; template cfgInst_t *Inverter::generalConfig {0}; +template +IApp *Inverter::App {nullptr}; /** @@ -847,7 +851,7 @@ cfgInst_t *Inverter::generalConfig {0}; */ template -static T calcYieldTotalCh0(Inverter<> *iv, uint8_t arg0) { +T calcYieldTotalCh0(Inverter<> *iv, uint8_t arg0) { DPRINTLN(DBG_VERBOSE, F("hmInverter.h:calcYieldTotalCh0")); if(NULL != iv) { record_t<> *rec = iv->getRecordStruct(RealTimeRunData_Debug); @@ -861,7 +865,7 @@ static T calcYieldTotalCh0(Inverter<> *iv, uint8_t arg0) { } template -static T calcYieldDayCh0(Inverter<> *iv, uint8_t arg0) { +T calcYieldDayCh0(Inverter<> *iv, uint8_t arg0) { DPRINTLN(DBG_VERBOSE, F("hmInverter.h:calcYieldDayCh0")); if(NULL != iv) { record_t<> *rec = iv->getRecordStruct(RealTimeRunData_Debug); @@ -875,7 +879,7 @@ static T calcYieldDayCh0(Inverter<> *iv, uint8_t arg0) { } template -static T calcUdcCh(Inverter<> *iv, uint8_t arg0) { +T calcUdcCh(Inverter<> *iv, uint8_t arg0) { DPRINTLN(DBG_VERBOSE, F("hmInverter.h:calcUdcCh")); // arg0 = channel of source record_t<> *rec = iv->getRecordStruct(RealTimeRunData_Debug); @@ -889,7 +893,7 @@ static T calcUdcCh(Inverter<> *iv, uint8_t arg0) { } template -static T calcPowerDcCh0(Inverter<> *iv, uint8_t arg0) { +T calcPowerDcCh0(Inverter<> *iv, uint8_t arg0) { DPRINTLN(DBG_VERBOSE, F("hmInverter.h:calcPowerDcCh0")); if(NULL != iv) { record_t<> *rec = iv->getRecordStruct(RealTimeRunData_Debug); @@ -903,7 +907,7 @@ static T calcPowerDcCh0(Inverter<> *iv, uint8_t arg0) { } template -static T calcEffiencyCh0(Inverter<> *iv, uint8_t arg0) { +T calcEffiencyCh0(Inverter<> *iv, uint8_t arg0) { DPRINTLN(DBG_VERBOSE, F("hmInverter.h:calcEfficiencyCh0")); if(NULL != iv) { record_t<> *rec = iv->getRecordStruct(RealTimeRunData_Debug); @@ -919,7 +923,7 @@ static T calcEffiencyCh0(Inverter<> *iv, uint8_t arg0) { } template -static T calcIrradiation(Inverter<> *iv, uint8_t arg0) { +T calcIrradiation(Inverter<> *iv, uint8_t arg0) { DPRINTLN(DBG_VERBOSE, F("hmInverter.h:calcIrradiation")); // arg0 = channel if(NULL != iv) { @@ -931,7 +935,7 @@ static T calcIrradiation(Inverter<> *iv, uint8_t arg0) { } template -static T calcMaxPowerAcCh0(Inverter<> *iv, uint8_t arg0) { +T calcMaxPowerAcCh0(Inverter<> *iv, uint8_t arg0) { DPRINTLN(DBG_VERBOSE, F("hmInverter.h:calcMaxPowerAcCh0")); T acMaxPower = 0.0; if(NULL != iv) { @@ -952,7 +956,7 @@ static T calcMaxPowerAcCh0(Inverter<> *iv, uint8_t arg0) { } template -static T calcMaxPowerDc(Inverter<> *iv, uint8_t arg0) { +T calcMaxPowerDc(Inverter<> *iv, uint8_t arg0) { DPRINTLN(DBG_VERBOSE, F("hmInverter.h:calcMaxPowerDc")); // arg0 = channel T dcMaxPower = 0.0; diff --git a/src/hm/hmSystem.h b/src/hm/hmSystem.h index 3b43b9f0..28c7905a 100644 --- a/src/hm/hmSystem.h +++ b/src/hm/hmSystem.h @@ -18,6 +18,7 @@ class HmSystem { void setup(uint32_t *timestamp, cfgInst_t *config, IApp *app) { INVERTERTYPE::timestamp = timestamp; INVERTERTYPE::generalConfig = config; + INVERTERTYPE::App = app; //mInverter[0].app = app; } diff --git a/src/web/Protection.h b/src/web/Protection.h index 74f04b52..e41249ac 100644 --- a/src/web/Protection.h +++ b/src/web/Protection.h @@ -24,7 +24,7 @@ class Protection { } public: - Protection(Protection &other) = delete; + Protection(const Protection &other) = delete; void operator=(const Protection &) = delete; static Protection* getInstance(const char *pwd) { diff --git a/src/web/html/setup.html b/src/web/html/setup.html index a7e4d983..adb9477a 100644 --- a/src/web/html/setup.html +++ b/src/web/html/setup.html @@ -612,23 +612,19 @@ var obj = {cmd: "discovery_cfg", token: "*"} getAjax("/api/setup", apiCbMqtt, "POST", JSON.stringify(obj)); } - // Wait for the DOM to be fully loaded + document.addEventListener('DOMContentLoaded', () => { - // Get references to the file input and button elements const fileInput = document.querySelector('#importFileInput'); const button = document.querySelector('#importButton'); - // Initially disable the button button.disabled = true; button.title = "Please select a file first"; - // Listen for changes on the file input fileInput.addEventListener('change', () => { - // Enable or disable the button based on whether a file is selected if (fileInput.value) { button.disabled = false; - button.title = ""; // Clear the tooltip when a file is selected + button.title = ""; } else { button.disabled = true; - button.title = "Please select a file first"; // Show the tooltip when no file is selected + button.title = "Please select a file first"; } }); }); diff --git a/src/web/html/update.html b/src/web/html/update.html index a72c6536..d73be7e0 100644 --- a/src/web/html/update.html +++ b/src/web/html/update.html @@ -23,23 +23,18 @@ {#HTML_FOOTER}