]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blobdiff - client/src/app/+admin/overview/videos/video-list.component.ts
Add ability to run transcoding jobs
[github/Chocobozzz/PeerTube.git] / client / src / app / +admin / overview / videos / video-list.component.ts
index 3c21adb44c8dd8bc346aff8b4cce4cd1ec7927cc..4aed5221b394fac3e363bee798fbec2782b9f3ca 100644 (file)
@@ -40,7 +40,8 @@ export class VideoListComponent extends RestTable implements OnInit {
     duplicate: true,
     mute: true,
     liveInfo: false,
-    removeFiles: true
+    removeFiles: true,
+    transcoding: true
   }
 
   loading = true
@@ -89,16 +90,28 @@ export class VideoListComponent extends RestTable implements OnInit {
         }
       ],
       [
+        {
+          label: $localize`Run HLS transcoding`,
+          handler: videos => this.runTranscoding(videos, 'hls'),
+          isDisplayed: videos => videos.every(v => v.canRunTranscoding(this.authUser)),
+          iconName: 'cog'
+        },
+        {
+          label: $localize`Run WebTorrent transcoding`,
+          handler: videos => this.runTranscoding(videos, 'webtorrent'),
+          isDisplayed: videos => videos.every(v => v.canRunTranscoding(this.authUser)),
+          iconName: 'cog'
+        },
         {
           label: $localize`Delete HLS files`,
           handler: videos => this.removeVideoFiles(videos, 'hls'),
-          isDisplayed: videos => this.authUser.hasRight(UserRight.MANAGE_VIDEO_FILES) && videos.every(v => v.hasHLS() && v.hasWebTorrent()),
+          isDisplayed: videos => videos.every(v => v.canRemoveFiles(this.authUser)),
           iconName: 'delete'
         },
         {
           label: $localize`Delete WebTorrent files`,
           handler: videos => this.removeVideoFiles(videos, 'webtorrent'),
-          isDisplayed: videos => this.authUser.hasRight(UserRight.MANAGE_VIDEO_FILES) && videos.every(v => v.hasHLS() && v.hasWebTorrent()),
+          isDisplayed: videos => videos.every(v => v.canRemoveFiles(this.authUser)),
           iconName: 'delete'
         }
       ]
@@ -226,4 +239,17 @@ export class VideoListComponent extends RestTable implements OnInit {
         error: err => this.notifier.error(err.message)
       })
   }
+
+  private runTranscoding (videos: Video[], type: 'hls' | 'webtorrent') {
+    this.videoService.runTranscoding(videos.map(v => v.id), type)
+      .subscribe({
+        next: () => {
+          this.notifier.success($localize`Transcoding jobs created.`)
+
+          this.reloadData()
+        },
+
+        error: err => this.notifier.error(err.message)
+      })
+  }
 }