diff options
Diffstat (limited to 'client/src/app/+admin/users/user-list')
-rw-r--r-- | client/src/app/+admin/users/user-list/user-list.component.ts | 26 |
1 files changed, 16 insertions, 10 deletions
diff --git a/client/src/app/+admin/users/user-list/user-list.component.ts b/client/src/app/+admin/users/user-list/user-list.component.ts index ca08ed305..baefb7064 100644 --- a/client/src/app/+admin/users/user-list/user-list.component.ts +++ b/client/src/app/+admin/users/user-list/user-list.component.ts | |||
@@ -2,6 +2,7 @@ import { Component, OnInit } from '@angular/core'; | |||
2 | 2 | ||
3 | import { NotificationsService } from 'angular2-notifications'; | 3 | import { NotificationsService } from 'angular2-notifications'; |
4 | 4 | ||
5 | import { ConfirmService } from '../../../core'; | ||
5 | import { User } from '../../../shared'; | 6 | import { User } from '../../../shared'; |
6 | import { UserService } from '../shared'; | 7 | import { UserService } from '../shared'; |
7 | 8 | ||
@@ -16,6 +17,7 @@ export class UserListComponent implements OnInit { | |||
16 | 17 | ||
17 | constructor( | 18 | constructor( |
18 | private notificationsService: NotificationsService, | 19 | private notificationsService: NotificationsService, |
20 | private confirmService: ConfirmService, | ||
19 | private userService: UserService | 21 | private userService: UserService |
20 | ) {} | 22 | ) {} |
21 | 23 | ||
@@ -36,15 +38,19 @@ export class UserListComponent implements OnInit { | |||
36 | 38 | ||
37 | 39 | ||
38 | removeUser(user: User) { | 40 | removeUser(user: User) { |
39 | if (confirm('Are you sure?')) { | 41 | this.confirmService.confirm('Do you really want to delete this user?', 'Delete').subscribe( |
40 | this.userService.removeUser(user).subscribe( | 42 | res => { |
41 | () => { | 43 | if (res === false) return; |
42 | this.notificationsService.success('Success', `User ${user.username} deleted.`); | 44 | |
43 | this.getUsers(); | 45 | this.userService.removeUser(user).subscribe( |
44 | }, | 46 | () => { |
45 | 47 | this.notificationsService.success('Success', `User ${user.username} deleted.`); | |
46 | err => this.notificationsService.error('Error', err.text) | 48 | this.getUsers(); |
47 | ); | 49 | }, |
48 | } | 50 | |
51 | err => this.notificationsService.error('Error', err.text) | ||
52 | ); | ||
53 | } | ||
54 | ); | ||
49 | } | 55 | } |
50 | } | 56 | } |