diff options
author | Chocobozzz <me@florianbigard.com> | 2021-10-27 09:36:37 +0200 |
---|---|---|
committer | Chocobozzz <chocobozzz@cpy.re> | 2021-10-29 11:48:21 +0200 |
commit | 00004f7f6b966a975498612117212b5373f4103c (patch) | |
tree | 4899b77da3c55bf1fbb77f927d9da5cd873e2c2a /client/src/app/+admin/overview/users/user-edit/user-password.component.ts | |
parent | bd898dd76babf6ab33a0040297bfb40a69a69dda (diff) | |
download | PeerTube-00004f7f6b966a975498612117212b5373f4103c.tar.gz PeerTube-00004f7f6b966a975498612117212b5373f4103c.tar.zst PeerTube-00004f7f6b966a975498612117212b5373f4103c.zip |
Put admin users in overview tab
Diffstat (limited to 'client/src/app/+admin/overview/users/user-edit/user-password.component.ts')
-rw-r--r-- | client/src/app/+admin/overview/users/user-edit/user-password.component.ts | 55 |
1 files changed, 55 insertions, 0 deletions
diff --git a/client/src/app/+admin/overview/users/user-edit/user-password.component.ts b/client/src/app/+admin/overview/users/user-edit/user-password.component.ts new file mode 100644 index 000000000..42bf20de1 --- /dev/null +++ b/client/src/app/+admin/overview/users/user-edit/user-password.component.ts | |||
@@ -0,0 +1,55 @@ | |||
1 | import { Component, Input, OnInit } from '@angular/core' | ||
2 | import { Notifier, UserService } 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 { UserUpdate } from '@shared/models' | ||
6 | |||
7 | @Component({ | ||
8 | selector: 'my-user-password', | ||
9 | templateUrl: './user-password.component.html', | ||
10 | styleUrls: [ './user-password.component.scss' ] | ||
11 | }) | ||
12 | export class UserPasswordComponent extends FormReactive implements OnInit { | ||
13 | error: string | ||
14 | username: string | ||
15 | showPassword = false | ||
16 | |||
17 | @Input() userId: number | ||
18 | |||
19 | constructor ( | ||
20 | protected formValidatorService: FormValidatorService, | ||
21 | private notifier: Notifier, | ||
22 | private userService: UserService | ||
23 | ) { | ||
24 | super() | ||
25 | } | ||
26 | |||
27 | ngOnInit () { | ||
28 | this.buildForm({ | ||
29 | password: USER_PASSWORD_VALIDATOR | ||
30 | }) | ||
31 | } | ||
32 | |||
33 | formValidated () { | ||
34 | this.error = undefined | ||
35 | |||
36 | const userUpdate: UserUpdate = this.form.value | ||
37 | |||
38 | this.userService.updateUser(this.userId, userUpdate) | ||
39 | .subscribe({ | ||
40 | next: () => this.notifier.success($localize`Password changed for user ${this.username}.`), | ||
41 | |||
42 | error: err => { | ||
43 | this.error = err.message | ||
44 | } | ||
45 | }) | ||
46 | } | ||
47 | |||
48 | togglePasswordVisibility () { | ||
49 | this.showPassword = !this.showPassword | ||
50 | } | ||
51 | |||
52 | getFormButtonTitle () { | ||
53 | return $localize`Update user password` | ||
54 | } | ||
55 | } | ||