diff options
author | Rigel Kent <sendmemail@rigelk.eu> | 2020-03-27 15:19:03 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-03-27 15:19:03 +0100 |
commit | 76314386aeafdd6849b7b70c517779d6b2013473 (patch) | |
tree | f0ba33e0f6e7b2eb99222a9eb5b85846cf309ab1 /client/src/app/+admin/users/user-edit/user-update.component.ts | |
parent | 56d72521ec139dfc0aef083b8541a5b16d974ac1 (diff) | |
download | PeerTube-76314386aeafdd6849b7b70c517779d6b2013473.tar.gz PeerTube-76314386aeafdd6849b7b70c517779d6b2013473.tar.zst PeerTube-76314386aeafdd6849b7b70c517779d6b2013473.zip |
Add overview of a user's actions in user-edit (#2558)
Diffstat (limited to 'client/src/app/+admin/users/user-edit/user-update.component.ts')
-rw-r--r-- | client/src/app/+admin/users/user-edit/user-update.component.ts | 33 |
1 files changed, 18 insertions, 15 deletions
diff --git a/client/src/app/+admin/users/user-edit/user-update.component.ts b/client/src/app/+admin/users/user-edit/user-update.component.ts index 1ab2e9dbf..fbe3d6950 100644 --- a/client/src/app/+admin/users/user-edit/user-update.component.ts +++ b/client/src/app/+admin/users/user-edit/user-update.component.ts | |||
@@ -4,13 +4,15 @@ import { Subscription } from 'rxjs' | |||
4 | import { AuthService, Notifier } from '@app/core' | 4 | import { AuthService, Notifier } from '@app/core' |
5 | import { ServerService } from '../../../core' | 5 | import { ServerService } from '../../../core' |
6 | import { UserEdit } from './user-edit' | 6 | import { UserEdit } from './user-edit' |
7 | import { User, UserUpdate } from '../../../../../../shared' | 7 | import { User as UserType, UserUpdate, UserRole } from '../../../../../../shared' |
8 | import { I18n } from '@ngx-translate/i18n-polyfill' | 8 | import { I18n } from '@ngx-translate/i18n-polyfill' |
9 | import { FormValidatorService } from '@app/shared/forms/form-validators/form-validator.service' | 9 | import { FormValidatorService } from '@app/shared/forms/form-validators/form-validator.service' |
10 | import { UserValidatorsService } from '@app/shared/forms/form-validators/user-validators.service' | 10 | import { UserValidatorsService } from '@app/shared/forms/form-validators/user-validators.service' |
11 | import { ConfigService } from '@app/+admin/config/shared/config.service' | 11 | import { ConfigService } from '@app/+admin/config/shared/config.service' |
12 | import { UserService } from '@app/shared' | 12 | import { UserService } from '@app/shared' |
13 | import { UserAdminFlag } from '@shared/models/users/user-flag.model' | 13 | import { UserAdminFlag } from '@shared/models/users/user-flag.model' |
14 | import { User } from '@app/shared/users/user.model' | ||
15 | import { ScreenService } from '@app/shared/misc/screen.service' | ||
14 | 16 | ||
15 | @Component({ | 17 | @Component({ |
16 | selector: 'my-user-update', | 18 | selector: 'my-user-update', |
@@ -19,9 +21,6 @@ import { UserAdminFlag } from '@shared/models/users/user-flag.model' | |||
19 | }) | 21 | }) |
20 | export class UserUpdateComponent extends UserEdit implements OnInit, OnDestroy { | 22 | export class UserUpdateComponent extends UserEdit implements OnInit, OnDestroy { |
21 | error: string | 23 | error: string |
22 | userId: number | ||
23 | userEmail: string | ||
24 | username: string | ||
25 | 24 | ||
26 | private paramsSub: Subscription | 25 | private paramsSub: Subscription |
27 | 26 | ||
@@ -29,6 +28,7 @@ export class UserUpdateComponent extends UserEdit implements OnInit, OnDestroy { | |||
29 | protected formValidatorService: FormValidatorService, | 28 | protected formValidatorService: FormValidatorService, |
30 | protected serverService: ServerService, | 29 | protected serverService: ServerService, |
31 | protected configService: ConfigService, | 30 | protected configService: ConfigService, |
31 | protected screenService: ScreenService, | ||
32 | protected auth: AuthService, | 32 | protected auth: AuthService, |
33 | private userValidatorsService: UserValidatorsService, | 33 | private userValidatorsService: UserValidatorsService, |
34 | private route: ActivatedRoute, | 34 | private route: ActivatedRoute, |
@@ -45,7 +45,12 @@ export class UserUpdateComponent extends UserEdit implements OnInit, OnDestroy { | |||
45 | ngOnInit () { | 45 | ngOnInit () { |
46 | super.ngOnInit() | 46 | super.ngOnInit() |
47 | 47 | ||
48 | const defaultValues = { videoQuota: '-1', videoQuotaDaily: '-1' } | 48 | const defaultValues = { |
49 | role: UserRole.USER.toString(), | ||
50 | videoQuota: '-1', | ||
51 | videoQuotaDaily: '-1' | ||
52 | } | ||
53 | |||
49 | this.buildForm({ | 54 | this.buildForm({ |
50 | email: this.userValidatorsService.USER_EMAIL, | 55 | email: this.userValidatorsService.USER_EMAIL, |
51 | role: this.userValidatorsService.USER_ROLE, | 56 | role: this.userValidatorsService.USER_ROLE, |
@@ -56,7 +61,7 @@ export class UserUpdateComponent extends UserEdit implements OnInit, OnDestroy { | |||
56 | 61 | ||
57 | this.paramsSub = this.route.params.subscribe(routeParams => { | 62 | this.paramsSub = this.route.params.subscribe(routeParams => { |
58 | const userId = routeParams['id'] | 63 | const userId = routeParams['id'] |
59 | this.userService.getUser(userId).subscribe( | 64 | this.userService.getUser(userId, true).subscribe( |
60 | user => this.onUserFetched(user), | 65 | user => this.onUserFetched(user), |
61 | 66 | ||
62 | err => this.error = err.message | 67 | err => this.error = err.message |
@@ -78,9 +83,9 @@ export class UserUpdateComponent extends UserEdit implements OnInit, OnDestroy { | |||
78 | userUpdate.videoQuota = parseInt(this.form.value['videoQuota'], 10) | 83 | userUpdate.videoQuota = parseInt(this.form.value['videoQuota'], 10) |
79 | userUpdate.videoQuotaDaily = parseInt(this.form.value['videoQuotaDaily'], 10) | 84 | userUpdate.videoQuotaDaily = parseInt(this.form.value['videoQuotaDaily'], 10) |
80 | 85 | ||
81 | this.userService.updateUser(this.userId, userUpdate).subscribe( | 86 | this.userService.updateUser(this.user.id, userUpdate).subscribe( |
82 | () => { | 87 | () => { |
83 | this.notifier.success(this.i18n('User {{username}} updated.', { username: this.username })) | 88 | this.notifier.success(this.i18n('User {{user.username}} updated.', { username: this.user.username })) |
84 | this.router.navigate([ '/admin/users/list' ]) | 89 | this.router.navigate([ '/admin/users/list' ]) |
85 | }, | 90 | }, |
86 | 91 | ||
@@ -101,10 +106,10 @@ export class UserUpdateComponent extends UserEdit implements OnInit, OnDestroy { | |||
101 | } | 106 | } |
102 | 107 | ||
103 | resetPassword () { | 108 | resetPassword () { |
104 | this.userService.askResetPassword(this.userEmail).subscribe( | 109 | this.userService.askResetPassword(this.user.email).subscribe( |
105 | () => { | 110 | () => { |
106 | this.notifier.success( | 111 | this.notifier.success( |
107 | this.i18n('An email asking for password reset has been sent to {{username}}.', { username: this.username }) | 112 | this.i18n('An email asking for password reset has been sent to {{username}}.', { username: this.user.username }) |
108 | ) | 113 | ) |
109 | }, | 114 | }, |
110 | 115 | ||
@@ -112,14 +117,12 @@ export class UserUpdateComponent extends UserEdit implements OnInit, OnDestroy { | |||
112 | ) | 117 | ) |
113 | } | 118 | } |
114 | 119 | ||
115 | private onUserFetched (userJson: User) { | 120 | private onUserFetched (userJson: UserType) { |
116 | this.userId = userJson.id | 121 | this.user = new User(userJson) |
117 | this.username = userJson.username | ||
118 | this.userEmail = userJson.email | ||
119 | 122 | ||
120 | this.form.patchValue({ | 123 | this.form.patchValue({ |
121 | email: userJson.email, | 124 | email: userJson.email, |
122 | role: userJson.role, | 125 | role: userJson.role.toString(), |
123 | videoQuota: userJson.videoQuota, | 126 | videoQuota: userJson.videoQuota, |
124 | videoQuotaDaily: userJson.videoQuotaDaily, | 127 | videoQuotaDaily: userJson.videoQuotaDaily, |
125 | byPassAutoBlacklist: userJson.adminFlags & UserAdminFlag.BY_PASS_VIDEO_AUTO_BLACKLIST | 128 | byPassAutoBlacklist: userJson.adminFlags & UserAdminFlag.BY_PASS_VIDEO_AUTO_BLACKLIST |