+import { Subject } from 'rxjs'
import { Component, Input, OnInit } from '@angular/core'
-import { NotificationsService } from 'angular2-notifications'
-import { FormReactive, USER_DESCRIPTION, USER_DISPLAY_NAME, 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/Subject'
+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',
constructor (
protected formValidatorService: FormValidatorService,
- private notificationsService: NotificationsService,
- private userService: UserService,
- private i18n: I18n
+ private notifier: Notifier,
+ private userService: UserService
) {
super()
}
ngOnInit () {
this.buildForm({
- 'display-name': USER_DISPLAY_NAME,
- description: 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
this.user.account.displayName = displayName
this.user.account.description = description
- this.notificationsService.success(this.i18n('Success'), this.i18n('Profile updated.'))
+ this.notifier.success($localize`Profile updated.`)
},
err => this.error = err.message