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 { CustomConfig } from '@shared/models'
6 import { SelectOptionsItem } from '../../../../types/select-options-item.model'
7 import { environment } from '../../../../environments/environment'
10 export class ConfigService {
11 private static BASE_APPLICATION_URL = environment.apiUrl + '/api/v1/config'
13 videoQuotaOptions: SelectOptionsItem[] = []
14 videoQuotaDailyOptions: SelectOptionsItem[] = []
17 private authHttp: HttpClient,
18 private restExtractor: RestExtractor
20 this.videoQuotaOptions = [
21 { id: -1, label: $localize`Unlimited` },
22 { id: 0, label: $localize`None - no upload possible` },
23 { id: 100 * 1024 * 1024, label: $localize`100MB` },
24 { id: 500 * 1024 * 1024, label: $localize`500MB` },
25 { id: 1024 * 1024 * 1024, label: $localize`1GB` },
26 { id: 5 * 1024 * 1024 * 1024, label: $localize`5GB` },
27 { id: 20 * 1024 * 1024 * 1024, label: $localize`20GB` },
28 { id: 50 * 1024 * 1024 * 1024, label: $localize`50GB` },
29 { id: 100 * 1024 * 1024 * 1024, label: $localize`100GB` },
30 { id: 200 * 1024 * 1024 * 1024, label: $localize`200GB` },
31 { id: 500 * 1024 * 1024 * 1024, label: $localize`500GB` }
34 this.videoQuotaDailyOptions = [
35 { id: -1, label: $localize`Unlimited` },
36 { id: 0, label: $localize`None - no upload possible` },
37 { id: 10 * 1024 * 1024, label: $localize`10MB` },
38 { id: 50 * 1024 * 1024, label: $localize`50MB` },
39 { id: 100 * 1024 * 1024, label: $localize`100MB` },
40 { id: 500 * 1024 * 1024, label: $localize`500MB` },
41 { id: 2 * 1024 * 1024 * 1024, label: $localize`2GB` },
42 { id: 5 * 1024 * 1024 * 1024, label: $localize`5GB` },
43 { id: 10 * 1024 * 1024 * 1024, label: $localize`10GB` },
44 { id: 20 * 1024 * 1024 * 1024, label: $localize`20GB` },
45 { id: 50 * 1024 * 1024 * 1024, label: $localize`50GB` }
50 return this.authHttp.get<CustomConfig>(ConfigService.BASE_APPLICATION_URL + '/custom')
51 .pipe(catchError(res => this.restExtractor.handleError(res)))
54 updateCustomConfig (data: CustomConfig) {
55 return this.authHttp.put<CustomConfig>(ConfigService.BASE_APPLICATION_URL + '/custom', data)
56 .pipe(catchError(res => this.restExtractor.handleError(res)))