]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blob - client/src/app/+admin/config/shared/config.service.ts
Update build steps for localization
[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 { RestExtractor } from '@app/core'
5 import { I18n } from '@ngx-translate/i18n-polyfill'
6 import { CustomConfig } from '@shared/models'
7 import { environment } from '../../../../environments/environment'
8
9 @Injectable()
10 export class ConfigService {
11 private static BASE_APPLICATION_URL = environment.apiUrl + '/api/v1/config'
12
13 videoQuotaOptions: { value: number, label: string, disabled?: boolean }[] = []
14 videoQuotaDailyOptions: { value: number, label: string, disabled?: boolean }[] = []
15
16 constructor (
17 private authHttp: HttpClient,
18 private restExtractor: RestExtractor,
19 private i18n: I18n
20 ) {
21 this.videoQuotaOptions = [
22 { value: undefined, label: 'Default quota', disabled: true },
23 { value: -1, label: this.i18n('Unlimited') },
24 { value: undefined, label: '─────', disabled: true },
25 { value: 0, label: this.i18n('None - no upload possible') },
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 = [
35 { value: undefined, label: 'Default daily upload limit', disabled: true },
36 { value: -1, label: this.i18n('Unlimited') },
37 { value: undefined, label: '─────', disabled: true },
38 { value: 0, label: this.i18n('None - no upload possible') },
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 }
47
48 getCustomConfig () {
49 return this.authHttp.get<CustomConfig>(ConfigService.BASE_APPLICATION_URL + '/custom')
50 .pipe(catchError(res => this.restExtractor.handleError(res)))
51 }
52
53 updateCustomConfig (data: CustomConfig) {
54 return this.authHttp.put<CustomConfig>(ConfigService.BASE_APPLICATION_URL + '/custom', data)
55 .pipe(catchError(res => this.restExtractor.handleError(res)))
56 }
57 }