1 import { Component, OnInit } from '@angular/core'
2 import { peertubeLocalStorage } from '@app/shared/misc/peertube-local-storage'
3 import { Notifier } from '@app/core'
4 import { SortMeta } from 'primeng/primeng'
5 import { Job } from '../../../../../../shared/index'
6 import { JobState } from '../../../../../../shared/models'
7 import { RestPagination, RestTable } from '../../../shared'
8 import { JobService } from '../shared'
9 import { I18n } from '@ngx-translate/i18n-polyfill'
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 private static JOB_STATE_LOCAL_STORAGE_STATE = 'jobs-list-state'
19 jobState: JobState = 'waiting'
20 jobStates: JobState[] = [ 'active', 'completed', 'failed', 'waiting', 'delayed' ]
24 sort: SortMeta = { field: 'createdAt', order: -1 }
25 pagination: RestPagination = { count: this.rowsPerPage, start: 0 }
28 private notifier: Notifier,
29 private jobsService: JobService,
40 onJobStateChanged () {
41 this.pagination.start = 0
47 protected loadData () {
49 .getJobs(this.jobState, this.pagination, this.sort)
52 this.jobs = resultList.data
53 this.totalRecords = resultList.total
56 err => this.notifier.error(err.message)
60 private loadJobState () {
61 const result = peertubeLocalStorage.getItem(JobsListComponent.JOB_STATE_LOCAL_STORAGE_STATE)
63 if (result) this.jobState = result as JobState
66 private saveJobState () {
67 peertubeLocalStorage.setItem(JobsListComponent.JOB_STATE_LOCAL_STORAGE_STATE, this.jobState)