From f2a6b861aae7206cb1dd2776689514116f8adb2c Mon Sep 17 00:00:00 2001 From: proddy Date: Fri, 26 Apr 2024 20:30:02 +0200 Subject: [PATCH] upload progress changes --- interface/package.json | 4 +- .../src/components/upload/SingleUpload.tsx | 18 ++++----- .../src/project/CustomEntitiesDialog.tsx | 38 ++++++++++++++----- interface/yarn.lock | 20 +++++----- src/command.cpp | 4 +- src/devices/boiler.cpp | 2 +- src/mqtt.cpp | 4 +- src/web/WebAPIService.cpp | 4 +- src/web/WebSchedulerService.cpp | 2 +- 9 files changed, 55 insertions(+), 41 deletions(-) diff --git a/interface/package.json b/interface/package.json index 50ea589a7..e1fc24a10 100644 --- a/interface/package.json +++ b/interface/package.json @@ -22,7 +22,7 @@ "lint": "eslint . --fix" }, "dependencies": { - "@alova/adapter-xhr": "^1.0.3", + "@alova/adapter-xhr": "^1.0.6", "@alova/scene-react": "^1.5.0", "@babel/core": "^7.24.4", "@emotion/react": "^11.11.4", @@ -35,7 +35,7 @@ "@types/react": "^18.3.0", "@types/react-dom": "^18.3.0", "@types/react-router-dom": "^5.3.3", - "alova": "^2.20.2", + "alova": "^2.20.3", "async-validator": "^4.2.5", "history": "^5.3.0", "jwt-decode": "^4.0.0", diff --git a/interface/src/components/upload/SingleUpload.tsx b/interface/src/components/upload/SingleUpload.tsx index 357b93aa8..9305fe2d1 100644 --- a/interface/src/components/upload/SingleUpload.tsx +++ b/interface/src/components/upload/SingleUpload.tsx @@ -55,18 +55,14 @@ const SingleUpload: FC = ({ const { LL } = useI18nContext(); const progressText = () => { + console.log(progress); if (uploading) { - if (progress.total && progress.loaded) { - return progress.loaded <= progress.total - ? LL.UPLOADING() + - ': ' + - Math.round((progress.loaded * 100) / progress.total) + - '%' - : LL.UPLOADING() + - ': ' + - Math.round((progress.total * 100) / progress.loaded) + - '%'; - } + return ( + LL.UPLOADING() + + ': ' + + Math.round((progress.loaded * 100) / progress.total) + + '%' + ); } return LL.UPLOAD_DROP_TEXT(); }; diff --git a/interface/src/project/CustomEntitiesDialog.tsx b/interface/src/project/CustomEntitiesDialog.tsx index b56645509..14e1292aa 100644 --- a/interface/src/project/CustomEntitiesDialog.tsx +++ b/interface/src/project/CustomEntitiesDialog.tsx @@ -26,7 +26,7 @@ import { useI18nContext } from 'i18n/i18n-react'; import { numberValue, updateValue } from 'utils'; import { validate } from 'validators'; -import { DeviceValueType, DeviceValueUOM_s, DeviceValueTypeNames } from './types'; +import { DeviceValueType, DeviceValueTypeNames, DeviceValueUOM_s } from './types'; import type { EntityItem } from './types'; interface CustomEntitiesDialogProps { @@ -210,15 +210,33 @@ const CustomEntitiesDialog = ({ fullWidth select > - {DeviceValueTypeNames[DeviceValueType.BOOL]} - {DeviceValueTypeNames[DeviceValueType.INT8]} - {DeviceValueTypeNames[DeviceValueType.UINT8]} - {DeviceValueTypeNames[DeviceValueType.INT16]} - {DeviceValueTypeNames[DeviceValueType.UINT16]} - {DeviceValueTypeNames[DeviceValueType.UINT24]} - {DeviceValueTypeNames[DeviceValueType.TIME]} - {DeviceValueTypeNames[DeviceValueType.UINT32]} - {DeviceValueTypeNames[DeviceValueType.STRING]} + + {DeviceValueTypeNames[DeviceValueType.BOOL]} + + + {DeviceValueTypeNames[DeviceValueType.INT8]} + + + {DeviceValueTypeNames[DeviceValueType.UINT8]} + + + {DeviceValueTypeNames[DeviceValueType.INT16]} + + + {DeviceValueTypeNames[DeviceValueType.UINT16]} + + + {DeviceValueTypeNames[DeviceValueType.UINT24]} + + + {DeviceValueTypeNames[DeviceValueType.TIME]} + + + {DeviceValueTypeNames[DeviceValueType.UINT32]} + + + {DeviceValueTypeNames[DeviceValueType.STRING]} + diff --git a/interface/yarn.lock b/interface/yarn.lock index b0cc0999b..7da8885f0 100644 --- a/interface/yarn.lock +++ b/interface/yarn.lock @@ -12,10 +12,10 @@ __metadata: languageName: node linkType: hard -"@alova/adapter-xhr@npm:^1.0.3": - version: 1.0.3 - resolution: "@alova/adapter-xhr@npm:1.0.3" - checksum: 10/53923b0b7f833bbbda662ad28f29bb8226d2126ab7dcc57c9aa5486212cb02f0cfa19760d33ab63334688458138fc3c4713084c2f6a558c969d83efda7828601 +"@alova/adapter-xhr@npm:^1.0.6": + version: 1.0.6 + resolution: "@alova/adapter-xhr@npm:1.0.6" + checksum: 10/4d1c589e589d1972a6007e156026e93ed3d2b1373cc5667dfa46c4b50ee8fd6a489a71b56e2ef492445bb33816c55eeac0e10288edd3b4e0ab4e9976f1c57b54 languageName: node linkType: hard @@ -1775,7 +1775,7 @@ __metadata: version: 0.0.0-use.local resolution: "EMS-ESP@workspace:." dependencies: - "@alova/adapter-xhr": "npm:^1.0.3" + "@alova/adapter-xhr": "npm:^1.0.6" "@alova/scene-react": "npm:^1.5.0" "@babel/core": "npm:^7.24.4" "@emotion/react": "npm:^11.11.4" @@ -1792,7 +1792,7 @@ __metadata: "@types/react": "npm:^18.3.0" "@types/react-dom": "npm:^18.3.0" "@types/react-router-dom": "npm:^5.3.3" - alova: "npm:^2.20.2" + alova: "npm:^2.20.3" async-validator: "npm:^4.2.5" concurrently: "npm:^8.2.2" eslint: "npm:^9.1.1" @@ -1876,10 +1876,10 @@ __metadata: languageName: node linkType: hard -"alova@npm:^2.20.2": - version: 2.20.2 - resolution: "alova@npm:2.20.2" - checksum: 10/355350451828e9ce473ba1eafeb7a93dc3177cb768cb7734ecb7f42aeda1440ba19aecb22b6d896f4f314235e1c18c55267251fbb9f2c47f79ace5f11d947644 +"alova@npm:^2.20.3": + version: 2.20.3 + resolution: "alova@npm:2.20.3" + checksum: 10/2717765e445ed1dfc7ad0b9456c43e82bccce874103188d8a986335dda9dec22bc45c3a5551b16580ced7fb940e3904d8e507b0e30d3ad81703913e7f4c866ac languageName: node linkType: hard diff --git a/src/command.cpp b/src/command.cpp index 81e0518fc..5d2b163c9 100644 --- a/src/command.cpp +++ b/src/command.cpp @@ -370,9 +370,9 @@ uint8_t Command::call(const uint8_t device_type, const char * cmd, const char * // report back. If not OK show output from error, other return the HTTP code if (return_code != CommandRet::OK) { if ((value == nullptr) || (strlen(value) == 0)) { - LOG_ERROR("Command '%s' failed with code: %d", cmd, return_code); + LOG_ERROR("Command '%s' failed with error code %d", cmd, return_code); } else { - LOG_ERROR("Command '%s/%s' failed with code: %d", cmd, value, return_code); + LOG_ERROR("Command '%s/%s' failed with error code %d", cmd, value, return_code); } return message(return_code, "callback function failed", output); } diff --git a/src/devices/boiler.cpp b/src/devices/boiler.cpp index b0056f5f6..daa4320a3 100644 --- a/src/devices/boiler.cpp +++ b/src/devices/boiler.cpp @@ -1755,7 +1755,7 @@ void Boiler::process_UBAErrorMessage(std::shared_ptr telegram) { } // data: displaycode(2), errornumber(2), year, month, hour, day, minute, duration(2), src-addr static uint32_t lastCodeDate_ = 0; // last code date - char code[3] = {telegram->message_data[0], telegram->message_data[1], 0}; + uint8_t code[3] = {telegram->message_data[0], telegram->message_data[1], 0}; uint16_t codeNo = telegram->message_data[2] * 256 + telegram->message_data[3]; uint16_t year = (telegram->message_data[4] & 0x7F) + 2000; uint8_t month = telegram->message_data[5]; diff --git a/src/mqtt.cpp b/src/mqtt.cpp index 4a93e654a..b5293cc15 100644 --- a/src/mqtt.cpp +++ b/src/mqtt.cpp @@ -287,11 +287,11 @@ void Mqtt::on_message(const char * topic, const uint8_t * payload, size_t len) { if (output.size()) { snprintf(error, sizeof(error), - "MQTT command failed with error: %s (%s)", + "MQTT command failed with error %s (%s)", (const char *)output["message"], Command::return_code_string(return_code).c_str()); } else { - snprintf(error, sizeof(error), "MQTT command failed with error code (%s)", Command::return_code_string(return_code).c_str()); + snprintf(error, sizeof(error), "MQTT command failed with error %s", Command::return_code_string(return_code).c_str()); } LOG_ERROR(error); Mqtt::queue_publish("response", error); diff --git a/src/web/WebAPIService.cpp b/src/web/WebAPIService.cpp index 2c9585537..3a242d01e 100644 --- a/src/web/WebAPIService.cpp +++ b/src/web/WebAPIService.cpp @@ -128,9 +128,9 @@ void WebAPIService::parse(AsyncWebServerRequest * request, JsonObject input) { if (return_code != CommandRet::OK) { char error[100]; if (output.size()) { - snprintf(error, sizeof(error), "API failed with error: %s (%s)", (const char *)output["message"], Command::return_code_string(return_code).c_str()); + snprintf(error, sizeof(error), "API failed with error %s (%s)", (const char *)output["message"], Command::return_code_string(return_code).c_str()); } else { - snprintf(error, sizeof(error), "API failed with error code (%s)", Command::return_code_string(return_code).c_str()); + snprintf(error, sizeof(error), "API failed with error %s", Command::return_code_string(return_code).c_str()); } emsesp::EMSESP::logger().err(error); api_fails_++; diff --git a/src/web/WebSchedulerService.cpp b/src/web/WebSchedulerService.cpp index a1a8bec2a..2116d7eb8 100644 --- a/src/web/WebSchedulerService.cpp +++ b/src/web/WebSchedulerService.cpp @@ -363,7 +363,7 @@ bool WebSchedulerService::command(const char * cmd, const char * data) { (const char *)output["message"], Command::return_code_string(return_code).c_str()); } else { - snprintf(error, sizeof(error), "Scheduled command %s failed with error code (%s)", cmd, Command::return_code_string(return_code).c_str()); + snprintf(error, sizeof(error), "Scheduled command %s failed with error %s", cmd, Command::return_code_string(return_code).c_str()); } emsesp::EMSESP::logger().warning(error);