]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blame - client/src/app/+admin/config/shared/config.service.ts
Merge branch 'release/2.2.0' into develop
[github/Chocobozzz/PeerTube.git] / client / src / app / +admin / config / shared / config.service.ts
CommitLineData
db400f44 1import { catchError } from 'rxjs/operators'
fd206f0b
C
2import { HttpClient } from '@angular/common/http'
3import { Injectable } from '@angular/core'
09cababd 4import { CustomConfig } from '../../../../../../shared/models/server/custom-config.model'
fd206f0b 5import { environment } from '../../../../environments/environment'
23db998f 6import { RestExtractor } from '../../../shared'
3827c3b3 7import { I18n } from '@ngx-translate/i18n-polyfill'
fd206f0b
C
8
9@Injectable()
10export class ConfigService {
11 private static BASE_APPLICATION_URL = environment.apiUrl + '/api/v1/config'
12
2bc9bd08
RK
13 videoQuotaOptions: { value: number, label: string, disabled?: boolean }[] = []
14 videoQuotaDailyOptions: { value: number, label: string, disabled?: boolean }[] = []
3827c3b3 15
fd206f0b
C
16 constructor (
17 private authHttp: HttpClient,
3827c3b3
C
18 private restExtractor: RestExtractor,
19 private i18n: I18n
20 ) {
21 this.videoQuotaOptions = [
2bc9bd08 22 { value: undefined, label: 'Default quota', disabled: true },
3827c3b3 23 { value: -1, label: this.i18n('Unlimited') },
2bc9bd08
RK
24 { value: undefined, label: '─────', disabled: true },
25 { value: 0, label: this.i18n('None - no upload possible') },
3827c3b3
C
26 { value: 100 * 1024 * 1024, label: this.i18n('100MB') },
27 { value: 500 * 1024 * 1024, label: this.i18n('500MB') },
28 { value: 1024 * 1024 * 1024, label: this.i18n('1GB') },
29 { value: 5 * 1024 * 1024 * 1024, label: this.i18n('5GB') },
30 { value: 20 * 1024 * 1024 * 1024, label: this.i18n('20GB') },
31 { value: 50 * 1024 * 1024 * 1024, label: this.i18n('50GB') }
32 ]
33
34 this.videoQuotaDailyOptions = [
2bc9bd08 35 { value: undefined, label: 'Default daily upload limit', disabled: true },
3827c3b3 36 { value: -1, label: this.i18n('Unlimited') },
2bc9bd08
RK
37 { value: undefined, label: '─────', disabled: true },
38 { value: 0, label: this.i18n('None - no upload possible') },
3827c3b3
C
39 { value: 10 * 1024 * 1024, label: this.i18n('10MB') },
40 { value: 50 * 1024 * 1024, label: this.i18n('50MB') },
41 { value: 100 * 1024 * 1024, label: this.i18n('100MB') },
42 { value: 500 * 1024 * 1024, label: this.i18n('500MB') },
43 { value: 2 * 1024 * 1024 * 1024, label: this.i18n('2GB') },
44 { value: 5 * 1024 * 1024 * 1024, label: this.i18n('5GB') }
45 ]
46 }
fd206f0b
C
47
48 getCustomConfig () {
49 return this.authHttp.get<CustomConfig>(ConfigService.BASE_APPLICATION_URL + '/custom')
db400f44 50 .pipe(catchError(res => this.restExtractor.handleError(res)))
fd206f0b
C
51 }
52
53 updateCustomConfig (data: CustomConfig) {
54 return this.authHttp.put<CustomConfig>(ConfigService.BASE_APPLICATION_URL + '/custom', data)
db400f44 55 .pipe(catchError(res => this.restExtractor.handleError(res)))
fd206f0b
C
56 }
57}