aboutsummaryrefslogtreecommitdiffhomepage
path: root/client/src/app/account/account-details
diff options
context:
space:
mode:
authorChocobozzz <florian.bigard@gmail.com>2017-04-06 21:21:03 +0200
committerChocobozzz <florian.bigard@gmail.com>2017-04-06 21:21:03 +0200
commitaf5e743b01f20f24d0c25e786d57f557b21f3a24 (patch)
tree5186d587135f13f00687f8ed6cd8504cdd35799f /client/src/app/account/account-details
parent92fb909c9b4a92a00b0d0da7629e6fb003de281b (diff)
downloadPeerTube-af5e743b01f20f24d0c25e786d57f557b21f3a24.tar.gz
PeerTube-af5e743b01f20f24d0c25e786d57f557b21f3a24.tar.zst
PeerTube-af5e743b01f20f24d0c25e786d57f557b21f3a24.zip
Client: add ability for user to change nsfw settings
Diffstat (limited to 'client/src/app/account/account-details')
-rw-r--r--client/src/app/account/account-details/account-details.component.html16
-rw-r--r--client/src/app/account/account-details/account-details.component.ts68
-rw-r--r--client/src/app/account/account-details/index.ts1
3 files changed, 85 insertions, 0 deletions
diff --git a/client/src/app/account/account-details/account-details.component.html b/client/src/app/account/account-details/account-details.component.html
new file mode 100644
index 000000000..24b0750d2
--- /dev/null
+++ b/client/src/app/account/account-details/account-details.component.html
@@ -0,0 +1,16 @@
1<div *ngIf="error" class="alert alert-danger">{{ error }}</div>
2
3<form role="form" (ngSubmit)="updateDetails()" [formGroup]="form">
4 <div class="form-group">
5 <label for="displayNSFW">Display NSFW videos</label>
6 <input
7 type="checkbox" id="displayNSFW"
8 formControlName="displayNSFW"
9 >
10 <div *ngIf="formErrors['displayNSFW']" class="alert alert-danger">
11 {{ formErrors['displayNSFW'] }}
12 </div>
13 </div>
14
15 <input type="submit" value="Update" class="btn btn-default" [disabled]="!form.valid">
16</form>
diff --git a/client/src/app/account/account-details/account-details.component.ts b/client/src/app/account/account-details/account-details.component.ts
new file mode 100644
index 000000000..30e5b14ee
--- /dev/null
+++ b/client/src/app/account/account-details/account-details.component.ts
@@ -0,0 +1,68 @@
1import { Component, OnInit, Input } from '@angular/core';
2import { FormBuilder, FormGroup } from '@angular/forms';
3import { Router } from '@angular/router';
4
5import { NotificationsService } from 'angular2-notifications';
6
7import { AuthService } from '../../core';
8import {
9 FormReactive,
10 User,
11 UserService,
12 USER_PASSWORD
13} from '../../shared';
14
15@Component({
16 selector: 'my-account-details',
17 templateUrl: './account-details.component.html'
18})
19
20export class AccountDetailsComponent extends FormReactive implements OnInit {
21 @Input() user: User = null;
22
23 error: string = null;
24
25 form: FormGroup;
26 formErrors = {};
27 validationMessages = {};
28
29 constructor(
30 private authService: AuthService,
31 private formBuilder: FormBuilder,
32 private router: Router,
33 private notificationsService: NotificationsService,
34 private userService: UserService
35 ) {
36 super();
37 }
38
39 buildForm() {
40 this.form = this.formBuilder.group({
41 displayNSFW: [ this.user.displayNSFW ],
42 });
43
44 this.form.valueChanges.subscribe(data => this.onValueChanged(data));
45 }
46
47 ngOnInit() {
48 this.buildForm();
49 }
50
51 updateDetails() {
52 const displayNSFW = this.form.value['displayNSFW'];
53 const details = {
54 displayNSFW
55 };
56
57 this.error = null;
58 this.userService.updateDetails(details).subscribe(
59 () => {
60 this.notificationsService.success('Success', 'Informations updated.');
61
62 this.authService.refreshUserInformations();
63 },
64
65 err => this.error = err
66 );
67 }
68}
diff --git a/client/src/app/account/account-details/index.ts b/client/src/app/account/account-details/index.ts
new file mode 100644
index 000000000..28f644738
--- /dev/null
+++ b/client/src/app/account/account-details/index.ts
@@ -0,0 +1 @@
export * from './account-details.component';