From 5769e1db8d3d5a1e3baa8dff23090cfe93d48a50 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Fri, 27 Jan 2017 16:54:44 +0100 Subject: Client: better confirm box for a beautiful world --- .../app/videos/video-list/video-miniature.component.ts | 18 ++++++++++++------ .../app/videos/video-watch/video-report.component.ts | 14 +++++++------- 2 files changed, 19 insertions(+), 13 deletions(-) (limited to 'client/src/app/videos') 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 ca4afc451..ba4715597 100644 --- a/client/src/app/videos/video-list/video-miniature.component.ts +++ b/client/src/app/videos/video-list/video-miniature.component.ts @@ -2,6 +2,7 @@ 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'; @@ -22,6 +23,7 @@ export class VideoMiniatureComponent { constructor( private notificationsService: NotificationsService, + private confirmService: ConfirmService, private videoService: VideoService ) {} @@ -38,12 +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), + this.confirmService.confirm('Do you really want to delete this video?', 'Delete').subscribe( + res => { + if (res === false) return; - error => this.notificationsService.error('Error', error.text) - ); - } + this.videoService.removeVideo(id).subscribe( + status => this.removed.emit(true), + + error => this.notificationsService.error('Error', error.text) + ); + } + ); } } 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 19a7af148..7906fdb5c 100644 --- a/client/src/app/videos/video-watch/video-report.component.ts +++ b/client/src/app/videos/video-watch/video-report.component.ts @@ -57,13 +57,13 @@ export class VideoReportComponent extends FormReactive implements OnInit { const reason = this.form.value['reason'] this.videoAbuseService.reportVideo(this.video.id, reason) - .subscribe( - () => { - this.notificationsService.success('Success', 'Video reported.'); - this.hide(); - }, + .subscribe( + () => { + this.notificationsService.success('Success', 'Video reported.'); + this.hide(); + }, - err => this.notificationsService.error('Error', err.text); - ) + err => this.notificationsService.error('Error', err.text) + ); } } -- cgit v1.2.3