diff options
author | Chocobozzz <florian.bigard@gmail.com> | 2017-01-27 16:14:11 +0100 |
---|---|---|
committer | Chocobozzz <florian.bigard@gmail.com> | 2017-01-27 16:14:11 +0100 |
commit | 7ddd02c9b8c1e088f6679a2227f105e6439fc992 (patch) | |
tree | a1ff7af17f2a95abe85a2380834957e44032e8c2 /client/src/app/+admin/users | |
parent | cddadde81f91219204cec1f4057a191c02a70894 (diff) | |
download | PeerTube-7ddd02c9b8c1e088f6679a2227f105e6439fc992.tar.gz PeerTube-7ddd02c9b8c1e088f6679a2227f105e6439fc992.tar.zst PeerTube-7ddd02c9b8c1e088f6679a2227f105e6439fc992.zip |
Client: better notifications for a beautiful world
Diffstat (limited to 'client/src/app/+admin/users')
-rw-r--r-- | client/src/app/+admin/users/user-add/user-add.component.ts | 8 | ||||
-rw-r--r-- | client/src/app/+admin/users/user-list/user-list.component.ts | 16 |
2 files changed, 19 insertions, 5 deletions
diff --git a/client/src/app/+admin/users/user-add/user-add.component.ts b/client/src/app/+admin/users/user-add/user-add.component.ts index ab96fb01d..a851fee44 100644 --- a/client/src/app/+admin/users/user-add/user-add.component.ts +++ b/client/src/app/+admin/users/user-add/user-add.component.ts | |||
@@ -2,6 +2,8 @@ import { Component, OnInit } from '@angular/core'; | |||
2 | import { FormBuilder, FormGroup } from '@angular/forms'; | 2 | import { FormBuilder, FormGroup } from '@angular/forms'; |
3 | import { Router } from '@angular/router'; | 3 | import { Router } from '@angular/router'; |
4 | 4 | ||
5 | import { NotificationsService } from 'angular2-notifications'; | ||
6 | |||
5 | import { UserService } from '../shared'; | 7 | import { UserService } from '../shared'; |
6 | import { FormReactive, USER_USERNAME, USER_PASSWORD } from '../../../shared'; | 8 | import { FormReactive, USER_USERNAME, USER_PASSWORD } from '../../../shared'; |
7 | 9 | ||
@@ -25,6 +27,7 @@ export class UserAddComponent extends FormReactive implements OnInit { | |||
25 | constructor( | 27 | constructor( |
26 | private formBuilder: FormBuilder, | 28 | private formBuilder: FormBuilder, |
27 | private router: Router, | 29 | private router: Router, |
30 | private notificationsService: NotificationsService, | ||
28 | private userService: UserService | 31 | private userService: UserService |
29 | ) { | 32 | ) { |
30 | super(); | 33 | super(); |
@@ -49,7 +52,10 @@ export class UserAddComponent extends FormReactive implements OnInit { | |||
49 | const { username, password } = this.form.value; | 52 | const { username, password } = this.form.value; |
50 | 53 | ||
51 | this.userService.addUser(username, password).subscribe( | 54 | this.userService.addUser(username, password).subscribe( |
52 | ok => this.router.navigate([ '/admin/users/list' ]), | 55 | () => { |
56 | this.notificationsService.success('Success', `User ${username} created.`); | ||
57 | this.router.navigate([ '/admin/users/list' ]); | ||
58 | }, | ||
53 | 59 | ||
54 | err => this.error = err.text | 60 | err => this.error = err.text |
55 | ); | 61 | ); |
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 03f4e5c0a..ca08ed305 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 | |||
@@ -1,5 +1,7 @@ | |||
1 | import { Component, OnInit } from '@angular/core'; | 1 | import { Component, OnInit } from '@angular/core'; |
2 | 2 | ||
3 | import { NotificationsService } from 'angular2-notifications'; | ||
4 | |||
3 | import { User } from '../../../shared'; | 5 | import { User } from '../../../shared'; |
4 | import { UserService } from '../shared'; | 6 | import { UserService } from '../shared'; |
5 | 7 | ||
@@ -12,7 +14,10 @@ export class UserListComponent implements OnInit { | |||
12 | totalUsers: number; | 14 | totalUsers: number; |
13 | users: User[]; | 15 | users: User[]; |
14 | 16 | ||
15 | constructor(private userService: UserService) {} | 17 | constructor( |
18 | private notificationsService: NotificationsService, | ||
19 | private userService: UserService | ||
20 | ) {} | ||
16 | 21 | ||
17 | ngOnInit() { | 22 | ngOnInit() { |
18 | this.getUsers(); | 23 | this.getUsers(); |
@@ -25,7 +30,7 @@ export class UserListComponent implements OnInit { | |||
25 | this.totalUsers = totalUsers; | 30 | this.totalUsers = totalUsers; |
26 | }, | 31 | }, |
27 | 32 | ||
28 | err => alert(err.text) | 33 | err => this.notificationsService.error('Error', err.text) |
29 | ); | 34 | ); |
30 | } | 35 | } |
31 | 36 | ||
@@ -33,9 +38,12 @@ export class UserListComponent implements OnInit { | |||
33 | removeUser(user: User) { | 38 | removeUser(user: User) { |
34 | if (confirm('Are you sure?')) { | 39 | if (confirm('Are you sure?')) { |
35 | this.userService.removeUser(user).subscribe( | 40 | this.userService.removeUser(user).subscribe( |
36 | () => this.getUsers(), | 41 | () => { |
42 | this.notificationsService.success('Success', `User ${user.username} deleted.`); | ||
43 | this.getUsers(); | ||
44 | }, | ||
37 | 45 | ||
38 | err => alert(err.text) | 46 | err => this.notificationsService.error('Error', err.text) |
39 | ); | 47 | ); |
40 | } | 48 | } |
41 | } | 49 | } |