179. Update user / test user update (#26)
This commit is contained in:
@ -168,9 +168,8 @@
|
||||
</div>
|
||||
<div class="tab-content pt-3">
|
||||
<div class="tab-pane active">
|
||||
<form #profileUserForm="ngForm" (ngSubmit)="onUpdateCurrentUser(profileUserForm)"
|
||||
class="form"
|
||||
novalidate>
|
||||
<form #profileUserForm="ngForm" (ngSubmit)="onUpdateCurrentUser(profileUserForm.value)"
|
||||
class="form" novalidate>
|
||||
<div class="row">
|
||||
<div class="col">
|
||||
<div class="row">
|
||||
|
||||
@ -200,8 +200,25 @@ export class UserComponent implements OnInit, OnDestroy {
|
||||
this.subscriptions.push(subscription);
|
||||
}
|
||||
|
||||
onUpdateCurrentUser(profileUserForm: any) {
|
||||
|
||||
onUpdateCurrentUser(user: User) {
|
||||
this.currentUsername = this.authenticationService.getUserFromLocalStorage().username;
|
||||
this.refreshing = true;
|
||||
const formData = this.userService.createUserFormData(this.currentUsername, user, this.profileImage);
|
||||
let subscription = this.userService.updateUser(formData)
|
||||
.subscribe(
|
||||
(user: User) => {
|
||||
this.authenticationService.addUserToLocalStorage(user);
|
||||
this.getUsers(false);
|
||||
this.invalidateVariables();
|
||||
this.notificationService.notify(NotificationType.SUCCESS, `User ${user.username} updated successfully`);
|
||||
this.refreshing = false;
|
||||
},
|
||||
(errorResponse: HttpErrorResponse) => {
|
||||
this.sendErrorNotification(errorResponse.error.message);
|
||||
this.refreshing = false;
|
||||
}
|
||||
);
|
||||
this.subscriptions.push(subscription);
|
||||
}
|
||||
|
||||
onLogOut() {
|
||||
|
||||
Reference in New Issue
Block a user