diff --git a/frontend/src/app/upload/upload.component.html b/frontend/src/app/upload/upload.component.html index 4f51bde..02540d4 100644 --- a/frontend/src/app/upload/upload.component.html +++ b/frontend/src/app/upload/upload.component.html @@ -45,10 +45,12 @@ +
{{ uploadProgress | number:'1.0-0' }}%

Uploading {{ fileToUpload.name }}...

+

File uploaded successfully!

diff --git a/frontend/src/app/upload/upload.component.ts b/frontend/src/app/upload/upload.component.ts index ef48bd8..5661c04 100644 --- a/frontend/src/app/upload/upload.component.ts +++ b/frontend/src/app/upload/upload.component.ts @@ -85,8 +85,12 @@ export class UploadComponent { 'Access-Control-Allow-Origin': '*', // Allow CORS }, onUploadProgress: (progressEvent: AxiosProgressEvent) => { - // @ts-ignore - this.targetUploadProgress = Math.round((progressEvent.loaded / progressEvent.total) * 100); + if (progressEvent.total) { + this.targetUploadProgress = Math.round((progressEvent.loaded / progressEvent.total) * 100); + } else { + this.uploadProgress = 99; // Unable to compute progress since total size is unknown + console.error('Unable to compute progress since total size is unknown'); + } this.smoothProgressUpdate(); } }; @@ -94,6 +98,7 @@ export class UploadComponent { axios.post(this.developmentStore.getBaseUrl() + 'api/v1/upload', formData, config) .then(response => { console.log('Upload completed successfully:', response.data); + this.uploadFinished = true; }) .catch(error => { console.error('Upload failed:', error.response ? error.response.data : error.message);