165. Getting profile image and click save button (#22)

This commit is contained in:
Art
2021-09-21 10:52:53 +03:00
parent 3944b43cfa
commit 5222961c68
2 changed files with 12 additions and 5 deletions

View File

@ -219,7 +219,7 @@
</div>
<div class="custom-file">
<input type="file" accept="image/*" name="profileImage"
(change)="onProfileImageChange($event)"
(change)="onProfileImageChange($any($event).target.files)"
class="custom-file-input">
<label class="custom-file-label">
<span [hidden]="true"> fileName </span>
@ -247,7 +247,7 @@
</div>
<div class="modal-footer">
<button type="button" class="btn btn-secondary" data-bs-dismiss="modal" id="new-user-close">Close</button>
<button type="button" class="btn btn-primary">Save changes</button>
<button type="button" class="btn btn-primary" (click)="saveNewUser()">Save changes</button>
</div>
</div>
</div>

View File

@ -20,6 +20,8 @@ export class UserComponent implements OnInit, OnDestroy {
public refreshing: boolean;
private subscriptions: Subscription[] = [];
public selectedUser: User;
public profileImageFileName: string;
public profileImage: File;
constructor(private userService: UserService,
private notificationService: NotificationService) {
@ -64,11 +66,16 @@ export class UserComponent implements OnInit, OnDestroy {
document.getElementById('openUserInfo')?.click();
}
public onProfileImageChange(event: any): void {
console.log(event);
public onProfileImageChange(fileList: FileList): void {
this.profileImageFileName = fileList[0].name;
this.profileImage = fileList[0];
}
private sendErrorNotification(message: string) {
this.notificationService.notify(NotificationType.ERROR, message ? message : 'An error occurred. Please try again')
}
public saveNewUser(): void {
document.getElementById('new-user-save')?.click();
}
}