diff options
Diffstat (limited to 'client/src/app/+admin/system/jobs/jobs.component.ts')
-rw-r--r-- | client/src/app/+admin/system/jobs/jobs.component.ts | 39 |
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' | |||
2 | import { peertubeLocalStorage } from '@app/shared/misc/peertube-local-storage' | 2 | import { peertubeLocalStorage } from '@app/shared/misc/peertube-local-storage' |
3 | import { Notifier } from '@app/core' | 3 | import { Notifier } from '@app/core' |
4 | import { SortMeta } from 'primeng/api' | 4 | import { SortMeta } from 'primeng/api' |
5 | import { Job } from '../../../../../../shared/index' | 5 | import { Job, JobType } from '../../../../../../shared/index' |
6 | import { JobState } from '../../../../../../shared/models' | 6 | import { JobState } from '../../../../../../shared/models' |
7 | import { RestPagination, RestTable } from '../../../shared' | 7 | import { RestPagination, RestTable } from '../../../shared' |
8 | import { JobService } from './job.service' | 8 | import { JobService } from './job.service' |
9 | import { I18n } from '@ngx-translate/i18n-polyfill' | 9 | import { I18n } from '@ngx-translate/i18n-polyfill' |
10 | import { 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 | }) |
16 | export class JobsComponent extends RestTable implements OnInit { | 17 | export 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 | } |