aboutsummaryrefslogtreecommitdiffhomepage
path: root/client/src/app/+admin/users/user-edit
diff options
context:
space:
mode:
authorChocobozzz <florian.bigard@gmail.com>2017-10-27 16:55:03 +0200
committerChocobozzz <florian.bigard@gmail.com>2017-10-27 16:55:03 +0200
commit954605a804da399317ca62afa2fb9244afa11ebf (patch)
treede6ee69280bfb928bc01c29430e13d5b820e921a /client/src/app/+admin/users/user-edit
parente02573ad67626210ed279bad321ee139094921a1 (diff)
downloadPeerTube-954605a804da399317ca62afa2fb9244afa11ebf.tar.gz
PeerTube-954605a804da399317ca62afa2fb9244afa11ebf.tar.zst
PeerTube-954605a804da399317ca62afa2fb9244afa11ebf.zip
Support roles with rights and add moderator role
Diffstat (limited to 'client/src/app/+admin/users/user-edit')
-rw-r--r--client/src/app/+admin/users/user-edit/user-add.component.ts8
-rw-r--r--client/src/app/+admin/users/user-edit/user-edit.component.html13
-rw-r--r--client/src/app/+admin/users/user-edit/user-edit.ts4
-rw-r--r--client/src/app/+admin/users/user-edit/user-update.component.ts14
4 files changed, 33 insertions, 6 deletions
diff --git a/client/src/app/+admin/users/user-edit/user-add.component.ts b/client/src/app/+admin/users/user-edit/user-add.component.ts
index 6d8151b42..8e3e3d53d 100644
--- a/client/src/app/+admin/users/user-edit/user-add.component.ts
+++ b/client/src/app/+admin/users/user-edit/user-add.component.ts
@@ -9,10 +9,11 @@ import {
9 USER_USERNAME, 9 USER_USERNAME,
10 USER_EMAIL, 10 USER_EMAIL,
11 USER_PASSWORD, 11 USER_PASSWORD,
12 USER_VIDEO_QUOTA 12 USER_VIDEO_QUOTA,
13 USER_ROLE
13} from '../../../shared' 14} from '../../../shared'
14import { ServerService } from '../../../core' 15import { ServerService } from '../../../core'
15import { UserCreate } from '../../../../../../shared' 16import { UserCreate, UserRole } from '../../../../../../shared'
16import { UserEdit } from './user-edit' 17import { UserEdit } from './user-edit'
17 18
18@Component({ 19@Component({
@@ -28,12 +29,14 @@ export class UserAddComponent extends UserEdit implements OnInit {
28 'username': '', 29 'username': '',
29 'email': '', 30 'email': '',
30 'password': '', 31 'password': '',
32 'role': '',
31 'videoQuota': '' 33 'videoQuota': ''
32 } 34 }
33 validationMessages = { 35 validationMessages = {
34 'username': USER_USERNAME.MESSAGES, 36 'username': USER_USERNAME.MESSAGES,
35 'email': USER_EMAIL.MESSAGES, 37 'email': USER_EMAIL.MESSAGES,
36 'password': USER_PASSWORD.MESSAGES, 38 'password': USER_PASSWORD.MESSAGES,
39 'role': USER_ROLE.MESSAGES,
37 'videoQuota': USER_VIDEO_QUOTA.MESSAGES 40 'videoQuota': USER_VIDEO_QUOTA.MESSAGES
38 } 41 }
39 42
@@ -52,6 +55,7 @@ export class UserAddComponent extends UserEdit implements OnInit {
52 username: [ '', USER_USERNAME.VALIDATORS ], 55 username: [ '', USER_USERNAME.VALIDATORS ],
53 email: [ '', USER_EMAIL.VALIDATORS ], 56 email: [ '', USER_EMAIL.VALIDATORS ],
54 password: [ '', USER_PASSWORD.VALIDATORS ], 57 password: [ '', USER_PASSWORD.VALIDATORS ],
58 role: [ UserRole.USER, USER_ROLE.VALIDATORS ],
55 videoQuota: [ '-1', USER_VIDEO_QUOTA.VALIDATORS ] 59 videoQuota: [ '-1', USER_VIDEO_QUOTA.VALIDATORS ]
56 }) 60 })
57 61
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 6988071ce..349be13c1 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
@@ -41,6 +41,19 @@
41 </div> 41 </div>
42 42
43 <div class="form-group"> 43 <div class="form-group">
44 <label for="role">Role</label>
45 <select class="form-control" id="role" formControlName="role">
46 <option *ngFor="let role of roles" [value]="role.value">
47 {{ role.label }}
48 </option>
49 </select>
50
51 <div *ngIf="formErrors.role" class="alert alert-danger">
52 {{ formErrors.role }}
53 </div>
54 </div>
55
56 <div class="form-group">
44 <label for="videoQuota">Video quota</label> 57 <label for="videoQuota">Video quota</label>
45 <select class="form-control" id="videoQuota" formControlName="videoQuota"> 58 <select class="form-control" id="videoQuota" formControlName="videoQuota">
46 <option *ngFor="let videoQuotaOption of videoQuotaOptions" [value]="videoQuotaOption.value"> 59 <option *ngFor="let videoQuotaOption of videoQuotaOptions" [value]="videoQuotaOption.value">
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 76497c9b6..51d90da39 100644
--- a/client/src/app/+admin/users/user-edit/user-edit.ts
+++ b/client/src/app/+admin/users/user-edit/user-edit.ts
@@ -1,6 +1,6 @@
1import { ServerService } from '../../../core' 1import { ServerService } from '../../../core'
2import { FormReactive } from '../../../shared' 2import { FormReactive } from '../../../shared'
3import { VideoResolution } from '../../../../../../shared/models/videos/video-resolution.enum' 3import { USER_ROLE_LABELS, VideoResolution } from '../../../../../../shared'
4 4
5export abstract class UserEdit extends FormReactive { 5export abstract class UserEdit extends FormReactive {
6 videoQuotaOptions = [ 6 videoQuotaOptions = [
@@ -14,6 +14,8 @@ export abstract class UserEdit extends FormReactive {
14 { value: 50 * 1024 * 1024 * 1024, label: '50GB' } 14 { value: 50 * 1024 * 1024 * 1024, label: '50GB' }
15 ] 15 ]
16 16
17 roles = Object.keys(USER_ROLE_LABELS).map(key => ({ value: key, label: USER_ROLE_LABELS[key] }))
18
17 protected abstract serverService: ServerService 19 protected abstract serverService: ServerService
18 abstract isCreation (): boolean 20 abstract isCreation (): boolean
19 abstract getFormButtonTitle (): string 21 abstract getFormButtonTitle (): string
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 bd901e655..bcba78a35 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
@@ -6,11 +6,15 @@ import { Subscription } from 'rxjs/Subscription'
6import { NotificationsService } from 'angular2-notifications' 6import { NotificationsService } from 'angular2-notifications'
7 7
8import { UserService } from '../shared' 8import { UserService } from '../shared'
9import { USER_EMAIL, USER_VIDEO_QUOTA } from '../../../shared' 9import {
10 USER_EMAIL,
11 USER_VIDEO_QUOTA,
12 USER_ROLE,
13 User
14} from '../../../shared'
10import { ServerService } from '../../../core' 15import { ServerService } from '../../../core'
11import { UserUpdate } from '../../../../../../shared/models/users/user-update.model'
12import { User } from '../../../shared/users/user.model'
13import { UserEdit } from './user-edit' 16import { UserEdit } from './user-edit'
17import { UserUpdate, UserRole } from '../../../../../../shared'
14 18
15@Component({ 19@Component({
16 selector: 'my-user-update', 20 selector: 'my-user-update',
@@ -25,10 +29,12 @@ export class UserUpdateComponent extends UserEdit implements OnInit, OnDestroy {
25 form: FormGroup 29 form: FormGroup
26 formErrors = { 30 formErrors = {
27 'email': '', 31 'email': '',
32 'role': '',
28 'videoQuota': '' 33 'videoQuota': ''
29 } 34 }
30 validationMessages = { 35 validationMessages = {
31 'email': USER_EMAIL.MESSAGES, 36 'email': USER_EMAIL.MESSAGES,
37 'role': USER_ROLE.MESSAGES,
32 'videoQuota': USER_VIDEO_QUOTA.MESSAGES 38 'videoQuota': USER_VIDEO_QUOTA.MESSAGES
33 } 39 }
34 40
@@ -48,6 +54,7 @@ export class UserUpdateComponent extends UserEdit implements OnInit, OnDestroy {
48 buildForm () { 54 buildForm () {
49 this.form = this.formBuilder.group({ 55 this.form = this.formBuilder.group({
50 email: [ '', USER_EMAIL.VALIDATORS ], 56 email: [ '', USER_EMAIL.VALIDATORS ],
57 role: [ '', USER_ROLE.VALIDATORS ],
51 videoQuota: [ '-1', USER_VIDEO_QUOTA.VALIDATORS ] 58 videoQuota: [ '-1', USER_VIDEO_QUOTA.VALIDATORS ]
52 }) 59 })
53 60
@@ -103,6 +110,7 @@ export class UserUpdateComponent extends UserEdit implements OnInit, OnDestroy {
103 110
104 this.form.patchValue({ 111 this.form.patchValue({
105 email: userJson.email, 112 email: userJson.email,
113 role: userJson.role,
106 videoQuota: userJson.videoQuota 114 videoQuota: userJson.videoQuota
107 }) 115 })
108 } 116 }