aboutsummaryrefslogtreecommitdiffhomepage
path: root/client/src/app/+admin/users
diff options
context:
space:
mode:
Diffstat (limited to 'client/src/app/+admin/users')
-rw-r--r--client/src/app/+admin/users/shared/user.service.ts7
-rw-r--r--client/src/app/+admin/users/user-edit/user-create.component.ts21
-rw-r--r--client/src/app/+admin/users/user-edit/user-edit.component.html20
-rw-r--r--client/src/app/+admin/users/user-edit/user-update.component.ts11
-rw-r--r--client/src/app/+admin/users/user-list/user-list.component.html14
-rw-r--r--client/src/app/+admin/users/user-list/user-list.component.ts19
6 files changed, 49 insertions, 43 deletions
diff --git a/client/src/app/+admin/users/shared/user.service.ts b/client/src/app/+admin/users/shared/user.service.ts
index 578cd98c3..d8b00b862 100644
--- a/client/src/app/+admin/users/shared/user.service.ts
+++ b/client/src/app/+admin/users/shared/user.service.ts
@@ -7,6 +7,7 @@ import { Observable } from 'rxjs'
7import { ResultList, UserCreate, UserUpdate } from '../../../../../../shared' 7import { ResultList, UserCreate, UserUpdate } from '../../../../../../shared'
8import { environment } from '../../../../environments/environment' 8import { environment } from '../../../../environments/environment'
9import { RestExtractor, RestPagination, RestService, User } from '../../../shared' 9import { RestExtractor, RestPagination, RestService, User } from '../../../shared'
10import { I18n } from '@ngx-translate/i18n-polyfill'
10 11
11@Injectable() 12@Injectable()
12export class UserService { 13export class UserService {
@@ -16,9 +17,9 @@ export class UserService {
16 constructor ( 17 constructor (
17 private authHttp: HttpClient, 18 private authHttp: HttpClient,
18 private restService: RestService, 19 private restService: RestService,
19 private restExtractor: RestExtractor 20 private restExtractor: RestExtractor,
20 ) { 21 private i18n: I18n
21 } 22 ) { }
22 23
23 addUser (userCreate: UserCreate) { 24 addUser (userCreate: UserCreate) {
24 return this.authHttp.post(UserService.BASE_USERS_URL, userCreate) 25 return this.authHttp.post(UserService.BASE_USERS_URL, userCreate)
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 2a9882cde..b91ffa115 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
@@ -1,20 +1,13 @@
1import { Component, OnInit } from '@angular/core' 1import { Component, OnInit } from '@angular/core'
2import { FormBuilder, FormGroup } from '@angular/forms' 2import { FormBuilder, FormGroup } from '@angular/forms'
3import { Router } from '@angular/router' 3import { Router } from '@angular/router'
4
5import { NotificationsService } from 'angular2-notifications' 4import { NotificationsService } from 'angular2-notifications'
6
7import { UserService } from '../shared' 5import { UserService } from '../shared'
8import { 6import { USER_EMAIL, USER_PASSWORD, USER_ROLE, USER_USERNAME, USER_VIDEO_QUOTA } from '../../../shared'
9 USER_USERNAME,
10 USER_EMAIL,
11 USER_PASSWORD,
12 USER_VIDEO_QUOTA,
13 USER_ROLE
14} from '../../../shared'
15import { ServerService } from '../../../core' 7import { ServerService } from '../../../core'
16import { UserCreate, UserRole } from '../../../../../../shared' 8import { UserCreate, UserRole } from '../../../../../../shared'
17import { UserEdit } from './user-edit' 9import { UserEdit } from './user-edit'
10import { I18n } from '@ngx-translate/i18n-polyfill'
18 11
19@Component({ 12@Component({
20 selector: 'my-user-create', 13 selector: 'my-user-create',
@@ -45,7 +38,8 @@ export class UserCreateComponent extends UserEdit implements OnInit {
45 private formBuilder: FormBuilder, 38 private formBuilder: FormBuilder,
46 private router: Router, 39 private router: Router,
47 private notificationsService: NotificationsService, 40 private notificationsService: NotificationsService,
48 private userService: UserService 41 private userService: UserService,
42 private i18n: I18n
49 ) { 43 ) {
50 super() 44 super()
51 } 45 }
@@ -76,7 +70,10 @@ export class UserCreateComponent extends UserEdit implements OnInit {
76 70
77 this.userService.addUser(userCreate).subscribe( 71 this.userService.addUser(userCreate).subscribe(
78 () => { 72 () => {
79 this.notificationsService.success('Success', `User ${userCreate.username} created.`) 73 this.notificationsService.success(
74 this.i18n('Success'),
75 this.i18n('User {{ username }} created.', { username: userCreate.username })
76 )
80 this.router.navigate([ '/admin/users/list' ]) 77 this.router.navigate([ '/admin/users/list' ])
81 }, 78 },
82 79
@@ -89,6 +86,6 @@ export class UserCreateComponent extends UserEdit implements OnInit {
89 } 86 }
90 87
91 getFormButtonTitle () { 88 getFormButtonTitle () {
92 return 'Create user' 89 return this.i18n('Create user')
93 } 90 }
94} 91}
diff --git a/client/src/app/+admin/users/user-edit/user-edit.component.html b/client/src/app/+admin/users/user-edit/user-edit.component.html
index a8c0ddadb..4626a40c9 100644
--- a/client/src/app/+admin/users/user-edit/user-edit.component.html
+++ b/client/src/app/+admin/users/user-edit/user-edit.component.html
@@ -1,13 +1,13 @@
1<div class="form-sub-title" *ngIf="isCreation() === true">Create user</div> 1<div i18n class="form-sub-title" *ngIf="isCreation() === true">Create user</div>
2<div class="form-sub-title" *ngIf="isCreation() === false">Edit user {{ username }}</div> 2<div i18n class="form-sub-title" *ngIf="isCreation() === false">Edit user {{ username }}</div>
3 3
4<div *ngIf="error" class="alert alert-danger">{{ error }}</div> 4<div *ngIf="error" class="alert alert-danger">{{ error }}</div>
5 5
6<form role="form" (ngSubmit)="formValidated()" [formGroup]="form"> 6<form role="form" (ngSubmit)="formValidated()" [formGroup]="form">
7 <div class="form-group" *ngIf="isCreation()"> 7 <div class="form-group" *ngIf="isCreation()">
8 <label for="username">Username</label> 8 <label i18n for="username">Username</label>
9 <input 9 <input
10 type="text" id="username" placeholder="john" 10 type="text" id="username" i18n-placeholder placeholder="john"
11 formControlName="username" [ngClass]="{ 'input-error': formErrors['username'] }" 11 formControlName="username" [ngClass]="{ 'input-error': formErrors['username'] }"
12 > 12 >
13 <div *ngIf="formErrors.username" class="form-error"> 13 <div *ngIf="formErrors.username" class="form-error">
@@ -16,9 +16,9 @@
16 </div> 16 </div>
17 17
18 <div class="form-group"> 18 <div class="form-group">
19 <label for="email">Email</label> 19 <label i18n for="email">Email</label>
20 <input 20 <input
21 type="text" id="email" placeholder="mail@example.com" 21 type="text" id="email" i18n-placeholder placeholder="mail@example.com"
22 formControlName="email" [ngClass]="{ 'input-error': formErrors['email'] }" 22 formControlName="email" [ngClass]="{ 'input-error': formErrors['email'] }"
23 > 23 >
24 <div *ngIf="formErrors.email" class="form-error"> 24 <div *ngIf="formErrors.email" class="form-error">
@@ -27,7 +27,7 @@
27 </div> 27 </div>
28 28
29 <div class="form-group" *ngIf="isCreation()"> 29 <div class="form-group" *ngIf="isCreation()">
30 <label for="password">Password</label> 30 <label i18n for="password">Password</label>
31 <input 31 <input
32 type="password" id="password" 32 type="password" id="password"
33 formControlName="password" [ngClass]="{ 'input-error': formErrors['password'] }" 33 formControlName="password" [ngClass]="{ 'input-error': formErrors['password'] }"
@@ -38,7 +38,7 @@
38 </div> 38 </div>
39 39
40 <div class="form-group"> 40 <div class="form-group">
41 <label for="role">Role</label> 41 <label i18n for="role">Role</label>
42 <div class="peertube-select-container"> 42 <div class="peertube-select-container">
43 <select id="role" formControlName="role"> 43 <select id="role" formControlName="role">
44 <option *ngFor="let role of roles" [value]="role.value"> 44 <option *ngFor="let role of roles" [value]="role.value">
@@ -53,7 +53,7 @@
53 </div> 53 </div>
54 54
55 <div class="form-group"> 55 <div class="form-group">
56 <label for="videoQuota">Video quota</label> 56 <label i18n for="videoQuota">Video quota</label>
57 <div class="peertube-select-container"> 57 <div class="peertube-select-container">
58 <select id="videoQuota" formControlName="videoQuota"> 58 <select id="videoQuota" formControlName="videoQuota">
59 <option *ngFor="let videoQuotaOption of videoQuotaOptions" [value]="videoQuotaOption.value"> 59 <option *ngFor="let videoQuotaOption of videoQuotaOptions" [value]="videoQuotaOption.value">
@@ -62,7 +62,7 @@
62 </select> 62 </select>
63 </div> 63 </div>
64 64
65 <div class="transcoding-information" *ngIf="isTranscodingInformationDisplayed()"> 65 <div i18n class="transcoding-information" *ngIf="isTranscodingInformationDisplayed()">
66 Transcoding is enabled on server. The video quota only take in account <strong>original</strong> video. <br /> 66 Transcoding is enabled on server. The video quota only take in account <strong>original</strong> video. <br />
67 At most, this user could use ~ {{ computeQuotaWithTranscoding() | bytes: 0 }}. 67 At most, this user could use ~ {{ computeQuotaWithTranscoding() | bytes: 0 }}.
68 </div> 68 </div>
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 3cde07c65..dca555706 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
@@ -8,6 +8,7 @@ import { User, USER_EMAIL, USER_ROLE, USER_VIDEO_QUOTA } from '../../../shared'
8import { ServerService } from '../../../core' 8import { ServerService } from '../../../core'
9import { UserEdit } from './user-edit' 9import { UserEdit } from './user-edit'
10import { UserUpdate } from '../../../../../../shared' 10import { UserUpdate } from '../../../../../../shared'
11import { I18n } from '@ngx-translate/i18n-polyfill'
11 12
12@Component({ 13@Component({
13 selector: 'my-user-update', 14 selector: 'my-user-update',
@@ -39,7 +40,8 @@ export class UserUpdateComponent extends UserEdit implements OnInit, OnDestroy {
39 private router: Router, 40 private router: Router,
40 private notificationsService: NotificationsService, 41 private notificationsService: NotificationsService,
41 private formBuilder: FormBuilder, 42 private formBuilder: FormBuilder,
42 private userService: UserService 43 private userService: UserService,
44 private i18n: I18n
43 ) { 45 ) {
44 super() 46 super()
45 } 47 }
@@ -81,7 +83,10 @@ export class UserUpdateComponent extends UserEdit implements OnInit, OnDestroy {
81 83
82 this.userService.updateUser(this.userId, userUpdate).subscribe( 84 this.userService.updateUser(this.userId, userUpdate).subscribe(
83 () => { 85 () => {
84 this.notificationsService.success('Success', `User ${this.username} updated.`) 86 this.notificationsService.success(
87 this.i18n('Success'),
88 this.i18n('User {{ username }} updated.', { username: this.username })
89 )
85 this.router.navigate([ '/admin/users/list' ]) 90 this.router.navigate([ '/admin/users/list' ])
86 }, 91 },
87 92
@@ -94,7 +99,7 @@ export class UserUpdateComponent extends UserEdit implements OnInit, OnDestroy {
94 } 99 }
95 100
96 getFormButtonTitle () { 101 getFormButtonTitle () {
97 return 'Update user' 102 return this.i18n('Update user')
98 } 103 }
99 104
100 private onUserFetched (userJson: User) { 105 private onUserFetched (userJson: User) {
diff --git a/client/src/app/+admin/users/user-list/user-list.component.html b/client/src/app/+admin/users/user-list/user-list.component.html
index 09a4ac1e7..166fafef0 100644
--- a/client/src/app/+admin/users/user-list/user-list.component.html
+++ b/client/src/app/+admin/users/user-list/user-list.component.html
@@ -1,9 +1,9 @@
1<div class="admin-sub-header"> 1<div class="admin-sub-header">
2 <div class="form-sub-title">Users list</div> 2 <div i18n class="form-sub-title">Users list</div>
3 3
4 <a class="add-button" routerLink="/admin/users/create"> 4 <a class="add-button" routerLink="/admin/users/create">
5 <span class="icon icon-add"></span> 5 <span class="icon icon-add"></span>
6 Create user 6 <ng-container i18n>Create user</ng-container>
7 </a> 7 </a>
8</div> 8</div>
9 9
@@ -13,11 +13,11 @@
13> 13>
14 <ng-template pTemplate="header"> 14 <ng-template pTemplate="header">
15 <tr> 15 <tr>
16 <th pSortableColumn="username">Username <p-sortIcon field="username"></p-sortIcon></th> 16 <th i18n pSortableColumn="username">Username <p-sortIcon field="username"></p-sortIcon></th>
17 <th>Email</th> 17 <th i18n>Email</th>
18 <th>Video quota</th> 18 <th i18n>Video quota</th>
19 <th>Role</th> 19 <th i18n>Role</th>
20 <th pSortableColumn="createdAt">Created <p-sortIcon field="createdAt"></p-sortIcon></th> 20 <th i18n pSortableColumn="createdAt">Created <p-sortIcon field="createdAt"></p-sortIcon></th>
21 <th></th> 21 <th></th>
22 </tr> 22 </tr>
23 </ng-template> 23 </ng-template>
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 2cc4d4349..b644fcf71 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 @@
1import { Component, OnInit } from '@angular/core' 1import { Component, OnInit } from '@angular/core'
2
3import { NotificationsService } from 'angular2-notifications' 2import { NotificationsService } from 'angular2-notifications'
4import { SortMeta } from 'primeng/components/common/sortmeta' 3import { SortMeta } from 'primeng/components/common/sortmeta'
5
6import { ConfirmService } from '../../../core' 4import { ConfirmService } from '../../../core'
7import { RestPagination, RestTable, User } from '../../../shared' 5import { RestPagination, RestTable, User } from '../../../shared'
8import { UserService } from '../shared' 6import { UserService } from '../shared'
7import { I18n } from '@ngx-translate/i18n-polyfill'
9 8
10@Component({ 9@Component({
11 selector: 'my-user-list', 10 selector: 'my-user-list',
@@ -22,7 +21,8 @@ export class UserListComponent extends RestTable implements OnInit {
22 constructor ( 21 constructor (
23 private notificationsService: NotificationsService, 22 private notificationsService: NotificationsService,
24 private confirmService: ConfirmService, 23 private confirmService: ConfirmService,
25 private userService: UserService 24 private userService: UserService,
25 private i18n: I18n
26 ) { 26 ) {
27 super() 27 super()
28 } 28 }
@@ -33,20 +33,23 @@ export class UserListComponent extends RestTable implements OnInit {
33 33
34 async removeUser (user: User) { 34 async removeUser (user: User) {
35 if (user.username === 'root') { 35 if (user.username === 'root') {
36 this.notificationsService.error('Error', 'You cannot delete root.') 36 this.notificationsService.error(this.i18n('Error'), this.i18n('You cannot delete root.'))
37 return 37 return
38 } 38 }
39 39
40 const res = await this.confirmService.confirm('Do you really want to delete this user?', 'Delete') 40 const res = await this.confirmService.confirm(this.i18n('Do you really want to delete this user?'), this.i18n('Delete'))
41 if (res === false) return 41 if (res === false) return
42 42
43 this.userService.removeUser(user).subscribe( 43 this.userService.removeUser(user).subscribe(
44 () => { 44 () => {
45 this.notificationsService.success('Success', `User ${user.username} deleted.`) 45 this.notificationsService.success(
46 this.i18n('Success'),
47 this.i18n('User {{ username }} deleted.', { username: user.username })
48 )
46 this.loadData() 49 this.loadData()
47 }, 50 },
48 51
49 err => this.notificationsService.error('Error', err.message) 52 err => this.notificationsService.error(this.i18n('Error'), err.message)
50 ) 53 )
51 } 54 }
52 55
@@ -62,7 +65,7 @@ export class UserListComponent extends RestTable implements OnInit {
62 this.totalRecords = resultList.total 65 this.totalRecords = resultList.total
63 }, 66 },
64 67
65 err => this.notificationsService.error('Error', err.message) 68 err => this.notificationsService.error(this.i18n('Error'), err.message)
66 ) 69 )
67 } 70 }
68} 71}