diff options
author | Chocobozzz <me@florianbigard.com> | 2019-04-10 15:26:33 +0200 |
---|---|---|
committer | Chocobozzz <me@florianbigard.com> | 2019-04-10 16:38:32 +0200 |
commit | fd8710b897a67518d3a61c319e54b6a65ba443ef (patch) | |
tree | d9953b7e0bb4e5a119c872ab21021f4c1ab33bea /client/src/app/+admin/jobs/shared | |
parent | 31b6ddf86652502e0c96d77fa10861ce4af11aa4 (diff) | |
download | PeerTube-fd8710b897a67518d3a61c319e54b6a65ba443ef.tar.gz PeerTube-fd8710b897a67518d3a61c319e54b6a65ba443ef.tar.zst PeerTube-fd8710b897a67518d3a61c319e54b6a65ba443ef.zip |
Add logs endpoint
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 | 46 |
2 files changed, 0 insertions, 47 deletions
diff --git a/client/src/app/+admin/jobs/shared/index.ts b/client/src/app/+admin/jobs/shared/index.ts deleted file mode 100644 index 609439e5c..000000000 --- a/client/src/app/+admin/jobs/shared/index.ts +++ /dev/null | |||
@@ -1 +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 deleted file mode 100644 index b96dc3359..000000000 --- a/client/src/app/+admin/jobs/shared/job.service.ts +++ /dev/null | |||
@@ -1,46 +0,0 @@ | |||
1 | import { catchError, map } from 'rxjs/operators' | ||
2 | import { HttpClient, HttpParams } from '@angular/common/http' | ||
3 | import { Injectable } from '@angular/core' | ||
4 | import { SortMeta } from 'primeng/primeng' | ||
5 | import { Observable } from 'rxjs' | ||
6 | import { ResultList } from '../../../../../../shared' | ||
7 | import { JobState } from '../../../../../../shared/models' | ||
8 | import { Job } from '../../../../../../shared/models/server/job.model' | ||
9 | import { environment } from '../../../../environments/environment' | ||
10 | import { RestExtractor, RestPagination, RestService } from '../../../shared' | ||
11 | |||
12 | @Injectable() | ||
13 | export class JobService { | ||
14 | private static BASE_JOB_URL = environment.apiUrl + '/api/v1/jobs' | ||
15 | |||
16 | constructor ( | ||
17 | private authHttp: HttpClient, | ||
18 | private restService: RestService, | ||
19 | private restExtractor: RestExtractor | ||
20 | ) {} | ||
21 | |||
22 | getJobs (state: JobState, 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 + '/' + state, { params }) | ||
27 | .pipe( | ||
28 | map(res => { | ||
29 | return this.restExtractor.convertResultListDateToHuman(res, [ 'createdAt', 'processedOn', 'finishedOn' ]) | ||
30 | }), | ||
31 | map(res => this.restExtractor.applyToResultListData(res, this.prettyPrintData)), | ||
32 | map(res => this.restExtractor.applyToResultListData(res, this.buildUniqId)), | ||
33 | catchError(err => this.restExtractor.handleError(err)) | ||
34 | ) | ||
35 | } | ||
36 | |||
37 | private prettyPrintData (obj: Job) { | ||
38 | const data = JSON.stringify(obj.data, null, 2) | ||
39 | |||
40 | return Object.assign(obj, { data }) | ||
41 | } | ||
42 | |||
43 | private buildUniqId (obj: Job) { | ||
44 | return Object.assign(obj, { uniqId: `${obj.id}-${obj.type}` }) | ||
45 | } | ||
46 | } | ||