diff options
author | Chocobozzz <me@florianbigard.com> | 2018-05-09 09:26:41 +0200 |
---|---|---|
committer | Chocobozzz <me@florianbigard.com> | 2018-05-09 09:32:26 +0200 |
commit | 62e62f118d5da57acd3494fece2e8ed357564ffe (patch) | |
tree | ff5b7c6ec5708d71a76a2eb5744d810015ae29a5 /client/src/app/+my-account/my-account-settings/my-account-video-settings | |
parent | 1952a538baa330b13bd11631b3975f7ef1c37e70 (diff) | |
download | PeerTube-62e62f118d5da57acd3494fece2e8ed357564ffe.tar.gz PeerTube-62e62f118d5da57acd3494fece2e8ed357564ffe.tar.zst PeerTube-62e62f118d5da57acd3494fece2e8ed357564ffe.zip |
Load my-account module lazily
Diffstat (limited to 'client/src/app/+my-account/my-account-settings/my-account-video-settings')
4 files changed, 106 insertions, 0 deletions
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-video-settings/my-account-video-settings.component.html b/client/src/app/+my-account/my-account-settings/my-account-video-settings/my-account-video-settings.component.html new file mode 100644 index 000000000..0e8598e9e --- /dev/null +++ b/client/src/app/+my-account/my-account-settings/my-account-video-settings/my-account-video-settings.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-video-settings/my-account-video-settings.component.scss b/client/src/app/+my-account/my-account-settings/my-account-video-settings/my-account-video-settings.component.scss new file mode 100644 index 000000000..ed59e4689 --- /dev/null +++ b/client/src/app/+my-account/my-account-settings/my-account-video-settings/my-account-video-settings.component.scss | |||
@@ -0,0 +1,20 @@ | |||
1 | @import '_variables'; | ||
2 | @import '_mixins'; | ||
3 | |||
4 | input[type=checkbox] { | ||
5 | @include peertube-checkbox(1px); | ||
6 | } | ||
7 | |||
8 | input[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-video-settings/my-account-video-settings.component.ts b/client/src/app/+my-account/my-account-settings/my-account-video-settings/my-account-video-settings.component.ts new file mode 100644 index 000000000..acc70c14d --- /dev/null +++ b/client/src/app/+my-account/my-account-settings/my-account-video-settings/my-account-video-settings.component.ts | |||
@@ -0,0 +1,60 @@ | |||
1 | import { Component, Input, OnInit } from '@angular/core' | ||
2 | import { FormBuilder, FormGroup } from '@angular/forms' | ||
3 | import { NotificationsService } from 'angular2-notifications' | ||
4 | import { UserUpdateMe } from '../../../../../../shared' | ||
5 | import { AuthService } from '../../../core' | ||
6 | import { FormReactive, User, UserService } from '../../../shared' | ||
7 | |||
8 | @Component({ | ||
9 | selector: 'my-account-video-settings', | ||
10 | templateUrl: './my-account-video-settings.component.html', | ||
11 | styleUrls: [ './my-account-video-settings.component.scss' ] | ||
12 | }) | ||
13 | export class MyAccountVideoSettingsComponent 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.updateMyProfile(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 | } | ||