1 import { Component, Input, OnInit } from '@angular/core'
2 import { Notifier, UserService } from '@app/core'
3 import { FormReactive, FormValidatorService, UserValidatorsService } from '@app/shared/shared-forms'
4 import { I18n } from '@ngx-translate/i18n-polyfill'
5 import { UserUpdate } from '@shared/models'
8 selector: 'my-user-password',
9 templateUrl: './user-password.component.html',
10 styleUrls: [ './user-password.component.scss' ]
12 export class UserPasswordComponent extends FormReactive implements OnInit {
17 @Input() userId: number
20 protected formValidatorService: FormValidatorService,
21 private userValidatorsService: UserValidatorsService,
22 private notifier: Notifier,
23 private userService: UserService,
31 password: this.userValidatorsService.USER_PASSWORD
36 this.error = undefined
38 const userUpdate: UserUpdate = this.form.value
40 this.userService.updateUser(this.userId, userUpdate).subscribe(
42 this.notifier.success(
43 this.i18n('Password changed for user {{username}}.', { username: this.username })
47 err => this.error = err.message
51 togglePasswordVisibility () {
52 this.showPassword = !this.showPassword
55 getFormButtonTitle () {
56 return this.i18n('Update user password')