Merge pull request #492 from MichaelDvP/dev

some small fixes
This commit is contained in:
Proddy
2022-05-06 12:42:43 +02:00
committed by GitHub
5 changed files with 13 additions and 9 deletions

View File

@@ -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,

View File

@@ -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

View File

@@ -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_;

View File

@@ -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;

View File

@@ -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<String>());
request->send(200, "text/plain; charset=utf-8", data.as<String>());
api_count_++;
return;
}