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'
12 selector: 'my-jobs-list',
13 templateUrl: './jobs-list.component.html',
14 styleUrls: [ './jobs-list.component.scss' ]
16 export class JobsListComponent extends RestTable implements OnInit {
17 jobState: JobState = 'inactive'
18 jobStates: JobState[] = [ 'active', 'complete', 'failed', 'inactive', 'delayed' ]
22 sort: SortMeta = { field: 'createdAt', order: -1 }
23 pagination: RestPagination = { count: this.rowsPerPage, start: 0 }
27 private notificationsService: NotificationsService,
28 private restExtractor: RestExtractor,
29 private jobsService: JobService
35 // 270 -> headers + footer...
36 this.scrollHeight = (viewportHeight() - 380) + 'px'
39 onJobStateChanged () {
43 protected loadData () {
45 .getJobs(this.jobState, this.pagination, this.sort)
48 this.jobs = resultList.data
49 this.totalRecords = resultList.total
52 err => this.notificationsService.error('Error', err.message)