diff options
author | Chocobozzz <me@florianbigard.com> | 2018-01-25 15:05:18 +0100 |
---|---|---|
committer | Chocobozzz <me@florianbigard.com> | 2018-01-25 18:41:17 +0100 |
commit | 94a5ff8a4a75d75bb9df542a39ce8769e7a7e6a4 (patch) | |
tree | 32a9148e0e4567f0c4ffae0412cbed20b84e8873 /client/src | |
parent | d765fafc3faf0db9818eb1a07161df1cb1bc0efa (diff) | |
download | PeerTube-94a5ff8a4a75d75bb9df542a39ce8769e7a7e6a4.tar.gz PeerTube-94a5ff8a4a75d75bb9df542a39ce8769e7a7e6a4.tar.zst PeerTube-94a5ff8a4a75d75bb9df542a39ce8769e7a7e6a4.zip |
Move job queue to redis
We'll use it as cache in the future.
/!\ You'll loose your old jobs (pending jobs too) so upgrade only when
you don't have pending job anymore.
Diffstat (limited to 'client/src')
4 files changed, 33 insertions, 11 deletions
diff --git a/client/src/app/+admin/jobs/jobs-list/jobs-list.component.html b/client/src/app/+admin/jobs/jobs-list/jobs-list.component.html index 809155338..f1b14e5e3 100644 --- a/client/src/app/+admin/jobs/jobs-list/jobs-list.component.html +++ b/client/src/app/+admin/jobs/jobs-list/jobs-list.component.html | |||
@@ -1,20 +1,27 @@ | |||
1 | <div class="admin-sub-header"> | 1 | <div class="admin-sub-header"> |
2 | <div class="admin-sub-title">Jobs list</div> | 2 | <div class="admin-sub-title">Jobs list</div> |
3 | |||
4 | <div class="peertube-select-container"> | ||
5 | <select [(ngModel)]="jobState" (ngModelChange)="onJobStateChanged()"> | ||
6 | <option *ngFor="let state of jobStates" [value]="state">{{ state }}</option> | ||
7 | </select> | ||
8 | </div> | ||
3 | </div> | 9 | </div> |
4 | 10 | ||
11 | |||
12 | |||
5 | <p-dataTable | 13 | <p-dataTable |
6 | [value]="jobs" [lazy]="true" [paginator]="true" [totalRecords]="totalRecords" [rows]="rowsPerPage" | 14 | [value]="jobs" [lazy]="true" [paginator]="true" [totalRecords]="totalRecords" [rows]="rowsPerPage" |
7 | sortField="createdAt" (onLazyLoad)="loadLazy($event)" [scrollable]="true" [virtualScroll]="true" [scrollHeight]="scrollHeight" | 15 | sortField="createdAt" (onLazyLoad)="loadLazy($event)" [scrollable]="true" [virtualScroll]="true" [scrollHeight]="scrollHeight" |
8 | > | 16 | > |
9 | <p-column field="id" header="ID" [style]="{ width: '60px' }"></p-column> | 17 | <p-column field="id" header="ID" [style]="{ width: '60px' }"></p-column> |
10 | <p-column field="category" header="Category" [style]="{ width: '130px' }"></p-column> | 18 | <p-column field="type" header="Type" [style]="{ width: '210px' }"></p-column> |
11 | <p-column field="handlerName" header="Handler name" [style]="{ width: '210px' }"></p-column> | 19 | <p-column field="state" header="State" [style]="{ width: '130px' }"></p-column> |
12 | <p-column header="Input data"> | 20 | <p-column header="Payload"> |
13 | <ng-template pTemplate="body" let-job="rowData"> | 21 | <ng-template pTemplate="body" let-job="rowData"> |
14 | <pre>{{ job.handlerInputData }}</pre> | 22 | <pre>{{ job.data }}</pre> |
15 | </ng-template> | 23 | </ng-template> |
16 | </p-column> | 24 | </p-column> |
17 | <p-column field="state" header="State" [style]="{ width: '100px' }"></p-column> | ||
18 | <p-column field="createdAt" header="Created date" [sortable]="true" [style]="{ width: '250px' }"></p-column> | 25 | <p-column field="createdAt" header="Created date" [sortable]="true" [style]="{ width: '250px' }"></p-column> |
19 | <p-column field="updatedAt" header="Updated date" [style]="{ width: '250px' }"></p-column> | 26 | <p-column field="updatedAt" header="Updated date" [style]="{ width: '250px' }"></p-column> |
20 | </p-dataTable> | 27 | </p-dataTable> |
diff --git a/client/src/app/+admin/jobs/jobs-list/jobs-list.component.scss b/client/src/app/+admin/jobs/jobs-list/jobs-list.component.scss index 47c01f64a..5c2ad21f2 100644 --- a/client/src/app/+admin/jobs/jobs-list/jobs-list.component.scss +++ b/client/src/app/+admin/jobs/jobs-list/jobs-list.component.scss | |||
@@ -1,3 +1,10 @@ | |||
1 | @import '_variables'; | ||
2 | @import '_mixins'; | ||
3 | |||
4 | .peertube-select-container { | ||
5 | @include peertube-select-container(auto); | ||
6 | } | ||
7 | |||
1 | pre { | 8 | pre { |
2 | font-size: 11px; | 9 | font-size: 11px; |
3 | } | 10 | } |
diff --git a/client/src/app/+admin/jobs/jobs-list/jobs-list.component.ts b/client/src/app/+admin/jobs/jobs-list/jobs-list.component.ts index f93847f29..7de6f70d2 100644 --- a/client/src/app/+admin/jobs/jobs-list/jobs-list.component.ts +++ b/client/src/app/+admin/jobs/jobs-list/jobs-list.component.ts | |||
@@ -2,6 +2,7 @@ import { Component, OnInit } from '@angular/core' | |||
2 | import { NotificationsService } from 'angular2-notifications' | 2 | import { NotificationsService } from 'angular2-notifications' |
3 | import { SortMeta } from 'primeng/primeng' | 3 | import { SortMeta } from 'primeng/primeng' |
4 | import { Job } from '../../../../../../shared/index' | 4 | import { Job } from '../../../../../../shared/index' |
5 | import { JobState } from '../../../../../../shared/models' | ||
5 | import { RestPagination, RestTable } from '../../../shared' | 6 | import { RestPagination, RestTable } from '../../../shared' |
6 | import { viewportHeight } from '../../../shared/misc/utils' | 7 | import { viewportHeight } from '../../../shared/misc/utils' |
7 | import { JobService } from '../shared' | 8 | import { JobService } from '../shared' |
@@ -13,10 +14,12 @@ import { RestExtractor } from '../../../shared/rest/rest-extractor.service' | |||
13 | styleUrls: [ './jobs-list.component.scss' ] | 14 | styleUrls: [ './jobs-list.component.scss' ] |
14 | }) | 15 | }) |
15 | export class JobsListComponent extends RestTable implements OnInit { | 16 | export class JobsListComponent extends RestTable implements OnInit { |
17 | jobState: JobState = 'inactive' | ||
18 | jobStates: JobState[] = [ 'active', 'complete', 'failed', 'inactive', 'delayed' ] | ||
16 | jobs: Job[] = [] | 19 | jobs: Job[] = [] |
17 | totalRecords = 0 | 20 | totalRecords = 0 |
18 | rowsPerPage = 20 | 21 | rowsPerPage = 20 |
19 | sort: SortMeta = { field: 'createdAt', order: 1 } | 22 | sort: SortMeta = { field: 'createdAt', order: -1 } |
20 | pagination: RestPagination = { count: this.rowsPerPage, start: 0 } | 23 | pagination: RestPagination = { count: this.rowsPerPage, start: 0 } |
21 | scrollHeight = '' | 24 | scrollHeight = '' |
22 | 25 | ||
@@ -33,9 +36,13 @@ export class JobsListComponent extends RestTable implements OnInit { | |||
33 | this.scrollHeight = (viewportHeight() - 380) + 'px' | 36 | this.scrollHeight = (viewportHeight() - 380) + 'px' |
34 | } | 37 | } |
35 | 38 | ||
39 | onJobStateChanged () { | ||
40 | this.loadData() | ||
41 | } | ||
42 | |||
36 | protected loadData () { | 43 | protected loadData () { |
37 | this.jobsService | 44 | this.jobsService |
38 | .getJobs(this.pagination, this.sort) | 45 | .getJobs(this.jobState, this.pagination, this.sort) |
39 | .subscribe( | 46 | .subscribe( |
40 | resultList => { | 47 | resultList => { |
41 | this.jobs = resultList.data | 48 | this.jobs = resultList.data |
diff --git a/client/src/app/+admin/jobs/shared/job.service.ts b/client/src/app/+admin/jobs/shared/job.service.ts index 61ee16077..a19d278c9 100644 --- a/client/src/app/+admin/jobs/shared/job.service.ts +++ b/client/src/app/+admin/jobs/shared/job.service.ts | |||
@@ -5,6 +5,7 @@ import 'rxjs/add/operator/catch' | |||
5 | import 'rxjs/add/operator/map' | 5 | import 'rxjs/add/operator/map' |
6 | import { Observable } from 'rxjs/Observable' | 6 | import { Observable } from 'rxjs/Observable' |
7 | import { ResultList } from '../../../../../../shared' | 7 | import { ResultList } from '../../../../../../shared' |
8 | import { JobState } from '../../../../../../shared/models' | ||
8 | import { Job } from '../../../../../../shared/models/job.model' | 9 | import { Job } from '../../../../../../shared/models/job.model' |
9 | import { environment } from '../../../../environments/environment' | 10 | import { environment } from '../../../../environments/environment' |
10 | import { RestExtractor, RestPagination, RestService } from '../../../shared' | 11 | import { RestExtractor, RestPagination, RestService } from '../../../shared' |
@@ -19,19 +20,19 @@ export class JobService { | |||
19 | private restExtractor: RestExtractor | 20 | private restExtractor: RestExtractor |
20 | ) {} | 21 | ) {} |
21 | 22 | ||
22 | getJobs (pagination: RestPagination, sort: SortMeta): Observable<ResultList<Job>> { | 23 | getJobs (state: JobState, 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 | ||
26 | return this.authHttp.get<ResultList<Job>>(JobService.BASE_JOB_URL, { params }) | 27 | return this.authHttp.get<ResultList<Job>>(JobService.BASE_JOB_URL + '/' + state, { params }) |
27 | .map(res => this.restExtractor.convertResultListDateToHuman(res)) | 28 | .map(res => this.restExtractor.convertResultListDateToHuman(res)) |
28 | .map(res => this.restExtractor.applyToResultListData(res, this.prettyPrintData)) | 29 | .map(res => this.restExtractor.applyToResultListData(res, this.prettyPrintData)) |
29 | .catch(err => this.restExtractor.handleError(err)) | 30 | .catch(err => this.restExtractor.handleError(err)) |
30 | } | 31 | } |
31 | 32 | ||
32 | private prettyPrintData (obj: Job) { | 33 | private prettyPrintData (obj: Job) { |
33 | const handlerInputData = JSON.stringify(obj.handlerInputData, null, 2) | 34 | const data = JSON.stringify(obj.data, null, 2) |
34 | 35 | ||
35 | return Object.assign(obj, { handlerInputData }) | 36 | return Object.assign(obj, { data }) |
36 | } | 37 | } |
37 | } | 38 | } |