From 6b02187f1034f9e982c154651fdca48c80324fc7 Mon Sep 17 00:00:00 2001 From: klakhov Date: Mon, 10 Jan 2022 12:38:18 +0300 Subject: [PATCH 1/2] fix progressbar --- cvat-core/src/server-proxy.js | 8 ++++---- cvat-ui/src/actions/tasks-actions.ts | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/cvat-core/src/server-proxy.js b/cvat-core/src/server-proxy.js index ec6e0204db1d..40786a634ebc 100644 --- a/cvat-core/src/server-proxy.js +++ b/cvat-core/src/server-proxy.js @@ -840,8 +840,8 @@ }, onProgress(bytesUploaded) { const currentUploadedSize = totalSentSize + bytesUploaded; - const percentage = ((currentUploadedSize / totalSize) * 100).toFixed(2); - onUpdate(`The data are being uploaded to the server ${percentage}%`); + const percentage = currentUploadedSize / totalSize; + onUpdate('The data are being uploaded to the server', percentage); }, onSuccess() { totalSentSize += file.size; @@ -869,8 +869,8 @@ for (const [idx, element] of fileBulks[currentChunkNumber].files.entries()) { taskData.append(`client_files[${idx}]`, element); } - onUpdate(`The data are being uploaded to the server - ${((totalSentSize / totalSize) * 100).toFixed(2)}%`); + const percentage = totalSentSize / totalSize; + onUpdate('The data are being uploaded to the server', percentage); await Axios.post(`${backendAPI}/tasks/${taskId}/data`, taskData, { ...params, proxy: config.proxy, diff --git a/cvat-ui/src/actions/tasks-actions.ts b/cvat-ui/src/actions/tasks-actions.ts index 53e91d512833..fc4639e28e43 100644 --- a/cvat-ui/src/actions/tasks-actions.ts +++ b/cvat-ui/src/actions/tasks-actions.ts @@ -414,7 +414,7 @@ export function createTaskAsync(data: any): ThunkAction, {}, {}, A dispatch(createTask()); try { const savedTask = await taskInstance.save((status: string, progress: number): void => { - dispatch(createTaskUpdateStatus(status + (progress !== null ? ` ${Math.floor(progress * 100)}%` : ''))); + dispatch(createTaskUpdateStatus(status + (progress ? ` ${Math.floor(progress * 100)}%` : ''))); }); dispatch(createTaskSuccess(savedTask.id)); } catch (error) { From d25a9fcce7b4579f7668ffd8f6132b6c952a874c Mon Sep 17 00:00:00 2001 From: klakhov Date: Mon, 10 Jan 2022 14:53:40 +0300 Subject: [PATCH 2/2] updated changelog, changed progress check --- CHANGELOG.md | 1 + cvat-ui/src/actions/tasks-actions.ts | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 2d6f3b2a75fb..b34f8929ee4e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -47,6 +47,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Added information to export CVAT_HOST when performing local installation for accessing over network () - Fixed possible color collisions in the generated colormap () - Original pdf file is deleted when using share() +- Fixed task data upload progressbar() ### Security - Updated ELK to 6.8.22 which uses log4j 2.17.0 () diff --git a/cvat-ui/src/actions/tasks-actions.ts b/cvat-ui/src/actions/tasks-actions.ts index fc4639e28e43..53e91d512833 100644 --- a/cvat-ui/src/actions/tasks-actions.ts +++ b/cvat-ui/src/actions/tasks-actions.ts @@ -414,7 +414,7 @@ export function createTaskAsync(data: any): ThunkAction, {}, {}, A dispatch(createTask()); try { const savedTask = await taskInstance.save((status: string, progress: number): void => { - dispatch(createTaskUpdateStatus(status + (progress ? ` ${Math.floor(progress * 100)}%` : ''))); + dispatch(createTaskUpdateStatus(status + (progress !== null ? ` ${Math.floor(progress * 100)}%` : ''))); }); dispatch(createTaskSuccess(savedTask.id)); } catch (error) {