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

master
Max_ES 5 years ago committed by Gitea
commit a84e6ab098

@ -39,6 +39,7 @@ export class DialogFileUploadComponent {
* Fired when the ok button was pressed * Fired when the ok button was pressed
*/ */
onOkClicked() { onOkClicked() {
if (this.file) {
this.errorOccurred = false; this.errorOccurred = false;
this.uploading = true; this.uploading = true;
this.selfService.changeProfilePicture(this.file).subscribe((response) => { this.selfService.changeProfilePicture(this.file).subscribe((response) => {
@ -60,6 +61,10 @@ export class DialogFileUploadComponent {
this.errorMessage = 'Failed to upload the profile picture.'; this.errorMessage = 'Failed to upload the profile picture.';
} }
}); });
} else {
this.errorOccurred = true;
this.errorMessage = 'Please select a file to upload.';
}
} }
/** /**

@ -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