aboutsummaryrefslogtreecommitdiffhomepage
path: root/client/src/app/account/account-videos/account-videos.component.ts
diff options
context:
space:
mode:
Diffstat (limited to 'client/src/app/account/account-videos/account-videos.component.ts')
-rw-r--r--client/src/app/account/account-videos/account-videos.component.ts22
1 files changed, 22 insertions, 0 deletions
diff --git a/client/src/app/account/account-videos/account-videos.component.ts b/client/src/app/account/account-videos/account-videos.component.ts
index 1bc6c0a35..9c2cc2404 100644
--- a/client/src/app/account/account-videos/account-videos.component.ts
+++ b/client/src/app/account/account-videos/account-videos.component.ts
@@ -1,7 +1,9 @@
1import { Component, OnInit } from '@angular/core' 1import { Component, OnInit } from '@angular/core'
2import { ActivatedRoute, Router } from '@angular/router' 2import { ActivatedRoute, Router } from '@angular/router'
3import { NotificationsService } from 'angular2-notifications' 3import { NotificationsService } from 'angular2-notifications'
4import { ConfirmService } from '../../core/confirm'
4import { AbstractVideoList } from '../../shared/video/abstract-video-list' 5import { AbstractVideoList } from '../../shared/video/abstract-video-list'
6import { Video } from '../../shared/video/video.model'
5import { VideoService } from '../../shared/video/video.service' 7import { VideoService } from '../../shared/video/video.service'
6 8
7@Component({ 9@Component({
@@ -16,6 +18,7 @@ export class AccountVideosComponent extends AbstractVideoList implements OnInit
16 constructor (protected router: Router, 18 constructor (protected router: Router,
17 protected route: ActivatedRoute, 19 protected route: ActivatedRoute,
18 protected notificationsService: NotificationsService, 20 protected notificationsService: NotificationsService,
21 protected confirmService: ConfirmService,
19 private videoService: VideoService) { 22 private videoService: VideoService) {
20 super() 23 super()
21 } 24 }
@@ -27,4 +30,23 @@ export class AccountVideosComponent extends AbstractVideoList implements OnInit
27 getVideosObservable () { 30 getVideosObservable () {
28 return this.videoService.getMyVideos(this.pagination, this.sort) 31 return this.videoService.getMyVideos(this.pagination, this.sort)
29 } 32 }
33
34 deleteVideo (video: Video) {
35 this.confirmService.confirm(`Do you really want to delete ${video.name}?`, 'Delete').subscribe(
36 res => {
37 if (res === false) return
38
39 this.videoService.removeVideo(video.id)
40 .subscribe(
41 status => {
42 this.notificationsService.success('Success', `Video ${video.name} deleted.`)
43 const index = this.videos.findIndex(v => v.id === video.id)
44 this.videos.splice(index, 1)
45 },
46
47 error => this.notificationsService.error('Error', error.text)
48 )
49 }
50 )
51 }
30} 52}