diff options
author | Chocobozzz <florian.bigard@gmail.com> | 2017-11-30 10:51:13 +0100 |
---|---|---|
committer | Chocobozzz <florian.bigard@gmail.com> | 2017-11-30 10:55:06 +0100 |
commit | 5cd80545422bba855cc9a730a2e13cc9d982c34b (patch) | |
tree | 9a60cd7c9218c296a1460938d11e3bce784f7cc0 /client/src/app/+admin/jobs/shared | |
parent | 1f3e9feca2caf68024168b0ea9ed39d8438fa235 (diff) | |
download | PeerTube-5cd80545422bba855cc9a730a2e13cc9d982c34b.tar.gz PeerTube-5cd80545422bba855cc9a730a2e13cc9d982c34b.tar.zst PeerTube-5cd80545422bba855cc9a730a2e13cc9d982c34b.zip |
Add ability to list jobs
Diffstat (limited to 'client/src/app/+admin/jobs/shared')
-rw-r--r-- | client/src/app/+admin/jobs/shared/index.ts | 1 | ||||
-rw-r--r-- | client/src/app/+admin/jobs/shared/job.service.ts | 30 |
2 files changed, 31 insertions, 0 deletions
diff --git a/client/src/app/+admin/jobs/shared/index.ts b/client/src/app/+admin/jobs/shared/index.ts new file mode 100644 index 000000000..609439e5c --- /dev/null +++ b/client/src/app/+admin/jobs/shared/index.ts | |||
@@ -0,0 +1 @@ | |||
export * from './job.service' | |||
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 | } | ||