aboutsummaryrefslogtreecommitdiffhomepage
path: root/client
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2019-04-10 09:23:18 +0200
committerChocobozzz <me@florianbigard.com>2019-04-10 09:23:18 +0200
commit31b6ddf86652502e0c96d77fa10861ce4af11aa4 (patch)
treeb94402972945699134b2a504af5d551124f0bf54 /client
parent22834691abb6e74d31654ffd2ebeaaaa8ef3ac7b (diff)
downloadPeerTube-31b6ddf86652502e0c96d77fa10861ce4af11aa4.tar.gz
PeerTube-31b6ddf86652502e0c96d77fa10861ce4af11aa4.tar.zst
PeerTube-31b6ddf86652502e0c96d77fa10861ce4af11aa4.zip
Add ability to disable tracker
Diffstat (limited to 'client')
-rw-r--r--client/src/app/core/server/server.service.ts3
-rw-r--r--client/src/app/shared/instance/instance-features-table.component.ts5
-rw-r--r--client/src/app/videos/+video-watch/video-watch.component.scss1
-rw-r--r--client/src/app/videos/+video-watch/video-watch.component.ts18
-rw-r--r--client/src/assets/player/utils.ts5
-rw-r--r--client/src/sass/player/peertube-skin.scss6
-rw-r--r--client/src/standalone/videos/embed.ts26
7 files changed, 46 insertions, 18 deletions
diff --git a/client/src/app/core/server/server.service.ts b/client/src/app/core/server/server.service.ts
index b0c5d1130..3a8a535fd 100644
--- a/client/src/app/core/server/server.service.ts
+++ b/client/src/app/core/server/server.service.ts
@@ -105,6 +105,9 @@ export class ServerService {
105 enabled: false 105 enabled: false
106 } 106 }
107 } 107 }
108 },
109 tracker: {
110 enabled: true
108 } 111 }
109 } 112 }
110 private videoCategories: Array<VideoConstant<number>> = [] 113 private videoCategories: Array<VideoConstant<number>> = []
diff --git a/client/src/app/shared/instance/instance-features-table.component.ts b/client/src/app/shared/instance/instance-features-table.component.ts
index c0257fd59..72e7c2730 100644
--- a/client/src/app/shared/instance/instance-features-table.component.ts
+++ b/client/src/app/shared/instance/instance-features-table.component.ts
@@ -1,7 +1,6 @@
1import { Component, OnInit } from '@angular/core' 1import { Component, OnInit } from '@angular/core'
2import { ServerService } from '@app/core' 2import { ServerService } from '@app/core'
3import { I18n } from '@ngx-translate/i18n-polyfill' 3import { I18n } from '@ngx-translate/i18n-polyfill'
4import { ServerConfig } from '../../../../../shared'
5 4
6@Component({ 5@Component({
7 selector: 'my-instance-features-table', 6 selector: 'my-instance-features-table',
@@ -65,6 +64,10 @@ export class InstanceFeaturesTableComponent implements OnInit {
65 { 64 {
66 label: this.i18n('Torrent import'), 65 label: this.i18n('Torrent import'),
67 value: config.import.videos.torrent.enabled 66 value: config.import.videos.torrent.enabled
67 },
68 {
69 label: this.i18n('P2P enabled'),
70 value: config.tracker.enabled
68 } 71 }
69 ] 72 ]
70 } 73 }
diff --git a/client/src/app/videos/+video-watch/video-watch.component.scss b/client/src/app/videos/+video-watch/video-watch.component.scss
index d61a0bc3e..84b9aed39 100644
--- a/client/src/app/videos/+video-watch/video-watch.component.scss
+++ b/client/src/app/videos/+video-watch/video-watch.component.scss
@@ -427,6 +427,7 @@ my-video-comments {
427// If the view is not expanded, take into account the menu 427// If the view is not expanded, take into account the menu
428.privacy-concerns { 428.privacy-concerns {
429 width: calc(100% - #{$menu-width}); 429 width: calc(100% - #{$menu-width});
430 margin-left: -15px;
430} 431}
431 432
432@media screen and (max-width: $small-view) { 433@media screen and (max-width: $small-view) {
diff --git a/client/src/app/videos/+video-watch/video-watch.component.ts b/client/src/app/videos/+video-watch/video-watch.component.ts
index edc546b28..bce652210 100644
--- a/client/src/app/videos/+video-watch/video-watch.component.ts
+++ b/client/src/app/videos/+video-watch/video-watch.component.ts
@@ -29,6 +29,7 @@ import { VideoPlaylist } from '@app/shared/video-playlist/video-playlist.model'
29import { VideoPlaylistService } from '@app/shared/video-playlist/video-playlist.service' 29import { VideoPlaylistService } from '@app/shared/video-playlist/video-playlist.service'
30import { ComponentPagination } from '@app/shared/rest/component-pagination.model' 30import { ComponentPagination } from '@app/shared/rest/component-pagination.model'
31import { Video } from '@app/shared/video/video.model' 31import { Video } from '@app/shared/video/video.model'
32import { isWebRTCDisabled } from '../../../assets/player/utils'
32 33
33@Component({ 34@Component({
34 selector: 'my-video-watch', 35 selector: 'my-video-watch',
@@ -71,6 +72,7 @@ export class VideoWatchComponent implements OnInit, OnDestroy {
71 private currentTime: number 72 private currentTime: number
72 private paramsSub: Subscription 73 private paramsSub: Subscription
73 private queryParamsSub: Subscription 74 private queryParamsSub: Subscription
75 private configSub: Subscription
74 76
75 constructor ( 77 constructor (
76 private elementRef: ElementRef, 78 private elementRef: ElementRef,
@@ -100,12 +102,16 @@ export class VideoWatchComponent implements OnInit, OnDestroy {
100 } 102 }
101 103
102 ngOnInit () { 104 ngOnInit () {
103 if ( 105 this.configSub = this.serverService.configLoaded
104 !!((window as any).RTCPeerConnection || (window as any).mozRTCPeerConnection || (window as any).webkitRTCPeerConnection) === false || 106 .subscribe(() => {
105 peertubeLocalStorage.getItem(VideoWatchComponent.LOCAL_STORAGE_PRIVACY_CONCERN_KEY) === 'true' 107 if (
106 ) { 108 isWebRTCDisabled() ||
107 this.hasAlreadyAcceptedPrivacyConcern = true 109 this.serverService.getConfig().tracker.enabled === false ||
108 } 110 peertubeLocalStorage.getItem(VideoWatchComponent.LOCAL_STORAGE_PRIVACY_CONCERN_KEY) === 'true'
111 ) {
112 this.hasAlreadyAcceptedPrivacyConcern = true
113 }
114 })
109 115
110 this.paramsSub = this.route.params.subscribe(routeParams => { 116 this.paramsSub = this.route.params.subscribe(routeParams => {
111 const videoId = routeParams[ 'videoId' ] 117 const videoId = routeParams[ 'videoId' ]
diff --git a/client/src/assets/player/utils.ts b/client/src/assets/player/utils.ts
index 0966027ac..366689962 100644
--- a/client/src/assets/player/utils.ts
+++ b/client/src/assets/player/utils.ts
@@ -4,6 +4,10 @@ function toTitleCase (str: string) {
4 return str.charAt(0).toUpperCase() + str.slice(1) 4 return str.charAt(0).toUpperCase() + str.slice(1)
5} 5}
6 6
7function isWebRTCDisabled () {
8 return !!((window as any).RTCPeerConnection || (window as any).mozRTCPeerConnection || (window as any).webkitRTCPeerConnection) === false
9}
10
7// https://github.com/danrevah/ngx-pipes/blob/master/src/pipes/math/bytes.ts 11// https://github.com/danrevah/ngx-pipes/blob/master/src/pipes/math/bytes.ts
8// Don't import all Angular stuff, just copy the code with shame 12// Don't import all Angular stuff, just copy the code with shame
9const dictionaryBytes: Array<{max: number, type: string}> = [ 13const dictionaryBytes: Array<{max: number, type: string}> = [
@@ -141,6 +145,7 @@ export {
141 toTitleCase, 145 toTitleCase,
142 timeToInt, 146 timeToInt,
143 secondsToTime, 147 secondsToTime,
148 isWebRTCDisabled,
144 buildVideoLink, 149 buildVideoLink,
145 buildVideoEmbed, 150 buildVideoEmbed,
146 videoFileMaxByResolution, 151 videoFileMaxByResolution,
diff --git a/client/src/sass/player/peertube-skin.scss b/client/src/sass/player/peertube-skin.scss
index a6942001a..e63a2875c 100644
--- a/client/src/sass/player/peertube-skin.scss
+++ b/client/src/sass/player/peertube-skin.scss
@@ -21,16 +21,16 @@
21 .vjs-dock-description { 21 .vjs-dock-description {
22 font-size: 11px; 22 font-size: 11px;
23 23
24 &::before, &::after { 24 .text::before, .text::after {
25 display: inline-block; 25 display: inline-block;
26 content: '\1F308'; 26 content: '\1F308';
27 } 27 }
28 28
29 &::before { 29 .text::before {
30 margin-right: 4px; 30 margin-right: 4px;
31 } 31 }
32 32
33 &::after { 33 .text::after {
34 margin-left: 4px; 34 margin-left: 4px;
35 transform: scale(-1, 1); 35 transform: scale(-1, 1);
36 } 36 }
diff --git a/client/src/standalone/videos/embed.ts b/client/src/standalone/videos/embed.ts
index 626d55a7c..707f04253 100644
--- a/client/src/standalone/videos/embed.ts
+++ b/client/src/standalone/videos/embed.ts
@@ -2,7 +2,7 @@ import './embed.scss'
2 2
3import * as Channel from 'jschannel' 3import * as Channel from 'jschannel'
4 4
5import { peertubeTranslate, ResultList, VideoDetails } from '../../../../shared' 5import { peertubeTranslate, ResultList, ServerConfig, VideoDetails } from '../../../../shared'
6import { PeerTubeResolution } from '../player/definitions' 6import { PeerTubeResolution } from '../player/definitions'
7import { VideoJSCaption } from '../../assets/player/peertube-videojs-typings' 7import { VideoJSCaption } from '../../assets/player/peertube-videojs-typings'
8import { VideoCaption } from '../../../../shared/models/videos/caption/video-caption.model' 8import { VideoCaption } from '../../../../shared/models/videos/caption/video-caption.model'
@@ -177,6 +177,10 @@ class PeerTubeEmbed {
177 return fetch(this.getVideoUrl(videoId) + '/captions') 177 return fetch(this.getVideoUrl(videoId) + '/captions')
178 } 178 }
179 179
180 loadConfig (): Promise<Response> {
181 return fetch('/api/v1/config')
182 }
183
180 removeElement (element: HTMLElement) { 184 removeElement (element: HTMLElement) {
181 element.parentElement.removeChild(element) 185 element.parentElement.removeChild(element)
182 } 186 }
@@ -237,10 +241,10 @@ class PeerTubeEmbed {
237 try { 241 try {
238 const params = new URL(window.location.toString()).searchParams 242 const params = new URL(window.location.toString()).searchParams
239 243
240 this.autoplay = this.getParamToggle(params, 'autoplay') 244 this.autoplay = this.getParamToggle(params, 'autoplay', false)
241 this.controls = this.getParamToggle(params, 'controls') 245 this.controls = this.getParamToggle(params, 'controls', true)
242 this.muted = this.getParamToggle(params, 'muted') 246 this.muted = this.getParamToggle(params, 'muted', false)
243 this.loop = this.getParamToggle(params, 'loop') 247 this.loop = this.getParamToggle(params, 'loop', false)
244 this.enableApi = this.getParamToggle(params, 'api', this.enableApi) 248 this.enableApi = this.getParamToggle(params, 'api', this.enableApi)
245 249
246 this.scope = this.getParamString(params, 'scope', this.scope) 250 this.scope = this.getParamString(params, 'scope', this.scope)
@@ -258,10 +262,11 @@ class PeerTubeEmbed {
258 const urlParts = window.location.pathname.split('/') 262 const urlParts = window.location.pathname.split('/')
259 const videoId = urlParts[ urlParts.length - 1 ] 263 const videoId = urlParts[ urlParts.length - 1 ]
260 264
261 const [ serverTranslations, videoResponse, captionsResponse ] = await Promise.all([ 265 const [ serverTranslations, videoResponse, captionsResponse, configResponse ] = await Promise.all([
262 PeertubePlayerManager.getServerTranslations(window.location.origin, navigator.language), 266 PeertubePlayerManager.getServerTranslations(window.location.origin, navigator.language),
263 this.loadVideoInfo(videoId), 267 this.loadVideoInfo(videoId),
264 this.loadVideoCaptions(videoId) 268 this.loadVideoCaptions(videoId),
269 this.loadConfig()
265 ]) 270 ])
266 271
267 if (!videoResponse.ok) { 272 if (!videoResponse.ok) {
@@ -338,9 +343,14 @@ class PeerTubeEmbed {
338 window[ 'videojsPlayer' ] = this.player 343 window[ 'videojsPlayer' ] = this.player
339 344
340 if (this.controls) { 345 if (this.controls) {
346 const config: ServerConfig = await configResponse.json()
347 const description = config.tracker.enabled
348 ? '<span class="text">' + this.player.localize('Uses P2P, others may know your IP is downloading this video.') + '</span>'
349 : undefined
350
341 this.player.dock({ 351 this.player.dock({
342 title: videoInfo.name, 352 title: videoInfo.name,
343 description: this.player.localize('Uses P2P, others may know your IP is downloading this video.') 353 description
344 }) 354 })
345 } 355 }
346 356