diff options
Diffstat (limited to 'client/src/app/+admin/users/user-edit/user-update.component.ts')
-rw-r--r-- | client/src/app/+admin/users/user-edit/user-update.component.ts | 23 |
1 files changed, 17 insertions, 6 deletions
diff --git a/client/src/app/+admin/users/user-edit/user-update.component.ts b/client/src/app/+admin/users/user-edit/user-update.component.ts index cd3885a99..94ef87b08 100644 --- a/client/src/app/+admin/users/user-edit/user-update.component.ts +++ b/client/src/app/+admin/users/user-edit/user-update.component.ts | |||
@@ -1,7 +1,7 @@ | |||
1 | import { Component, OnDestroy, OnInit } from '@angular/core' | 1 | import { Component, OnDestroy, OnInit } from '@angular/core' |
2 | import { ActivatedRoute, Router } from '@angular/router' | 2 | import { ActivatedRoute, Router } from '@angular/router' |
3 | import { Subscription } from 'rxjs' | 3 | import { Subscription } from 'rxjs' |
4 | import { NotificationsService } from 'angular2-notifications' | 4 | import { Notifier } from '@app/core' |
5 | import { ServerService } from '../../../core' | 5 | import { ServerService } from '../../../core' |
6 | import { UserEdit } from './user-edit' | 6 | import { UserEdit } from './user-edit' |
7 | import { User, UserUpdate } from '../../../../../../shared' | 7 | import { User, UserUpdate } from '../../../../../../shared' |
@@ -19,6 +19,7 @@ import { UserService } from '@app/shared' | |||
19 | export class UserUpdateComponent extends UserEdit implements OnInit, OnDestroy { | 19 | export class UserUpdateComponent extends UserEdit implements OnInit, OnDestroy { |
20 | error: string | 20 | error: string |
21 | userId: number | 21 | userId: number |
22 | userEmail: string | ||
22 | username: string | 23 | username: string |
23 | 24 | ||
24 | private paramsSub: Subscription | 25 | private paramsSub: Subscription |
@@ -30,7 +31,7 @@ export class UserUpdateComponent extends UserEdit implements OnInit, OnDestroy { | |||
30 | private userValidatorsService: UserValidatorsService, | 31 | private userValidatorsService: UserValidatorsService, |
31 | private route: ActivatedRoute, | 32 | private route: ActivatedRoute, |
32 | private router: Router, | 33 | private router: Router, |
33 | private notificationsService: NotificationsService, | 34 | private notifier: Notifier, |
34 | private userService: UserService, | 35 | private userService: UserService, |
35 | private i18n: I18n | 36 | private i18n: I18n |
36 | ) { | 37 | ) { |
@@ -73,10 +74,7 @@ export class UserUpdateComponent extends UserEdit implements OnInit, OnDestroy { | |||
73 | 74 | ||
74 | this.userService.updateUser(this.userId, userUpdate).subscribe( | 75 | this.userService.updateUser(this.userId, userUpdate).subscribe( |
75 | () => { | 76 | () => { |
76 | this.notificationsService.success( | 77 | this.notifier.success(this.i18n('User {{username}} updated.', { username: this.username })) |
77 | this.i18n('Success'), | ||
78 | this.i18n('User {{username}} updated.', { username: this.username }) | ||
79 | ) | ||
80 | this.router.navigate([ '/admin/users/list' ]) | 78 | this.router.navigate([ '/admin/users/list' ]) |
81 | }, | 79 | }, |
82 | 80 | ||
@@ -92,9 +90,22 @@ export class UserUpdateComponent extends UserEdit implements OnInit, OnDestroy { | |||
92 | return this.i18n('Update user') | 90 | return this.i18n('Update user') |
93 | } | 91 | } |
94 | 92 | ||
93 | resetPassword () { | ||
94 | this.userService.askResetPassword(this.userEmail).subscribe( | ||
95 | () => { | ||
96 | this.notifier.success( | ||
97 | this.i18n('An email asking for password reset has been sent to {{username}}.', { username: this.username }) | ||
98 | ) | ||
99 | }, | ||
100 | |||
101 | err => this.error = err.message | ||
102 | ) | ||
103 | } | ||
104 | |||
95 | private onUserFetched (userJson: User) { | 105 | private onUserFetched (userJson: User) { |
96 | this.userId = userJson.id | 106 | this.userId = userJson.id |
97 | this.username = userJson.username | 107 | this.username = userJson.username |
108 | this.userEmail = userJson.email | ||
98 | 109 | ||
99 | this.form.patchValue({ | 110 | this.form.patchValue({ |
100 | email: userJson.email, | 111 | email: userJson.email, |