diff options
Diffstat (limited to 'client/src/app')
4 files changed, 25 insertions, 0 deletions
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 index 96629940f..adbb97f00 100644 --- 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 | |||
@@ -15,6 +15,18 @@ | |||
15 | </div> | 15 | </div> |
16 | </div> | 16 | </div> |
17 | 17 | ||
18 | <div class="form-group"> | ||
19 | <label i18n for="webTorrentPolicy">Policy regarding P2P technologies</label> | ||
20 | |||
21 | <div class="peertube-select-container"> | ||
22 | <select id="webTorrentPolicy" formControlName="webTorrentPolicy"> | ||
23 | <option i18n value="enable">Enable WebTorrent</option> | ||
24 | <option i18n value="disable">Disable WebTorrent globally</option> | ||
25 | <option i18n value="disable_on_mobile" disabled>Disable WebTorrent on mobile devices (not yet available)</option> | ||
26 | </select> | ||
27 | </div> | ||
28 | </div> | ||
29 | |||
18 | <my-peertube-checkbox | 30 | <my-peertube-checkbox |
19 | inputName="autoPlayVideo" formControlName="autoPlayVideo" | 31 | inputName="autoPlayVideo" formControlName="autoPlayVideo" |
20 | i18n-labelText labelText="Automatically plays video" | 32 | i18n-labelText labelText="Automatically plays video" |
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 index 7089b2057..9e711a227 100644 --- 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 | |||
@@ -29,12 +29,14 @@ export class MyAccountVideoSettingsComponent extends FormReactive implements OnI | |||
29 | ngOnInit () { | 29 | ngOnInit () { |
30 | this.buildForm({ | 30 | this.buildForm({ |
31 | nsfwPolicy: null, | 31 | nsfwPolicy: null, |
32 | webTorrentPolicy: null, | ||
32 | autoPlayVideo: null | 33 | autoPlayVideo: null |
33 | }) | 34 | }) |
34 | 35 | ||
35 | this.userInformationLoaded.subscribe(() => { | 36 | this.userInformationLoaded.subscribe(() => { |
36 | this.form.patchValue({ | 37 | this.form.patchValue({ |
37 | nsfwPolicy: this.user.nsfwPolicy, | 38 | nsfwPolicy: this.user.nsfwPolicy, |
39 | webTorrentPolicy: this.user.webTorrentPolicy, | ||
38 | autoPlayVideo: this.user.autoPlayVideo === true | 40 | autoPlayVideo: this.user.autoPlayVideo === true |
39 | }) | 41 | }) |
40 | }) | 42 | }) |
@@ -42,9 +44,11 @@ export class MyAccountVideoSettingsComponent extends FormReactive implements OnI | |||
42 | 44 | ||
43 | updateDetails () { | 45 | updateDetails () { |
44 | const nsfwPolicy = this.form.value['nsfwPolicy'] | 46 | const nsfwPolicy = this.form.value['nsfwPolicy'] |
47 | const webTorrentPolicy = this.form.value['webTorrentPolicy'] | ||
45 | const autoPlayVideo = this.form.value['autoPlayVideo'] | 48 | const autoPlayVideo = this.form.value['autoPlayVideo'] |
46 | const details: UserUpdateMe = { | 49 | const details: UserUpdateMe = { |
47 | nsfwPolicy, | 50 | nsfwPolicy, |
51 | webTorrentPolicy, | ||
48 | autoPlayVideo | 52 | autoPlayVideo |
49 | } | 53 | } |
50 | 54 | ||
diff --git a/client/src/app/core/auth/auth-user.model.ts b/client/src/app/core/auth/auth-user.model.ts index 74ed1c580..97acf7bfe 100644 --- a/client/src/app/core/auth/auth-user.model.ts +++ b/client/src/app/core/auth/auth-user.model.ts | |||
@@ -4,6 +4,7 @@ import { UserRight } from '../../../../../shared/models/users/user-right.enum' | |||
4 | import { hasUserRight, UserRole } from '../../../../../shared/models/users/user-role' | 4 | import { hasUserRight, UserRole } from '../../../../../shared/models/users/user-role' |
5 | import { User, UserConstructorHash } from '../../shared/users/user.model' | 5 | import { User, UserConstructorHash } from '../../shared/users/user.model' |
6 | import { NSFWPolicyType } from '../../../../../shared/models/videos/nsfw-policy.type' | 6 | import { NSFWPolicyType } from '../../../../../shared/models/videos/nsfw-policy.type' |
7 | import { WebTorrentPolicyType } from '../../../../../shared/models/users/user-webtorrent-policy.type' | ||
7 | 8 | ||
8 | export type TokenOptions = { | 9 | export type TokenOptions = { |
9 | accessToken: string | 10 | accessToken: string |
@@ -72,6 +73,7 @@ export class AuthUser extends User { | |||
72 | EMAIL: 'email', | 73 | EMAIL: 'email', |
73 | USERNAME: 'username', | 74 | USERNAME: 'username', |
74 | NSFW_POLICY: 'nsfw_policy', | 75 | NSFW_POLICY: 'nsfw_policy', |
76 | WEBTORRENT_POLICY: 'peertube-videojs-' + 'webtorrent_policy', | ||
75 | AUTO_PLAY_VIDEO: 'auto_play_video' | 77 | AUTO_PLAY_VIDEO: 'auto_play_video' |
76 | } | 78 | } |
77 | 79 | ||
@@ -87,6 +89,7 @@ export class AuthUser extends User { | |||
87 | email: peertubeLocalStorage.getItem(this.KEYS.EMAIL), | 89 | email: peertubeLocalStorage.getItem(this.KEYS.EMAIL), |
88 | role: parseInt(peertubeLocalStorage.getItem(this.KEYS.ROLE), 10) as UserRole, | 90 | role: parseInt(peertubeLocalStorage.getItem(this.KEYS.ROLE), 10) as UserRole, |
89 | nsfwPolicy: peertubeLocalStorage.getItem(this.KEYS.NSFW_POLICY) as NSFWPolicyType, | 91 | nsfwPolicy: peertubeLocalStorage.getItem(this.KEYS.NSFW_POLICY) as NSFWPolicyType, |
92 | webTorrentPolicy: peertubeLocalStorage.getItem(this.KEYS.WEBTORRENT_POLICY) as WebTorrentPolicyType, | ||
90 | autoPlayVideo: peertubeLocalStorage.getItem(this.KEYS.AUTO_PLAY_VIDEO) === 'true' | 93 | autoPlayVideo: peertubeLocalStorage.getItem(this.KEYS.AUTO_PLAY_VIDEO) === 'true' |
91 | }, | 94 | }, |
92 | Tokens.load() | 95 | Tokens.load() |
@@ -101,6 +104,7 @@ export class AuthUser extends User { | |||
101 | peertubeLocalStorage.removeItem(this.KEYS.ID) | 104 | peertubeLocalStorage.removeItem(this.KEYS.ID) |
102 | peertubeLocalStorage.removeItem(this.KEYS.ROLE) | 105 | peertubeLocalStorage.removeItem(this.KEYS.ROLE) |
103 | peertubeLocalStorage.removeItem(this.KEYS.NSFW_POLICY) | 106 | peertubeLocalStorage.removeItem(this.KEYS.NSFW_POLICY) |
107 | peertubeLocalStorage.removeItem(this.KEYS.WEBTORRENT_POLICY) | ||
104 | peertubeLocalStorage.removeItem(this.KEYS.AUTO_PLAY_VIDEO) | 108 | peertubeLocalStorage.removeItem(this.KEYS.AUTO_PLAY_VIDEO) |
105 | peertubeLocalStorage.removeItem(this.KEYS.EMAIL) | 109 | peertubeLocalStorage.removeItem(this.KEYS.EMAIL) |
106 | Tokens.flush() | 110 | Tokens.flush() |
@@ -138,6 +142,7 @@ export class AuthUser extends User { | |||
138 | peertubeLocalStorage.setItem(AuthUser.KEYS.EMAIL, this.email) | 142 | peertubeLocalStorage.setItem(AuthUser.KEYS.EMAIL, this.email) |
139 | peertubeLocalStorage.setItem(AuthUser.KEYS.ROLE, this.role.toString()) | 143 | peertubeLocalStorage.setItem(AuthUser.KEYS.ROLE, this.role.toString()) |
140 | peertubeLocalStorage.setItem(AuthUser.KEYS.NSFW_POLICY, this.nsfwPolicy.toString()) | 144 | peertubeLocalStorage.setItem(AuthUser.KEYS.NSFW_POLICY, this.nsfwPolicy.toString()) |
145 | peertubeLocalStorage.setItem(AuthUser.KEYS.WEBTORRENT_POLICY, this.webTorrentPolicy.toString()) | ||
141 | peertubeLocalStorage.setItem(AuthUser.KEYS.AUTO_PLAY_VIDEO, JSON.stringify(this.autoPlayVideo)) | 146 | peertubeLocalStorage.setItem(AuthUser.KEYS.AUTO_PLAY_VIDEO, JSON.stringify(this.autoPlayVideo)) |
142 | this.tokens.save() | 147 | this.tokens.save() |
143 | } | 148 | } |
diff --git a/client/src/app/shared/users/user.model.ts b/client/src/app/shared/users/user.model.ts index 877f1bf3a..240c7aacf 100644 --- a/client/src/app/shared/users/user.model.ts +++ b/client/src/app/shared/users/user.model.ts | |||
@@ -9,6 +9,7 @@ import { | |||
9 | import { NSFWPolicyType } from '../../../../../shared/models/videos/nsfw-policy.type' | 9 | import { NSFWPolicyType } from '../../../../../shared/models/videos/nsfw-policy.type' |
10 | import { Account } from '@app/shared/account/account.model' | 10 | import { Account } from '@app/shared/account/account.model' |
11 | import { Avatar } from '../../../../../shared/models/avatars/avatar.model' | 11 | import { Avatar } from '../../../../../shared/models/avatars/avatar.model' |
12 | import { WebTorrentPolicyType } from '../../../../../shared/models/users/user-webtorrent-policy.type' | ||
12 | 13 | ||
13 | export type UserConstructorHash = { | 14 | export type UserConstructorHash = { |
14 | id: number, | 15 | id: number, |
@@ -18,6 +19,7 @@ export type UserConstructorHash = { | |||
18 | videoQuota?: number, | 19 | videoQuota?: number, |
19 | videoQuotaDaily?: number, | 20 | videoQuotaDaily?: number, |
20 | nsfwPolicy?: NSFWPolicyType, | 21 | nsfwPolicy?: NSFWPolicyType, |
22 | webTorrentPolicy?: WebTorrentPolicyType, | ||
21 | autoPlayVideo?: boolean, | 23 | autoPlayVideo?: boolean, |
22 | createdAt?: Date, | 24 | createdAt?: Date, |
23 | account?: AccountServerModel, | 25 | account?: AccountServerModel, |
@@ -32,6 +34,7 @@ export class User implements UserServerModel { | |||
32 | email: string | 34 | email: string |
33 | role: UserRole | 35 | role: UserRole |
34 | nsfwPolicy: NSFWPolicyType | 36 | nsfwPolicy: NSFWPolicyType |
37 | webTorrentPolicy: WebTorrentPolicyType | ||
35 | autoPlayVideo: boolean | 38 | autoPlayVideo: boolean |
36 | videoQuota: number | 39 | videoQuota: number |
37 | videoQuotaDaily: number | 40 | videoQuotaDaily: number |
@@ -52,6 +55,7 @@ export class User implements UserServerModel { | |||
52 | this.videoQuota = hash.videoQuota | 55 | this.videoQuota = hash.videoQuota |
53 | this.videoQuotaDaily = hash.videoQuotaDaily | 56 | this.videoQuotaDaily = hash.videoQuotaDaily |
54 | this.nsfwPolicy = hash.nsfwPolicy | 57 | this.nsfwPolicy = hash.nsfwPolicy |
58 | this.webTorrentPolicy = hash.webTorrentPolicy | ||
55 | this.autoPlayVideo = hash.autoPlayVideo | 59 | this.autoPlayVideo = hash.autoPlayVideo |
56 | this.createdAt = hash.createdAt | 60 | this.createdAt = hash.createdAt |
57 | this.blocked = hash.blocked | 61 | this.blocked = hash.blocked |