aboutsummaryrefslogtreecommitdiffhomepage
path: root/client/src/app/+admin
diff options
context:
space:
mode:
Diffstat (limited to 'client/src/app/+admin')
-rw-r--r--client/src/app/+admin/users/user-edit/user-edit.component.html16
-rw-r--r--client/src/app/+admin/users/user-edit/user-edit.component.scss13
-rw-r--r--client/src/app/+admin/users/user-edit/user-edit.ts5
-rw-r--r--client/src/app/+admin/users/user-edit/user-password.component.html16
-rw-r--r--client/src/app/+admin/users/user-edit/user-password.component.scss1
-rw-r--r--client/src/app/+admin/users/user-edit/user-password.component.ts35
-rw-r--r--client/src/app/+admin/users/user-edit/user-update.component.ts5
7 files changed, 42 insertions, 49 deletions
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 3ce246771..c6566da24 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
@@ -82,12 +82,16 @@
82 <input type="submit" value="{{ getFormButtonTitle() }}" [disabled]="!form.valid"> 82 <input type="submit" value="{{ getFormButtonTitle() }}" [disabled]="!form.valid">
83</form> 83</form>
84 84
85<div *ngIf="!isCreation()"> 85<div *ngIf="!isCreation()" class="danger-zone">
86 <div class="account-title" i18n>Danger Zone</div> 86 <div class="account-title" i18n>Danger Zone</div>
87 87
88 <p i18n>Send a link to reset the password by mail to the user.</p> 88 <div class="form-group reset-password-email">
89 <button style="margin-top:0;" (click)="resetPassword()" i18n>Ask for new password</button> 89 <label i18n>Send a link to reset the password by email to the user</label>
90 <button (click)="resetPassword()" i18n>Ask for new password</button>
91 </div>
90 92
91 <p class="mt-4" i18n>Manually set the user password</p> 93 <div class="form-group">
92 <my-user-password userId="userId"></my-user-password> 94 <label i18n>Manually set the user password</label>
93</div> \ No newline at end of file 95 <my-user-password [userId]="userId"></my-user-password>
96 </div>
97</div>
diff --git a/client/src/app/+admin/users/user-edit/user-edit.component.scss b/client/src/app/+admin/users/user-edit/user-edit.component.scss
index 2b4aae83c..c1cc4ca45 100644
--- a/client/src/app/+admin/users/user-edit/user-edit.component.scss
+++ b/client/src/app/+admin/users/user-edit/user-edit.component.scss
@@ -32,3 +32,16 @@ input[type=submit], button {
32 margin-top: 55px; 32 margin-top: 55px;
33 margin-bottom: 30px; 33 margin-bottom: 30px;
34} 34}
35
36.danger-zone {
37 .reset-password-email {
38 margin-bottom: 30px;
39 padding-bottom: 30px;
40 border-bottom: 1px solid rgba(0, 0, 0, 0.1);
41
42 button {
43 display: block;
44 margin-top: 0;
45 }
46 }
47}
diff --git a/client/src/app/+admin/users/user-edit/user-edit.ts b/client/src/app/+admin/users/user-edit/user-edit.ts
index 021b1feb4..649b35b0c 100644
--- a/client/src/app/+admin/users/user-edit/user-edit.ts
+++ b/client/src/app/+admin/users/user-edit/user-edit.ts
@@ -8,6 +8,7 @@ export abstract class UserEdit extends FormReactive {
8 videoQuotaDailyOptions: { value: string, label: string }[] = [] 8 videoQuotaDailyOptions: { value: string, label: string }[] = []
9 roles = Object.keys(USER_ROLE_LABELS).map(key => ({ value: key.toString(), label: USER_ROLE_LABELS[key] })) 9 roles = Object.keys(USER_ROLE_LABELS).map(key => ({ value: key.toString(), label: USER_ROLE_LABELS[key] }))
10 username: string 10 username: string
11 userId: number
11 12
12 protected abstract serverService: ServerService 13 protected abstract serverService: ServerService
13 protected abstract configService: ConfigService 14 protected abstract configService: ConfigService
@@ -37,6 +38,10 @@ export abstract class UserEdit extends FormReactive {
37 return multiplier * parseInt(this.form.value['videoQuota'], 10) 38 return multiplier * parseInt(this.form.value['videoQuota'], 10)
38 } 39 }
39 40
41 resetPassword () {
42 return
43 }
44
40 protected buildQuotaOptions () { 45 protected buildQuotaOptions () {
41 // These are used by a HTML select, so convert key into strings 46 // These are used by a HTML select, so convert key into strings
42 this.videoQuotaOptions = this.configService 47 this.videoQuotaOptions = this.configService
diff --git a/client/src/app/+admin/users/user-edit/user-password.component.html b/client/src/app/+admin/users/user-edit/user-password.component.html
index 822e4688e..a1e1f6216 100644
--- a/client/src/app/+admin/users/user-edit/user-password.component.html
+++ b/client/src/app/+admin/users/user-edit/user-password.component.html
@@ -1,19 +1,15 @@
1<form role="form" (ngSubmit)="formValidated()" [formGroup]="form"> 1<form role="form" (ngSubmit)="formValidated()" [formGroup]="form">
2 <div class="form-group"> 2 <div class="form-group">
3 3
4 <div class="input-group mb-3"> 4 <div class="input-group">
5 <div class="input-group-prepend"> 5 <input id="password" [attr.type]="showPassword ? 'text' : 'password'"
6 <div class="input-group-text">
7 <input type="checkbox" aria-label="Show password" (change)="togglePasswordVisibility()">
8 </div>
9 </div>
10 <input id="passwordField" #passwordField
11 [attr.type]="showPassword ? 'text' : 'password'" id="password"
12 formControlName="password" [ngClass]="{ 'input-error': formErrors['password'] }" 6 formControlName="password" [ngClass]="{ 'input-error': formErrors['password'] }"
13 > 7 >
14 <div class="input-group-append"> 8 <div class="input-group-append">
15 <button class="btn btn-sm btn-outline-secondary" (click)="generatePassword() " 9 <button class="btn btn-sm btn-outline-secondary" (click)="togglePasswordVisibility()" type="button">
16 type="button">Generate</button> 10 <ng-container *ngIf="!showPassword" i18n>Show</ng-container>
11 <ng-container *ngIf="!!showPassword" i18n>Hide</ng-container>
12 </button>
17 </div> 13 </div>
18 </div> 14 </div>
19 <div *ngIf="formErrors.password" class="form-error"> 15 <div *ngIf="formErrors.password" class="form-error">
diff --git a/client/src/app/+admin/users/user-edit/user-password.component.scss b/client/src/app/+admin/users/user-edit/user-password.component.scss
index 9185e787c..217d585af 100644
--- a/client/src/app/+admin/users/user-edit/user-password.component.scss
+++ b/client/src/app/+admin/users/user-edit/user-password.component.scss
@@ -3,6 +3,7 @@
3 3
4input:not([type=submit]):not([type=checkbox]) { 4input:not([type=submit]):not([type=checkbox]) {
5 @include peertube-input-text(340px); 5 @include peertube-input-text(340px);
6
6 display: block; 7 display: block;
7 border-top-right-radius: 0; 8 border-top-right-radius: 0;
8 border-bottom-right-radius: 0; 9 border-bottom-right-radius: 0;
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 30cd21ccd..5b3040440 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,14 +1,11 @@
1import { Component, OnDestroy, OnInit, Input } from '@angular/core' 1import { Component, Input, OnInit } from '@angular/core'
2import { ActivatedRoute, Router } from '@angular/router' 2import { ActivatedRoute, Router } from '@angular/router'
3import * as generator from 'generate-password-browser'
4import { NotificationsService } from 'angular2-notifications'
5import { UserService } from '@app/shared/users/user.service' 3import { UserService } from '@app/shared/users/user.service'
6import { ServerService } from '../../../core' 4import { Notifier } from '../../../core'
7import { User, UserUpdate } from '../../../../../../shared' 5import { User, UserUpdate } from '../../../../../../shared'
8import { I18n } from '@ngx-translate/i18n-polyfill' 6import { I18n } from '@ngx-translate/i18n-polyfill'
9import { FormValidatorService } from '@app/shared/forms/form-validators/form-validator.service' 7import { FormValidatorService } from '@app/shared/forms/form-validators/form-validator.service'
10import { UserValidatorsService } from '@app/shared/forms/form-validators/user-validators.service' 8import { UserValidatorsService } from '@app/shared/forms/form-validators/user-validators.service'
11import { ConfigService } from '@app/+admin/config/shared/config.service'
12import { FormReactive } from '../../../shared' 9import { FormReactive } from '../../../shared'
13 10
14@Component({ 11@Component({
@@ -16,7 +13,7 @@ import { FormReactive } from '../../../shared'
16 templateUrl: './user-password.component.html', 13 templateUrl: './user-password.component.html',
17 styleUrls: [ './user-password.component.scss' ] 14 styleUrls: [ './user-password.component.scss' ]
18}) 15})
19export class UserPasswordComponent extends FormReactive implements OnInit, OnDestroy { 16export class UserPasswordComponent extends FormReactive implements OnInit {
20 error: string 17 error: string
21 username: string 18 username: string
22 showPassword = false 19 showPassword = false
@@ -25,12 +22,10 @@ export class UserPasswordComponent extends FormReactive implements OnInit, OnDes
25 22
26 constructor ( 23 constructor (
27 protected formValidatorService: FormValidatorService, 24 protected formValidatorService: FormValidatorService,
28 protected serverService: ServerService,
29 protected configService: ConfigService,
30 private userValidatorsService: UserValidatorsService, 25 private userValidatorsService: UserValidatorsService,
31 private route: ActivatedRoute, 26 private route: ActivatedRoute,
32 private router: Router, 27 private router: Router,
33 private notificationsService: NotificationsService, 28 private notifier: Notifier,
34 private userService: UserService, 29 private userService: UserService,
35 private i18n: I18n 30 private i18n: I18n
36 ) { 31 ) {
@@ -43,10 +38,6 @@ export class UserPasswordComponent extends FormReactive implements OnInit, OnDes
43 }) 38 })
44 } 39 }
45 40
46 ngOnDestroy () {
47 //
48 }
49
50 formValidated () { 41 formValidated () {
51 this.error = undefined 42 this.error = undefined
52 43
@@ -54,8 +45,7 @@ export class UserPasswordComponent extends FormReactive implements OnInit, OnDes
54 45
55 this.userService.updateUser(this.userId, userUpdate).subscribe( 46 this.userService.updateUser(this.userId, userUpdate).subscribe(
56 () => { 47 () => {
57 this.notificationsService.success( 48 this.notifier.success(
58 this.i18n('Success'),
59 this.i18n('Password changed for user {{username}}.', { username: this.username }) 49 this.i18n('Password changed for user {{username}}.', { username: this.username })
60 ) 50 )
61 }, 51 },
@@ -64,16 +54,6 @@ export class UserPasswordComponent extends FormReactive implements OnInit, OnDes
64 ) 54 )
65 } 55 }
66 56
67 generatePassword () {
68 this.form.patchValue({
69 password: generator.generate({
70 length: 16,
71 excludeSimilarCharacters: true,
72 strict: true
73 })
74 })
75 }
76
77 togglePasswordVisibility () { 57 togglePasswordVisibility () {
78 this.showPassword = !this.showPassword 58 this.showPassword = !this.showPassword
79 } 59 }
@@ -81,9 +61,4 @@ export class UserPasswordComponent extends FormReactive implements OnInit, OnDes
81 getFormButtonTitle () { 61 getFormButtonTitle () {
82 return this.i18n('Update user password') 62 return this.i18n('Update user password')
83 } 63 }
84
85 private onUserFetched (userJson: User) {
86 this.userId = userJson.id
87 this.username = userJson.username
88 }
89} 64}
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 4e4002a73..94ef87b08 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
@@ -1,4 +1,4 @@
1import { Component, OnDestroy, OnInit, Input } from '@angular/core' 1import { Component, OnDestroy, OnInit } from '@angular/core'
2import { ActivatedRoute, Router } from '@angular/router' 2import { ActivatedRoute, Router } from '@angular/router'
3import { Subscription } from 'rxjs' 3import { Subscription } from 'rxjs'
4import { Notifier } from '@app/core' 4import { Notifier } from '@app/core'
@@ -93,8 +93,7 @@ export class UserUpdateComponent extends UserEdit implements OnInit, OnDestroy {
93 resetPassword () { 93 resetPassword () {
94 this.userService.askResetPassword(this.userEmail).subscribe( 94 this.userService.askResetPassword(this.userEmail).subscribe(
95 () => { 95 () => {
96 this.notificationsService.success( 96 this.notifier.success(
97 this.i18n('Success'),
98 this.i18n('An email asking for password reset has been sent to {{username}}.', { username: this.username }) 97 this.i18n('An email asking for password reset has been sent to {{username}}.', { username: this.username })
99 ) 98 )
100 }, 99 },