]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blob - jobs-list.component.ts
f93847f295c31571c7b270070a124cc436fe38fa
[github/Chocobozzz/PeerTube.git] / 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 { RestPagination, RestTable } from '../../../shared'
6 import { viewportHeight } from '../../../shared/misc/utils'
7 import { JobService } from '../shared'
8 import { RestExtractor } from '../../../shared/rest/rest-extractor.service'
9
10 @Component({
11 selector: 'my-jobs-list',
12 templateUrl: './jobs-list.component.html',
13 styleUrls: [ './jobs-list.component.scss' ]
14 })
15 export class JobsListComponent extends RestTable implements OnInit {
16 jobs: Job[] = []
17 totalRecords = 0
18 rowsPerPage = 20
19 sort: SortMeta = { field: 'createdAt', order: 1 }
20 pagination: RestPagination = { count: this.rowsPerPage, start: 0 }
21 scrollHeight = ''
22
23 constructor (
24 private notificationsService: NotificationsService,
25 private restExtractor: RestExtractor,
26 private jobsService: JobService
27 ) {
28 super()
29 }
30
31 ngOnInit () {
32 // 270 -> headers + footer...
33 this.scrollHeight = (viewportHeight() - 380) + 'px'
34 }
35
36 protected loadData () {
37 this.jobsService
38 .getJobs(this.pagination, this.sort)
39 .subscribe(
40 resultList => {
41 this.jobs = resultList.data
42 this.totalRecords = resultList.total
43 },
44
45 err => this.notificationsService.error('Error', err.message)
46 )
47 }
48 }