aboutsummaryrefslogtreecommitdiffhomepage
path: root/client/src/app/+admin/system/jobs/jobs.component.ts
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2019-12-04 14:49:59 +0100
committerChocobozzz <me@florianbigard.com>2019-12-04 14:49:59 +0100
commit1061c73fde3005100ead8764eacb444f240440d6 (patch)
tree0a548d7f0a9a548a52adf6d702dd589b04cd5ab0 /client/src/app/+admin/system/jobs/jobs.component.ts
parent44df5c755c31798e64eba1ec41dd7e2d7ef50e56 (diff)
downloadPeerTube-1061c73fde3005100ead8764eacb444f240440d6.tar.gz
PeerTube-1061c73fde3005100ead8764eacb444f240440d6.tar.zst
PeerTube-1061c73fde3005100ead8764eacb444f240440d6.zip
Add ability to filter per job type
Diffstat (limited to 'client/src/app/+admin/system/jobs/jobs.component.ts')
-rw-r--r--client/src/app/+admin/system/jobs/jobs.component.ts39
1 files changed, 30 insertions, 9 deletions
diff --git a/client/src/app/+admin/system/jobs/jobs.component.ts b/client/src/app/+admin/system/jobs/jobs.component.ts
index b24353ca6..95ee17023 100644
--- a/client/src/app/+admin/system/jobs/jobs.component.ts
+++ b/client/src/app/+admin/system/jobs/jobs.component.ts
@@ -2,11 +2,12 @@ import { Component, OnInit } from '@angular/core'
2import { peertubeLocalStorage } from '@app/shared/misc/peertube-local-storage' 2import { peertubeLocalStorage } from '@app/shared/misc/peertube-local-storage'
3import { Notifier } from '@app/core' 3import { Notifier } from '@app/core'
4import { SortMeta } from 'primeng/api' 4import { SortMeta } from 'primeng/api'
5import { Job } from '../../../../../../shared/index' 5import { Job, JobType } from '../../../../../../shared/index'
6import { JobState } from '../../../../../../shared/models' 6import { JobState } from '../../../../../../shared/models'
7import { RestPagination, RestTable } from '../../../shared' 7import { RestPagination, RestTable } from '../../../shared'
8import { JobService } from './job.service' 8import { JobService } from './job.service'
9import { I18n } from '@ngx-translate/i18n-polyfill' 9import { I18n } from '@ngx-translate/i18n-polyfill'
10import { JobTypeClient } from '../../../../types/job-type-client.type'
10 11
11@Component({ 12@Component({
12 selector: 'my-jobs', 13 selector: 'my-jobs',
@@ -15,9 +16,26 @@ import { I18n } from '@ngx-translate/i18n-polyfill'
15}) 16})
16export class JobsComponent extends RestTable implements OnInit { 17export class JobsComponent extends RestTable implements OnInit {
17 private static JOB_STATE_LOCAL_STORAGE_STATE = 'jobs-list-state' 18 private static JOB_STATE_LOCAL_STORAGE_STATE = 'jobs-list-state'
19 private static JOB_STATE_LOCAL_STORAGE_TYPE = 'jobs-list-type'
18 20
19 jobState: JobState = 'waiting' 21 jobState: JobState = 'waiting'
20 jobStates: JobState[] = [ 'active', 'completed', 'failed', 'waiting', 'delayed' ] 22 jobStates: JobState[] = [ 'active', 'completed', 'failed', 'waiting', 'delayed' ]
23
24 jobType: JobTypeClient = 'all'
25 jobTypes: JobTypeClient[] = [
26 'all',
27 'activitypub-follow',
28 'activitypub-http-broadcast',
29 'activitypub-http-fetcher',
30 'activitypub-http-unicast',
31 'email',
32 'video-transcoding',
33 'video-file-import',
34 'video-import',
35 'videos-views',
36 'activitypub-refresher'
37 ]
38
21 jobs: Job[] = [] 39 jobs: Job[] = []
22 totalRecords: number 40 totalRecords: number
23 rowsPerPage = 10 41 rowsPerPage = 10
@@ -33,20 +51,20 @@ export class JobsComponent extends RestTable implements OnInit {
33 } 51 }
34 52
35 ngOnInit () { 53 ngOnInit () {
36 this.loadJobState() 54 this.loadJobStateAndType()
37 this.initialize() 55 this.initialize()
38 } 56 }
39 57
40 onJobStateChanged () { 58 onJobStateOrTypeChanged () {
41 this.pagination.start = 0 59 this.pagination.start = 0
42 60
43 this.loadData() 61 this.loadData()
44 this.saveJobState() 62 this.saveJobStateAndType()
45 } 63 }
46 64
47 protected loadData () { 65 protected loadData () {
48 this.jobsService 66 this.jobsService
49 .getJobs(this.jobState, this.pagination, this.sort) 67 .getJobs(this.jobState, this.jobType, this.pagination, this.sort)
50 .subscribe( 68 .subscribe(
51 resultList => { 69 resultList => {
52 this.jobs = resultList.data 70 this.jobs = resultList.data
@@ -57,13 +75,16 @@ export class JobsComponent extends RestTable implements OnInit {
57 ) 75 )
58 } 76 }
59 77
60 private loadJobState () { 78 private loadJobStateAndType () {
61 const result = peertubeLocalStorage.getItem(JobsComponent.JOB_STATE_LOCAL_STORAGE_STATE) 79 const state = peertubeLocalStorage.getItem(JobsComponent.JOB_STATE_LOCAL_STORAGE_STATE)
80 if (state) this.jobState = state as JobState
62 81
63 if (result) this.jobState = result as JobState 82 const type = peertubeLocalStorage.getItem(JobsComponent.JOB_STATE_LOCAL_STORAGE_TYPE)
83 if (type) this.jobType = type as JobType
64 } 84 }
65 85
66 private saveJobState () { 86 private saveJobStateAndType () {
67 peertubeLocalStorage.setItem(JobsComponent.JOB_STATE_LOCAL_STORAGE_STATE, this.jobState) 87 peertubeLocalStorage.setItem(JobsComponent.JOB_STATE_LOCAL_STORAGE_STATE, this.jobState)
88 peertubeLocalStorage.setItem(JobsComponent.JOB_STATE_LOCAL_STORAGE_TYPE, this.jobType)
68 } 89 }
69} 90}