]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blob - client/src/app/+admin/config/shared/config.service.ts
7c61fe9e7fc7c7964a4ea1c06525ab09d1911b37
[github/Chocobozzz/PeerTube.git] / client / src / app / +admin / config / shared / config.service.ts
1 import { catchError } from 'rxjs/operators'
2 import { HttpClient } from '@angular/common/http'
3 import { Injectable } from '@angular/core'
4 import { CustomConfig } from '../../../../../../shared/models/server/custom-config.model'
5 import { environment } from '../../../../environments/environment'
6 import { RestExtractor } from '../../../shared'
7
8 @Injectable()
9 export class ConfigService {
10 private static BASE_APPLICATION_URL = environment.apiUrl + '/api/v1/config'
11
12 constructor (
13 private authHttp: HttpClient,
14 private restExtractor: RestExtractor
15 ) {}
16
17 getCustomConfig () {
18 return this.authHttp.get<CustomConfig>(ConfigService.BASE_APPLICATION_URL + '/custom')
19 .pipe(catchError(res => this.restExtractor.handleError(res)))
20 }
21
22 updateCustomConfig (data: CustomConfig) {
23 return this.authHttp.put<CustomConfig>(ConfigService.BASE_APPLICATION_URL + '/custom', data)
24 .pipe(catchError(res => this.restExtractor.handleError(res)))
25 }
26 }