Merge branch 'julius-dev' of Software_Engineering_I/greenvironment-frontend into master

master
Max_ES 5 years ago committed by Gitea
commit a84e6ab098

@ -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.';
}
});
} }
/** /**

@ -1,7 +1,8 @@
<div id="file-upload-dialog"> <div id="file-upload-dialog">
<h1 mat-dialog-title align="center">Upload a new Profile picture!</h1> <h1 mat-dialog-title align="center">Upload a new Profile picture!</h1>
<div class="uploadDialogContent" mat-dialog-content> <div class="uploadDialogContent" mat-dialog-content>
<input type="file" accept="image/*" (change)="onFileInputChange($event)" #name> <input style="display: none" id="input-file" type="file" accept="image/*" (change)="onFileInputChange($event)" #name>
<label for="input-file" class="mat-button mat-raised-button mat-primary">Choose File</label>
<div id="inputPreviewWrapper"> <div id="inputPreviewWrapper">
<h2 *ngIf="localFileUrl">Preview:</h2> <h2 *ngIf="localFileUrl">Preview:</h2>
<img *ngIf="localFileUrl" id="inputPreview" [src]="localFileUrl"/> <img *ngIf="localFileUrl" id="inputPreview" [src]="localFileUrl"/>

Loading…
Cancel
Save