aboutsummaryrefslogtreecommitdiffhomepage
path: root/client/src/app/+admin
diff options
context:
space:
mode:
authorChocobozzz <florian.bigard@gmail.com>2017-01-27 16:14:11 +0100
committerChocobozzz <florian.bigard@gmail.com>2017-01-27 16:14:11 +0100
commit7ddd02c9b8c1e088f6679a2227f105e6439fc992 (patch)
treea1ff7af17f2a95abe85a2380834957e44032e8c2 /client/src/app/+admin
parentcddadde81f91219204cec1f4057a191c02a70894 (diff)
downloadPeerTube-7ddd02c9b8c1e088f6679a2227f105e6439fc992.tar.gz
PeerTube-7ddd02c9b8c1e088f6679a2227f105e6439fc992.tar.zst
PeerTube-7ddd02c9b8c1e088f6679a2227f105e6439fc992.zip
Client: better notifications for a beautiful world
Diffstat (limited to 'client/src/app/+admin')
-rw-r--r--client/src/app/+admin/friends/friend-add/friend-add.component.ts13
-rw-r--r--client/src/app/+admin/friends/friend-list/friend-list.component.ts15
-rw-r--r--client/src/app/+admin/requests/request-stats/request-stats.component.ts25
-rw-r--r--client/src/app/+admin/users/user-add/user-add.component.ts8
-rw-r--r--client/src/app/+admin/users/user-list/user-list.component.ts16
-rw-r--r--client/src/app/+admin/video-abuses/video-abuse-list/video-abuse-list.component.ts10
6 files changed, 64 insertions, 23 deletions
diff --git a/client/src/app/+admin/friends/friend-add/friend-add.component.ts b/client/src/app/+admin/friends/friend-add/friend-add.component.ts
index 014252011..a271970ae 100644
--- a/client/src/app/+admin/friends/friend-add/friend-add.component.ts
+++ b/client/src/app/+admin/friends/friend-add/friend-add.component.ts
@@ -2,6 +2,8 @@ import { Component, OnInit } from '@angular/core';
2import { FormControl, FormGroup } from '@angular/forms'; 2import { FormControl, FormGroup } from '@angular/forms';
3import { Router } from '@angular/router'; 3import { Router } from '@angular/router';
4 4
5import { NotificationsService } from 'angular2-notifications';
6
5import { validateHost } from '../../../shared'; 7import { validateHost } from '../../../shared';
6import { FriendService } from '../shared'; 8import { FriendService } from '../shared';
7 9
@@ -15,7 +17,11 @@ export class FriendAddComponent implements OnInit {
15 hosts = [ ]; 17 hosts = [ ];
16 error: string = null; 18 error: string = null;
17 19
18 constructor(private router: Router, private friendService: FriendService) {} 20 constructor(
21 private router: Router,
22 private notificationsService: NotificationsService,
23 private friendService: FriendService
24 ) {}
19 25
20 ngOnInit() { 26 ngOnInit() {
21 this.form = new FormGroup({}); 27 this.form = new FormGroup({});
@@ -83,10 +89,11 @@ export class FriendAddComponent implements OnInit {
83 89
84 this.friendService.makeFriends(notEmptyHosts).subscribe( 90 this.friendService.makeFriends(notEmptyHosts).subscribe(
85 status => { 91 status => {
86 alert('Make friends request sent!'); 92 this.notificationsService.success('Sucess', 'Make friends request sent!');
87 this.router.navigate([ '/admin/friends/list' ]); 93 this.router.navigate([ '/admin/friends/list' ]);
88 }, 94 },
89 error => alert(error.text) 95
96 err => this.notificationsService.error('Error', err.text)
90 ); 97 );
91 } 98 }
92 99
diff --git a/client/src/app/+admin/friends/friend-list/friend-list.component.ts b/client/src/app/+admin/friends/friend-list/friend-list.component.ts
index bec10162c..700ea7a69 100644
--- a/client/src/app/+admin/friends/friend-list/friend-list.component.ts
+++ b/client/src/app/+admin/friends/friend-list/friend-list.component.ts
@@ -1,5 +1,7 @@
1import { Component, OnInit } from '@angular/core'; 1import { Component, OnInit } from '@angular/core';
2 2
3import { NotificationsService } from 'angular2-notifications';
4
3import { Friend, FriendService } from '../shared'; 5import { Friend, FriendService } from '../shared';
4 6
5@Component({ 7@Component({
@@ -10,7 +12,10 @@ import { Friend, FriendService } from '../shared';
10export class FriendListComponent implements OnInit { 12export class FriendListComponent implements OnInit {
11 friends: Friend[]; 13 friends: Friend[];
12 14
13 constructor(private friendService: FriendService) { } 15 constructor(
16 private notificationsService: NotificationsService,
17 private friendService: FriendService
18 ) { }
14 19
15 ngOnInit() { 20 ngOnInit() {
16 this.getFriends(); 21 this.getFriends();
@@ -21,10 +26,12 @@ export class FriendListComponent implements OnInit {
21 26
22 this.friendService.quitFriends().subscribe( 27 this.friendService.quitFriends().subscribe(
23 status => { 28 status => {
24 alert('Quit friends!'); 29 this.notificationsService.success('Sucess', 'Friends left!');
30
25 this.getFriends(); 31 this.getFriends();
26 }, 32 },
27 error => alert(error.text) 33
34 err => this.notificationsService.error('Error', err.text)
28 ); 35 );
29 } 36 }
30 37
@@ -32,7 +39,7 @@ export class FriendListComponent implements OnInit {
32 this.friendService.getFriends().subscribe( 39 this.friendService.getFriends().subscribe(
33 res => this.friends = res.friends, 40 res => this.friends = res.friends,
34 41
35 err => alert(err.text) 42 err => this.notificationsService.error('Error', err.text)
36 ); 43 );
37 } 44 }
38} 45}
diff --git a/client/src/app/+admin/requests/request-stats/request-stats.component.ts b/client/src/app/+admin/requests/request-stats/request-stats.component.ts
index 23b836779..18855a5f8 100644
--- a/client/src/app/+admin/requests/request-stats/request-stats.component.ts
+++ b/client/src/app/+admin/requests/request-stats/request-stats.component.ts
@@ -1,6 +1,7 @@
1import { setInterval } from 'timers'
2import { Component, OnInit, OnDestroy } from '@angular/core'; 1import { Component, OnInit, OnDestroy } from '@angular/core';
3 2
3import { NotificationsService } from 'angular2-notifications';
4
4import { RequestService, RequestStats } from '../shared'; 5import { RequestService, RequestStats } from '../shared';
5 6
6@Component({ 7@Component({
@@ -11,9 +12,13 @@ import { RequestService, RequestStats } from '../shared';
11export class RequestStatsComponent implements OnInit, OnDestroy { 12export class RequestStatsComponent implements OnInit, OnDestroy {
12 stats: RequestStats = null; 13 stats: RequestStats = null;
13 14
14 private interval: NodeJS.Timer = null; 15 private interval: number = null;
16 private timeout: number = null;
15 17
16 constructor(private requestService: RequestService) { } 18 constructor(
19 private notificationsService: NotificationsService,
20 private requestService: RequestService
21 ) { }
17 22
18 ngOnInit() { 23 ngOnInit() {
19 this.getStats(); 24 this.getStats();
@@ -21,8 +26,12 @@ export class RequestStatsComponent implements OnInit, OnDestroy {
21 } 26 }
22 27
23 ngOnDestroy() { 28 ngOnDestroy() {
24 if (this.stats !== null && this.stats.secondsInterval !== null) { 29 if (this.interval !== null) {
25 clearInterval(this.interval); 30 window.clearInterval(this.interval);
31 }
32
33 if (this.timeout !== null) {
34 window.clearTimeout(this.timeout);
26 } 35 }
27 } 36 }
28 37
@@ -30,16 +39,16 @@ export class RequestStatsComponent implements OnInit, OnDestroy {
30 this.requestService.getStats().subscribe( 39 this.requestService.getStats().subscribe(
31 stats => this.stats = stats, 40 stats => this.stats = stats,
32 41
33 err => alert(err.text) 42 err => this.notificationsService.error('Error', err.text)
34 ); 43 );
35 } 44 }
36 45
37 private runInterval() { 46 private runInterval() {
38 this.interval = setInterval(() => { 47 this.interval = window.setInterval(() => {
39 this.stats.remainingMilliSeconds -= 1000; 48 this.stats.remainingMilliSeconds -= 1000;
40 49
41 if (this.stats.remainingMilliSeconds <= 0) { 50 if (this.stats.remainingMilliSeconds <= 0) {
42 setTimeout(() => this.getStats(), this.stats.remainingMilliSeconds + 100); 51 this.timeout = window.setTimeout(() => this.getStats(), this.stats.remainingMilliSeconds + 100);
43 } 52 }
44 }, 1000); 53 }, 1000);
45 } 54 }
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';
2import { FormBuilder, FormGroup } from '@angular/forms'; 2import { FormBuilder, FormGroup } from '@angular/forms';
3import { Router } from '@angular/router'; 3import { Router } from '@angular/router';
4 4
5import { NotificationsService } from 'angular2-notifications';
6
5import { UserService } from '../shared'; 7import { UserService } from '../shared';
6import { FormReactive, USER_USERNAME, USER_PASSWORD } from '../../../shared'; 8import { 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 @@
1import { Component, OnInit } from '@angular/core'; 1import { Component, OnInit } from '@angular/core';
2 2
3import { NotificationsService } from 'angular2-notifications';
4
3import { User } from '../../../shared'; 5import { User } from '../../../shared';
4import { UserService } from '../shared'; 6import { 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 }
diff --git a/client/src/app/+admin/video-abuses/video-abuse-list/video-abuse-list.component.ts b/client/src/app/+admin/video-abuses/video-abuse-list/video-abuse-list.component.ts
index de58bba3d..cfd9151b0 100644
--- a/client/src/app/+admin/video-abuses/video-abuse-list/video-abuse-list.component.ts
+++ b/client/src/app/+admin/video-abuses/video-abuse-list/video-abuse-list.component.ts
@@ -1,6 +1,7 @@
1import { setInterval } from 'timers'
2import { Component, OnInit } from '@angular/core'; 1import { Component, OnInit } from '@angular/core';
3 2
3import { NotificationsService } from 'angular2-notifications';
4
4import { VideoAbuseService, VideoAbuse} from '../../../shared'; 5import { VideoAbuseService, VideoAbuse} from '../../../shared';
5 6
6@Component({ 7@Component({
@@ -11,7 +12,10 @@ import { VideoAbuseService, VideoAbuse} from '../../../shared';
11export class VideoAbuseListComponent implements OnInit { 12export class VideoAbuseListComponent implements OnInit {
12 videoAbuses: VideoAbuse[]; 13 videoAbuses: VideoAbuse[];
13 14
14 constructor(private videoAbuseService: VideoAbuseService) { } 15 constructor(
16 private notificationsService: NotificationsService,
17 private videoAbuseService: VideoAbuseService
18 ) { }
15 19
16 ngOnInit() { 20 ngOnInit() {
17 this.getVideoAbuses(); 21 this.getVideoAbuses();
@@ -25,7 +29,7 @@ export class VideoAbuseListComponent implements OnInit {
25 this.videoAbuseService.getVideoAbuses().subscribe( 29 this.videoAbuseService.getVideoAbuses().subscribe(
26 res => this.videoAbuses = res.videoAbuses, 30 res => this.videoAbuses = res.videoAbuses,
27 31
28 err => alert(err.text) 32 err => this.notificationsService.error('Error', err.text)
29 ); 33 );
30 } 34 }
31} 35}