aboutsummaryrefslogtreecommitdiffhomepage
path: root/client/src/app/+admin/jobs/shared
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2019-04-10 15:26:33 +0200
committerChocobozzz <me@florianbigard.com>2019-04-10 16:38:32 +0200
commitfd8710b897a67518d3a61c319e54b6a65ba443ef (patch)
treed9953b7e0bb4e5a119c872ab21021f4c1ab33bea /client/src/app/+admin/jobs/shared
parent31b6ddf86652502e0c96d77fa10861ce4af11aa4 (diff)
downloadPeerTube-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.ts1
-rw-r--r--client/src/app/+admin/jobs/shared/job.service.ts46
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 @@
1export * 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 @@
1import { catchError, map } from 'rxjs/operators'
2import { HttpClient, HttpParams } from '@angular/common/http'
3import { Injectable } from '@angular/core'
4import { SortMeta } from 'primeng/primeng'
5import { Observable } from 'rxjs'
6import { ResultList } from '../../../../../../shared'
7import { JobState } from '../../../../../../shared/models'
8import { Job } from '../../../../../../shared/models/server/job.model'
9import { environment } from '../../../../environments/environment'
10import { RestExtractor, RestPagination, RestService } from '../../../shared'
11
12@Injectable()
13export 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}