]>
Commit | Line | Data |
---|---|---|
db400f44 | 1 | import { catchError } from 'rxjs/operators' |
fd206f0b C |
2 | import { HttpClient } from '@angular/common/http' |
3 | import { Injectable } from '@angular/core' | |
67ed6552 | 4 | import { RestExtractor } from '@app/core' |
67ed6552 | 5 | import { CustomConfig } from '@shared/models' |
21e493d4 | 6 | import { SelectOptionsItem } from '../../../../types/select-options-item.model' |
67ed6552 | 7 | import { environment } from '../../../../environments/environment' |
fd206f0b C |
8 | |
9 | @Injectable() | |
10 | export class ConfigService { | |
11 | private static BASE_APPLICATION_URL = environment.apiUrl + '/api/v1/config' | |
12 | ||
21e493d4 C |
13 | videoQuotaOptions: SelectOptionsItem[] = [] |
14 | videoQuotaDailyOptions: SelectOptionsItem[] = [] | |
5f46d28c | 15 | transcodingThreadOptions: SelectOptionsItem[] = [] |
3827c3b3 | 16 | |
fd206f0b C |
17 | constructor ( |
18 | private authHttp: HttpClient, | |
66357162 | 19 | private restExtractor: RestExtractor |
5f46d28c | 20 | ) { |
3827c3b3 | 21 | this.videoQuotaOptions = [ |
21e493d4 C |
22 | { id: -1, label: $localize`Unlimited` }, |
23 | { id: 0, label: $localize`None - no upload possible` }, | |
24 | { id: 100 * 1024 * 1024, label: $localize`100MB` }, | |
25 | { id: 500 * 1024 * 1024, label: $localize`500MB` }, | |
26 | { id: 1024 * 1024 * 1024, label: $localize`1GB` }, | |
27 | { id: 5 * 1024 * 1024 * 1024, label: $localize`5GB` }, | |
28 | { id: 20 * 1024 * 1024 * 1024, label: $localize`20GB` }, | |
29 | { id: 50 * 1024 * 1024 * 1024, label: $localize`50GB` }, | |
30 | { id: 100 * 1024 * 1024 * 1024, label: $localize`100GB` }, | |
31 | { id: 200 * 1024 * 1024 * 1024, label: $localize`200GB` }, | |
32 | { id: 500 * 1024 * 1024 * 1024, label: $localize`500GB` } | |
3827c3b3 C |
33 | ] |
34 | ||
35 | this.videoQuotaDailyOptions = [ | |
21e493d4 C |
36 | { id: -1, label: $localize`Unlimited` }, |
37 | { id: 0, label: $localize`None - no upload possible` }, | |
38 | { id: 10 * 1024 * 1024, label: $localize`10MB` }, | |
39 | { id: 50 * 1024 * 1024, label: $localize`50MB` }, | |
40 | { id: 100 * 1024 * 1024, label: $localize`100MB` }, | |
41 | { id: 500 * 1024 * 1024, label: $localize`500MB` }, | |
42 | { id: 2 * 1024 * 1024 * 1024, label: $localize`2GB` }, | |
43 | { id: 5 * 1024 * 1024 * 1024, label: $localize`5GB` }, | |
44 | { id: 10 * 1024 * 1024 * 1024, label: $localize`10GB` }, | |
45 | { id: 20 * 1024 * 1024 * 1024, label: $localize`20GB` }, | |
46 | { id: 50 * 1024 * 1024 * 1024, label: $localize`50GB` } | |
3827c3b3 | 47 | ] |
5f46d28c C |
48 | |
49 | this.transcodingThreadOptions = [ | |
50 | { id: 0, label: $localize`Auto (via ffmpeg)` }, | |
51 | { id: 1, label: '1' }, | |
52 | { id: 2, label: '2' }, | |
53 | { id: 4, label: '4' }, | |
54 | { id: 8, label: '8' }, | |
55 | { id: 12, label: '12' }, | |
56 | { id: 16, label: '16' }, | |
57 | { id: 32, label: '32' } | |
58 | ] | |
3827c3b3 | 59 | } |
fd206f0b C |
60 | |
61 | getCustomConfig () { | |
62 | return this.authHttp.get<CustomConfig>(ConfigService.BASE_APPLICATION_URL + '/custom') | |
db400f44 | 63 | .pipe(catchError(res => this.restExtractor.handleError(res))) |
fd206f0b C |
64 | } |
65 | ||
66 | updateCustomConfig (data: CustomConfig) { | |
67 | return this.authHttp.put<CustomConfig>(ConfigService.BASE_APPLICATION_URL + '/custom', data) | |
db400f44 | 68 | .pipe(catchError(res => this.restExtractor.handleError(res))) |
fd206f0b C |
69 | } |
70 | } |