|
|
@ -39,27 +39,32 @@ export class DialogFileUploadComponent {
|
|
|
|
* Fired when the ok button was pressed
|
|
|
|
* Fired when the ok button was pressed
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
onOkClicked() {
|
|
|
|
onOkClicked() {
|
|
|
|
this.errorOccurred = false;
|
|
|
|
if (this.file) {
|
|
|
|
this.uploading = true;
|
|
|
|
this.errorOccurred = false;
|
|
|
|
this.selfService.changeProfilePicture(this.file).subscribe((response) => {
|
|
|
|
this.uploading = true;
|
|
|
|
this.uploading = false;
|
|
|
|
this.selfService.changeProfilePicture(this.file).subscribe((response) => {
|
|
|
|
if (response.success) {
|
|
|
|
this.uploading = false;
|
|
|
|
this.profilePictureUrl.next(environment.greenvironmentUrl + response.fileName);
|
|
|
|
if (response.success) {
|
|
|
|
this.dialogRef.close();
|
|
|
|
this.profilePictureUrl.next(environment.greenvironmentUrl + response.fileName);
|
|
|
|
} else {
|
|
|
|
this.dialogRef.close();
|
|
|
|
this.errorMessage = response.error;
|
|
|
|
} else {
|
|
|
|
|
|
|
|
this.errorMessage = response.error;
|
|
|
|
|
|
|
|
this.errorOccurred = true;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}, (error) => {
|
|
|
|
|
|
|
|
this.uploading = false;
|
|
|
|
this.errorOccurred = true;
|
|
|
|
this.errorOccurred = true;
|
|
|
|
}
|
|
|
|
console.log(error);
|
|
|
|
}, (error) => {
|
|
|
|
if (error.error) {
|
|
|
|
this.uploading = false;
|
|
|
|
this.errorMessage = error.error.error;
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
this.errorMessage = 'Failed to upload the profile picture.';
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
} else {
|
|
|
|
this.errorOccurred = true;
|
|
|
|
this.errorOccurred = true;
|
|
|
|
console.log(error);
|
|
|
|
this.errorMessage = 'Please select a file to upload.';
|
|
|
|
if (error.error) {
|
|
|
|
}
|
|
|
|
this.errorMessage = error.error.error;
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
this.errorMessage = 'Failed to upload the profile picture.';
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|