aboutsummaryrefslogtreecommitdiffhomepage
path: root/client/src/app/my-account/my-account-settings/my-account-details
diff options
context:
space:
mode:
Diffstat (limited to 'client/src/app/my-account/my-account-settings/my-account-details')
-rw-r--r--client/src/app/my-account/my-account-settings/my-account-details/index.ts1
-rw-r--r--client/src/app/my-account/my-account-settings/my-account-details/my-account-details.component.html25
-rw-r--r--client/src/app/my-account/my-account-settings/my-account-details/my-account-details.component.scss20
-rw-r--r--client/src/app/my-account/my-account-settings/my-account-details/my-account-details.component.ts60
4 files changed, 106 insertions, 0 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
new file mode 100644
index 000000000..b7f58e329
--- /dev/null
+++ b/client/src/app/my-account/my-account-settings/my-account-details/index.ts
@@ -0,0 +1 @@
export * from './my-account-details.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-details/my-account-details.component.html
new file mode 100644
index 000000000..0e8598e9e
--- /dev/null
+++ b/client/src/app/my-account/my-account-settings/my-account-details/my-account-details.component.html
@@ -0,0 +1,25 @@
1<form role="form" (ngSubmit)="updateDetails()" [formGroup]="form">
2 <div class="form-group">
3 <label for="nsfwPolicy">Default policy on videos containing sensitive content</label>
4 <my-help helpType="custom" customHtml="With <strong>Do not list</strong> or <strong>Blur thumbnails</strong>, a confirmation will be requested to watch the video."></my-help>
5
6 <div class="peertube-select-container">
7 <select id="nsfwPolicy" formControlName="nsfwPolicy">
8 <option value="do_not_list">Do not list</option>
9 <option value="blur">Blur thumbnails</option>
10 <option value="display">Display</option>
11 </select>
12 </div>
13 </div>
14
15 <div class="form-group">
16 <input
17 type="checkbox" id="autoPlayVideo"
18 formControlName="autoPlayVideo"
19 >
20 <label for="autoPlayVideo"></label>
21 <label for="autoPlayVideo">Automatically plays video</label>
22 </div>
23
24 <input type="submit" value="Save" [disabled]="!form.valid">
25</form>
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-details/my-account-details.component.scss
new file mode 100644
index 000000000..ed59e4689
--- /dev/null
+++ b/client/src/app/my-account/my-account-settings/my-account-details/my-account-details.component.scss
@@ -0,0 +1,20 @@
1@import '_variables';
2@import '_mixins';
3
4input[type=checkbox] {
5 @include peertube-checkbox(1px);
6}
7
8input[type=submit] {
9 @include peertube-button;
10 @include orange-button;
11
12 display: block;
13 margin-top: 15px;
14}
15
16.peertube-select-container {
17 @include peertube-select-container(340px);
18
19 margin-bottom: 30px;
20} \ No newline at end of file
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-details/my-account-details.component.ts
new file mode 100644
index 000000000..4c1456541
--- /dev/null
+++ b/client/src/app/my-account/my-account-settings/my-account-details/my-account-details.component.ts
@@ -0,0 +1,60 @@
1import { Component, Input, OnInit } from '@angular/core'
2import { FormBuilder, FormGroup } from '@angular/forms'
3import { NotificationsService } from 'angular2-notifications'
4import { UserUpdateMe } from '../../../../../../shared'
5import { AuthService } from '../../../core'
6import { FormReactive, User, UserService } from '../../../shared'
7
8@Component({
9 selector: 'my-account-details',
10 templateUrl: './my-account-details.component.html',
11 styleUrls: [ './my-account-details.component.scss' ]
12})
13export class MyAccountDetailsComponent extends FormReactive implements OnInit {
14 @Input() user: User = null
15
16 form: FormGroup
17 formErrors = {}
18 validationMessages = {}
19
20 constructor (
21 private authService: AuthService,
22 private formBuilder: FormBuilder,
23 private notificationsService: NotificationsService,
24 private userService: UserService
25 ) {
26 super()
27 }
28
29 buildForm () {
30 this.form = this.formBuilder.group({
31 nsfwPolicy: [ this.user.nsfwPolicy ],
32 autoPlayVideo: [ this.user.autoPlayVideo ]
33 })
34
35 this.form.valueChanges.subscribe(data => this.onValueChanged(data))
36 }
37
38 ngOnInit () {
39 this.buildForm()
40 }
41
42 updateDetails () {
43 const nsfwPolicy = this.form.value['nsfwPolicy']
44 const autoPlayVideo = this.form.value['autoPlayVideo']
45 const details: UserUpdateMe = {
46 nsfwPolicy,
47 autoPlayVideo
48 }
49
50 this.userService.updateMyDetails(details).subscribe(
51 () => {
52 this.notificationsService.success('Success', 'Information updated.')
53
54 this.authService.refreshUserInformation()
55 },
56
57 err => this.notificationsService.error('Error', err.message)
58 )
59 }
60}