]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blobdiff - client/src/app/account/account-videos/account-videos.component.ts
Add hover effect to buttons
[github/Chocobozzz/PeerTube.git] / client / src / app / account / account-videos / account-videos.component.ts
index 1bc6c0a358e1c56846f66969ba422c5eb3514304..9c2cc24045a06adcaf6f8a1b9df64a04b96b3b9e 100644 (file)
@@ -1,7 +1,9 @@
 import { Component, OnInit } from '@angular/core'
 import { ActivatedRoute, Router } from '@angular/router'
 import { NotificationsService } from 'angular2-notifications'
+import { ConfirmService } from '../../core/confirm'
 import { AbstractVideoList } from '../../shared/video/abstract-video-list'
+import { Video } from '../../shared/video/video.model'
 import { VideoService } from '../../shared/video/video.service'
 
 @Component({
@@ -16,6 +18,7 @@ export class AccountVideosComponent extends AbstractVideoList implements OnInit
   constructor (protected router: Router,
                protected route: ActivatedRoute,
                protected notificationsService: NotificationsService,
+               protected confirmService: ConfirmService,
                private videoService: VideoService) {
     super()
   }
@@ -27,4 +30,23 @@ export class AccountVideosComponent extends AbstractVideoList implements OnInit
   getVideosObservable () {
     return this.videoService.getMyVideos(this.pagination, this.sort)
   }
+
+  deleteVideo (video: Video) {
+    this.confirmService.confirm(`Do you really want to delete ${video.name}?`, 'Delete').subscribe(
+      res => {
+        if (res === false) return
+
+        this.videoService.removeVideo(video.id)
+          .subscribe(
+            status => {
+              this.notificationsService.success('Success', `Video ${video.name} deleted.`)
+              const index = this.videos.findIndex(v => v.id === video.id)
+              this.videos.splice(index, 1)
+            },
+
+            error => this.notificationsService.error('Error', error.text)
+          )
+      }
+    )
+  }
 }