From 94a5ff8a4a75d75bb9df542a39ce8769e7a7e6a4 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Thu, 25 Jan 2018 15:05:18 +0100 Subject: 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. --- .../app/+admin/jobs/jobs-list/jobs-list.component.html | 17 ++++++++++++----- .../app/+admin/jobs/jobs-list/jobs-list.component.scss | 7 +++++++ .../app/+admin/jobs/jobs-list/jobs-list.component.ts | 11 +++++++++-- client/src/app/+admin/jobs/shared/job.service.ts | 9 +++++---- 4 files changed, 33 insertions(+), 11 deletions(-) (limited to 'client/src/app/+admin/jobs') 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 @@
Jobs list
+ +
+ +
+ + - - - + + + -
{{ job.handlerInputData }}
+
{{ job.data }}
-
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 @@ +@import '_variables'; +@import '_mixins'; + +.peertube-select-container { + @include peertube-select-container(auto); +} + pre { font-size: 11px; } 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' import { NotificationsService } from 'angular2-notifications' import { SortMeta } from 'primeng/primeng' import { Job } from '../../../../../../shared/index' +import { JobState } from '../../../../../../shared/models' import { RestPagination, RestTable } from '../../../shared' import { viewportHeight } from '../../../shared/misc/utils' import { JobService } from '../shared' @@ -13,10 +14,12 @@ import { RestExtractor } from '../../../shared/rest/rest-extractor.service' styleUrls: [ './jobs-list.component.scss' ] }) export class JobsListComponent extends RestTable implements OnInit { + jobState: JobState = 'inactive' + jobStates: JobState[] = [ 'active', 'complete', 'failed', 'inactive', 'delayed' ] jobs: Job[] = [] totalRecords = 0 rowsPerPage = 20 - sort: SortMeta = { field: 'createdAt', order: 1 } + sort: SortMeta = { field: 'createdAt', order: -1 } pagination: RestPagination = { count: this.rowsPerPage, start: 0 } scrollHeight = '' @@ -33,9 +36,13 @@ export class JobsListComponent extends RestTable implements OnInit { this.scrollHeight = (viewportHeight() - 380) + 'px' } + onJobStateChanged () { + this.loadData() + } + protected loadData () { this.jobsService - .getJobs(this.pagination, this.sort) + .getJobs(this.jobState, this.pagination, this.sort) .subscribe( resultList => { 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' import 'rxjs/add/operator/map' import { Observable } from 'rxjs/Observable' import { ResultList } from '../../../../../../shared' +import { JobState } from '../../../../../../shared/models' import { Job } from '../../../../../../shared/models/job.model' import { environment } from '../../../../environments/environment' import { RestExtractor, RestPagination, RestService } from '../../../shared' @@ -19,19 +20,19 @@ export class JobService { private restExtractor: RestExtractor ) {} - getJobs (pagination: RestPagination, sort: SortMeta): Observable> { + getJobs (state: JobState, pagination: RestPagination, sort: SortMeta): Observable> { let params = new HttpParams() params = this.restService.addRestGetParams(params, pagination, sort) - return this.authHttp.get>(JobService.BASE_JOB_URL, { params }) + return this.authHttp.get>(JobService.BASE_JOB_URL + '/' + state, { params }) .map(res => this.restExtractor.convertResultListDateToHuman(res)) .map(res => this.restExtractor.applyToResultListData(res, this.prettyPrintData)) .catch(err => this.restExtractor.handleError(err)) } private prettyPrintData (obj: Job) { - const handlerInputData = JSON.stringify(obj.handlerInputData, null, 2) + const data = JSON.stringify(obj.data, null, 2) - return Object.assign(obj, { handlerInputData }) + return Object.assign(obj, { data }) } } -- cgit v1.2.3