From db00d8e0bfad463308d00419b0be71ff1364a195 Mon Sep 17 00:00:00 2001 From: Art Date: Wed, 22 Sep 2021 14:46:17 +0300 Subject: [PATCH] 183. Report upload progress - Part 1 (#26) --- .../src/app/component/user/user.component.ts | 13 ++++++++++--- .../src/app/model/file-upload.status.spec.ts | 7 +++++++ .../src/app/model/file-upload.status.ts | 6 ++++++ 3 files changed, 23 insertions(+), 3 deletions(-) create mode 100644 support-portal-frontend/src/app/model/file-upload.status.spec.ts create mode 100644 support-portal-frontend/src/app/model/file-upload.status.ts diff --git a/support-portal-frontend/src/app/component/user/user.component.ts b/support-portal-frontend/src/app/component/user/user.component.ts index 2bdc75f..f2de86c 100644 --- a/support-portal-frontend/src/app/component/user/user.component.ts +++ b/support-portal-frontend/src/app/component/user/user.component.ts @@ -242,15 +242,22 @@ export class UserComponent implements OnInit, OnDestroy { let subscription = this.userService.updateProfileImage(user.username, formData) .subscribe( (event: HttpEvent) => { - this.notificationService.notify(NotificationType.SUCCESS, `Profile image updated successfully: ${event}`); - this.refreshing = false; - this.getUsers(false); + this.reportUploadProgress(event); }, (errorResponse: HttpErrorResponse) => { this.sendErrorNotification(errorResponse.error.message); this.refreshing = false; + }, + () => { + this.notificationService.notify(NotificationType.SUCCESS, `Profile image updated successfully: ${event}`); + this.refreshing = false; + this.getUsers(false); } ); this.subscriptions.push(subscription); } + + private reportUploadProgress(event: HttpEvent): void { + + } } diff --git a/support-portal-frontend/src/app/model/file-upload.status.spec.ts b/support-portal-frontend/src/app/model/file-upload.status.spec.ts new file mode 100644 index 0000000..ae84cf7 --- /dev/null +++ b/support-portal-frontend/src/app/model/file-upload.status.spec.ts @@ -0,0 +1,7 @@ +import { FileUpload.Status } from './file-upload.status'; + +describe('FileUpload.Status', () => { + it('should create an instance', () => { + expect(new FileUpload.Status()).toBeTruthy(); + }); +}); diff --git a/support-portal-frontend/src/app/model/file-upload.status.ts b/support-portal-frontend/src/app/model/file-upload.status.ts new file mode 100644 index 0000000..17a4a5f --- /dev/null +++ b/support-portal-frontend/src/app/model/file-upload.status.ts @@ -0,0 +1,6 @@ +export class FileUploadStatus { + + public status: string = ''; + public percentage: number = 0; + +}