]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blobdiff - client/src/app/+admin/users/user-edit/user-create.component.ts
allow administration to change/reset a user's password
[github/Chocobozzz/PeerTube.git] / client / src / app / +admin / users / user-edit / user-create.component.ts
index e5f0903b646e4b6af73265fa0d94f90d3c2938a8..137ecfcbddc1c7d51d995f3458e7c34c715afe9f 100644 (file)
@@ -1,13 +1,13 @@
 import { Component, OnInit } from '@angular/core'
 import { Router } from '@angular/router'
-import { NotificationsService } from 'angular2-notifications'
-import { UserService } from '../shared'
-import { USER_EMAIL, USER_PASSWORD, USER_ROLE, USER_USERNAME, USER_VIDEO_QUOTA } from '../../../shared'
-import { ServerService } from '../../../core'
+import { Notifier, ServerService } from '@app/core'
 import { UserCreate, UserRole } from '../../../../../../shared'
 import { UserEdit } from './user-edit'
 import { I18n } from '@ngx-translate/i18n-polyfill'
 import { FormValidatorService } from '@app/shared/forms/form-validators/form-validator.service'
+import { UserValidatorsService } from '@app/shared/forms/form-validators/user-validators.service'
+import { ConfigService } from '@app/+admin/config/shared/config.service'
+import { UserService } from '@app/shared'
 
 @Component({
   selector: 'my-user-create',
@@ -20,26 +20,32 @@ export class UserCreateComponent extends UserEdit implements OnInit {
   constructor (
     protected serverService: ServerService,
     protected formValidatorService: FormValidatorService,
+    protected configService: ConfigService,
+    private userValidatorsService: UserValidatorsService,
     private router: Router,
-    private notificationsService: NotificationsService,
+    private notifier: Notifier,
     private userService: UserService,
     private i18n: I18n
   ) {
     super()
+
+    this.buildQuotaOptions()
   }
 
   ngOnInit () {
     const defaultValues = {
       role: UserRole.USER.toString(),
-      videoQuota: '-1'
+      videoQuota: '-1',
+      videoQuotaDaily: '-1'
     }
 
     this.buildForm({
-      username: USER_USERNAME,
-      email: USER_EMAIL,
-      password: USER_PASSWORD,
-      role: USER_ROLE,
-      videoQuota: USER_VIDEO_QUOTA
+      username: this.userValidatorsService.USER_USERNAME,
+      email: this.userValidatorsService.USER_EMAIL,
+      password: this.userValidatorsService.USER_PASSWORD,
+      role: this.userValidatorsService.USER_ROLE,
+      videoQuota: this.userValidatorsService.USER_VIDEO_QUOTA,
+      videoQuotaDaily: this.userValidatorsService.USER_VIDEO_QUOTA_DAILY
     }, defaultValues)
   }
 
@@ -53,10 +59,7 @@ export class UserCreateComponent extends UserEdit implements OnInit {
 
     this.userService.addUser(userCreate).subscribe(
       () => {
-        this.notificationsService.success(
-          this.i18n('Success'),
-          this.i18n('User {{username}} created.', { username: userCreate.username })
-        )
+        this.notifier.success(this.i18n('User {{username}} created.', { username: userCreate.username }))
         this.router.navigate([ '/admin/users/list' ])
       },