diff options
Diffstat (limited to 'client/src/app/+admin/jobs/shared/job.service.ts')
-rw-r--r-- | client/src/app/+admin/jobs/shared/job.service.ts | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/client/src/app/+admin/jobs/shared/job.service.ts b/client/src/app/+admin/jobs/shared/job.service.ts new file mode 100644 index 000000000..49f1ab6f5 --- /dev/null +++ b/client/src/app/+admin/jobs/shared/job.service.ts | |||
@@ -0,0 +1,30 @@ | |||
1 | import { HttpClient, HttpParams } from '@angular/common/http' | ||
2 | import { Injectable } from '@angular/core' | ||
3 | import { SortMeta } from 'primeng/primeng' | ||
4 | import 'rxjs/add/operator/catch' | ||
5 | import 'rxjs/add/operator/map' | ||
6 | import { Observable } from 'rxjs/Observable' | ||
7 | import { ResultList } from '../../../../../../shared' | ||
8 | import { Job } from '../../../../../../shared/models/job.model' | ||
9 | |||
10 | import { RestExtractor, RestPagination, RestService } from '../../../shared' | ||
11 | |||
12 | @Injectable() | ||
13 | export class JobService { | ||
14 | private static BASE_JOB_URL = API_URL + '/api/v1/jobs' | ||
15 | |||
16 | constructor ( | ||
17 | private authHttp: HttpClient, | ||
18 | private restService: RestService, | ||
19 | private restExtractor: RestExtractor | ||
20 | ) {} | ||
21 | |||
22 | getJobs (pagination: RestPagination, sort: SortMeta): Observable<ResultList<Job>> { | ||
23 | let params = new HttpParams() | ||
24 | params = this.restService.addRestGetParams(params, pagination, sort) | ||
25 | |||
26 | return this.authHttp.get<ResultList<Job>>(JobService.BASE_JOB_URL, { params }) | ||
27 | .map(res => this.restExtractor.convertResultListDateToHuman(res)) | ||
28 | .catch(err => this.restExtractor.handleError(err)) | ||
29 | } | ||
30 | } | ||