diff options
Diffstat (limited to 'client/src/app/+admin/users')
4 files changed, 30 insertions, 46 deletions
diff --git a/client/src/app/+admin/users/user-edit/user-create.component.ts b/client/src/app/+admin/users/user-edit/user-create.component.ts index 3fddb9c09..36d71a927 100644 --- a/client/src/app/+admin/users/user-edit/user-create.component.ts +++ b/client/src/app/+admin/users/user-edit/user-create.component.ts | |||
@@ -3,7 +3,6 @@ import { ActivatedRoute, Router } from '@angular/router' | |||
3 | import { ConfigService } from '@app/+admin/config/shared/config.service' | 3 | import { ConfigService } from '@app/+admin/config/shared/config.service' |
4 | import { AuthService, Notifier, ScreenService, ServerService, UserService } from '@app/core' | 4 | import { AuthService, Notifier, ScreenService, ServerService, UserService } from '@app/core' |
5 | import { FormValidatorService, UserValidatorsService } from '@app/shared/shared-forms' | 5 | import { FormValidatorService, UserValidatorsService } from '@app/shared/shared-forms' |
6 | import { I18n } from '@ngx-translate/i18n-polyfill' | ||
7 | import { UserCreate, UserRole } from '@shared/models' | 6 | import { UserCreate, UserRole } from '@shared/models' |
8 | import { UserEdit } from './user-edit' | 7 | import { UserEdit } from './user-edit' |
9 | 8 | ||
@@ -25,9 +24,8 @@ export class UserCreateComponent extends UserEdit implements OnInit { | |||
25 | private route: ActivatedRoute, | 24 | private route: ActivatedRoute, |
26 | private router: Router, | 25 | private router: Router, |
27 | private notifier: Notifier, | 26 | private notifier: Notifier, |
28 | private userService: UserService, | 27 | private userService: UserService |
29 | private i18n: I18n | 28 | ) { |
30 | ) { | ||
31 | super() | 29 | super() |
32 | 30 | ||
33 | this.buildQuotaOptions() | 31 | this.buildQuotaOptions() |
@@ -67,7 +65,7 @@ export class UserCreateComponent extends UserEdit implements OnInit { | |||
67 | 65 | ||
68 | this.userService.addUser(userCreate).subscribe( | 66 | this.userService.addUser(userCreate).subscribe( |
69 | () => { | 67 | () => { |
70 | this.notifier.success(this.i18n('User {{username}} created.', { username: userCreate.username })) | 68 | this.notifier.success($localize`User ${userCreate.username} created.`) |
71 | this.router.navigate([ '/admin/users/list' ]) | 69 | this.router.navigate([ '/admin/users/list' ]) |
72 | }, | 70 | }, |
73 | 71 | ||
@@ -85,6 +83,6 @@ export class UserCreateComponent extends UserEdit implements OnInit { | |||
85 | } | 83 | } |
86 | 84 | ||
87 | getFormButtonTitle () { | 85 | getFormButtonTitle () { |
88 | return this.i18n('Create user') | 86 | return $localize`Create user` |
89 | } | 87 | } |
90 | } | 88 | } |
diff --git a/client/src/app/+admin/users/user-edit/user-password.component.ts b/client/src/app/+admin/users/user-edit/user-password.component.ts index 33c7de31f..25f13495a 100644 --- a/client/src/app/+admin/users/user-edit/user-password.component.ts +++ b/client/src/app/+admin/users/user-edit/user-password.component.ts | |||
@@ -1,7 +1,6 @@ | |||
1 | import { Component, Input, OnInit } from '@angular/core' | 1 | import { Component, Input, OnInit } from '@angular/core' |
2 | import { Notifier, UserService } from '@app/core' | 2 | import { Notifier, UserService } from '@app/core' |
3 | import { FormReactive, FormValidatorService, UserValidatorsService } from '@app/shared/shared-forms' | 3 | import { FormReactive, FormValidatorService, UserValidatorsService } from '@app/shared/shared-forms' |
4 | import { I18n } from '@ngx-translate/i18n-polyfill' | ||
5 | import { UserUpdate } from '@shared/models' | 4 | import { UserUpdate } from '@shared/models' |
6 | 5 | ||
7 | @Component({ | 6 | @Component({ |
@@ -20,9 +19,8 @@ export class UserPasswordComponent extends FormReactive implements OnInit { | |||
20 | protected formValidatorService: FormValidatorService, | 19 | protected formValidatorService: FormValidatorService, |
21 | private userValidatorsService: UserValidatorsService, | 20 | private userValidatorsService: UserValidatorsService, |
22 | private notifier: Notifier, | 21 | private notifier: Notifier, |
23 | private userService: UserService, | 22 | private userService: UserService |
24 | private i18n: I18n | 23 | ) { |
25 | ) { | ||
26 | super() | 24 | super() |
27 | } | 25 | } |
28 | 26 | ||
@@ -39,9 +37,7 @@ export class UserPasswordComponent extends FormReactive implements OnInit { | |||
39 | 37 | ||
40 | this.userService.updateUser(this.userId, userUpdate).subscribe( | 38 | this.userService.updateUser(this.userId, userUpdate).subscribe( |
41 | () => { | 39 | () => { |
42 | this.notifier.success( | 40 | this.notifier.success($localize`Password changed for user ${this.username}.`) |
43 | this.i18n('Password changed for user {{username}}.', { username: this.username }) | ||
44 | ) | ||
45 | }, | 41 | }, |
46 | 42 | ||
47 | err => this.error = err.message | 43 | err => this.error = err.message |
@@ -53,6 +49,6 @@ export class UserPasswordComponent extends FormReactive implements OnInit { | |||
53 | } | 49 | } |
54 | 50 | ||
55 | getFormButtonTitle () { | 51 | getFormButtonTitle () { |
56 | return this.i18n('Update user password') | 52 | return $localize`Update user password` |
57 | } | 53 | } |
58 | } | 54 | } |
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 870880fee..55bc7290e 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,7 +4,6 @@ import { ActivatedRoute, Router } from '@angular/router' | |||
4 | import { ConfigService } from '@app/+admin/config/shared/config.service' | 4 | import { ConfigService } from '@app/+admin/config/shared/config.service' |
5 | import { AuthService, Notifier, ScreenService, ServerService, User, UserService } from '@app/core' | 5 | import { AuthService, Notifier, ScreenService, ServerService, User, UserService } from '@app/core' |
6 | import { FormValidatorService, UserValidatorsService } from '@app/shared/shared-forms' | 6 | import { FormValidatorService, UserValidatorsService } from '@app/shared/shared-forms' |
7 | import { I18n } from '@ngx-translate/i18n-polyfill' | ||
8 | import { User as UserType, UserAdminFlag, UserRole, UserUpdate } from '@shared/models' | 7 | import { User as UserType, UserAdminFlag, UserRole, UserUpdate } from '@shared/models' |
9 | import { UserEdit } from './user-edit' | 8 | import { UserEdit } from './user-edit' |
10 | 9 | ||
@@ -28,9 +27,8 @@ export class UserUpdateComponent extends UserEdit implements OnInit, OnDestroy { | |||
28 | private route: ActivatedRoute, | 27 | private route: ActivatedRoute, |
29 | private router: Router, | 28 | private router: Router, |
30 | private notifier: Notifier, | 29 | private notifier: Notifier, |
31 | private userService: UserService, | 30 | private userService: UserService |
32 | private i18n: I18n | 31 | ) { |
33 | ) { | ||
34 | super() | 32 | super() |
35 | 33 | ||
36 | this.buildQuotaOptions() | 34 | this.buildQuotaOptions() |
@@ -79,7 +77,7 @@ export class UserUpdateComponent extends UserEdit implements OnInit, OnDestroy { | |||
79 | 77 | ||
80 | this.userService.updateUser(this.user.id, userUpdate).subscribe( | 78 | this.userService.updateUser(this.user.id, userUpdate).subscribe( |
81 | () => { | 79 | () => { |
82 | this.notifier.success(this.i18n('User {{username}} updated.', { username: this.user.username })) | 80 | this.notifier.success($localize`User ${this.user.username} updated.`) |
83 | this.router.navigate([ '/admin/users/list' ]) | 81 | this.router.navigate([ '/admin/users/list' ]) |
84 | }, | 82 | }, |
85 | 83 | ||
@@ -96,15 +94,13 @@ export class UserUpdateComponent extends UserEdit implements OnInit, OnDestroy { | |||
96 | } | 94 | } |
97 | 95 | ||
98 | getFormButtonTitle () { | 96 | getFormButtonTitle () { |
99 | return this.i18n('Update user') | 97 | return $localize`Update user` |
100 | } | 98 | } |
101 | 99 | ||
102 | resetPassword () { | 100 | resetPassword () { |
103 | this.userService.askResetPassword(this.user.email).subscribe( | 101 | this.userService.askResetPassword(this.user.email).subscribe( |
104 | () => { | 102 | () => { |
105 | this.notifier.success( | 103 | this.notifier.success($localize`An email asking for password reset has been sent to ${this.user.username}.`) |
106 | this.i18n('An email asking for password reset has been sent to {{username}}.', { username: this.user.username }) | ||
107 | ) | ||
108 | }, | 104 | }, |
109 | 105 | ||
110 | err => this.error = err.message | 106 | err => this.error = err.message |
diff --git a/client/src/app/+admin/users/user-list/user-list.component.ts b/client/src/app/+admin/users/user-list/user-list.component.ts index 69d4e917d..86812f73d 100644 --- a/client/src/app/+admin/users/user-list/user-list.component.ts +++ b/client/src/app/+admin/users/user-list/user-list.component.ts | |||
@@ -1,11 +1,10 @@ | |||
1 | import { SortMeta } from 'primeng/api' | 1 | import { SortMeta } from 'primeng/api' |
2 | import { Component, OnInit, ViewChild } from '@angular/core' | 2 | import { Component, OnInit, ViewChild } from '@angular/core' |
3 | import { ActivatedRoute, Params, Router } from '@angular/router' | ||
3 | import { AuthService, ConfirmService, Notifier, RestPagination, RestTable, ServerService, UserService } from '@app/core' | 4 | import { AuthService, ConfirmService, Notifier, RestPagination, RestTable, ServerService, UserService } from '@app/core' |
4 | import { Actor, DropdownAction } from '@app/shared/shared-main' | 5 | import { Actor, DropdownAction } from '@app/shared/shared-main' |
5 | import { UserBanModalComponent } from '@app/shared/shared-moderation' | 6 | import { UserBanModalComponent } from '@app/shared/shared-moderation' |
6 | import { I18n } from '@ngx-translate/i18n-polyfill' | ||
7 | import { ServerConfig, User, UserRole } from '@shared/models' | 7 | import { ServerConfig, User, UserRole } from '@shared/models' |
8 | import { Params, Router, ActivatedRoute } from '@angular/router' | ||
9 | 8 | ||
10 | type UserForList = User & { | 9 | type UserForList = User & { |
11 | rawVideoQuota: number | 10 | rawVideoQuota: number |
@@ -42,9 +41,8 @@ export class UserListComponent extends RestTable implements OnInit { | |||
42 | private userService: UserService, | 41 | private userService: UserService, |
43 | private auth: AuthService, | 42 | private auth: AuthService, |
44 | private route: ActivatedRoute, | 43 | private route: ActivatedRoute, |
45 | private router: Router, | 44 | private router: Router |
46 | private i18n: I18n | 45 | ) { |
47 | ) { | ||
48 | super() | 46 | super() |
49 | } | 47 | } |
50 | 48 | ||
@@ -82,26 +80,26 @@ export class UserListComponent extends RestTable implements OnInit { | |||
82 | this.bulkUserActions = [ | 80 | this.bulkUserActions = [ |
83 | [ | 81 | [ |
84 | { | 82 | { |
85 | label: this.i18n('Delete'), | 83 | label: $localize`Delete`, |
86 | description: this.i18n('Videos will be deleted, comments will be tombstoned.'), | 84 | description: $localize`Videos will be deleted, comments will be tombstoned.`, |
87 | handler: users => this.removeUsers(users), | 85 | handler: users => this.removeUsers(users), |
88 | isDisplayed: users => users.every(u => this.authUser.canManage(u)) | 86 | isDisplayed: users => users.every(u => this.authUser.canManage(u)) |
89 | }, | 87 | }, |
90 | { | 88 | { |
91 | label: this.i18n('Ban'), | 89 | label: $localize`Ban`, |
92 | description: this.i18n('User won\'t be able to login anymore, but videos and comments will be kept as is.'), | 90 | description: $localize`User won't be able to login anymore, but videos and comments will be kept as is.`, |
93 | handler: users => this.openBanUserModal(users), | 91 | handler: users => this.openBanUserModal(users), |
94 | isDisplayed: users => users.every(u => this.authUser.canManage(u) && u.blocked === false) | 92 | isDisplayed: users => users.every(u => this.authUser.canManage(u) && u.blocked === false) |
95 | }, | 93 | }, |
96 | { | 94 | { |
97 | label: this.i18n('Unban'), | 95 | label: $localize`Unban`, |
98 | handler: users => this.unbanUsers(users), | 96 | handler: users => this.unbanUsers(users), |
99 | isDisplayed: users => users.every(u => this.authUser.canManage(u) && u.blocked === true) | 97 | isDisplayed: users => users.every(u => this.authUser.canManage(u) && u.blocked === true) |
100 | } | 98 | } |
101 | ], | 99 | ], |
102 | [ | 100 | [ |
103 | { | 101 | { |
104 | label: this.i18n('Set Email as Verified'), | 102 | label: $localize`Set Email as Verified`, |
105 | handler: users => this.setEmailsAsVerified(users), | 103 | handler: users => this.setEmailsAsVerified(users), |
106 | isDisplayed: users => { | 104 | isDisplayed: users => { |
107 | return this.requiresEmailVerification && | 105 | return this.requiresEmailVerification && |
@@ -160,7 +158,7 @@ export class UserListComponent extends RestTable implements OnInit { | |||
160 | openBanUserModal (users: User[]) { | 158 | openBanUserModal (users: User[]) { |
161 | for (const user of users) { | 159 | for (const user of users) { |
162 | if (user.username === 'root') { | 160 | if (user.username === 'root') { |
163 | this.notifier.error(this.i18n('You cannot ban root.')) | 161 | this.notifier.error($localize`You cannot ban root.`) |
164 | return | 162 | return |
165 | } | 163 | } |
166 | } | 164 | } |
@@ -197,17 +195,13 @@ export class UserListComponent extends RestTable implements OnInit { | |||
197 | } | 195 | } |
198 | 196 | ||
199 | async unbanUsers (users: User[]) { | 197 | async unbanUsers (users: User[]) { |
200 | const message = this.i18n('Do you really want to unban {{num}} users?', { num: users.length }) | 198 | const res = await this.confirmService.confirm($localize`Do you really want to unban ${users.length} users?`, $localize`Unban`) |
201 | |||
202 | const res = await this.confirmService.confirm(message, this.i18n('Unban')) | ||
203 | if (res === false) return | 199 | if (res === false) return |
204 | 200 | ||
205 | this.userService.unbanUsers(users) | 201 | this.userService.unbanUsers(users) |
206 | .subscribe( | 202 | .subscribe( |
207 | () => { | 203 | () => { |
208 | const message = this.i18n('{{num}} users unbanned.', { num: users.length }) | 204 | this.notifier.success($localize`${users.length} users unbanned.`) |
209 | |||
210 | this.notifier.success(message) | ||
211 | this.loadData() | 205 | this.loadData() |
212 | }, | 206 | }, |
213 | 207 | ||
@@ -218,18 +212,18 @@ export class UserListComponent extends RestTable implements OnInit { | |||
218 | async removeUsers (users: User[]) { | 212 | async removeUsers (users: User[]) { |
219 | for (const user of users) { | 213 | for (const user of users) { |
220 | if (user.username === 'root') { | 214 | if (user.username === 'root') { |
221 | this.notifier.error(this.i18n('You cannot delete root.')) | 215 | this.notifier.error($localize`You cannot delete root.`) |
222 | return | 216 | return |
223 | } | 217 | } |
224 | } | 218 | } |
225 | 219 | ||
226 | const message = this.i18n('If you remove these users, you will not be able to create others with the same username!') | 220 | const message = $localize`If you remove these users, you will not be able to create others with the same username!` |
227 | const res = await this.confirmService.confirm(message, this.i18n('Delete')) | 221 | const res = await this.confirmService.confirm(message, $localize`Delete`) |
228 | if (res === false) return | 222 | if (res === false) return |
229 | 223 | ||
230 | this.userService.removeUser(users).subscribe( | 224 | this.userService.removeUser(users).subscribe( |
231 | () => { | 225 | () => { |
232 | this.notifier.success(this.i18n('{{num}} users deleted.', { num: users.length })) | 226 | this.notifier.success($localize`${users.length} users deleted.`) |
233 | this.loadData() | 227 | this.loadData() |
234 | }, | 228 | }, |
235 | 229 | ||
@@ -240,7 +234,7 @@ export class UserListComponent extends RestTable implements OnInit { | |||
240 | async setEmailsAsVerified (users: User[]) { | 234 | async setEmailsAsVerified (users: User[]) { |
241 | this.userService.updateUsers(users, { emailVerified: true }).subscribe( | 235 | this.userService.updateUsers(users, { emailVerified: true }).subscribe( |
242 | () => { | 236 | () => { |
243 | this.notifier.success(this.i18n('{{num}} users email set as verified.', { num: users.length })) | 237 | this.notifier.success($localize`${users.length} users email set as verified.`) |
244 | this.loadData() | 238 | this.loadData() |
245 | }, | 239 | }, |
246 | 240 | ||