aboutsummaryrefslogtreecommitdiffhomepage
path: root/client/src/app/+admin/users/user-edit/user-update.component.ts
diff options
context:
space:
mode:
Diffstat (limited to 'client/src/app/+admin/users/user-edit/user-update.component.ts')
-rw-r--r--client/src/app/+admin/users/user-edit/user-update.component.ts33
1 files changed, 8 insertions, 25 deletions
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 5689aab2f..f8073c928 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
@@ -1,5 +1,4 @@
1import { Component, OnDestroy, OnInit } from '@angular/core' 1import { Component, OnDestroy, OnInit } from '@angular/core'
2import { FormBuilder, FormGroup } from '@angular/forms'
3import { ActivatedRoute, Router } from '@angular/router' 2import { ActivatedRoute, Router } from '@angular/router'
4import { Subscription } from 'rxjs' 3import { Subscription } from 'rxjs'
5import { NotificationsService } from 'angular2-notifications' 4import { NotificationsService } from 'angular2-notifications'
@@ -9,6 +8,7 @@ import { ServerService } from '../../../core'
9import { UserEdit } from './user-edit' 8import { UserEdit } from './user-edit'
10import { UserUpdate } from '../../../../../../shared' 9import { UserUpdate } from '../../../../../../shared'
11import { I18n } from '@ngx-translate/i18n-polyfill' 10import { I18n } from '@ngx-translate/i18n-polyfill'
11import { FormValidatorService } from '@app/shared/forms/form-validators/form-validator.service'
12 12
13@Component({ 13@Component({
14 selector: 'my-user-update', 14 selector: 'my-user-update',
@@ -20,44 +20,27 @@ export class UserUpdateComponent extends UserEdit implements OnInit, OnDestroy {
20 userId: number 20 userId: number
21 username: string 21 username: string
22 22
23 form: FormGroup
24 formErrors = {
25 'email': '',
26 'role': '',
27 'videoQuota': ''
28 }
29 validationMessages = {
30 'email': USER_EMAIL.MESSAGES,
31 'role': USER_ROLE.MESSAGES,
32 'videoQuota': USER_VIDEO_QUOTA.MESSAGES
33 }
34
35 private paramsSub: Subscription 23 private paramsSub: Subscription
36 24
37 constructor ( 25 constructor (
26 protected formValidatorService: FormValidatorService,
38 protected serverService: ServerService, 27 protected serverService: ServerService,
39 private route: ActivatedRoute, 28 private route: ActivatedRoute,
40 private router: Router, 29 private router: Router,
41 private notificationsService: NotificationsService, 30 private notificationsService: NotificationsService,
42 private formBuilder: FormBuilder,
43 private userService: UserService, 31 private userService: UserService,
44 private i18n: I18n 32 private i18n: I18n
45 ) { 33 ) {
46 super() 34 super()
47 } 35 }
48 36
49 buildForm () {
50 this.form = this.formBuilder.group({
51 email: [ '', USER_EMAIL.VALIDATORS ],
52 role: [ '', USER_ROLE.VALIDATORS ],
53 videoQuota: [ '-1', USER_VIDEO_QUOTA.VALIDATORS ]
54 })
55
56 this.form.valueChanges.subscribe(data => this.onValueChanged(data))
57 }
58
59 ngOnInit () { 37 ngOnInit () {
60 this.buildForm() 38 const defaultValues = { videoQuota: '-1' }
39 this.buildForm({
40 email: USER_EMAIL,
41 role: USER_ROLE,
42 videoQuota: USER_VIDEO_QUOTA
43 }, defaultValues)
61 44
62 this.paramsSub = this.route.params.subscribe(routeParams => { 45 this.paramsSub = this.route.params.subscribe(routeParams => {
63 const userId = routeParams['id'] 46 const userId = routeParams['id']