]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blobdiff - client/src/app/+my-account/my-account-settings/my-account-profile/my-account-profile.component.ts
add username information in profile settings
[github/Chocobozzz/PeerTube.git] / client / src / app / +my-account / my-account-settings / my-account-profile / my-account-profile.component.ts
index a9503ed1b8eb9769fb5292b357df98b3024490f7..957abe5555b6b5029cd63adcb0cf452a47fd2a5a 100644 (file)
@@ -1,11 +1,8 @@
-import { Component, Input, OnInit } from '@angular/core'
-import { Notifier } from '@app/core'
-import { FormReactive, UserService } from '../../../shared'
-import { User } from '@app/shared'
-import { I18n } from '@ngx-translate/i18n-polyfill'
-import { FormValidatorService } from '@app/shared/forms/form-validators/form-validator.service'
 import { Subject } from 'rxjs'
-import { UserValidatorsService } from '@app/shared/forms/form-validators/user-validators.service'
+import { Component, Input, OnInit } from '@angular/core'
+import { Notifier, User, UserService } from '@app/core'
+import { USER_DESCRIPTION_VALIDATOR, USER_DISPLAY_NAME_REQUIRED_VALIDATOR } from '@app/shared/form-validators/user-validators'
+import { FormReactive, FormValidatorService } from '@app/shared/shared-forms'
 
 @Component({
   selector: 'my-account-profile',
@@ -20,28 +17,33 @@ export class MyAccountProfileComponent extends FormReactive implements OnInit {
 
   constructor (
     protected formValidatorService: FormValidatorService,
-    private userValidatorsService: UserValidatorsService,
     private notifier: Notifier,
-    private userService: UserService,
-    private i18n: I18n
+    private userService: UserService
   ) {
     super()
   }
 
   ngOnInit () {
     this.buildForm({
-      'display-name': this.userValidatorsService.USER_DISPLAY_NAME,
-      description: this.userValidatorsService.USER_DESCRIPTION
+      'user-name': null,
+      'display-name': USER_DISPLAY_NAME_REQUIRED_VALIDATOR,
+      description: USER_DESCRIPTION_VALIDATOR
     })
+    this.form.controls['user-name'].disable()
 
     this.userInformationLoaded.subscribe(() => {
       this.form.patchValue({
+        'user-name': this.user.username,
         'display-name': this.user.account.displayName,
         description: this.user.account.description
       })
     })
   }
 
+  get instanceHost () {
+    return window.location.host
+  }
+
   updateMyProfile () {
     const displayName = this.form.value['display-name']
     const description = this.form.value['description'] || null
@@ -53,7 +55,7 @@ export class MyAccountProfileComponent extends FormReactive implements OnInit {
         this.user.account.displayName = displayName
         this.user.account.description = description
 
-        this.notifier.success(this.i18n('Profile updated.'))
+        this.notifier.success($localize`Profile updated.`)
       },
 
       err => this.error = err.message