diff options
author | Chocobozzz <me@florianbigard.com> | 2018-04-26 10:03:40 +0200 |
---|---|---|
committer | Chocobozzz <me@florianbigard.com> | 2018-04-26 10:03:40 +0200 |
commit | ed56ad1193bb5bb0a81fb843a11eb90d3fed9861 (patch) | |
tree | 64842447b4721978c69e1d2b3a964951c789c408 /client/src/app/my-account/my-account-settings | |
parent | d62cf3234ccfca0223a9639782635f0fb6594f8c (diff) | |
download | PeerTube-ed56ad1193bb5bb0a81fb843a11eb90d3fed9861.tar.gz PeerTube-ed56ad1193bb5bb0a81fb843a11eb90d3fed9861.tar.zst PeerTube-ed56ad1193bb5bb0a81fb843a11eb90d3fed9861.zip |
Add ability to update the user display name/description
Diffstat (limited to 'client/src/app/my-account/my-account-settings')
10 files changed, 126 insertions, 8 deletions
diff --git a/client/src/app/my-account/my-account-settings/my-account-details/index.ts b/client/src/app/my-account/my-account-settings/my-account-details/index.ts deleted file mode 100644 index b7f58e329..000000000 --- a/client/src/app/my-account/my-account-settings/my-account-details/index.ts +++ /dev/null | |||
@@ -1 +0,0 @@ | |||
1 | export * from './my-account-details.component' | ||
diff --git a/client/src/app/my-account/my-account-settings/my-account-profile/index.ts b/client/src/app/my-account/my-account-settings/my-account-profile/index.ts new file mode 100644 index 000000000..3cc049f8f --- /dev/null +++ b/client/src/app/my-account/my-account-settings/my-account-profile/index.ts | |||
@@ -0,0 +1 @@ | |||
export * from './my-account-profile.component' | |||
diff --git a/client/src/app/my-account/my-account-settings/my-account-profile/my-account-profile.component.html b/client/src/app/my-account/my-account-settings/my-account-profile/my-account-profile.component.html new file mode 100644 index 000000000..306f3a12c --- /dev/null +++ b/client/src/app/my-account/my-account-settings/my-account-profile/my-account-profile.component.html | |||
@@ -0,0 +1,24 @@ | |||
1 | <div *ngIf="error" class="alert alert-danger">{{ error }}</div> | ||
2 | |||
3 | <form role="form" (ngSubmit)="updateMyProfile()" [formGroup]="form"> | ||
4 | |||
5 | <label for="display-name">Display name</label> | ||
6 | <input | ||
7 | type="text" id="display-name" | ||
8 | formControlName="display-name" [ngClass]="{ 'input-error': formErrors['display-name'] }" | ||
9 | > | ||
10 | <div *ngIf="formErrors['display-name']" class="form-error"> | ||
11 | {{ formErrors['display-name'] }} | ||
12 | </div> | ||
13 | |||
14 | <label for="description">Description</label> | ||
15 | <textarea | ||
16 | id="description" formControlName="description" | ||
17 | [ngClass]="{ 'input-error': formErrors['description'] }" | ||
18 | ></textarea> | ||
19 | <div *ngIf="formErrors.description" class="form-error"> | ||
20 | {{ formErrors.description }} | ||
21 | </div> | ||
22 | |||
23 | <input type="submit" value="Update my profile" [disabled]="!form.valid"> | ||
24 | </form> | ||
diff --git a/client/src/app/my-account/my-account-settings/my-account-profile/my-account-profile.component.scss b/client/src/app/my-account/my-account-settings/my-account-profile/my-account-profile.component.scss new file mode 100644 index 000000000..fc2b92c89 --- /dev/null +++ b/client/src/app/my-account/my-account-settings/my-account-profile/my-account-profile.component.scss | |||
@@ -0,0 +1,23 @@ | |||
1 | @import '_variables'; | ||
2 | @import '_mixins'; | ||
3 | |||
4 | input[type=text] { | ||
5 | @include peertube-input-text(340px); | ||
6 | |||
7 | display: block; | ||
8 | margin-bottom: 15px; | ||
9 | } | ||
10 | |||
11 | textarea { | ||
12 | @include peertube-textarea(500px, 150px); | ||
13 | |||
14 | display: block; | ||
15 | } | ||
16 | |||
17 | input[type=submit] { | ||
18 | @include peertube-button; | ||
19 | @include orange-button; | ||
20 | |||
21 | margin-top: 15px; | ||
22 | } | ||
23 | |||
diff --git a/client/src/app/my-account/my-account-settings/my-account-profile/my-account-profile.component.ts b/client/src/app/my-account/my-account-settings/my-account-profile/my-account-profile.component.ts new file mode 100644 index 000000000..2b7ba353c --- /dev/null +++ b/client/src/app/my-account/my-account-settings/my-account-profile/my-account-profile.component.ts | |||
@@ -0,0 +1,65 @@ | |||
1 | import { Component, Input, OnInit } from '@angular/core' | ||
2 | import { FormBuilder, FormGroup } from '@angular/forms' | ||
3 | import { NotificationsService } from 'angular2-notifications' | ||
4 | import { FormReactive, USER_DESCRIPTION, USER_DISPLAY_NAME, UserService } from '../../../shared' | ||
5 | import { User } from '@app/shared' | ||
6 | |||
7 | @Component({ | ||
8 | selector: 'my-account-profile', | ||
9 | templateUrl: './my-account-profile.component.html', | ||
10 | styleUrls: [ './my-account-profile.component.scss' ] | ||
11 | }) | ||
12 | export class MyAccountProfileComponent extends FormReactive implements OnInit { | ||
13 | @Input() user: User = null | ||
14 | |||
15 | error: string = null | ||
16 | |||
17 | form: FormGroup | ||
18 | formErrors = { | ||
19 | 'display-name': '', | ||
20 | 'description': '' | ||
21 | } | ||
22 | validationMessages = { | ||
23 | 'display-name': USER_DISPLAY_NAME.MESSAGES, | ||
24 | 'description': USER_DESCRIPTION.MESSAGES | ||
25 | } | ||
26 | |||
27 | constructor ( | ||
28 | private formBuilder: FormBuilder, | ||
29 | private notificationsService: NotificationsService, | ||
30 | private userService: UserService | ||
31 | ) { | ||
32 | super() | ||
33 | } | ||
34 | |||
35 | buildForm () { | ||
36 | this.form = this.formBuilder.group({ | ||
37 | 'display-name': [ this.user.account.displayName, USER_DISPLAY_NAME.VALIDATORS ], | ||
38 | 'description': [ this.user.account.description, USER_DESCRIPTION.VALIDATORS ] | ||
39 | }) | ||
40 | |||
41 | this.form.valueChanges.subscribe(data => this.onValueChanged(data)) | ||
42 | } | ||
43 | |||
44 | ngOnInit () { | ||
45 | this.buildForm() | ||
46 | } | ||
47 | |||
48 | updateMyProfile () { | ||
49 | const displayName = this.form.value['display-name'] | ||
50 | const description = this.form.value['description'] | ||
51 | |||
52 | this.error = null | ||
53 | |||
54 | this.userService.updateMyProfile({ displayName, description }).subscribe( | ||
55 | () => { | ||
56 | this.user.account.displayName = displayName | ||
57 | this.user.account.description = description | ||
58 | |||
59 | this.notificationsService.success('Success', 'Profile updated.') | ||
60 | }, | ||
61 | |||
62 | err => this.error = err.message | ||
63 | ) | ||
64 | } | ||
65 | } | ||
diff --git a/client/src/app/my-account/my-account-settings/my-account-settings.component.html b/client/src/app/my-account/my-account-settings/my-account-settings.component.html index e11d93c01..e655b9d96 100644 --- a/client/src/app/my-account/my-account-settings/my-account-settings.component.html +++ b/client/src/app/my-account/my-account-settings/my-account-settings.component.html | |||
@@ -17,8 +17,13 @@ | |||
17 | <span class="user-quota-label">Video quota:</span> {{ userVideoQuotaUsed | bytes: 0 }} / {{ userVideoQuota }} | 17 | <span class="user-quota-label">Video quota:</span> {{ userVideoQuotaUsed | bytes: 0 }} / {{ userVideoQuota }} |
18 | </div> | 18 | </div> |
19 | 19 | ||
20 | <div class="account-title">Account settings</div> | 20 | <ng-template [ngIf]="user && user.account"> |
21 | <div class="account-title">Profile</div> | ||
22 | <my-account-profile [user]="user"></my-account-profile> | ||
23 | </ng-template> | ||
24 | |||
25 | <div class="account-title">Password</div> | ||
21 | <my-account-change-password></my-account-change-password> | 26 | <my-account-change-password></my-account-change-password> |
22 | 27 | ||
23 | <div class="account-title">Video settings</div> | 28 | <div class="account-title">Video settings</div> |
24 | <my-account-details [user]="user"></my-account-details> | 29 | <my-account-video-settings [user]="user"></my-account-video-settings> |
diff --git a/client/src/app/my-account/my-account-settings/my-account-video-settings/index.ts b/client/src/app/my-account/my-account-settings/my-account-video-settings/index.ts new file mode 100644 index 000000000..1253bd369 --- /dev/null +++ b/client/src/app/my-account/my-account-settings/my-account-video-settings/index.ts | |||
@@ -0,0 +1 @@ | |||
export * from './my-account-video-settings.component' | |||
diff --git a/client/src/app/my-account/my-account-settings/my-account-details/my-account-details.component.html b/client/src/app/my-account/my-account-settings/my-account-video-settings/my-account-video-settings.component.html index 0e8598e9e..0e8598e9e 100644 --- a/client/src/app/my-account/my-account-settings/my-account-details/my-account-details.component.html +++ b/client/src/app/my-account/my-account-settings/my-account-video-settings/my-account-video-settings.component.html | |||
diff --git a/client/src/app/my-account/my-account-settings/my-account-details/my-account-details.component.scss b/client/src/app/my-account/my-account-settings/my-account-video-settings/my-account-video-settings.component.scss index ed59e4689..ed59e4689 100644 --- a/client/src/app/my-account/my-account-settings/my-account-details/my-account-details.component.scss +++ b/client/src/app/my-account/my-account-settings/my-account-video-settings/my-account-video-settings.component.scss | |||
diff --git a/client/src/app/my-account/my-account-settings/my-account-details/my-account-details.component.ts b/client/src/app/my-account/my-account-settings/my-account-video-settings/my-account-video-settings.component.ts index 4c1456541..acc70c14d 100644 --- a/client/src/app/my-account/my-account-settings/my-account-details/my-account-details.component.ts +++ b/client/src/app/my-account/my-account-settings/my-account-video-settings/my-account-video-settings.component.ts | |||
@@ -6,11 +6,11 @@ import { AuthService } from '../../../core' | |||
6 | import { FormReactive, User, UserService } from '../../../shared' | 6 | import { FormReactive, User, UserService } from '../../../shared' |
7 | 7 | ||
8 | @Component({ | 8 | @Component({ |
9 | selector: 'my-account-details', | 9 | selector: 'my-account-video-settings', |
10 | templateUrl: './my-account-details.component.html', | 10 | templateUrl: './my-account-video-settings.component.html', |
11 | styleUrls: [ './my-account-details.component.scss' ] | 11 | styleUrls: [ './my-account-video-settings.component.scss' ] |
12 | }) | 12 | }) |
13 | export class MyAccountDetailsComponent extends FormReactive implements OnInit { | 13 | export class MyAccountVideoSettingsComponent extends FormReactive implements OnInit { |
14 | @Input() user: User = null | 14 | @Input() user: User = null |
15 | 15 | ||
16 | form: FormGroup | 16 | form: FormGroup |
@@ -47,7 +47,7 @@ export class MyAccountDetailsComponent extends FormReactive implements OnInit { | |||
47 | autoPlayVideo | 47 | autoPlayVideo |
48 | } | 48 | } |
49 | 49 | ||
50 | this.userService.updateMyDetails(details).subscribe( | 50 | this.userService.updateMyProfile(details).subscribe( |
51 | () => { | 51 | () => { |
52 | this.notificationsService.success('Success', 'Information updated.') | 52 | this.notificationsService.success('Success', 'Information updated.') |
53 | 53 | ||