upload progress changes

This commit is contained in:
proddy
2024-04-26 20:30:02 +02:00
parent 611f37bf2c
commit f2a6b861aa
9 changed files with 55 additions and 41 deletions

View File

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

View File

@@ -55,18 +55,14 @@ const SingleUpload: FC<SingleUploadProps> = ({
const { LL } = useI18nContext();
const progressText = () => {
console.log(progress);
if (uploading) {
if (progress.total && progress.loaded) {
return progress.loaded <= progress.total
? LL.UPLOADING() +
return (
LL.UPLOADING() +
': ' +
Math.round((progress.loaded * 100) / progress.total) +
'%'
: LL.UPLOADING() +
': ' +
Math.round((progress.total * 100) / progress.loaded) +
'%';
}
);
}
return LL.UPLOAD_DROP_TEXT();
};

View File

@@ -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
>
<MenuItem value={DeviceValueType.BOOL}>{DeviceValueTypeNames[DeviceValueType.BOOL]}</MenuItem>
<MenuItem value={DeviceValueType.INT8}>{DeviceValueTypeNames[DeviceValueType.INT8]}</MenuItem>
<MenuItem value={DeviceValueType.UINT8}>{DeviceValueTypeNames[DeviceValueType.UINT8]}</MenuItem>
<MenuItem value={DeviceValueType.INT16}>{DeviceValueTypeNames[DeviceValueType.INT16]}</MenuItem>
<MenuItem value={DeviceValueType.UINT16}>{DeviceValueTypeNames[DeviceValueType.UINT16]}</MenuItem>
<MenuItem value={DeviceValueType.UINT24}>{DeviceValueTypeNames[DeviceValueType.UINT24]}</MenuItem>
<MenuItem value={DeviceValueType.TIME}>{DeviceValueTypeNames[DeviceValueType.TIME]}</MenuItem>
<MenuItem value={DeviceValueType.UINT32}>{DeviceValueTypeNames[DeviceValueType.UINT32]}</MenuItem>
<MenuItem value={DeviceValueType.STRING}>{DeviceValueTypeNames[DeviceValueType.STRING]}</MenuItem>
<MenuItem value={DeviceValueType.BOOL}>
{DeviceValueTypeNames[DeviceValueType.BOOL]}
</MenuItem>
<MenuItem value={DeviceValueType.INT8}>
{DeviceValueTypeNames[DeviceValueType.INT8]}
</MenuItem>
<MenuItem value={DeviceValueType.UINT8}>
{DeviceValueTypeNames[DeviceValueType.UINT8]}
</MenuItem>
<MenuItem value={DeviceValueType.INT16}>
{DeviceValueTypeNames[DeviceValueType.INT16]}
</MenuItem>
<MenuItem value={DeviceValueType.UINT16}>
{DeviceValueTypeNames[DeviceValueType.UINT16]}
</MenuItem>
<MenuItem value={DeviceValueType.UINT24}>
{DeviceValueTypeNames[DeviceValueType.UINT24]}
</MenuItem>
<MenuItem value={DeviceValueType.TIME}>
{DeviceValueTypeNames[DeviceValueType.TIME]}
</MenuItem>
<MenuItem value={DeviceValueType.UINT32}>
{DeviceValueTypeNames[DeviceValueType.UINT32]}
</MenuItem>
<MenuItem value={DeviceValueType.STRING}>
{DeviceValueTypeNames[DeviceValueType.STRING]}
</MenuItem>
</TextField>
</Grid>

View File

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

View File

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

View File

@@ -1755,7 +1755,7 @@ void Boiler::process_UBAErrorMessage(std::shared_ptr<const Telegram> 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];

View File

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

View File

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

View File

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