X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=client%2Fsrc%2Fapp%2Fvideos%2Fvideo-list%2Fvideo-miniature.component.ts;h=ba47155972a08d2b24cce7290b488b9da3a2342d;hb=e2a2d6c86c7ca39074fdff3b545947d1d58dc008;hp=38317f8320b20668dc399f81f45a59b010a4044d;hpb=ab32b0fc805b92c5a1d7ac5901cb1a38e94622ca;p=github%2FChocobozzz%2FPeerTube.git 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 38317f832..ba4715597 100644 --- a/client/src/app/videos/video-list/video-miniature.component.ts +++ b/client/src/app/videos/video-list/video-miniature.component.ts @@ -1,12 +1,15 @@ import { Component, Input, Output, EventEmitter } from '@angular/core'; +import { NotificationsService } from 'angular2-notifications'; + +import { ConfirmService } from '../../core'; import { SortField, Video, VideoService } from '../shared'; import { User } from '../../shared'; @Component({ selector: 'my-video-miniature', - styles: [ require('./video-miniature.component.scss') ], - template: require('./video-miniature.component.html') + styleUrls: [ './video-miniature.component.scss' ], + templateUrl: './video-miniature.component.html' }) export class VideoMiniatureComponent { @@ -18,7 +21,11 @@ export class VideoMiniatureComponent { hovering = false; - constructor(private videoService: VideoService) {} + constructor( + private notificationsService: NotificationsService, + private confirmService: ConfirmService, + private videoService: VideoService + ) {} displayRemoveIcon() { return this.hovering && this.video.isRemovableBy(this.user); @@ -33,11 +40,16 @@ export class VideoMiniatureComponent { } removeVideo(id: string) { - if (confirm('Do you really want to remove this video?')) { - this.videoService.removeVideo(id).subscribe( - status => this.removed.emit(true), - error => alert(error) - ); - } + this.confirmService.confirm('Do you really want to delete this video?', 'Delete').subscribe( + res => { + if (res === false) return; + + this.videoService.removeVideo(id).subscribe( + status => this.removed.emit(true), + + error => this.notificationsService.error('Error', error.text) + ); + } + ); } }