From 39d9eec890346a5837834bf980fbf875a4f348c1 Mon Sep 17 00:00:00 2001 From: MichaelDvP Date: Fri, 6 May 2022 07:58:22 +0200 Subject: [PATCH 1/4] mdns in lib_standanlone --- lib_standalone/ESP8266React.h | 1 + 1 file changed, 1 insertion(+) diff --git a/lib_standalone/ESP8266React.h b/lib_standalone/ESP8266React.h index 2b1bd5039..d8c9a52d0 100644 --- a/lib_standalone/ESP8266React.h +++ b/lib_standalone/ESP8266React.h @@ -93,6 +93,7 @@ class DummySettings { String dnsIP1 = ""; String dnsIP2 = ""; bool enableIPv6 = false; + bool enableMDNS = true; uint8_t phy_type = 0; uint8_t eth_power = 0; // 0 means -1 From 90aa385326fa82b10bf6a6823ca79a188be3a7a2 Mon Sep 17 00:00:00 2001 From: MichaelDvP Date: Fri, 6 May 2022 07:59:07 +0200 Subject: [PATCH 2/4] shower-times in system/settings --- src/shower.h | 3 +++ src/system.cpp | 4 ++-- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/src/shower.h b/src/shower.h index 809a18031..b4fb29f7c 100644 --- a/src/shower.h +++ b/src/shower.h @@ -30,6 +30,8 @@ class Shower { void set_shower_state(bool state, bool force = false); + /* unused header + * bool shower_alert() const { return shower_alert_; } @@ -45,6 +47,7 @@ class Shower { void shower_timer(const bool shower_timer) { shower_timer_ = shower_timer; } + */ private: static uuid::log::Logger logger_; diff --git a/src/system.cpp b/src/system.cpp index f0f03fad3..f63159737 100644 --- a/src/system.cpp +++ b/src/system.cpp @@ -1000,8 +1000,8 @@ bool System::command_settings(const char * value, const int8_t id, JsonObject & node["shower_timer"] = settings.shower_timer; node["shower_alert"] = settings.shower_alert; if (settings.shower_alert) { - node["shower_alert_coldshot"] = settings.shower_alert_coldshot / 1000; // seconds - node["shower_alert_trigger"] = settings.shower_alert_trigger / 60000; // minutes + node["shower_alert_coldshot"] = settings.shower_alert_coldshot; // seconds + node["shower_alert_trigger"] = settings.shower_alert_trigger; // minutes } node["rx_gpio"] = settings.rx_gpio; From b2429e3cff65bdcabcdbcbd34d7ba046adc95f97 Mon Sep 17 00:00:00 2001 From: MichaelDvP Date: Fri, 6 May 2022 07:59:48 +0200 Subject: [PATCH 3/4] charset for plain text output --- src/web/WebAPIService.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/web/WebAPIService.cpp b/src/web/WebAPIService.cpp index be8966a1e..c79e04ca5 100644 --- a/src/web/WebAPIService.cpp +++ b/src/web/WebAPIService.cpp @@ -124,7 +124,7 @@ void WebAPIService::parse(AsyncWebServerRequest * request, JsonObject & input) { // https://github.com/emsesp/EMS-ESP32/issues/462#issuecomment-1093877210 if (output.containsKey("api_data")) { JsonVariant data = output["api_data"]; - request->send(200, "text/plain", data.as()); + request->send(200, "text/plain; charset=utf-8", data.as()); api_count_++; return; } From 1a5b0125456fed561ead0462106222f79acb9680 Mon Sep 17 00:00:00 2001 From: MichaelDvP Date: Fri, 6 May 2022 12:15:25 +0200 Subject: [PATCH 4/4] csv utf-8 with semicolon and Intl.Number format --- interface/src/project/DashboardData.tsx | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/interface/src/project/DashboardData.tsx b/interface/src/project/DashboardData.tsx index 827120708..5b4bd827d 100644 --- a/interface/src/project/DashboardData.tsx +++ b/interface/src/project/DashboardData.tsx @@ -355,7 +355,7 @@ const DashboardData: FC = () => { if (sc === '' || sc === '""') { return sc; } - if (sc.includes('"') || sc.includes(',') || sc.includes('\n') || sc.includes('\r')) { + if (sc.includes('"') || sc.includes(';') || sc.includes('\n') || sc.includes('\r')) { return '"' + sc.replace(/"/g, '""') + '"'; } return sc; @@ -363,13 +363,13 @@ const DashboardData: FC = () => { const makeCsvData = (columns: any, data: any) => { return data.reduce((csvString: any, rowItem: any) => { - return csvString + columns.map(({ accessor }: any) => escapeCsvCell(accessor(rowItem))).join(',') + '\r\n'; - }, columns.map(({ name }: any) => escapeCsvCell(name)).join(',') + '\r\n'); + return csvString + columns.map(({ accessor }: any) => escapeCsvCell(accessor(rowItem))).join(';') + '\r\n'; + }, columns.map(({ name }: any) => escapeCsvCell(name)).join(';') + '\r\n'); }; const downloadAsCsv = (columns: any, data: any, filename: string) => { const csvData = makeCsvData(columns, data); - const csvFile = new Blob([csvData], { type: 'text/csv' }); + const csvFile = new Blob([csvData], { type: 'text/csv;charset:utf-8' }); const downloadLink = document.createElement('a'); downloadLink.download = filename; @@ -384,8 +384,8 @@ const DashboardData: FC = () => { const handleDownloadCsv = () => { const columns = [ { accessor: (dv: any) => dv.id.slice(2), name: 'Entity' }, - { accessor: (dv: any) => dv.v, name: 'Value' }, - { accessor: (dv: any) => (dv.u >= 1 && dv.u <= 2 ? 'C' : DeviceValueUOM_s[dv.u]), name: 'UoM' } + { accessor: (dv: any) => (typeof dv.v === 'number') ? new Intl.NumberFormat().format(dv.v) : dv.v, name: 'Value' }, + { accessor: (dv: any) => DeviceValueUOM_s[dv.u], name: 'UoM' } ]; downloadAsCsv( columns,