]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blame - client/src/app/+admin/config/shared/config.service.ts
Fix quota translations
[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
3827c3b3
C
13 videoQuotaOptions: { value: number, label: string }[] = []
14 videoQuotaDailyOptions: { value: number, label: string }[] = []
15
fd206f0b
C
16 constructor (
17 private authHttp: HttpClient,
3827c3b3
C
18 private restExtractor: RestExtractor,
19 private i18n: I18n
20 ) {
21 this.videoQuotaOptions = [
22 { value: -1, label: this.i18n('Unlimited') },
23 { value: 0, label: '0' },
24 { value: 100 * 1024 * 1024, label: this.i18n('100MB') },
25 { value: 500 * 1024 * 1024, label: this.i18n('500MB') },
26 { value: 1024 * 1024 * 1024, label: this.i18n('1GB') },
27 { value: 5 * 1024 * 1024 * 1024, label: this.i18n('5GB') },
28 { value: 20 * 1024 * 1024 * 1024, label: this.i18n('20GB') },
29 { value: 50 * 1024 * 1024 * 1024, label: this.i18n('50GB') }
30 ]
31
32 this.videoQuotaDailyOptions = [
33 { value: -1, label: this.i18n('Unlimited') },
34 { value: 0, label: '0' },
35 { value: 10 * 1024 * 1024, label: this.i18n('10MB') },
36 { value: 50 * 1024 * 1024, label: this.i18n('50MB') },
37 { value: 100 * 1024 * 1024, label: this.i18n('100MB') },
38 { value: 500 * 1024 * 1024, label: this.i18n('500MB') },
39 { value: 2 * 1024 * 1024 * 1024, label: this.i18n('2GB') },
40 { value: 5 * 1024 * 1024 * 1024, label: this.i18n('5GB') }
41 ]
42 }
fd206f0b
C
43
44 getCustomConfig () {
45 return this.authHttp.get<CustomConfig>(ConfigService.BASE_APPLICATION_URL + '/custom')
db400f44 46 .pipe(catchError(res => this.restExtractor.handleError(res)))
fd206f0b
C
47 }
48
49 updateCustomConfig (data: CustomConfig) {
50 return this.authHttp.put<CustomConfig>(ConfigService.BASE_APPLICATION_URL + '/custom', data)
db400f44 51 .pipe(catchError(res => this.restExtractor.handleError(res)))
fd206f0b
C
52 }
53}