aboutsummaryrefslogtreecommitdiffhomepage
path: root/client/src/app/+admin/users/user-edit
diff options
context:
space:
mode:
authorFelix Ableitner <me@nutomic.com>2018-08-28 02:01:35 -0500
committerChocobozzz <me@florianbigard.com>2018-08-28 09:01:35 +0200
commitbee0abffff73804d816b90c7fd599e0a51c09d61 (patch)
treefae6d58637f9c63a3800090277f8e130b43442dd /client/src/app/+admin/users/user-edit
parentc907c2fa3fd7c0a741117a0204d0ebca675124bd (diff)
downloadPeerTube-bee0abffff73804d816b90c7fd599e0a51c09d61.tar.gz
PeerTube-bee0abffff73804d816b90c7fd599e0a51c09d61.tar.zst
PeerTube-bee0abffff73804d816b90c7fd599e0a51c09d61.zip
Implement daily upload limit (#956)
* Implement daily upload limit (ref #652) * remove duplicate code * review fixes * fix tests? * whitespace fixes, finish leftover todo * fix tests * added some new tests * use different config value for tests * remove todo
Diffstat (limited to 'client/src/app/+admin/users/user-edit')
-rw-r--r--client/src/app/+admin/users/user-edit/user-edit.component.html9
-rw-r--r--client/src/app/+admin/users/user-edit/user-edit.ts17
-rw-r--r--client/src/app/+admin/users/user-edit/user-update.component.ts9
3 files changed, 22 insertions, 13 deletions
diff --git a/client/src/app/+admin/users/user-edit/user-edit.component.html b/client/src/app/+admin/users/user-edit/user-edit.component.html
index 4626a40c9..bb745d6aa 100644
--- a/client/src/app/+admin/users/user-edit/user-edit.component.html
+++ b/client/src/app/+admin/users/user-edit/user-edit.component.html
@@ -61,6 +61,15 @@
61 </option> 61 </option>
62 </select> 62 </select>
63 </div> 63 </div>
64
65 <label i18n for="videoQuotaDaily">Daily video quota</label>
66 <div class="peertube-select-container">
67 <select id="videoQuotaDaily" formControlName="videoQuotaDaily">
68 <option *ngFor="let videoQuotaDailyOption of videoQuotaDailyOptions" [value]="videoQuotaDailyOption.value">
69 {{ videoQuotaDailyOption.label }}
70 </option>
71 </select>
72 </div>
64 73
65 <div i18n class="transcoding-information" *ngIf="isTranscodingInformationDisplayed()"> 74 <div i18n class="transcoding-information" *ngIf="isTranscodingInformationDisplayed()">
66 Transcoding is enabled on server. The video quota only take in account <strong>original</strong> video. <br /> 75 Transcoding is enabled on server. The video quota only take in account <strong>original</strong> video. <br />
diff --git a/client/src/app/+admin/users/user-edit/user-edit.ts b/client/src/app/+admin/users/user-edit/user-edit.ts
index ea8c733c3..4e7ca8a1b 100644
--- a/client/src/app/+admin/users/user-edit/user-edit.ts
+++ b/client/src/app/+admin/users/user-edit/user-edit.ts
@@ -1,18 +1,15 @@
1import { ServerService } from '../../../core' 1import { ServerService } from '../../../core'
2import { FormReactive } from '../../../shared' 2import { FormReactive } from '../../../shared'
3import { USER_ROLE_LABELS, VideoResolution } from '../../../../../../shared' 3import { USER_ROLE_LABELS, VideoResolution } from '../../../../../../shared'
4import { EditCustomConfigComponent } from '../../../+admin/config/edit-custom-config/'
4 5
5export abstract class UserEdit extends FormReactive { 6export abstract class UserEdit extends FormReactive {
6 videoQuotaOptions = [ 7
7 { value: -1, label: 'Unlimited' }, 8 // These are used by a HTML select, so convert key into strings
8 { value: 0, label: '0' }, 9 videoQuotaOptions = EditCustomConfigComponent.videoQuotaOptions
9 { value: 100 * 1024 * 1024, label: '100MB' }, 10 .map(q => ({ value: q.value.toString(), label: q.label }))
10 { value: 500 * 1024 * 1024, label: '500MB' }, 11 videoQuotaDailyOptions = EditCustomConfigComponent.videoQuotaDailyOptions
11 { value: 1024 * 1024 * 1024, label: '1GB' }, 12 .map(q => ({ value: q.value.toString(), label: q.label }))
12 { value: 5 * 1024 * 1024 * 1024, label: '5GB' },
13 { value: 20 * 1024 * 1024 * 1024, label: '20GB' },
14 { value: 50 * 1024 * 1024 * 1024, label: '50GB' }
15 ].map(q => ({ value: q.value.toString(), label: q.label })) // Used by a HTML select, so convert key into strings
16 13
17 roles = Object.keys(USER_ROLE_LABELS).map(key => ({ value: key.toString(), label: USER_ROLE_LABELS[key] })) 14 roles = Object.keys(USER_ROLE_LABELS).map(key => ({ value: key.toString(), label: USER_ROLE_LABELS[key] }))
18 15
diff --git a/client/src/app/+admin/users/user-edit/user-update.component.ts b/client/src/app/+admin/users/user-edit/user-update.component.ts
index 06bde582e..5821229b3 100644
--- a/client/src/app/+admin/users/user-edit/user-update.component.ts
+++ b/client/src/app/+admin/users/user-edit/user-update.component.ts
@@ -36,11 +36,12 @@ export class UserUpdateComponent extends UserEdit implements OnInit, OnDestroy {
36 } 36 }
37 37
38 ngOnInit () { 38 ngOnInit () {
39 const defaultValues = { videoQuota: '-1' } 39 const defaultValues = { videoQuota: '-1', videoQuotaDaily: '-1' }
40 this.buildForm({ 40 this.buildForm({
41 email: this.userValidatorsService.USER_EMAIL, 41 email: this.userValidatorsService.USER_EMAIL,
42 role: this.userValidatorsService.USER_ROLE, 42 role: this.userValidatorsService.USER_ROLE,
43 videoQuota: this.userValidatorsService.USER_VIDEO_QUOTA 43 videoQuota: this.userValidatorsService.USER_VIDEO_QUOTA,
44 videoQuotaDaily: this.userValidatorsService.USER_VIDEO_QUOTA_DAILY
44 }, defaultValues) 45 }, defaultValues)
45 46
46 this.paramsSub = this.route.params.subscribe(routeParams => { 47 this.paramsSub = this.route.params.subscribe(routeParams => {
@@ -64,6 +65,7 @@ export class UserUpdateComponent extends UserEdit implements OnInit, OnDestroy {
64 65
65 // A select in HTML is always mapped as a string, we convert it to number 66 // A select in HTML is always mapped as a string, we convert it to number
66 userUpdate.videoQuota = parseInt(this.form.value['videoQuota'], 10) 67 userUpdate.videoQuota = parseInt(this.form.value['videoQuota'], 10)
68 userUpdate.videoQuotaDaily = parseInt(this.form.value['videoQuotaDaily'], 10)
67 69
68 this.userService.updateUser(this.userId, userUpdate).subscribe( 70 this.userService.updateUser(this.userId, userUpdate).subscribe(
69 () => { 71 () => {
@@ -93,7 +95,8 @@ export class UserUpdateComponent extends UserEdit implements OnInit, OnDestroy {
93 this.form.patchValue({ 95 this.form.patchValue({
94 email: userJson.email, 96 email: userJson.email,
95 role: userJson.role, 97 role: userJson.role,
96 videoQuota: userJson.videoQuota 98 videoQuota: userJson.videoQuota,
99 videoQuotaDaily: userJson.videoQuotaDaily
97 }) 100 })
98 } 101 }
99} 102}