]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blob - client/src/app/+admin/jobs/jobs-list/jobs-list.component.ts
Move job queue to redis
[github/Chocobozzz/PeerTube.git] / client / src / app / +admin / jobs / jobs-list / jobs-list.component.ts
1 import { Component, OnInit } from '@angular/core'
2 import { NotificationsService } from 'angular2-notifications'
3 import { SortMeta } from 'primeng/primeng'
4 import { Job } from '../../../../../../shared/index'
5 import { JobState } from '../../../../../../shared/models'
6 import { RestPagination, RestTable } from '../../../shared'
7 import { viewportHeight } from '../../../shared/misc/utils'
8 import { JobService } from '../shared'
9 import { RestExtractor } from '../../../shared/rest/rest-extractor.service'
10
11 @Component({
12 selector: 'my-jobs-list',
13 templateUrl: './jobs-list.component.html',
14 styleUrls: [ './jobs-list.component.scss' ]
15 })
16 export class JobsListComponent extends RestTable implements OnInit {
17 jobState: JobState = 'inactive'
18 jobStates: JobState[] = [ 'active', 'complete', 'failed', 'inactive', 'delayed' ]
19 jobs: Job[] = []
20 totalRecords = 0
21 rowsPerPage = 20
22 sort: SortMeta = { field: 'createdAt', order: -1 }
23 pagination: RestPagination = { count: this.rowsPerPage, start: 0 }
24 scrollHeight = ''
25
26 constructor (
27 private notificationsService: NotificationsService,
28 private restExtractor: RestExtractor,
29 private jobsService: JobService
30 ) {
31 super()
32 }
33
34 ngOnInit () {
35 // 270 -> headers + footer...
36 this.scrollHeight = (viewportHeight() - 380) + 'px'
37 }
38
39 onJobStateChanged () {
40 this.loadData()
41 }
42
43 protected loadData () {
44 this.jobsService
45 .getJobs(this.jobState, this.pagination, this.sort)
46 .subscribe(
47 resultList => {
48 this.jobs = resultList.data
49 this.totalRecords = resultList.total
50 },
51
52 err => this.notificationsService.error('Error', err.message)
53 )
54 }
55 }