]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blame - client/src/app/+admin/overview/users/user-edit/user-password.component.ts
Increase global font size
[github/Chocobozzz/PeerTube.git] / client / src / app / +admin / overview / users / user-edit / user-password.component.ts
CommitLineData
b426edd4 1import { Component, Input, OnInit } from '@angular/core'
d92d070c 2import { Notifier } from '@app/core'
7ed1edbb
C
3import { USER_PASSWORD_VALIDATOR } from '@app/shared/form-validators/user-validators'
4import { FormReactive, FormValidatorService } from '@app/shared/shared-forms'
d92d070c 5import { UserAdminService } from '@app/shared/shared-users'
67ed6552 6import { UserUpdate } from '@shared/models'
328c78bc
RK
7
8@Component({
9 selector: 'my-user-password',
10 templateUrl: './user-password.component.html',
11 styleUrls: [ './user-password.component.scss' ]
12})
b426edd4 13export class UserPasswordComponent extends FormReactive implements OnInit {
328c78bc 14 error: string
328c78bc
RK
15 username: string
16 showPassword = false
17
2c2baef6
RK
18 @Input() userId: number
19
328c78bc
RK
20 constructor (
21 protected formValidatorService: FormValidatorService,
b426edd4 22 private notifier: Notifier,
d92d070c 23 private userAdminService: UserAdminService
9df52d66 24 ) {
328c78bc
RK
25 super()
26 }
27
28 ngOnInit () {
29 this.buildForm({
7ed1edbb 30 password: USER_PASSWORD_VALIDATOR
328c78bc 31 })
328c78bc
RK
32 }
33
328c78bc
RK
34 formValidated () {
35 this.error = undefined
36
37 const userUpdate: UserUpdate = this.form.value
38
d92d070c 39 this.userAdminService.updateUser(this.userId, userUpdate)
1378c0d3
C
40 .subscribe({
41 next: () => this.notifier.success($localize`Password changed for user ${this.username}.`),
328c78bc 42
9df52d66
C
43 error: err => {
44 this.error = err.message
45 }
1378c0d3 46 })
328c78bc
RK
47 }
48
328c78bc
RK
49 togglePasswordVisibility () {
50 this.showPassword = !this.showPassword
51 }
52
53 getFormButtonTitle () {
66357162 54 return $localize`Update user password`
328c78bc 55 }
328c78bc 56}