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 { UserUpdate } from '@shared/models'
7 selector: 'my-user-password',
8 templateUrl: './user-password.component.html',
9 styleUrls: [ './user-password.component.scss' ]
11 export class UserPasswordComponent extends FormReactive implements OnInit {
16 @Input() userId: number
19 protected formValidatorService: FormValidatorService,
20 private userValidatorsService: UserValidatorsService,
21 private notifier: Notifier,
22 private userService: UserService
29 password: this.userValidatorsService.USER_PASSWORD
34 this.error = undefined
36 const userUpdate: UserUpdate = this.form.value
38 this.userService.updateUser(this.userId, userUpdate).subscribe(
40 this.notifier.success($localize`Password changed for user ${this.username}.`)
43 err => this.error = err.message
47 togglePasswordVisibility () {
48 this.showPassword = !this.showPassword
51 getFormButtonTitle () {
52 return $localize`Update user password`