"@types/videojs": "0.0.30",
"@types/webpack": "^2.0.0",
"angular-pipes": "^5.0.0",
+ "angular2-notifications": "^0.4.49",
"angular2-template-loader": "^0.6.0",
"assets-webpack-plugin": "^3.4.0",
"awesome-typescript-loader": "~3.0.0-beta.17",
import { FormControl, FormGroup } from '@angular/forms';
import { Router } from '@angular/router';
+import { NotificationsService } from 'angular2-notifications';
+
import { validateHost } from '../../../shared';
import { FriendService } from '../shared';
hosts = [ ];
error: string = null;
- constructor(private router: Router, private friendService: FriendService) {}
+ constructor(
+ private router: Router,
+ private notificationsService: NotificationsService,
+ private friendService: FriendService
+ ) {}
ngOnInit() {
this.form = new FormGroup({});
this.friendService.makeFriends(notEmptyHosts).subscribe(
status => {
- alert('Make friends request sent!');
+ this.notificationsService.success('Sucess', 'Make friends request sent!');
this.router.navigate([ '/admin/friends/list' ]);
},
- error => alert(error.text)
+
+ err => this.notificationsService.error('Error', err.text)
);
}
import { Component, OnInit } from '@angular/core';
+import { NotificationsService } from 'angular2-notifications';
+
import { Friend, FriendService } from '../shared';
@Component({
export class FriendListComponent implements OnInit {
friends: Friend[];
- constructor(private friendService: FriendService) { }
+ constructor(
+ private notificationsService: NotificationsService,
+ private friendService: FriendService
+ ) { }
ngOnInit() {
this.getFriends();
this.friendService.quitFriends().subscribe(
status => {
- alert('Quit friends!');
+ this.notificationsService.success('Sucess', 'Friends left!');
+
this.getFriends();
},
- error => alert(error.text)
+
+ err => this.notificationsService.error('Error', err.text)
);
}
this.friendService.getFriends().subscribe(
res => this.friends = res.friends,
- err => alert(err.text)
+ err => this.notificationsService.error('Error', err.text)
);
}
}
-import { setInterval } from 'timers'
import { Component, OnInit, OnDestroy } from '@angular/core';
+import { NotificationsService } from 'angular2-notifications';
+
import { RequestService, RequestStats } from '../shared';
@Component({
export class RequestStatsComponent implements OnInit, OnDestroy {
stats: RequestStats = null;
- private interval: NodeJS.Timer = null;
+ private interval: number = null;
+ private timeout: number = null;
- constructor(private requestService: RequestService) { }
+ constructor(
+ private notificationsService: NotificationsService,
+ private requestService: RequestService
+ ) { }
ngOnInit() {
this.getStats();
}
ngOnDestroy() {
- if (this.stats !== null && this.stats.secondsInterval !== null) {
- clearInterval(this.interval);
+ if (this.interval !== null) {
+ window.clearInterval(this.interval);
+ }
+
+ if (this.timeout !== null) {
+ window.clearTimeout(this.timeout);
}
}
this.requestService.getStats().subscribe(
stats => this.stats = stats,
- err => alert(err.text)
+ err => this.notificationsService.error('Error', err.text)
);
}
private runInterval() {
- this.interval = setInterval(() => {
+ this.interval = window.setInterval(() => {
this.stats.remainingMilliSeconds -= 1000;
if (this.stats.remainingMilliSeconds <= 0) {
- setTimeout(() => this.getStats(), this.stats.remainingMilliSeconds + 100);
+ this.timeout = window.setTimeout(() => this.getStats(), this.stats.remainingMilliSeconds + 100);
}
}, 1000);
}
import { FormBuilder, FormGroup } from '@angular/forms';
import { Router } from '@angular/router';
+import { NotificationsService } from 'angular2-notifications';
+
import { UserService } from '../shared';
import { FormReactive, USER_USERNAME, USER_PASSWORD } from '../../../shared';
constructor(
private formBuilder: FormBuilder,
private router: Router,
+ private notificationsService: NotificationsService,
private userService: UserService
) {
super();
const { username, password } = this.form.value;
this.userService.addUser(username, password).subscribe(
- ok => this.router.navigate([ '/admin/users/list' ]),
+ () => {
+ this.notificationsService.success('Success', `User ${username} created.`);
+ this.router.navigate([ '/admin/users/list' ]);
+ },
err => this.error = err.text
);
import { Component, OnInit } from '@angular/core';
+import { NotificationsService } from 'angular2-notifications';
+
import { User } from '../../../shared';
import { UserService } from '../shared';
totalUsers: number;
users: User[];
- constructor(private userService: UserService) {}
+ constructor(
+ private notificationsService: NotificationsService,
+ private userService: UserService
+ ) {}
ngOnInit() {
this.getUsers();
this.totalUsers = totalUsers;
},
- err => alert(err.text)
+ err => this.notificationsService.error('Error', err.text)
);
}
removeUser(user: User) {
if (confirm('Are you sure?')) {
this.userService.removeUser(user).subscribe(
- () => this.getUsers(),
+ () => {
+ this.notificationsService.success('Success', `User ${user.username} deleted.`);
+ this.getUsers();
+ },
- err => alert(err.text)
+ err => this.notificationsService.error('Error', err.text)
);
}
}
-import { setInterval } from 'timers'
import { Component, OnInit } from '@angular/core';
+import { NotificationsService } from 'angular2-notifications';
+
import { VideoAbuseService, VideoAbuse} from '../../../shared';
@Component({
export class VideoAbuseListComponent implements OnInit {
videoAbuses: VideoAbuse[];
- constructor(private videoAbuseService: VideoAbuseService) { }
+ constructor(
+ private notificationsService: NotificationsService,
+ private videoAbuseService: VideoAbuseService
+ ) { }
ngOnInit() {
this.getVideoAbuses();
this.videoAbuseService.getVideoAbuses().subscribe(
res => this.videoAbuses = res.videoAbuses,
- err => alert(err.text)
+ err => this.notificationsService.error('Error', err.text)
);
}
}
<h3>Account</h3>
-<div *ngIf="information" class="alert alert-success">{{ information }}</div>
<div *ngIf="error" class="alert alert-danger">{{ error }}</div>
<form role="form" (ngSubmit)="changePassword()" [formGroup]="form">
-import { } from '@angular/common';
import { Component, OnInit } from '@angular/core';
import { FormBuilder, FormGroup } from '@angular/forms';
import { Router } from '@angular/router';
+import { NotificationsService } from 'angular2-notifications';
+
import { AccountService } from './account.service';
import { FormReactive, USER_PASSWORD } from '../shared';
})
export class AccountComponent extends FormReactive implements OnInit {
- information: string = null;
error: string = null;
form: FormGroup;
};
constructor(
- private accountService: AccountService,
private formBuilder: FormBuilder,
- private router: Router
+ private router: Router,
+ private notificationsService: NotificationsService,
+ private accountService: AccountService
) {
super();
}
const newPassword = this.form.value['new-password'];
const newConfirmedPassword = this.form.value['new-confirmed-password'];
- this.information = null;
this.error = null;
if (newPassword !== newConfirmedPassword) {
}
this.accountService.changePassword(newPassword).subscribe(
- ok => this.information = 'Password updated.',
+ () => this.notificationsService.success('Success', 'Password updated.'),
err => this.error = err
);
</div>
</div>
+ <simple-notifications [options]="notificationOptions"></simple-notifications>
+
<footer>
PeerTube, CopyLeft 2015-2016
</footer>
})
export class AppComponent {
+ notificationOptions = {
+ timeOut: 3000,
+ lastOnBottom: true,
+ clickToClose: true,
+ maxLength: 0,
+ maxStack: 7,
+ showProgressBar: false,
+ pauseOnHover: false,
+ preventDuplicates: false,
+ preventLastDuplicates: 'visible',
+ rtl: false
+ };
+
constructor(
private router: Router,
private metaService: MetaService,
import 'rxjs/add/operator/mergeMap';
import 'rxjs/add/observable/throw';
+import { NotificationsService } from 'angular2-notifications';
+
// Do not use the barrel (dependency loop)
import { AuthStatus } from '../../shared/auth/auth-status.model';
import { AuthUser } from '../../shared/auth/auth-user.model';
constructor(
private http: Http,
+ private notificationsService: NotificationsService,
private restExtractor: RestExtractor,
private router: Router
) {
this.clientSecret = result.client_secret;
console.log('Client credentials loaded.');
},
+
error => {
- alert(
- `Cannot retrieve OAuth Client credentials: ${error.text}. \n` +
- 'Ensure you have correctly configured PeerTube (config/ directory), in particular the "webserver" section.'
- );
+ let errorMessage = `Cannot retrieve OAuth Client credentials: ${error.text}. \n`;
+ errorMessage += 'Ensure you have correctly configured PeerTube (config/ directory), in particular the "webserver" section.';
+
+ // We put a bigger timeout
+ // This is an important message
+ this.notificationsService.error('Error', errorMessage, { timeOut: 7000 });
}
);
import { HttpModule } from '@angular/http';
import { RouterModule } from '@angular/router';
+import { SimpleNotificationsModule } from 'angular2-notifications';
+
import { AuthService } from './auth';
import { MenuComponent, MenuAdminComponent } from './menu';
import { throwIfAlreadyLoaded } from './module-import-guard';
imports: [
CommonModule,
HttpModule,
- RouterModule
+ RouterModule,
+
+ SimpleNotificationsModule
],
declarations: [
MenuComponent,
MenuAdminComponent
],
exports: [
+ SimpleNotificationsModule,
+
MenuComponent,
MenuAdminComponent
],
import { Router } from '@angular/router';
import { FileUploader } from 'ng2-file-upload/ng2-file-upload';
+import { NotificationsService } from 'angular2-notifications';
import { AuthService } from '../../core';
import { FormReactive, VIDEO_NAME, VIDEO_DESCRIPTION, VIDEO_TAGS } from '../../shared';
private authService: AuthService,
private elementRef: ElementRef,
private formBuilder: FormBuilder,
- private router: Router
+ private router: Router,
+ private notificationsService: NotificationsService
) {
super();
}
clearInterval(interval);
console.log('Video uploaded.');
+ this.notificationsService.success('Success', 'Video uploaded.');
+
// Print all the videos once it's finished
this.router.navigate(['/videos/list']);
import { ActivatedRoute, Router } from '@angular/router';
import { BehaviorSubject } from 'rxjs/BehaviorSubject';
+import { NotificationsService } from 'angular2-notifications';
+
import {
SortField,
Video,
private subSearch: any;
constructor(
+ private notificationsService: NotificationsService,
private authService: AuthService,
private changeDetector: ChangeDetectorRef,
private router: Router,
this.loading.next(false);
},
- error => alert(error.text)
+ error => this.notificationsService.error('Error', error.text)
);
}
}
onRemoved(video: Video) {
+ this.notificationsService.success('Success', `Video ${video.name} deleted.`);
this.getVideos();
}
import { Component, Input, Output, EventEmitter } from '@angular/core';
+import { NotificationsService } from 'angular2-notifications';
+
import { SortField, Video, VideoService } from '../shared';
import { User } from '../../shared';
hovering = false;
- constructor(private videoService: VideoService) {}
+ constructor(
+ private notificationsService: NotificationsService,
+ private videoService: VideoService
+ ) {}
displayRemoveIcon() {
return this.hovering && this.video.isRemovableBy(this.user);
if (confirm('Do you really want to remove this video?')) {
this.videoService.removeVideo(id).subscribe(
status => this.removed.emit(true),
- error => alert(error.text)
+
+ error => this.notificationsService.error('Error', error.text)
);
}
}
import { FormBuilder, FormGroup } from '@angular/forms';
import { ModalDirective } from 'ng2-bootstrap/modal';
+import { NotificationsService } from 'angular2-notifications';
import { FormReactive, VideoAbuseService, VIDEO_ABUSE_REASON } from '../../shared';
import { Video, VideoService } from '../shared';
constructor(
private formBuilder: FormBuilder,
- private videoAbuseService: VideoAbuseService
+ private videoAbuseService: VideoAbuseService,
+ private notificationsService: NotificationsService
) {
super();
}
this.videoAbuseService.reportVideo(this.video.id, reason)
.subscribe(
- // TODO: move alert to beautiful notifications
- ok => {
- alert('Video reported.');
+ () => {
+ this.notificationsService.success('Success', 'Video reported.');
this.hide();
},
- err => alert(err.text)
+ err => this.notificationsService.error('Error', err.text);
)
}
}
import { Component, ElementRef, NgZone, OnDestroy, OnInit, ViewChild } from '@angular/core';
import { ActivatedRoute } from '@angular/router';
-import { MetaService } from 'ng2-meta';
import * as videojs from 'video.js';
+import { MetaService } from 'ng2-meta';
+import { NotificationsService } from 'angular2-notifications';
import { AuthService } from '../../core';
import { VideoMagnetComponent } from './video-magnet.component';
private videoService: VideoService,
private metaService: MetaService,
private webTorrentService: WebTorrentService,
- private authService: AuthService
+ private authService: AuthService,
+ private notificationsService: NotificationsService
) {}
ngOnInit() {
console.log('Added ' + this.video.magnetUri + '.');
torrent.files[0].renderTo(this.playerElement, { autoplay: true }, (err) => {
if (err) {
- alert('Cannot append the file.');
+ this.notificationsService.error('Error', 'Cannot append the file in the video element.');
console.error(err);
}
});