aboutsummaryrefslogtreecommitdiffhomepage
path: root/client/src/app/+admin/config
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2021-02-10 09:05:29 +0100
committerChocobozzz <me@florianbigard.com>2021-02-10 11:36:40 +0100
commit21e493d4d8acb7a650eff3a30cd7e086b3cb8a28 (patch)
treef3a451d6a59925907c62b0c36db99745a43b67db /client/src/app/+admin/config
parentead64cdf8d917fa0d6a20271e42378f38e5f2407 (diff)
downloadPeerTube-21e493d4d8acb7a650eff3a30cd7e086b3cb8a28.tar.gz
PeerTube-21e493d4d8acb7a650eff3a30cd7e086b3cb8a28.tar.zst
PeerTube-21e493d4d8acb7a650eff3a30cd7e086b3cb8a28.zip
Add ability to set a custom quota
Diffstat (limited to 'client/src/app/+admin/config')
-rw-r--r--client/src/app/+admin/config/edit-custom-config/edit-custom-config.component.html32
-rw-r--r--client/src/app/+admin/config/edit-custom-config/edit-custom-config.component.ts3
-rw-r--r--client/src/app/+admin/config/shared/config.service.ts47
3 files changed, 45 insertions, 37 deletions
diff --git a/client/src/app/+admin/config/edit-custom-config/edit-custom-config.component.html b/client/src/app/+admin/config/edit-custom-config/edit-custom-config.component.html
index 844620ca2..637203b96 100644
--- a/client/src/app/+admin/config/edit-custom-config/edit-custom-config.component.html
+++ b/client/src/app/+admin/config/edit-custom-config/edit-custom-config.component.html
@@ -402,25 +402,29 @@
402 <ng-container formGroupName="user"> 402 <ng-container formGroupName="user">
403 <div class="form-group"> 403 <div class="form-group">
404 <label i18n for="userVideoQuota">Default video quota per user</label> 404 <label i18n for="userVideoQuota">Default video quota per user</label>
405 <div class="peertube-select-container"> 405
406 <select id="userVideoQuota" formControlName="videoQuota" class="form-control"> 406 <my-select-custom-value
407 <option *ngFor="let videoQuotaOption of videoQuotaOptions" [value]="videoQuotaOption.value" [disabled]="videoQuotaOption.disabled"> 407 id="userVideoQuota"
408 {{ videoQuotaOption.label }} 408 [items]="videoQuotaOptions"
409 </option> 409 formControlName="videoQuota"
410 </select> 410 i18n-inputSuffix inputSuffix="bytes" inputType="number"
411 </div> 411 [clearable]="false"
412 ></my-select-custom-value>
413
412 <div *ngIf="formErrors.user.videoQuota" class="form-error">{{ formErrors.user.videoQuota }}</div> 414 <div *ngIf="formErrors.user.videoQuota" class="form-error">{{ formErrors.user.videoQuota }}</div>
413 </div> 415 </div>
414 416
415 <div class="form-group"> 417 <div class="form-group">
416 <label i18n for="userVideoQuotaDaily">Default daily upload limit per user</label> 418 <label i18n for="userVideoQuotaDaily">Default daily upload limit per user</label>
417 <div class="peertube-select-container"> 419
418 <select id="userVideoQuotaDaily" formControlName="videoQuotaDaily" class="form-control"> 420 <my-select-custom-value
419 <option *ngFor="let videoQuotaDailyOption of videoQuotaDailyOptions" [value]="videoQuotaDailyOption.value" [disabled]="videoQuotaDailyOption.disabled"> 421 id="userVideoQuotaDaily"
420 {{ videoQuotaDailyOption.label }} 422 [items]="videoQuotaDailyOptions"
421 </option> 423 formControlName="videoQuotaDaily"
422 </select> 424 i18n-inputSuffix inputSuffix="bytes" inputType="number"
423 </div> 425 [clearable]="false"
426 ></my-select-custom-value>
427
424 <div *ngIf="formErrors.user.videoQuotaDaily" class="form-error">{{ formErrors.user.videoQuotaDaily }}</div> 428 <div *ngIf="formErrors.user.videoQuotaDaily" class="form-error">{{ formErrors.user.videoQuotaDaily }}</div>
425 </div> 429 </div>
426 </ng-container> 430 </ng-container>
diff --git a/client/src/app/+admin/config/edit-custom-config/edit-custom-config.component.ts b/client/src/app/+admin/config/edit-custom-config/edit-custom-config.component.ts
index a9f72d7db..56be97e84 100644
--- a/client/src/app/+admin/config/edit-custom-config/edit-custom-config.component.ts
+++ b/client/src/app/+admin/config/edit-custom-config/edit-custom-config.component.ts
@@ -19,9 +19,10 @@ import {
19 TRANSCODING_THREADS_VALIDATOR 19 TRANSCODING_THREADS_VALIDATOR
20} from '@app/shared/form-validators/custom-config-validators' 20} from '@app/shared/form-validators/custom-config-validators'
21import { USER_VIDEO_QUOTA_DAILY_VALIDATOR, USER_VIDEO_QUOTA_VALIDATOR } from '@app/shared/form-validators/user-validators' 21import { USER_VIDEO_QUOTA_DAILY_VALIDATOR, USER_VIDEO_QUOTA_VALIDATOR } from '@app/shared/form-validators/user-validators'
22import { FormReactive, FormValidatorService, SelectOptionsItem } from '@app/shared/shared-forms' 22import { FormReactive, FormValidatorService } from '@app/shared/shared-forms'
23import { NgbNav } from '@ng-bootstrap/ng-bootstrap' 23import { NgbNav } from '@ng-bootstrap/ng-bootstrap'
24import { CustomConfig, ServerConfig } from '@shared/models' 24import { CustomConfig, ServerConfig } from '@shared/models'
25import { SelectOptionsItem } from 'src/types/select-options-item.model'
25 26
26@Component({ 27@Component({
27 selector: 'my-edit-custom-config', 28 selector: 'my-edit-custom-config',
diff --git a/client/src/app/+admin/config/shared/config.service.ts b/client/src/app/+admin/config/shared/config.service.ts
index 5f98aa545..d29b752f7 100644
--- a/client/src/app/+admin/config/shared/config.service.ts
+++ b/client/src/app/+admin/config/shared/config.service.ts
@@ -3,43 +3,46 @@ import { HttpClient } from '@angular/common/http'
3import { Injectable } from '@angular/core' 3import { Injectable } from '@angular/core'
4import { RestExtractor } from '@app/core' 4import { RestExtractor } from '@app/core'
5import { CustomConfig } from '@shared/models' 5import { CustomConfig } from '@shared/models'
6import { SelectOptionsItem } from '../../../../types/select-options-item.model'
6import { environment } from '../../../../environments/environment' 7import { environment } from '../../../../environments/environment'
7 8
8@Injectable() 9@Injectable()
9export class ConfigService { 10export class ConfigService {
10 private static BASE_APPLICATION_URL = environment.apiUrl + '/api/v1/config' 11 private static BASE_APPLICATION_URL = environment.apiUrl + '/api/v1/config'
11 12
12 videoQuotaOptions: { value: number, label: string, disabled?: boolean }[] = [] 13 videoQuotaOptions: SelectOptionsItem[] = []
13 videoQuotaDailyOptions: { value: number, label: string, disabled?: boolean }[] = [] 14 videoQuotaDailyOptions: SelectOptionsItem[] = []
14 15
15 constructor ( 16 constructor (
16 private authHttp: HttpClient, 17 private authHttp: HttpClient,
17 private restExtractor: RestExtractor 18 private restExtractor: RestExtractor
18 ) { 19 ) {
19 this.videoQuotaOptions = [ 20 this.videoQuotaOptions = [
20 { value: undefined, label: 'Default quota', disabled: true }, 21 { id: -1, label: $localize`Unlimited` },
21 { value: -1, label: $localize`Unlimited` }, 22 { id: 0, label: $localize`None - no upload possible` },
22 { value: undefined, label: '─────', disabled: true }, 23 { id: 100 * 1024 * 1024, label: $localize`100MB` },
23 { value: 0, label: $localize`None - no upload possible` }, 24 { id: 500 * 1024 * 1024, label: $localize`500MB` },
24 { value: 100 * 1024 * 1024, label: $localize`100MB` }, 25 { id: 1024 * 1024 * 1024, label: $localize`1GB` },
25 { value: 500 * 1024 * 1024, label: $localize`500MB` }, 26 { id: 5 * 1024 * 1024 * 1024, label: $localize`5GB` },
26 { value: 1024 * 1024 * 1024, label: $localize`1GB` }, 27 { id: 20 * 1024 * 1024 * 1024, label: $localize`20GB` },
27 { value: 5 * 1024 * 1024 * 1024, label: $localize`5GB` }, 28 { id: 50 * 1024 * 1024 * 1024, label: $localize`50GB` },
28 { value: 20 * 1024 * 1024 * 1024, label: $localize`20GB` }, 29 { id: 100 * 1024 * 1024 * 1024, label: $localize`100GB` },
29 { value: 50 * 1024 * 1024 * 1024, label: $localize`50GB` } 30 { id: 200 * 1024 * 1024 * 1024, label: $localize`200GB` },
31 { id: 500 * 1024 * 1024 * 1024, label: $localize`500GB` }
30 ] 32 ]
31 33
32 this.videoQuotaDailyOptions = [ 34 this.videoQuotaDailyOptions = [
33 { value: undefined, label: 'Default daily upload limit', disabled: true }, 35 { id: -1, label: $localize`Unlimited` },
34 { value: -1, label: $localize`Unlimited` }, 36 { id: 0, label: $localize`None - no upload possible` },
35 { value: undefined, label: '─────', disabled: true }, 37 { id: 10 * 1024 * 1024, label: $localize`10MB` },
36 { value: 0, label: $localize`None - no upload possible` }, 38 { id: 50 * 1024 * 1024, label: $localize`50MB` },
37 { value: 10 * 1024 * 1024, label: $localize`10MB` }, 39 { id: 100 * 1024 * 1024, label: $localize`100MB` },
38 { value: 50 * 1024 * 1024, label: $localize`50MB` }, 40 { id: 500 * 1024 * 1024, label: $localize`500MB` },
39 { value: 100 * 1024 * 1024, label: $localize`100MB` }, 41 { id: 2 * 1024 * 1024 * 1024, label: $localize`2GB` },
40 { value: 500 * 1024 * 1024, label: $localize`500MB` }, 42 { id: 5 * 1024 * 1024 * 1024, label: $localize`5GB` },
41 { value: 2 * 1024 * 1024 * 1024, label: $localize`2GB` }, 43 { id: 10 * 1024 * 1024 * 1024, label: $localize`10GB` },
42 { value: 5 * 1024 * 1024 * 1024, label: $localize`5GB` } 44 { id: 20 * 1024 * 1024 * 1024, label: $localize`20GB` },
45 { id: 50 * 1024 * 1024 * 1024, label: $localize`50GB` }
43 ] 46 ]
44 } 47 }
45 48