]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/commitdiff
Add ability to remove a video on watch page
authorChocobozzz <me@florianbigard.com>
Wed, 20 Dec 2017 16:53:58 +0000 (17:53 +0100)
committerChocobozzz <me@florianbigard.com>
Wed, 20 Dec 2017 16:53:58 +0000 (17:53 +0100)
client/src/app/videos/+video-watch/video-watch.component.html
client/src/app/videos/+video-watch/video-watch.component.ts

index e3214a331be56b89694ceeed17ea051d272d92f9..e9ca336dd41a5f81ea897640c5dc78b4e501673f 100644 (file)
                   <span class="icon icon-blacklist"></span> Blacklist
                 </a>
               </li>
+
+              <li *ngIf="isVideoRemovable()" role="menuitem">
+                <a class="dropdown-item" title="Delete this video" href="#" (click)="removeVideo($event)">
+                  <span class="icon icon-blacklist"></span> Delete
+                </a>
+              </li>
             </ul>
           </div>
         </div>
index adb698e99ac9149710356298c5920fda8e23a9e7..df4cfa66687b9c2a48f36097867323036fd3b476 100644 (file)
@@ -221,6 +221,32 @@ export class VideoWatchComponent implements OnInit, OnDestroy {
     return this.video.tags.join(', ')
   }
 
+  isVideoRemovable () {
+    return this.video.isRemovableBy(this.authService.getUser())
+  }
+
+  removeVideo (event: Event) {
+    event.preventDefault()
+
+    this.confirmService.confirm('Do you really want to delete this video?', 'Delete').subscribe(
+      res => {
+        if (res === false) return
+
+        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' ])
+            },
+
+            error => this.notificationsService.error('Error', error.text)
+          )
+      }
+    )
+  }
+
   private updateVideoDescription (description: string) {
     this.video.description = description
     this.setVideoDescriptionHTML()