From 7ddd02c9b8c1e088f6679a2227f105e6439fc992 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Fri, 27 Jan 2017 16:14:11 +0100 Subject: Client: better notifications for a beautiful world --- client/src/app/videos/video-list/video-list.component.ts | 6 +++++- client/src/app/videos/video-list/video-miniature.component.ts | 10 ++++++++-- 2 files changed, 13 insertions(+), 3 deletions(-) (limited to 'client/src/app/videos/video-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'; import { ActivatedRoute, Router } from '@angular/router'; import { BehaviorSubject } from 'rxjs/BehaviorSubject'; +import { NotificationsService } from 'angular2-notifications'; + import { SortField, Video, @@ -33,6 +35,7 @@ export class VideoListComponent implements OnInit, OnDestroy { private subSearch: any; constructor( + private notificationsService: NotificationsService, private authService: AuthService, private changeDetector: ChangeDetectorRef, private router: Router, @@ -91,7 +94,7 @@ export class VideoListComponent implements OnInit, OnDestroy { this.loading.next(false); }, - error => alert(error.text) + error => this.notificationsService.error('Error', error.text) ); } @@ -107,6 +110,7 @@ export class VideoListComponent implements OnInit, OnDestroy { } onRemoved(video: Video) { + this.notificationsService.success('Success', `Video ${video.name} deleted.`); this.getVideos(); } 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 @@ import { Component, Input, Output, EventEmitter } from '@angular/core'; +import { NotificationsService } from 'angular2-notifications'; + import { SortField, Video, VideoService } from '../shared'; import { User } from '../../shared'; @@ -18,7 +20,10 @@ export class VideoMiniatureComponent { hovering = false; - constructor(private videoService: VideoService) {} + constructor( + private notificationsService: NotificationsService, + private videoService: VideoService + ) {} displayRemoveIcon() { return this.hovering && this.video.isRemovableBy(this.user); @@ -36,7 +41,8 @@ export class VideoMiniatureComponent { 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) ); } } -- cgit v1.2.3