aboutsummaryrefslogtreecommitdiffhomepage
path: root/client/src/app
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
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')
-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
-rw-r--r--client/src/app/account/account.component.html1
-rw-r--r--client/src/app/account/account.component.ts12
-rw-r--r--client/src/app/app.component.html2
-rw-r--r--client/src/app/app.component.ts13
-rw-r--r--client/src/app/core/auth/auth.service.ts14
-rw-r--r--client/src/app/core/core.module.ts8
-rw-r--r--client/src/app/videos/video-add/video-add.component.ts6
-rw-r--r--client/src/app/videos/video-list/video-list.component.ts6
-rw-r--r--client/src/app/videos/video-list/video-miniature.component.ts10
-rw-r--r--client/src/app/videos/video-watch/video-report.component.ts11
-rw-r--r--client/src/app/videos/video-watch/video-watch.component.ts8
17 files changed, 131 insertions, 47 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}
diff --git a/client/src/app/account/account.component.html b/client/src/app/account/account.component.html
index 5a8847acd..2fbb5a908 100644
--- a/client/src/app/account/account.component.html
+++ b/client/src/app/account/account.component.html
@@ -1,6 +1,5 @@
1<h3>Account</h3> 1<h3>Account</h3>
2 2
3<div *ngIf="information" class="alert alert-success">{{ information }}</div>
4<div *ngIf="error" class="alert alert-danger">{{ error }}</div> 3<div *ngIf="error" class="alert alert-danger">{{ error }}</div>
5 4
6<form role="form" (ngSubmit)="changePassword()" [formGroup]="form"> 5<form role="form" (ngSubmit)="changePassword()" [formGroup]="form">
diff --git a/client/src/app/account/account.component.ts b/client/src/app/account/account.component.ts
index 851eaf198..9b6b5fbf4 100644
--- a/client/src/app/account/account.component.ts
+++ b/client/src/app/account/account.component.ts
@@ -1,8 +1,9 @@
1import { } from '@angular/common';
2import { Component, OnInit } from '@angular/core'; 1import { Component, OnInit } from '@angular/core';
3import { FormBuilder, FormGroup } from '@angular/forms'; 2import { FormBuilder, FormGroup } from '@angular/forms';
4import { Router } from '@angular/router'; 3import { Router } from '@angular/router';
5 4
5import { NotificationsService } from 'angular2-notifications';
6
6import { AccountService } from './account.service'; 7import { AccountService } from './account.service';
7import { FormReactive, USER_PASSWORD } from '../shared'; 8import { FormReactive, USER_PASSWORD } from '../shared';
8 9
@@ -12,7 +13,6 @@ import { FormReactive, USER_PASSWORD } from '../shared';
12}) 13})
13 14
14export class AccountComponent extends FormReactive implements OnInit { 15export class AccountComponent extends FormReactive implements OnInit {
15 information: string = null;
16 error: string = null; 16 error: string = null;
17 17
18 form: FormGroup; 18 form: FormGroup;
@@ -26,9 +26,10 @@ export class AccountComponent extends FormReactive implements OnInit {
26 }; 26 };
27 27
28 constructor( 28 constructor(
29 private accountService: AccountService,
30 private formBuilder: FormBuilder, 29 private formBuilder: FormBuilder,
31 private router: Router 30 private router: Router,
31 private notificationsService: NotificationsService,
32 private accountService: AccountService
32 ) { 33 ) {
33 super(); 34 super();
34 } 35 }
@@ -50,7 +51,6 @@ export class AccountComponent extends FormReactive implements OnInit {
50 const newPassword = this.form.value['new-password']; 51 const newPassword = this.form.value['new-password'];
51 const newConfirmedPassword = this.form.value['new-confirmed-password']; 52 const newConfirmedPassword = this.form.value['new-confirmed-password'];
52 53
53 this.information = null;
54 this.error = null; 54 this.error = null;
55 55
56 if (newPassword !== newConfirmedPassword) { 56 if (newPassword !== newConfirmedPassword) {
@@ -59,7 +59,7 @@ export class AccountComponent extends FormReactive implements OnInit {
59 } 59 }
60 60
61 this.accountService.changePassword(newPassword).subscribe( 61 this.accountService.changePassword(newPassword).subscribe(
62 ok => this.information = 'Password updated.', 62 () => this.notificationsService.success('Success', 'Password updated.'),
63 63
64 err => this.error = err 64 err => this.error = err
65 ); 65 );
diff --git a/client/src/app/app.component.html b/client/src/app/app.component.html
index 04c32f596..95a025832 100644
--- a/client/src/app/app.component.html
+++ b/client/src/app/app.component.html
@@ -22,6 +22,8 @@
22 </div> 22 </div>
23 </div> 23 </div>
24 24
25 <simple-notifications [options]="notificationOptions"></simple-notifications>
26
25 <footer> 27 <footer>
26 PeerTube, CopyLeft 2015-2016 28 PeerTube, CopyLeft 2015-2016
27 </footer> 29 </footer>
diff --git a/client/src/app/app.component.ts b/client/src/app/app.component.ts
index ce4fc04ff..f487e6c48 100644
--- a/client/src/app/app.component.ts
+++ b/client/src/app/app.component.ts
@@ -9,6 +9,19 @@ import { MetaService } from 'ng2-meta';
9}) 9})
10 10
11export class AppComponent { 11export class AppComponent {
12 notificationOptions = {
13 timeOut: 3000,
14 lastOnBottom: true,
15 clickToClose: true,
16 maxLength: 0,
17 maxStack: 7,
18 showProgressBar: false,
19 pauseOnHover: false,
20 preventDuplicates: false,
21 preventLastDuplicates: 'visible',
22 rtl: false
23 };
24
12 constructor( 25 constructor(
13 private router: Router, 26 private router: Router,
14 private metaService: MetaService, 27 private metaService: MetaService,
diff --git a/client/src/app/core/auth/auth.service.ts b/client/src/app/core/auth/auth.service.ts
index 06ffa1a42..a56adbbad 100644
--- a/client/src/app/core/auth/auth.service.ts
+++ b/client/src/app/core/auth/auth.service.ts
@@ -7,6 +7,8 @@ import 'rxjs/add/operator/map';
7import 'rxjs/add/operator/mergeMap'; 7import 'rxjs/add/operator/mergeMap';
8import 'rxjs/add/observable/throw'; 8import 'rxjs/add/observable/throw';
9 9
10import { NotificationsService } from 'angular2-notifications';
11
10// Do not use the barrel (dependency loop) 12// Do not use the barrel (dependency loop)
11import { AuthStatus } from '../../shared/auth/auth-status.model'; 13import { AuthStatus } from '../../shared/auth/auth-status.model';
12import { AuthUser } from '../../shared/auth/auth-user.model'; 14import { AuthUser } from '../../shared/auth/auth-user.model';
@@ -27,6 +29,7 @@ export class AuthService {
27 29
28 constructor( 30 constructor(
29 private http: Http, 31 private http: Http,
32 private notificationsService: NotificationsService,
30 private restExtractor: RestExtractor, 33 private restExtractor: RestExtractor,
31 private router: Router 34 private router: Router
32 ) { 35 ) {
@@ -44,11 +47,14 @@ export class AuthService {
44 this.clientSecret = result.client_secret; 47 this.clientSecret = result.client_secret;
45 console.log('Client credentials loaded.'); 48 console.log('Client credentials loaded.');
46 }, 49 },
50
47 error => { 51 error => {
48 alert( 52 let errorMessage = `Cannot retrieve OAuth Client credentials: ${error.text}. \n`;
49 `Cannot retrieve OAuth Client credentials: ${error.text}. \n` + 53 errorMessage += 'Ensure you have correctly configured PeerTube (config/ directory), in particular the "webserver" section.';
50 'Ensure you have correctly configured PeerTube (config/ directory), in particular the "webserver" section.' 54
51 ); 55 // We put a bigger timeout
56 // This is an important message
57 this.notificationsService.error('Error', errorMessage, { timeOut: 7000 });
52 } 58 }
53 ); 59 );
54 60
diff --git a/client/src/app/core/core.module.ts b/client/src/app/core/core.module.ts
index 09a6f92f5..48fec2d43 100644
--- a/client/src/app/core/core.module.ts
+++ b/client/src/app/core/core.module.ts
@@ -3,6 +3,8 @@ import { CommonModule } from '@angular/common';
3import { HttpModule } from '@angular/http'; 3import { HttpModule } from '@angular/http';
4import { RouterModule } from '@angular/router'; 4import { RouterModule } from '@angular/router';
5 5
6import { SimpleNotificationsModule } from 'angular2-notifications';
7
6import { AuthService } from './auth'; 8import { AuthService } from './auth';
7import { MenuComponent, MenuAdminComponent } from './menu'; 9import { MenuComponent, MenuAdminComponent } from './menu';
8import { throwIfAlreadyLoaded } from './module-import-guard'; 10import { throwIfAlreadyLoaded } from './module-import-guard';
@@ -11,13 +13,17 @@ import { throwIfAlreadyLoaded } from './module-import-guard';
11 imports: [ 13 imports: [
12 CommonModule, 14 CommonModule,
13 HttpModule, 15 HttpModule,
14 RouterModule 16 RouterModule,
17
18 SimpleNotificationsModule
15 ], 19 ],
16 declarations: [ 20 declarations: [
17 MenuComponent, 21 MenuComponent,
18 MenuAdminComponent 22 MenuAdminComponent
19 ], 23 ],
20 exports: [ 24 exports: [
25 SimpleNotificationsModule,
26
21 MenuComponent, 27 MenuComponent,
22 MenuAdminComponent 28 MenuAdminComponent
23 ], 29 ],
diff --git a/client/src/app/videos/video-add/video-add.component.ts b/client/src/app/videos/video-add/video-add.component.ts
index 1e700ae48..cd6bb9989 100644
--- a/client/src/app/videos/video-add/video-add.component.ts
+++ b/client/src/app/videos/video-add/video-add.component.ts
@@ -3,6 +3,7 @@ import { FormBuilder, FormGroup } from '@angular/forms';
3import { Router } from '@angular/router'; 3import { Router } from '@angular/router';
4 4
5import { FileUploader } from 'ng2-file-upload/ng2-file-upload'; 5import { FileUploader } from 'ng2-file-upload/ng2-file-upload';
6import { NotificationsService } from 'angular2-notifications';
6 7
7import { AuthService } from '../../core'; 8import { AuthService } from '../../core';
8import { FormReactive, VIDEO_NAME, VIDEO_DESCRIPTION, VIDEO_TAGS } from '../../shared'; 9import { FormReactive, VIDEO_NAME, VIDEO_DESCRIPTION, VIDEO_TAGS } from '../../shared';
@@ -38,7 +39,8 @@ export class VideoAddComponent extends FormReactive implements OnInit {
38 private authService: AuthService, 39 private authService: AuthService,
39 private elementRef: ElementRef, 40 private elementRef: ElementRef,
40 private formBuilder: FormBuilder, 41 private formBuilder: FormBuilder,
41 private router: Router 42 private router: Router,
43 private notificationsService: NotificationsService
42 ) { 44 ) {
43 super(); 45 super();
44 } 46 }
@@ -151,6 +153,8 @@ export class VideoAddComponent extends FormReactive implements OnInit {
151 clearInterval(interval); 153 clearInterval(interval);
152 154
153 console.log('Video uploaded.'); 155 console.log('Video uploaded.');
156 this.notificationsService.success('Success', 'Video uploaded.');
157
154 158
155 // Print all the videos once it's finished 159 // Print all the videos once it's finished
156 this.router.navigate(['/videos/list']); 160 this.router.navigate(['/videos/list']);
diff --git a/client/src/app/videos/video-list/video-list.component.ts b/client/src/app/videos/video-list/video-list.component.ts
index 6c42ba5be..b3780f8b6 100644
--- a/client/src/app/videos/video-list/video-list.component.ts
+++ b/client/src/app/videos/video-list/video-list.component.ts
@@ -2,6 +2,8 @@ import { ChangeDetectorRef, Component, OnDestroy, OnInit } from '@angular/core';
2import { ActivatedRoute, Router } from '@angular/router'; 2import { ActivatedRoute, Router } from '@angular/router';
3import { BehaviorSubject } from 'rxjs/BehaviorSubject'; 3import { BehaviorSubject } from 'rxjs/BehaviorSubject';
4 4
5import { NotificationsService } from 'angular2-notifications';
6
5import { 7import {
6 SortField, 8 SortField,
7 Video, 9 Video,
@@ -33,6 +35,7 @@ export class VideoListComponent implements OnInit, OnDestroy {
33 private subSearch: any; 35 private subSearch: any;
34 36
35 constructor( 37 constructor(
38 private notificationsService: NotificationsService,
36 private authService: AuthService, 39 private authService: AuthService,
37 private changeDetector: ChangeDetectorRef, 40 private changeDetector: ChangeDetectorRef,
38 private router: Router, 41 private router: Router,
@@ -91,7 +94,7 @@ export class VideoListComponent implements OnInit, OnDestroy {
91 94
92 this.loading.next(false); 95 this.loading.next(false);
93 }, 96 },
94 error => alert(error.text) 97 error => this.notificationsService.error('Error', error.text)
95 ); 98 );
96 } 99 }
97 100
@@ -107,6 +110,7 @@ export class VideoListComponent implements OnInit, OnDestroy {
107 } 110 }
108 111
109 onRemoved(video: Video) { 112 onRemoved(video: Video) {
113 this.notificationsService.success('Success', `Video ${video.name} deleted.`);
110 this.getVideos(); 114 this.getVideos();
111 } 115 }
112 116
diff --git a/client/src/app/videos/video-list/video-miniature.component.ts b/client/src/app/videos/video-list/video-miniature.component.ts
index 398d2db75..ca4afc451 100644
--- a/client/src/app/videos/video-list/video-miniature.component.ts
+++ b/client/src/app/videos/video-list/video-miniature.component.ts
@@ -1,5 +1,7 @@
1import { Component, Input, Output, EventEmitter } from '@angular/core'; 1import { Component, Input, Output, EventEmitter } from '@angular/core';
2 2
3import { NotificationsService } from 'angular2-notifications';
4
3import { SortField, Video, VideoService } from '../shared'; 5import { SortField, Video, VideoService } from '../shared';
4import { User } from '../../shared'; 6import { User } from '../../shared';
5 7
@@ -18,7 +20,10 @@ export class VideoMiniatureComponent {
18 20
19 hovering = false; 21 hovering = false;
20 22
21 constructor(private videoService: VideoService) {} 23 constructor(
24 private notificationsService: NotificationsService,
25 private videoService: VideoService
26 ) {}
22 27
23 displayRemoveIcon() { 28 displayRemoveIcon() {
24 return this.hovering && this.video.isRemovableBy(this.user); 29 return this.hovering && this.video.isRemovableBy(this.user);
@@ -36,7 +41,8 @@ export class VideoMiniatureComponent {
36 if (confirm('Do you really want to remove this video?')) { 41 if (confirm('Do you really want to remove this video?')) {
37 this.videoService.removeVideo(id).subscribe( 42 this.videoService.removeVideo(id).subscribe(
38 status => this.removed.emit(true), 43 status => this.removed.emit(true),
39 error => alert(error.text) 44
45 error => this.notificationsService.error('Error', error.text)
40 ); 46 );
41 } 47 }
42 } 48 }
diff --git a/client/src/app/videos/video-watch/video-report.component.ts b/client/src/app/videos/video-watch/video-report.component.ts
index 7a125f53e..19a7af148 100644
--- a/client/src/app/videos/video-watch/video-report.component.ts
+++ b/client/src/app/videos/video-watch/video-report.component.ts
@@ -2,6 +2,7 @@ import { Component, Input, OnInit, ViewChild } from '@angular/core';
2import { FormBuilder, FormGroup } from '@angular/forms'; 2import { FormBuilder, FormGroup } from '@angular/forms';
3 3
4import { ModalDirective } from 'ng2-bootstrap/modal'; 4import { ModalDirective } from 'ng2-bootstrap/modal';
5import { NotificationsService } from 'angular2-notifications';
5 6
6import { FormReactive, VideoAbuseService, VIDEO_ABUSE_REASON } from '../../shared'; 7import { FormReactive, VideoAbuseService, VIDEO_ABUSE_REASON } from '../../shared';
7import { Video, VideoService } from '../shared'; 8import { Video, VideoService } from '../shared';
@@ -26,7 +27,8 @@ export class VideoReportComponent extends FormReactive implements OnInit {
26 27
27 constructor( 28 constructor(
28 private formBuilder: FormBuilder, 29 private formBuilder: FormBuilder,
29 private videoAbuseService: VideoAbuseService 30 private videoAbuseService: VideoAbuseService,
31 private notificationsService: NotificationsService
30 ) { 32 ) {
31 super(); 33 super();
32 } 34 }
@@ -56,13 +58,12 @@ export class VideoReportComponent extends FormReactive implements OnInit {
56 58
57 this.videoAbuseService.reportVideo(this.video.id, reason) 59 this.videoAbuseService.reportVideo(this.video.id, reason)
58 .subscribe( 60 .subscribe(
59 // TODO: move alert to beautiful notifications 61 () => {
60 ok => { 62 this.notificationsService.success('Success', 'Video reported.');
61 alert('Video reported.');
62 this.hide(); 63 this.hide();
63 }, 64 },
64 65
65 err => alert(err.text) 66 err => this.notificationsService.error('Error', err.text);
66 ) 67 )
67 } 68 }
68} 69}
diff --git a/client/src/app/videos/video-watch/video-watch.component.ts b/client/src/app/videos/video-watch/video-watch.component.ts
index 5cd7550be..c27133f74 100644
--- a/client/src/app/videos/video-watch/video-watch.component.ts
+++ b/client/src/app/videos/video-watch/video-watch.component.ts
@@ -1,8 +1,9 @@
1import { Component, ElementRef, NgZone, OnDestroy, OnInit, ViewChild } from '@angular/core'; 1import { Component, ElementRef, NgZone, OnDestroy, OnInit, ViewChild } from '@angular/core';
2import { ActivatedRoute } from '@angular/router'; 2import { ActivatedRoute } from '@angular/router';
3 3
4import { MetaService } from 'ng2-meta';
5import * as videojs from 'video.js'; 4import * as videojs from 'video.js';
5import { MetaService } from 'ng2-meta';
6import { NotificationsService } from 'angular2-notifications';
6 7
7import { AuthService } from '../../core'; 8import { AuthService } from '../../core';
8import { VideoMagnetComponent } from './video-magnet.component'; 9import { VideoMagnetComponent } from './video-magnet.component';
@@ -45,7 +46,8 @@ export class VideoWatchComponent implements OnInit, OnDestroy {
45 private videoService: VideoService, 46 private videoService: VideoService,
46 private metaService: MetaService, 47 private metaService: MetaService,
47 private webTorrentService: WebTorrentService, 48 private webTorrentService: WebTorrentService,
48 private authService: AuthService 49 private authService: AuthService,
50 private notificationsService: NotificationsService
49 ) {} 51 ) {}
50 52
51 ngOnInit() { 53 ngOnInit() {
@@ -117,7 +119,7 @@ export class VideoWatchComponent implements OnInit, OnDestroy {
117 console.log('Added ' + this.video.magnetUri + '.'); 119 console.log('Added ' + this.video.magnetUri + '.');
118 torrent.files[0].renderTo(this.playerElement, { autoplay: true }, (err) => { 120 torrent.files[0].renderTo(this.playerElement, { autoplay: true }, (err) => {
119 if (err) { 121 if (err) {
120 alert('Cannot append the file.'); 122 this.notificationsService.error('Error', 'Cannot append the file in the video element.');
121 console.error(err); 123 console.error(err);
122 } 124 }
123 }); 125 });