aboutsummaryrefslogtreecommitdiffhomepage
path: root/client/src/app/+admin
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2019-04-15 10:49:46 +0200
committerChocobozzz <me@florianbigard.com>2019-04-15 14:39:52 +0200
commit1eddc9a74f9a80fa5d0cb25fceb3fc47a1a3c14a (patch)
tree91a10310cdf924779527525d39f8eb7e09e4ba49 /client/src/app/+admin
parent31b48aad478506d4214586f02792816efa968e4b (diff)
downloadPeerTube-1eddc9a74f9a80fa5d0cb25fceb3fc47a1a3c14a.tar.gz
PeerTube-1eddc9a74f9a80fa5d0cb25fceb3fc47a1a3c14a.tar.zst
PeerTube-1eddc9a74f9a80fa5d0cb25fceb3fc47a1a3c14a.zip
Add user adminFlags
Diffstat (limited to 'client/src/app/+admin')
-rw-r--r--client/src/app/+admin/users/user-edit/user-create.component.ts7
-rw-r--r--client/src/app/+admin/users/user-edit/user-edit.component.html7
-rw-r--r--client/src/app/+admin/users/user-edit/user-edit.ts5
-rw-r--r--client/src/app/+admin/users/user-edit/user-update.component.ts8
4 files changed, 24 insertions, 3 deletions
diff --git a/client/src/app/+admin/users/user-edit/user-create.component.ts b/client/src/app/+admin/users/user-edit/user-create.component.ts
index 137ecfcbd..9a6801806 100644
--- a/client/src/app/+admin/users/user-edit/user-create.component.ts
+++ b/client/src/app/+admin/users/user-edit/user-create.component.ts
@@ -8,6 +8,7 @@ import { FormValidatorService } from '@app/shared/forms/form-validators/form-val
8import { UserValidatorsService } from '@app/shared/forms/form-validators/user-validators.service' 8import { UserValidatorsService } from '@app/shared/forms/form-validators/user-validators.service'
9import { ConfigService } from '@app/+admin/config/shared/config.service' 9import { ConfigService } from '@app/+admin/config/shared/config.service'
10import { UserService } from '@app/shared' 10import { UserService } from '@app/shared'
11import { UserAdminFlag } from '@shared/models/users/user-flag.model'
11 12
12@Component({ 13@Component({
13 selector: 'my-user-create', 14 selector: 'my-user-create',
@@ -45,7 +46,8 @@ export class UserCreateComponent extends UserEdit implements OnInit {
45 password: this.userValidatorsService.USER_PASSWORD, 46 password: this.userValidatorsService.USER_PASSWORD,
46 role: this.userValidatorsService.USER_ROLE, 47 role: this.userValidatorsService.USER_ROLE,
47 videoQuota: this.userValidatorsService.USER_VIDEO_QUOTA, 48 videoQuota: this.userValidatorsService.USER_VIDEO_QUOTA,
48 videoQuotaDaily: this.userValidatorsService.USER_VIDEO_QUOTA_DAILY 49 videoQuotaDaily: this.userValidatorsService.USER_VIDEO_QUOTA_DAILY,
50 byPassAutoBlacklist: null
49 }, defaultValues) 51 }, defaultValues)
50 } 52 }
51 53
@@ -54,8 +56,11 @@ export class UserCreateComponent extends UserEdit implements OnInit {
54 56
55 const userCreate: UserCreate = this.form.value 57 const userCreate: UserCreate = this.form.value
56 58
59 userCreate.adminFlags = this.buildAdminFlags(this.form.value)
60
57 // A select in HTML is always mapped as a string, we convert it to number 61 // A select in HTML is always mapped as a string, we convert it to number
58 userCreate.videoQuota = parseInt(this.form.value['videoQuota'], 10) 62 userCreate.videoQuota = parseInt(this.form.value['videoQuota'], 10)
63 userCreate.videoQuotaDaily = parseInt(this.form.value['videoQuotaDaily'], 10)
59 64
60 this.userService.addUser(userCreate).subscribe( 65 this.userService.addUser(userCreate).subscribe(
61 () => { 66 () => {
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 c6566da24..400bac5d4 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
@@ -79,6 +79,13 @@
79 </div> 79 </div>
80 </div> 80 </div>
81 81
82 <div class="form-group">
83 <my-peertube-checkbox
84 inputName="byPassAutoBlacklist" formControlName="byPassAutoBlacklist"
85 i18n-labelText labelText="Bypass video auto blacklist"
86 ></my-peertube-checkbox>
87 </div>
88
82 <input type="submit" value="{{ getFormButtonTitle() }}" [disabled]="!form.valid"> 89 <input type="submit" value="{{ getFormButtonTitle() }}" [disabled]="!form.valid">
83</form> 90</form>
84 91
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 649b35b0c..adce1b2d4 100644
--- a/client/src/app/+admin/users/user-edit/user-edit.ts
+++ b/client/src/app/+admin/users/user-edit/user-edit.ts
@@ -2,6 +2,7 @@ import { 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 { ConfigService } from '@app/+admin/config/shared/config.service' 4import { ConfigService } from '@app/+admin/config/shared/config.service'
5import { UserAdminFlag } from '@shared/models/users/user-flag.model'
5 6
6export abstract class UserEdit extends FormReactive { 7export abstract class UserEdit extends FormReactive {
7 videoQuotaOptions: { value: string, label: string }[] = [] 8 videoQuotaOptions: { value: string, label: string }[] = []
@@ -42,6 +43,10 @@ export abstract class UserEdit extends FormReactive {
42 return 43 return
43 } 44 }
44 45
46 protected buildAdminFlags (formValue: any) {
47 return formValue.byPassAutoBlacklist ? UserAdminFlag.BY_PASS_VIDEO_AUTO_BLACKLIST : UserAdminFlag.NONE
48 }
49
45 protected buildQuotaOptions () { 50 protected buildQuotaOptions () {
46 // These are used by a HTML select, so convert key into strings 51 // These are used by a HTML select, so convert key into strings
47 this.videoQuotaOptions = this.configService 52 this.videoQuotaOptions = this.configService
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 94ef87b08..04b2935f4 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
@@ -10,6 +10,7 @@ import { FormValidatorService } from '@app/shared/forms/form-validators/form-val
10import { UserValidatorsService } from '@app/shared/forms/form-validators/user-validators.service' 10import { UserValidatorsService } from '@app/shared/forms/form-validators/user-validators.service'
11import { ConfigService } from '@app/+admin/config/shared/config.service' 11import { ConfigService } from '@app/+admin/config/shared/config.service'
12import { UserService } from '@app/shared' 12import { UserService } from '@app/shared'
13import { UserAdminFlag } from '@shared/models/users/user-flag.model'
13 14
14@Component({ 15@Component({
15 selector: 'my-user-update', 16 selector: 'my-user-update',
@@ -46,7 +47,8 @@ export class UserUpdateComponent extends UserEdit implements OnInit, OnDestroy {
46 email: this.userValidatorsService.USER_EMAIL, 47 email: this.userValidatorsService.USER_EMAIL,
47 role: this.userValidatorsService.USER_ROLE, 48 role: this.userValidatorsService.USER_ROLE,
48 videoQuota: this.userValidatorsService.USER_VIDEO_QUOTA, 49 videoQuota: this.userValidatorsService.USER_VIDEO_QUOTA,
49 videoQuotaDaily: this.userValidatorsService.USER_VIDEO_QUOTA_DAILY 50 videoQuotaDaily: this.userValidatorsService.USER_VIDEO_QUOTA_DAILY,
51 byPassAutoBlacklist: null
50 }, defaultValues) 52 }, defaultValues)
51 53
52 this.paramsSub = this.route.params.subscribe(routeParams => { 54 this.paramsSub = this.route.params.subscribe(routeParams => {
@@ -67,6 +69,7 @@ export class UserUpdateComponent extends UserEdit implements OnInit, OnDestroy {
67 this.error = undefined 69 this.error = undefined
68 70
69 const userUpdate: UserUpdate = this.form.value 71 const userUpdate: UserUpdate = this.form.value
72 userUpdate.adminFlags = this.buildAdminFlags(this.form.value)
70 73
71 // A select in HTML is always mapped as a string, we convert it to number 74 // A select in HTML is always mapped as a string, we convert it to number
72 userUpdate.videoQuota = parseInt(this.form.value['videoQuota'], 10) 75 userUpdate.videoQuota = parseInt(this.form.value['videoQuota'], 10)
@@ -111,7 +114,8 @@ export class UserUpdateComponent extends UserEdit implements OnInit, OnDestroy {
111 email: userJson.email, 114 email: userJson.email,
112 role: userJson.role, 115 role: userJson.role,
113 videoQuota: userJson.videoQuota, 116 videoQuota: userJson.videoQuota,
114 videoQuotaDaily: userJson.videoQuotaDaily 117 videoQuotaDaily: userJson.videoQuotaDaily,
118 byPassAutoBlacklist: userJson.adminFlags & UserAdminFlag.BY_PASS_VIDEO_AUTO_BLACKLIST
115 }) 119 })
116 } 120 }
117} 121}