aboutsummaryrefslogtreecommitdiffhomepage
path: root/client/src/app/+admin/system/jobs
diff options
context:
space:
mode:
Diffstat (limited to 'client/src/app/+admin/system/jobs')
-rw-r--r--client/src/app/+admin/system/jobs/job.service.ts7
-rw-r--r--client/src/app/+admin/system/jobs/jobs.component.html20
-rw-r--r--client/src/app/+admin/system/jobs/jobs.component.scss18
-rw-r--r--client/src/app/+admin/system/jobs/jobs.component.ts39
4 files changed, 67 insertions, 17 deletions
diff --git a/client/src/app/+admin/system/jobs/job.service.ts b/client/src/app/+admin/system/jobs/job.service.ts
index 1daae8f03..120144dff 100644
--- a/client/src/app/+admin/system/jobs/job.service.ts
+++ b/client/src/app/+admin/system/jobs/job.service.ts
@@ -3,11 +3,12 @@ import { HttpClient, HttpParams } from '@angular/common/http'
3import { Injectable } from '@angular/core' 3import { Injectable } from '@angular/core'
4import { SortMeta } from 'primeng/api' 4import { SortMeta } from 'primeng/api'
5import { Observable } from 'rxjs' 5import { Observable } from 'rxjs'
6import { ResultList } from '../../../../../../shared' 6import { JobType, ResultList } from '../../../../../../shared'
7import { JobState } from '../../../../../../shared/models' 7import { JobState } from '../../../../../../shared/models'
8import { Job } from '../../../../../../shared/models/server/job.model' 8import { Job } from '../../../../../../shared/models/server/job.model'
9import { environment } from '../../../../environments/environment' 9import { environment } from '../../../../environments/environment'
10import { RestExtractor, RestPagination, RestService } from '../../../shared' 10import { RestExtractor, RestPagination, RestService } from '../../../shared'
11import { JobTypeClient } from '../../../../types/job-type-client.type'
11 12
12@Injectable() 13@Injectable()
13export class JobService { 14export class JobService {
@@ -19,10 +20,12 @@ export class JobService {
19 private restExtractor: RestExtractor 20 private restExtractor: RestExtractor
20 ) {} 21 ) {}
21 22
22 getJobs (state: JobState, pagination: RestPagination, sort: SortMeta): Observable<ResultList<Job>> { 23 getJobs (state: JobState, jobType: JobTypeClient, pagination: RestPagination, sort: SortMeta): Observable<ResultList<Job>> {
23 let params = new HttpParams() 24 let params = new HttpParams()
24 params = this.restService.addRestGetParams(params, pagination, sort) 25 params = this.restService.addRestGetParams(params, pagination, sort)
25 26
27 if (jobType !== 'all') params = params.append('jobType', jobType)
28
26 return this.authHttp.get<ResultList<Job>>(JobService.BASE_JOB_URL + '/' + state, { params }) 29 return this.authHttp.get<ResultList<Job>>(JobService.BASE_JOB_URL + '/' + state, { params })
27 .pipe( 30 .pipe(
28 map(res => { 31 map(res => {
diff --git a/client/src/app/+admin/system/jobs/jobs.component.html b/client/src/app/+admin/system/jobs/jobs.component.html
index 7ed1888e2..cd26257dd 100644
--- a/client/src/app/+admin/system/jobs/jobs.component.html
+++ b/client/src/app/+admin/system/jobs/jobs.component.html
@@ -1,10 +1,22 @@
1<div class="admin-sub-header"> 1<div class="admin-sub-header">
2 <div i18n class="form-sub-title">Jobs list</div> 2 <div i18n class="form-sub-title">Jobs list</div>
3 3
4 <div class="peertube-select-container"> 4 <div class="select-filter-block">
5 <select [(ngModel)]="jobState" (ngModelChange)="onJobStateChanged()"> 5 <label for="jobType">Job type</label>
6 <option *ngFor="let state of jobStates" [value]="state">{{ state }}</option> 6 <div class="peertube-select-container">
7 </select> 7 <select id="jobType" name="jobType" [(ngModel)]="jobType" (ngModelChange)="onJobStateOrTypeChanged()">
8 <option *ngFor="let jobType of jobTypes" [value]="jobType">{{ jobType }}</option>
9 </select>
10 </div>
11 </div>
12
13 <div class="select-filter-block">
14 <label for="jobState">Job state</label>
15 <div class="peertube-select-container">
16 <select id="jobState" name="jobState" [(ngModel)]="jobState" (ngModelChange)="onJobStateOrTypeChanged()">
17 <option *ngFor="let state of jobStates" [value]="state">{{ state }}</option>
18 </select>
19 </div>
8 </div> 20 </div>
9</div> 21</div>
10 22
diff --git a/client/src/app/+admin/system/jobs/jobs.component.scss b/client/src/app/+admin/system/jobs/jobs.component.scss
index ab05f1982..ccc0b35ca 100644
--- a/client/src/app/+admin/system/jobs/jobs.component.scss
+++ b/client/src/app/+admin/system/jobs/jobs.component.scss
@@ -1,8 +1,22 @@
1@import '_variables'; 1@import '_variables';
2@import '_mixins'; 2@import '_mixins';
3 3
4.peertube-select-container { 4.admin-sub-header {
5 @include peertube-select-container(auto); 5 align-items: flex-end;
6
7 .select-filter-block {
8 &:not(:last-child) {
9 margin-right: 10px;
10 }
11
12 label {
13 margin-bottom: 2px;
14 }
15
16 .peertube-select-container {
17 @include peertube-select-container(auto);
18 }
19 }
6} 20}
7 21
8pre { 22pre {
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}