From 1f30a1853e38c20a45722dbd6d38aaaec63839e8 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Thu, 22 Feb 2018 15:29:32 +0100 Subject: Add confirm when admin use custom js/css --- .../videos/+video-watch/video-watch.component.ts | 51 ++++++++++------------ 1 file changed, 22 insertions(+), 29 deletions(-) (limited to 'client/src/app/videos/+video-watch/video-watch.component.ts') 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 6b118b1de..d04d50310 100644 --- a/client/src/app/videos/+video-watch/video-watch.component.ts +++ b/client/src/app/videos/+video-watch/video-watch.component.ts @@ -130,24 +130,21 @@ export class VideoWatchComponent implements OnInit, OnDestroy { } } - blacklistVideo (event: Event) { + async blacklistVideo (event: Event) { event.preventDefault() - this.confirmService.confirm('Do you really want to blacklist this video?', 'Blacklist').subscribe( - res => { - if (res === false) return + const res = await this.confirmService.confirm('Do you really want to blacklist this video?', 'Blacklist') + if (res === false) return - this.videoBlacklistService.blacklistVideo(this.video.id) - .subscribe( - status => { - this.notificationsService.success('Success', `Video ${this.video.name} had been blacklisted.`) - this.router.navigate(['/videos/list']) - }, + this.videoBlacklistService.blacklistVideo(this.video.id) + .subscribe( + status => { + this.notificationsService.success('Success', `Video ${this.video.name} had been blacklisted.`) + this.router.navigate(['/videos/list']) + }, - error => this.notificationsService.error('Error', error.message) - ) - } - ) + error => this.notificationsService.error('Error', error.message) + ) } showMoreDescription () { @@ -236,26 +233,22 @@ export class VideoWatchComponent implements OnInit, OnDestroy { return this.video.isRemovableBy(this.authService.getUser()) } - removeVideo (event: Event) { + async removeVideo (event: Event) { event.preventDefault() - this.confirmService.confirm('Do you really want to delete this video?', 'Delete') - .subscribe( - res => { - if (res === false) return + const res = await this.confirmService.confirm('Do you really want to delete this video?', 'Delete') + if (res === false) return - this.videoService.removeVideo(this.video.id) - .subscribe( - status => { - this.notificationsService.success('Success', `Video ${this.video.name} deleted.`) + this.videoService.removeVideo(this.video.id) + .subscribe( + status => { + this.notificationsService.success('Success', `Video ${this.video.name} deleted.`) - // Go back to the video-list. - this.router.navigate([ '/videos/list' ]) - }, + // Go back to the video-list. + this.router.navigate([ '/videos/list' ]) + }, - error => this.notificationsService.error('Error', error.message) - ) - } + error => this.notificationsService.error('Error', error.message) ) } -- cgit v1.2.3