diff --git a/src/app/components/profile/fileUpload/fileUpload.component.ts b/src/app/components/profile/fileUpload/fileUpload.component.ts index b86767c..b4b5bf0 100644 --- a/src/app/components/profile/fileUpload/fileUpload.component.ts +++ b/src/app/components/profile/fileUpload/fileUpload.component.ts @@ -39,27 +39,32 @@ export class DialogFileUploadComponent { * Fired when the ok button was pressed */ onOkClicked() { - this.errorOccurred = false; - this.uploading = true; - this.selfService.changeProfilePicture(this.file).subscribe((response) => { - this.uploading = false; - if (response.success) { - this.profilePictureUrl.next(environment.greenvironmentUrl + response.fileName); - this.dialogRef.close(); - } else { - this.errorMessage = response.error; + if (this.file) { + this.errorOccurred = false; + this.uploading = true; + this.selfService.changeProfilePicture(this.file).subscribe((response) => { + this.uploading = false; + if (response.success) { + this.profilePictureUrl.next(environment.greenvironmentUrl + response.fileName); + this.dialogRef.close(); + } else { + this.errorMessage = response.error; + this.errorOccurred = true; + } + }, (error) => { + this.uploading = false; this.errorOccurred = true; - } - }, (error) => { - this.uploading = false; + console.log(error); + if (error.error) { + this.errorMessage = error.error.error; + } else { + this.errorMessage = 'Failed to upload the profile picture.'; + } + }); + } else { this.errorOccurred = true; - console.log(error); - if (error.error) { - this.errorMessage = error.error.error; - } else { - this.errorMessage = 'Failed to upload the profile picture.'; - } - }); + this.errorMessage = 'Please select a file to upload.'; + } } /** diff --git a/src/app/components/profile/fileUpload/fileUploadDialog.component.html b/src/app/components/profile/fileUpload/fileUploadDialog.component.html index 7edfd5c..3ed10fd 100644 --- a/src/app/components/profile/fileUpload/fileUploadDialog.component.html +++ b/src/app/components/profile/fileUpload/fileUploadDialog.component.html @@ -1,7 +1,8 @@

Upload a new Profile picture!

- + +

Preview: