diff options
Diffstat (limited to 'client/src/app/+my-account/my-account-settings/my-account-video-settings')
4 files changed, 0 insertions, 242 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 deleted file mode 100644 index 1253bd369..000000000 --- a/client/src/app/+my-account/my-account-settings/my-account-video-settings/index.ts +++ /dev/null | |||
@@ -1 +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 deleted file mode 100644 index 0dda33af2..000000000 --- a/client/src/app/+my-account/my-account-settings/my-account-video-settings/my-account-video-settings.component.html +++ /dev/null | |||
@@ -1,75 +0,0 @@ | |||
1 | <form role="form" (ngSubmit)="updateDetails()" [formGroup]="form"> | ||
2 | <div class="form-group form-group-select"> | ||
3 | <label i18n for="nsfwPolicy">Default policy on videos containing sensitive content</label> | ||
4 | <my-help> | ||
5 | <ng-template ptTemplate="customHtml"> | ||
6 | <ng-container i18n> | ||
7 | With <strong>Do not list</strong> or <strong>Blur thumbnails</strong>, a confirmation will be requested to watch the video. | ||
8 | </ng-container> | ||
9 | </ng-template> | ||
10 | </my-help> | ||
11 | |||
12 | <div class="peertube-select-container"> | ||
13 | <select id="nsfwPolicy" formControlName="nsfwPolicy" class="form-control"> | ||
14 | <option i18n value="undefined" disabled>Policy for sensitive videos</option> | ||
15 | <option i18n value="do_not_list">Do not list</option> | ||
16 | <option i18n value="blur">Blur thumbnails</option> | ||
17 | <option i18n value="display">Display</option> | ||
18 | </select> | ||
19 | </div> | ||
20 | </div> | ||
21 | |||
22 | <div class="form-group form-group-select"> | ||
23 | <label i18n for="videoLanguages">Only display videos in the following languages/subtitles</label> | ||
24 | <my-help> | ||
25 | <ng-template ptTemplate="customHtml"> | ||
26 | <ng-container i18n>In Recently added, Trending, Local, Most liked and Search pages</ng-container> | ||
27 | </ng-template> | ||
28 | </my-help> | ||
29 | |||
30 | <div> | ||
31 | <p-multiSelect | ||
32 | inputId="videoLanguages" [options]="languageItems" formControlName="videoLanguages" [showToggleAll]="true" | ||
33 | [defaultLabel]="getDefaultVideoLanguageLabel()" [selectedItemsLabel]="getSelectedVideoLanguageLabel()" | ||
34 | emptyFilterMessage="No results found" i18n-emptyFilterMessage | ||
35 | ></p-multiSelect> | ||
36 | </div> | ||
37 | </div> | ||
38 | |||
39 | <ng-content select="inner-title"></ng-content> | ||
40 | |||
41 | <div class="form-group"> | ||
42 | <my-peertube-checkbox | ||
43 | inputName="webTorrentEnabled" formControlName="webTorrentEnabled" [recommended]="true" | ||
44 | i18n-labelText labelText="Help share videos being played" | ||
45 | > | ||
46 | <ng-container ngProjectAs="description"> | ||
47 | <span i18n>The <a routerLink="/about/peertube" fragment="privacy">sharing system</a> implies that some technical information about your system (such as a public IP address) can be sent to other peers, but greatly helps to reduce server load.</span> | ||
48 | </ng-container> | ||
49 | </my-peertube-checkbox> | ||
50 | </div> | ||
51 | |||
52 | <div class="form-group"> | ||
53 | <my-peertube-checkbox | ||
54 | inputName="autoPlayVideo" formControlName="autoPlayVideo" | ||
55 | i18n-labelText labelText="Automatically play videos" | ||
56 | > | ||
57 | <ng-container ngProjectAs="description"> | ||
58 | <span i18n>When on a video page, directly start playing the video.</span> | ||
59 | </ng-container> | ||
60 | </my-peertube-checkbox> | ||
61 | </div> | ||
62 | |||
63 | <div class="form-group"> | ||
64 | <my-peertube-checkbox | ||
65 | inputName="autoPlayNextVideo" formControlName="autoPlayNextVideo" | ||
66 | i18n-labelText labelText="Automatically start playing the next video" | ||
67 | > | ||
68 | <ng-container ngProjectAs="description"> | ||
69 | <span i18n>When a video ends, follow up with the next suggested video.</span> | ||
70 | </ng-container> | ||
71 | </my-peertube-checkbox> | ||
72 | </div> | ||
73 | |||
74 | <input *ngIf="!reactiveUpdate" type="submit" i18n-value value="Save" [disabled]="!form.valid"> | ||
75 | </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 deleted file mode 100644 index 430250b87..000000000 --- a/client/src/app/+my-account/my-account-settings/my-account-video-settings/my-account-video-settings.component.scss +++ /dev/null | |||
@@ -1,24 +0,0 @@ | |||
1 | @import '_variables'; | ||
2 | @import '_mixins'; | ||
3 | |||
4 | label { | ||
5 | font-weight: $font-regular; | ||
6 | font-size: 100%; | ||
7 | } | ||
8 | |||
9 | input[type=submit] { | ||
10 | @include peertube-button; | ||
11 | @include orange-button; | ||
12 | |||
13 | margin-top: 15px; | ||
14 | } | ||
15 | |||
16 | .peertube-select-container { | ||
17 | @include peertube-select-container(340px); | ||
18 | |||
19 | margin-bottom: 30px; | ||
20 | } | ||
21 | |||
22 | .form-group-select { | ||
23 | margin-bottom: 30px; | ||
24 | } | ||
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 deleted file mode 100644 index 0aaa54cd7..000000000 --- a/client/src/app/+my-account/my-account-settings/my-account-video-settings/my-account-video-settings.component.ts +++ /dev/null | |||
@@ -1,142 +0,0 @@ | |||
1 | import { Component, Input, OnInit, OnDestroy } from '@angular/core' | ||
2 | import { Notifier, ServerService } from '@app/core' | ||
3 | import { UserUpdateMe } from '../../../../../../shared/models/users' | ||
4 | import { User, UserService } from '@app/shared/users' | ||
5 | import { AuthService } from '../../../core' | ||
6 | import { FormReactive } from '@app/shared/forms/form-reactive' | ||
7 | import { I18n } from '@ngx-translate/i18n-polyfill' | ||
8 | import { FormValidatorService } from '@app/shared/forms/form-validators/form-validator.service' | ||
9 | import { forkJoin, Subject, Subscription } from 'rxjs' | ||
10 | import { SelectItem } from 'primeng/api' | ||
11 | import { first } from 'rxjs/operators' | ||
12 | import { NSFWPolicyType } from '@shared/models/videos/nsfw-policy.type' | ||
13 | import { pick } from 'lodash-es' | ||
14 | |||
15 | @Component({ | ||
16 | selector: 'my-account-video-settings', | ||
17 | templateUrl: './my-account-video-settings.component.html', | ||
18 | styleUrls: [ './my-account-video-settings.component.scss' ] | ||
19 | }) | ||
20 | export class MyAccountVideoSettingsComponent extends FormReactive implements OnInit, OnDestroy { | ||
21 | @Input() user: User = null | ||
22 | @Input() reactiveUpdate = false | ||
23 | @Input() notifyOnUpdate = true | ||
24 | @Input() userInformationLoaded: Subject<any> | ||
25 | |||
26 | languageItems: SelectItem[] = [] | ||
27 | defaultNSFWPolicy: NSFWPolicyType | ||
28 | formValuesWatcher: Subscription | ||
29 | |||
30 | constructor ( | ||
31 | protected formValidatorService: FormValidatorService, | ||
32 | private authService: AuthService, | ||
33 | private notifier: Notifier, | ||
34 | private userService: UserService, | ||
35 | private serverService: ServerService, | ||
36 | private i18n: I18n | ||
37 | ) { | ||
38 | super() | ||
39 | } | ||
40 | |||
41 | ngOnInit () { | ||
42 | let oldForm: any | ||
43 | |||
44 | this.buildForm({ | ||
45 | nsfwPolicy: null, | ||
46 | webTorrentEnabled: null, | ||
47 | autoPlayVideo: null, | ||
48 | autoPlayNextVideo: null, | ||
49 | videoLanguages: null | ||
50 | }) | ||
51 | |||
52 | forkJoin([ | ||
53 | this.serverService.getVideoLanguages(), | ||
54 | this.serverService.getConfig(), | ||
55 | this.userInformationLoaded.pipe(first()) | ||
56 | ]).subscribe(([ languages, config ]) => { | ||
57 | this.languageItems = [ { label: this.i18n('Unknown language'), value: '_unknown' } ] | ||
58 | this.languageItems = this.languageItems | ||
59 | .concat(languages.map(l => ({ label: l.label, value: l.id }))) | ||
60 | |||
61 | const videoLanguages = this.user.videoLanguages | ||
62 | ? this.user.videoLanguages | ||
63 | : this.languageItems.map(l => l.value) | ||
64 | |||
65 | this.defaultNSFWPolicy = config.instance.defaultNSFWPolicy | ||
66 | |||
67 | this.form.patchValue({ | ||
68 | nsfwPolicy: this.user.nsfwPolicy || this.defaultNSFWPolicy, | ||
69 | webTorrentEnabled: this.user.webTorrentEnabled, | ||
70 | autoPlayVideo: this.user.autoPlayVideo === true, | ||
71 | autoPlayNextVideo: this.user.autoPlayNextVideo, | ||
72 | videoLanguages | ||
73 | }) | ||
74 | |||
75 | if (this.reactiveUpdate) { | ||
76 | oldForm = { ...this.form.value } | ||
77 | this.formValuesWatcher = this.form.valueChanges.subscribe((formValue: any) => { | ||
78 | const updatedKey = Object.keys(formValue).find(k => formValue[k] !== oldForm[k]) | ||
79 | oldForm = { ...this.form.value } | ||
80 | this.updateDetails([updatedKey]) | ||
81 | }) | ||
82 | } | ||
83 | }) | ||
84 | } | ||
85 | |||
86 | ngOnDestroy () { | ||
87 | this.formValuesWatcher?.unsubscribe() | ||
88 | } | ||
89 | |||
90 | updateDetails (onlyKeys?: string[]) { | ||
91 | const nsfwPolicy = this.form.value[ 'nsfwPolicy' ] | ||
92 | const webTorrentEnabled = this.form.value['webTorrentEnabled'] | ||
93 | const autoPlayVideo = this.form.value['autoPlayVideo'] | ||
94 | const autoPlayNextVideo = this.form.value['autoPlayNextVideo'] | ||
95 | |||
96 | let videoLanguages: string[] = this.form.value['videoLanguages'] | ||
97 | if (Array.isArray(videoLanguages)) { | ||
98 | if (videoLanguages.length === this.languageItems.length) { | ||
99 | videoLanguages = null // null means "All" | ||
100 | } else if (videoLanguages.length > 20) { | ||
101 | this.notifier.error('Too many languages are enabled. Please enable them all or stay below 20 enabled languages.') | ||
102 | return | ||
103 | } else if (videoLanguages.length === 0) { | ||
104 | this.notifier.error('You need to enabled at least 1 video language.') | ||
105 | return | ||
106 | } | ||
107 | } | ||
108 | |||
109 | let details: UserUpdateMe = { | ||
110 | nsfwPolicy, | ||
111 | webTorrentEnabled, | ||
112 | autoPlayVideo, | ||
113 | autoPlayNextVideo, | ||
114 | videoLanguages | ||
115 | } | ||
116 | |||
117 | if (onlyKeys) details = pick(details, onlyKeys) | ||
118 | |||
119 | if (this.authService.isLoggedIn()) { | ||
120 | this.userService.updateMyProfile(details).subscribe( | ||
121 | () => { | ||
122 | this.authService.refreshUserInformation() | ||
123 | |||
124 | if (this.notifyOnUpdate) this.notifier.success(this.i18n('Video settings updated.')) | ||
125 | }, | ||
126 | |||
127 | err => this.notifier.error(err.message) | ||
128 | ) | ||
129 | } else { | ||
130 | this.userService.updateMyAnonymousProfile(details) | ||
131 | if (this.notifyOnUpdate) this.notifier.success(this.i18n('Display/Video settings updated.')) | ||
132 | } | ||
133 | } | ||
134 | |||
135 | getDefaultVideoLanguageLabel () { | ||
136 | return this.i18n('No language') | ||
137 | } | ||
138 | |||
139 | getSelectedVideoLanguageLabel () { | ||
140 | return this.i18n('{{\'{0} languages selected') | ||
141 | } | ||
142 | } | ||