]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blobdiff - client/src/app/+admin/system/jobs/jobs.component.ts
Fix broken player on live reload
[github/Chocobozzz/PeerTube.git] / client / src / app / +admin / system / jobs / jobs.component.ts
index 602362fe91694420fd5b0221ef74ef45d6aeb27c..d5da1b743a835f4f4fe4abf2f4b3534c117fc074 100644 (file)
@@ -16,24 +16,35 @@ export class JobsComponent extends RestTable implements OnInit {
   private static LOCAL_STORAGE_STATE = 'jobs-list-state'
   private static LOCAL_STORAGE_TYPE = 'jobs-list-type'
 
-  jobState: JobStateClient = 'waiting'
+  jobState?: JobStateClient | 'all'
   jobStates: JobStateClient[] = [ 'active', 'completed', 'failed', 'waiting', 'delayed' ]
 
   jobType: JobTypeClient = 'all'
   jobTypes: JobTypeClient[] = [
     'all',
+
+    'activitypub-cleaner',
     'activitypub-follow',
+    'activitypub-http-broadcast-parallel',
     'activitypub-http-broadcast',
     'activitypub-http-fetcher',
     'activitypub-http-unicast',
+    'activitypub-refresher',
+    'actor-keys',
+    'after-video-channel-import',
     'email',
-    'video-transcoding',
+    'federate-video',
+    'manage-video-torrent',
+    'move-to-object-storage',
+    'notify',
+    'video-channel-import',
     'video-file-import',
     'video-import',
-    'videos-views',
-    'activitypub-refresher',
     'video-live-ending',
-    'video-redundancy'
+    'video-redundancy',
+    'video-studio-edition',
+    'video-transcoding',
+    'videos-views-stats'
   ]
 
   jobs: Job[] = []
@@ -44,7 +55,7 @@ export class JobsComponent extends RestTable implements OnInit {
   constructor (
     private notifier: Notifier,
     private jobsService: JobService
-    ) {
+  ) {
     super()
   }
 
@@ -72,24 +83,61 @@ export class JobsComponent extends RestTable implements OnInit {
     }
   }
 
+  getColspan () {
+    if (this.jobState === 'all' && this.hasGlobalProgress()) return 7
+
+    if (this.jobState === 'all' || this.hasGlobalProgress()) return 6
+
+    return 5
+  }
+
   onJobStateOrTypeChanged () {
     this.pagination.start = 0
 
-    this.loadData()
+    this.reloadData()
     this.saveJobStateAndType()
   }
 
-  protected loadData () {
+  hasGlobalProgress () {
+    return this.jobType === 'all' || this.jobType === 'video-transcoding'
+  }
+
+  hasProgress (job: Job) {
+    return job.type === 'video-transcoding'
+  }
+
+  getProgress (job: Job) {
+    if (job.state === 'active') return job.progress + '%'
+
+    return ''
+  }
+
+  refresh () {
+    this.jobs = []
+    this.totalRecords = 0
+
+    this.reloadData()
+  }
+
+  protected reloadData () {
+    let jobState = this.jobState as JobState
+    if (this.jobState === 'all') jobState = null
+
     this.jobsService
-      .getJobs(this.jobState, this.jobType, this.pagination, this.sort)
-      .subscribe(
-        resultList => {
+      .getJobs({
+        jobState,
+        jobType: this.jobType,
+        pagination: this.pagination,
+        sort: this.sort
+      })
+      .subscribe({
+        next: resultList => {
           this.jobs = resultList.data
           this.totalRecords = resultList.total
         },
 
-        err => this.notifier.error(err.message)
-      )
+        error: err => this.notifier.error(err.message)
+      })
   }
 
   private loadJobStateAndType () {