Browse Source

0.8.111

* merge PR: Disable upload and import buttons when no file is selected #1586 #1519
pull/1541/head
lumapu 9 months ago
parent
commit
388cd8976c
  1. 1
      src/CHANGES.md
  2. 38
      src/hm/hmInverter.h
  3. 1
      src/hm/hmSystem.h
  4. 2
      src/web/Protection.h
  5. 10
      src/web/html/setup.html
  6. 11
      src/web/html/update.html

1
src/CHANGES.md

@ -4,6 +4,7 @@
* fix MqTT discovery field `ALARM_MES_ID` #1591 * fix MqTT discovery field `ALARM_MES_ID` #1591
* fix Wifi reconnect for ESP32 #1589 #1575 * fix Wifi reconnect for ESP32 #1589 #1575
* open link from `index.html` in new tab #1588 #1587 * 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 ## 0.8.110 - 2024-04-11
* revert CMT2300A changes #1553 * revert CMT2300A changes #1553

38
src/hm/hmInverter.h

@ -33,28 +33,28 @@
// prototypes // prototypes
template<class T=float> template<class T=float>
static T calcYieldTotalCh0(Inverter<> *iv, uint8_t arg0); T calcYieldTotalCh0(Inverter<> *iv, uint8_t arg0);
template<class T=float> template<class T=float>
static T calcYieldDayCh0(Inverter<> *iv, uint8_t arg0); T calcYieldDayCh0(Inverter<> *iv, uint8_t arg0);
template<class T=float> template<class T=float>
static T calcUdcCh(Inverter<> *iv, uint8_t arg0); T calcUdcCh(Inverter<> *iv, uint8_t arg0);
template<class T=float> template<class T=float>
static T calcPowerDcCh0(Inverter<> *iv, uint8_t arg0); T calcPowerDcCh0(Inverter<> *iv, uint8_t arg0);
template<class T=float> template<class T=float>
static T calcEffiencyCh0(Inverter<> *iv, uint8_t arg0); T calcEffiencyCh0(Inverter<> *iv, uint8_t arg0);
template<class T=float> template<class T=float>
static T calcIrradiation(Inverter<> *iv, uint8_t arg0); T calcIrradiation(Inverter<> *iv, uint8_t arg0);
template<class T=float> template<class T=float>
static T calcMaxPowerAcCh0(Inverter<> *iv, uint8_t arg0); T calcMaxPowerAcCh0(Inverter<> *iv, uint8_t arg0);
template<class T=float> template<class T=float>
static T calcMaxPowerDc(Inverter<> *iv, uint8_t arg0); T calcMaxPowerDc(Inverter<> *iv, uint8_t arg0);
template<class T=float> template<class T=float>
using func_t = T (Inverter<> *, uint8_t); using func_t = T (Inverter<> *, uint8_t);
@ -270,7 +270,8 @@ class Inverter {
if(InverterStatus::OFF != status) { if(InverterStatus::OFF != status) {
mDevControlRequest = true; mDevControlRequest = true;
devControlCmd = cmd; devControlCmd = cmd;
//app->triggerTickSend(); // done in RestApi.h, because of "chicken-and-egg problem ;-)" //assert(App);
//App->triggerTickSend(0);
} }
return (InverterStatus::OFF != status); return (InverterStatus::OFF != status);
} }
@ -818,6 +819,7 @@ class Inverter {
public: public:
static uint32_t *timestamp; // system timestamp static uint32_t *timestamp; // system timestamp
static cfgInst_t *generalConfig; // general inverter configuration from setup static cfgInst_t *generalConfig; // general inverter configuration from setup
static IApp *App;
uint16_t mDtuRxCnt = 0; uint16_t mDtuRxCnt = 0;
uint16_t mDtuTxCnt = 0; uint16_t mDtuTxCnt = 0;
@ -838,6 +840,8 @@ template <class REC_TYP>
uint32_t *Inverter<REC_TYP>::timestamp {0}; uint32_t *Inverter<REC_TYP>::timestamp {0};
template <class REC_TYP> template <class REC_TYP>
cfgInst_t *Inverter<REC_TYP>::generalConfig {0}; cfgInst_t *Inverter<REC_TYP>::generalConfig {0};
template <class REC_TYP>
IApp *Inverter<REC_TYP>::App {nullptr};
/** /**
@ -847,7 +851,7 @@ cfgInst_t *Inverter<REC_TYP>::generalConfig {0};
*/ */
template<class T=float> template<class T=float>
static T calcYieldTotalCh0(Inverter<> *iv, uint8_t arg0) { T calcYieldTotalCh0(Inverter<> *iv, uint8_t arg0) {
DPRINTLN(DBG_VERBOSE, F("hmInverter.h:calcYieldTotalCh0")); DPRINTLN(DBG_VERBOSE, F("hmInverter.h:calcYieldTotalCh0"));
if(NULL != iv) { if(NULL != iv) {
record_t<> *rec = iv->getRecordStruct(RealTimeRunData_Debug); record_t<> *rec = iv->getRecordStruct(RealTimeRunData_Debug);
@ -861,7 +865,7 @@ static T calcYieldTotalCh0(Inverter<> *iv, uint8_t arg0) {
} }
template<class T=float> template<class T=float>
static T calcYieldDayCh0(Inverter<> *iv, uint8_t arg0) { T calcYieldDayCh0(Inverter<> *iv, uint8_t arg0) {
DPRINTLN(DBG_VERBOSE, F("hmInverter.h:calcYieldDayCh0")); DPRINTLN(DBG_VERBOSE, F("hmInverter.h:calcYieldDayCh0"));
if(NULL != iv) { if(NULL != iv) {
record_t<> *rec = iv->getRecordStruct(RealTimeRunData_Debug); record_t<> *rec = iv->getRecordStruct(RealTimeRunData_Debug);
@ -875,7 +879,7 @@ static T calcYieldDayCh0(Inverter<> *iv, uint8_t arg0) {
} }
template<class T=float> template<class T=float>
static T calcUdcCh(Inverter<> *iv, uint8_t arg0) { T calcUdcCh(Inverter<> *iv, uint8_t arg0) {
DPRINTLN(DBG_VERBOSE, F("hmInverter.h:calcUdcCh")); DPRINTLN(DBG_VERBOSE, F("hmInverter.h:calcUdcCh"));
// arg0 = channel of source // arg0 = channel of source
record_t<> *rec = iv->getRecordStruct(RealTimeRunData_Debug); record_t<> *rec = iv->getRecordStruct(RealTimeRunData_Debug);
@ -889,7 +893,7 @@ static T calcUdcCh(Inverter<> *iv, uint8_t arg0) {
} }
template<class T=float> template<class T=float>
static T calcPowerDcCh0(Inverter<> *iv, uint8_t arg0) { T calcPowerDcCh0(Inverter<> *iv, uint8_t arg0) {
DPRINTLN(DBG_VERBOSE, F("hmInverter.h:calcPowerDcCh0")); DPRINTLN(DBG_VERBOSE, F("hmInverter.h:calcPowerDcCh0"));
if(NULL != iv) { if(NULL != iv) {
record_t<> *rec = iv->getRecordStruct(RealTimeRunData_Debug); record_t<> *rec = iv->getRecordStruct(RealTimeRunData_Debug);
@ -903,7 +907,7 @@ static T calcPowerDcCh0(Inverter<> *iv, uint8_t arg0) {
} }
template<class T=float> template<class T=float>
static T calcEffiencyCh0(Inverter<> *iv, uint8_t arg0) { T calcEffiencyCh0(Inverter<> *iv, uint8_t arg0) {
DPRINTLN(DBG_VERBOSE, F("hmInverter.h:calcEfficiencyCh0")); DPRINTLN(DBG_VERBOSE, F("hmInverter.h:calcEfficiencyCh0"));
if(NULL != iv) { if(NULL != iv) {
record_t<> *rec = iv->getRecordStruct(RealTimeRunData_Debug); record_t<> *rec = iv->getRecordStruct(RealTimeRunData_Debug);
@ -919,7 +923,7 @@ static T calcEffiencyCh0(Inverter<> *iv, uint8_t arg0) {
} }
template<class T=float> template<class T=float>
static T calcIrradiation(Inverter<> *iv, uint8_t arg0) { T calcIrradiation(Inverter<> *iv, uint8_t arg0) {
DPRINTLN(DBG_VERBOSE, F("hmInverter.h:calcIrradiation")); DPRINTLN(DBG_VERBOSE, F("hmInverter.h:calcIrradiation"));
// arg0 = channel // arg0 = channel
if(NULL != iv) { if(NULL != iv) {
@ -931,7 +935,7 @@ static T calcIrradiation(Inverter<> *iv, uint8_t arg0) {
} }
template<class T=float> template<class T=float>
static T calcMaxPowerAcCh0(Inverter<> *iv, uint8_t arg0) { T calcMaxPowerAcCh0(Inverter<> *iv, uint8_t arg0) {
DPRINTLN(DBG_VERBOSE, F("hmInverter.h:calcMaxPowerAcCh0")); DPRINTLN(DBG_VERBOSE, F("hmInverter.h:calcMaxPowerAcCh0"));
T acMaxPower = 0.0; T acMaxPower = 0.0;
if(NULL != iv) { if(NULL != iv) {
@ -952,7 +956,7 @@ static T calcMaxPowerAcCh0(Inverter<> *iv, uint8_t arg0) {
} }
template<class T=float> template<class T=float>
static T calcMaxPowerDc(Inverter<> *iv, uint8_t arg0) { T calcMaxPowerDc(Inverter<> *iv, uint8_t arg0) {
DPRINTLN(DBG_VERBOSE, F("hmInverter.h:calcMaxPowerDc")); DPRINTLN(DBG_VERBOSE, F("hmInverter.h:calcMaxPowerDc"));
// arg0 = channel // arg0 = channel
T dcMaxPower = 0.0; T dcMaxPower = 0.0;

1
src/hm/hmSystem.h

@ -18,6 +18,7 @@ class HmSystem {
void setup(uint32_t *timestamp, cfgInst_t *config, IApp *app) { void setup(uint32_t *timestamp, cfgInst_t *config, IApp *app) {
INVERTERTYPE::timestamp = timestamp; INVERTERTYPE::timestamp = timestamp;
INVERTERTYPE::generalConfig = config; INVERTERTYPE::generalConfig = config;
INVERTERTYPE::App = app;
//mInverter[0].app = app; //mInverter[0].app = app;
} }

2
src/web/Protection.h

@ -24,7 +24,7 @@ class Protection {
} }
public: public:
Protection(Protection &other) = delete; Protection(const Protection &other) = delete;
void operator=(const Protection &) = delete; void operator=(const Protection &) = delete;
static Protection* getInstance(const char *pwd) { static Protection* getInstance(const char *pwd) {

10
src/web/html/setup.html

@ -612,23 +612,19 @@
var obj = {cmd: "discovery_cfg", token: "*"} var obj = {cmd: "discovery_cfg", token: "*"}
getAjax("/api/setup", apiCbMqtt, "POST", JSON.stringify(obj)); getAjax("/api/setup", apiCbMqtt, "POST", JSON.stringify(obj));
} }
// Wait for the DOM to be fully loaded
document.addEventListener('DOMContentLoaded', () => { document.addEventListener('DOMContentLoaded', () => {
// Get references to the file input and button elements
const fileInput = document.querySelector('#importFileInput'); const fileInput = document.querySelector('#importFileInput');
const button = document.querySelector('#importButton'); const button = document.querySelector('#importButton');
// Initially disable the button
button.disabled = true; button.disabled = true;
button.title = "Please select a file first"; button.title = "Please select a file first";
// Listen for changes on the file input
fileInput.addEventListener('change', () => { fileInput.addEventListener('change', () => {
// Enable or disable the button based on whether a file is selected
if (fileInput.value) { if (fileInput.value) {
button.disabled = false; button.disabled = false;
button.title = ""; // Clear the tooltip when a file is selected button.title = "";
} else { } else {
button.disabled = true; 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";
} }
}); });
}); });

11
src/web/html/update.html

@ -23,23 +23,18 @@
</div> </div>
{#HTML_FOOTER} {#HTML_FOOTER}
<script type="text/javascript"> <script type="text/javascript">
// Wait for the DOM to be fully loaded
document.addEventListener('DOMContentLoaded', () => { document.addEventListener('DOMContentLoaded', () => {
// Get references to the file input and button elements
const fileInput = document.querySelector('#uploadFileInput'); const fileInput = document.querySelector('#uploadFileInput');
const button = document.querySelector('#uploadButton'); const button = document.querySelector('#uploadButton');
// Initially disable the button
button.disabled = true; 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";
// Listen for changes on the file input
fileInput.addEventListener('change', () => { fileInput.addEventListener('change', () => {
// Enable or disable the button based on whether a file is selected
if (fileInput.value) { if (fileInput.value) {
button.disabled = false; button.disabled = false;
button.title = ""; // Clear the tooltip when a file is selected button.title = "";
} else { } else {
button.disabled = true; 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";
} }
}); });
}); });

Loading…
Cancel
Save