+import { SortMeta } from 'primeng/api'
+import { Observable } from 'rxjs'
import { catchError, map } from 'rxjs/operators'
import { HttpClient, HttpParams } from '@angular/common/http'
import { Injectable } from '@angular/core'
-import { SortMeta } from 'primeng/api'
-import { Observable } from 'rxjs'
-import { ResultList } from '../../../../../../shared'
-import { JobState } from '../../../../../../shared/models'
-import { Job } from '../../../../../../shared/models/server/job.model'
+import { RestExtractor, RestPagination, RestService } from '@app/core'
+import { Job, ResultList } from '@shared/models'
import { environment } from '../../../../environments/environment'
-import { RestExtractor, RestPagination, RestService } from '../../../shared'
+import { JobStateClient } from '../../../../types/job-state-client.type'
+import { JobTypeClient } from '../../../../types/job-type-client.type'
@Injectable()
export class JobService {
private restExtractor: RestExtractor
) {}
- getJobs (state: JobState, pagination: RestPagination, sort: SortMeta): Observable<ResultList<Job>> {
+ getJobs (options: {
+ jobState?: JobStateClient,
+ jobType: JobTypeClient,
+ pagination: RestPagination,
+ sort: SortMeta
+ }): Observable<ResultList<Job>> {
+ const { jobState, jobType, pagination, sort } = options
+
let params = new HttpParams()
params = this.restService.addRestGetParams(params, pagination, sort)
- return this.authHttp.get<ResultList<Job>>(JobService.BASE_JOB_URL + '/' + state, { params })
+ if (jobType !== 'all') params = params.append('jobType', jobType)
+
+ return this.authHttp.get<ResultList<Job>>(JobService.BASE_JOB_URL + `/${jobState ? jobState : ''}`, { params })
.pipe(
map(res => {
return this.restExtractor.convertResultListDateToHuman(res, [ 'createdAt', 'processedOn', 'finishedOn' ])