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