diff options
author | Rigel Kent <sendmemail@rigelk.eu> | 2020-02-28 13:52:21 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-02-28 13:52:21 +0100 |
commit | d3217560a611b94f888ecf3de93b428a7521d4de (patch) | |
tree | 26fc984f351afb994dc13c94e138476ded50c76a /client/src/app/videos/+video-watch | |
parent | 64645512b08875c18ebdc009a550cdfa69def955 (diff) | |
download | PeerTube-d3217560a611b94f888ecf3de93b428a7521d4de.tar.gz PeerTube-d3217560a611b94f888ecf3de93b428a7521d4de.tar.zst PeerTube-d3217560a611b94f888ecf3de93b428a7521d4de.zip |
Add visitor settings, rework logged-in dropdown (#2514)
* Add visitor settings, rework logged-in dropdown
* Make user dropdown P2P switch functional
* Fix lint
* Fix unnecessary notification when user logs out
* Simplify visitor settings code and remove unnecessary icons
* Catch parsing errors and reindent menu styles
Diffstat (limited to 'client/src/app/videos/+video-watch')
5 files changed, 37 insertions, 18 deletions
diff --git a/client/src/app/videos/+video-watch/video-watch-playlist.component.ts b/client/src/app/videos/+video-watch/video-watch-playlist.component.ts index c5ed36000..827c34d41 100644 --- a/client/src/app/videos/+video-watch/video-watch-playlist.component.ts +++ b/client/src/app/videos/+video-watch/video-watch-playlist.component.ts | |||
@@ -9,6 +9,7 @@ import { VideoPlaylistService } from '@app/shared/video-playlist/video-playlist. | |||
9 | import { VideoPlaylistElement } from '@app/shared/video-playlist/video-playlist-element.model' | 9 | import { VideoPlaylistElement } from '@app/shared/video-playlist/video-playlist-element.model' |
10 | import { peertubeLocalStorage, peertubeSessionStorage } from '@app/shared/misc/peertube-web-storage' | 10 | import { peertubeLocalStorage, peertubeSessionStorage } from '@app/shared/misc/peertube-web-storage' |
11 | import { I18n } from '@ngx-translate/i18n-polyfill' | 11 | import { I18n } from '@ngx-translate/i18n-polyfill' |
12 | import { SessionStorageService, LocalStorageService } from '@app/shared/misc/storage.service' | ||
12 | 13 | ||
13 | @Component({ | 14 | @Component({ |
14 | selector: 'my-video-watch-playlist', | 15 | selector: 'my-video-watch-playlist', |
@@ -42,16 +43,18 @@ export class VideoWatchPlaylistComponent { | |||
42 | private notifier: Notifier, | 43 | private notifier: Notifier, |
43 | private i18n: I18n, | 44 | private i18n: I18n, |
44 | private videoPlaylist: VideoPlaylistService, | 45 | private videoPlaylist: VideoPlaylistService, |
46 | private localStorageService: LocalStorageService, | ||
47 | private sessionStorageService: SessionStorageService, | ||
45 | private router: Router | 48 | private router: Router |
46 | ) { | 49 | ) { |
47 | // defaults to true | 50 | // defaults to true |
48 | this.autoPlayNextVideoPlaylist = this.auth.isLoggedIn() | 51 | this.autoPlayNextVideoPlaylist = this.auth.isLoggedIn() |
49 | ? this.auth.getUser().autoPlayNextVideoPlaylist | 52 | ? this.auth.getUser().autoPlayNextVideoPlaylist |
50 | : peertubeLocalStorage.getItem(VideoWatchPlaylistComponent.LOCAL_STORAGE_AUTO_PLAY_NEXT_VIDEO_PLAYLIST) !== 'false' | 53 | : this.localStorageService.getItem(VideoWatchPlaylistComponent.LOCAL_STORAGE_AUTO_PLAY_NEXT_VIDEO_PLAYLIST) !== 'false' |
51 | this.setAutoPlayNextVideoPlaylistSwitchText() | 54 | this.setAutoPlayNextVideoPlaylistSwitchText() |
52 | 55 | ||
53 | // defaults to false | 56 | // defaults to false |
54 | this.loopPlaylist = peertubeSessionStorage.getItem(VideoWatchPlaylistComponent.SESSION_STORAGE_AUTO_PLAY_NEXT_VIDEO_PLAYLIST) === 'true' | 57 | this.loopPlaylist = this.sessionStorageService.getItem(VideoWatchPlaylistComponent.SESSION_STORAGE_AUTO_PLAY_NEXT_VIDEO_PLAYLIST) === 'true' |
55 | this.setLoopPlaylistSwitchText() | 58 | this.setLoopPlaylistSwitchText() |
56 | } | 59 | } |
57 | 60 | ||
diff --git a/client/src/app/videos/+video-watch/video-watch.component.html b/client/src/app/videos/+video-watch/video-watch.component.html index cfa0432ad..585acd7a8 100644 --- a/client/src/app/videos/+video-watch/video-watch.component.html +++ b/client/src/app/videos/+video-watch/video-watch.component.html | |||
@@ -257,15 +257,18 @@ | |||
257 | 257 | ||
258 | <div class="row privacy-concerns" *ngIf="hasAlreadyAcceptedPrivacyConcern === false"> | 258 | <div class="row privacy-concerns" *ngIf="hasAlreadyAcceptedPrivacyConcern === false"> |
259 | <div class="privacy-concerns-text"> | 259 | <div class="privacy-concerns-text"> |
260 | <strong i18n>Friendly Reminder: </strong> | 260 | <span i18n class="mr-2"> |
261 | <ng-container i18n> | 261 | <strong>Help your peers</strong> |
262 | the sharing system used for this video implies that some technical information about your system (such as a public IP address) can be sent to other peers. | 262 | and activate the sharing system to improve the experience for everyone. |
263 | </ng-container> | 263 | </span> |
264 | <a i18n i18n-title title="Get more information" target="_blank" rel="noopener noreferrer" href="/about/peertube">More information</a> | 264 | <a i18n i18n-title title="Get more information" target="_blank" rel="noopener noreferrer" href="/about/peertube">More information</a> |
265 | </div> | 265 | </div> |
266 | 266 | ||
267 | <div i18n class="privacy-concerns-okay" (click)="acceptedPrivacyConcern()"> | 267 | <div i18n class="privacy-concerns-button" (click)="declinedPrivacyConcern()"> |
268 | OK | 268 | No thanks |
269 | </div> | ||
270 | <div i18n class="privacy-concerns-button privacy-concerns-okay" (click)="acceptedPrivacyConcern()"> | ||
271 | Activate | ||
269 | </div> | 272 | </div> |
270 | </div> | 273 | </div> |
271 | </div> | 274 | </div> |
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 ae79c2ff6..10e129ac5 100644 --- a/client/src/app/videos/+video-watch/video-watch.component.scss +++ b/client/src/app/videos/+video-watch/video-watch.component.scss | |||
@@ -443,6 +443,7 @@ my-video-comments { | |||
443 | 443 | ||
444 | // If the view is not expanded, take into account the menu | 444 | // If the view is not expanded, take into account the menu |
445 | .privacy-concerns { | 445 | .privacy-concerns { |
446 | z-index: z(dropdown) + 1; | ||
446 | width: calc(100% - #{$menu-width}); | 447 | width: calc(100% - #{$menu-width}); |
447 | } | 448 | } |
448 | 449 | ||
@@ -488,11 +489,11 @@ my-video-comments { | |||
488 | } | 489 | } |
489 | } | 490 | } |
490 | 491 | ||
491 | .privacy-concerns-okay { | 492 | .privacy-concerns-button { |
492 | background-color: var(--mainColor); | ||
493 | padding: 5px 8px 5px 7px; | 493 | padding: 5px 8px 5px 7px; |
494 | margin-left: auto; | 494 | margin-left: auto; |
495 | border-radius: 3px; | 495 | border-radius: 3px; |
496 | white-space: nowrap; | ||
496 | cursor: pointer; | 497 | cursor: pointer; |
497 | transition: background-color 0.3s; | 498 | transition: background-color 0.3s; |
498 | font-weight: $font-semibold; | 499 | font-weight: $font-semibold; |
@@ -501,6 +502,11 @@ my-video-comments { | |||
501 | background-color: #000; | 502 | background-color: #000; |
502 | } | 503 | } |
503 | } | 504 | } |
505 | |||
506 | .privacy-concerns-okay { | ||
507 | background-color: var(--mainColor); | ||
508 | margin-left: 10px; | ||
509 | } | ||
504 | } | 510 | } |
505 | 511 | ||
506 | @media screen and (max-width: 1600px) { | 512 | @media screen and (max-width: 1600px) { |
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 ee3deb5e9..9ba14316c 100644 --- a/client/src/app/videos/+video-watch/video-watch.component.ts +++ b/client/src/app/videos/+video-watch/video-watch.component.ts | |||
@@ -2,7 +2,7 @@ import { catchError } from 'rxjs/operators' | |||
2 | import { ChangeDetectorRef, Component, ElementRef, Inject, LOCALE_ID, NgZone, OnDestroy, OnInit, ViewChild } from '@angular/core' | 2 | import { ChangeDetectorRef, Component, ElementRef, Inject, LOCALE_ID, NgZone, OnDestroy, OnInit, ViewChild } from '@angular/core' |
3 | import { ActivatedRoute, Router } from '@angular/router' | 3 | import { ActivatedRoute, Router } from '@angular/router' |
4 | import { RedirectService } from '@app/core/routing/redirect.service' | 4 | import { RedirectService } from '@app/core/routing/redirect.service' |
5 | import { peertubeLocalStorage, peertubeSessionStorage } from '@app/shared/misc/peertube-web-storage' | 5 | import { peertubeLocalStorage } from '@app/shared/misc/peertube-web-storage' |
6 | import { VideoSupportComponent } from '@app/videos/+video-watch/modal/video-support.component' | 6 | import { VideoSupportComponent } from '@app/videos/+video-watch/modal/video-support.component' |
7 | import { MetaService } from '@ngx-meta/core' | 7 | import { MetaService } from '@ngx-meta/core' |
8 | import { AuthUser, Notifier, ServerService } from '@app/core' | 8 | import { AuthUser, Notifier, ServerService } from '@app/core' |
@@ -10,7 +10,7 @@ import { forkJoin, Observable, Subscription } from 'rxjs' | |||
10 | import { Hotkey, HotkeysService } from 'angular2-hotkeys' | 10 | import { Hotkey, HotkeysService } from 'angular2-hotkeys' |
11 | import { ServerConfig, UserVideoRateType, VideoCaption, VideoPrivacy, VideoState } from '../../../../../shared' | 11 | import { ServerConfig, UserVideoRateType, VideoCaption, VideoPrivacy, VideoState } from '../../../../../shared' |
12 | import { AuthService, ConfirmService } from '../../core' | 12 | import { AuthService, ConfirmService } from '../../core' |
13 | import { RestExtractor } from '../../shared' | 13 | import { RestExtractor, UserService } from '../../shared' |
14 | import { VideoDetails } from '../../shared/video/video-details.model' | 14 | import { VideoDetails } from '../../shared/video/video-details.model' |
15 | import { VideoService } from '../../shared/video/video.service' | 15 | import { VideoService } from '../../shared/video/video.service' |
16 | import { VideoShareComponent } from './modal/video-share.component' | 16 | import { VideoShareComponent } from './modal/video-share.component' |
@@ -35,7 +35,6 @@ import { VideoWatchPlaylistComponent } from '@app/videos/+video-watch/video-watc | |||
35 | import { getStoredP2PEnabled, getStoredTheater } from '../../../assets/player/peertube-player-local-storage' | 35 | import { getStoredP2PEnabled, getStoredTheater } from '../../../assets/player/peertube-player-local-storage' |
36 | import { HooksService } from '@app/core/plugins/hooks.service' | 36 | import { HooksService } from '@app/core/plugins/hooks.service' |
37 | import { PlatformLocation } from '@angular/common' | 37 | import { PlatformLocation } from '@angular/common' |
38 | import { RecommendedVideosComponent } from '../recommendations/recommended-videos.component' | ||
39 | import { scrollToTop, isXPercentInViewport } from '@app/shared/misc/utils' | 38 | import { scrollToTop, isXPercentInViewport } from '@app/shared/misc/utils' |
40 | 39 | ||
41 | @Component({ | 40 | @Component({ |
@@ -95,6 +94,7 @@ export class VideoWatchComponent implements OnInit, OnDestroy { | |||
95 | private confirmService: ConfirmService, | 94 | private confirmService: ConfirmService, |
96 | private metaService: MetaService, | 95 | private metaService: MetaService, |
97 | private authService: AuthService, | 96 | private authService: AuthService, |
97 | private userService: UserService, | ||
98 | private serverService: ServerService, | 98 | private serverService: ServerService, |
99 | private restExtractor: RestExtractor, | 99 | private restExtractor: RestExtractor, |
100 | private notifier: Notifier, | 100 | private notifier: Notifier, |
@@ -118,6 +118,10 @@ export class VideoWatchComponent implements OnInit, OnDestroy { | |||
118 | return this.authService.getUser() | 118 | return this.authService.getUser() |
119 | } | 119 | } |
120 | 120 | ||
121 | get anonymousUser () { | ||
122 | return this.userService.getAnonymousUser() | ||
123 | } | ||
124 | |||
121 | async ngOnInit () { | 125 | async ngOnInit () { |
122 | this.serverConfig = this.serverService.getTmpConfig() | 126 | this.serverConfig = this.serverService.getTmpConfig() |
123 | 127 | ||
@@ -266,6 +270,11 @@ export class VideoWatchComponent implements OnInit, OnDestroy { | |||
266 | this.redirectService.redirectToHomepage() | 270 | this.redirectService.redirectToHomepage() |
267 | } | 271 | } |
268 | 272 | ||
273 | declinedPrivacyConcern () { | ||
274 | peertubeLocalStorage.setItem(VideoWatchComponent.LOCAL_STORAGE_PRIVACY_CONCERN_KEY, 'false') | ||
275 | this.hasAlreadyAcceptedPrivacyConcern = false | ||
276 | } | ||
277 | |||
269 | acceptedPrivacyConcern () { | 278 | acceptedPrivacyConcern () { |
270 | peertubeLocalStorage.setItem(VideoWatchComponent.LOCAL_STORAGE_PRIVACY_CONCERN_KEY, 'true') | 279 | peertubeLocalStorage.setItem(VideoWatchComponent.LOCAL_STORAGE_PRIVACY_CONCERN_KEY, 'true') |
271 | this.hasAlreadyAcceptedPrivacyConcern = true | 280 | this.hasAlreadyAcceptedPrivacyConcern = true |
@@ -290,7 +299,7 @@ export class VideoWatchComponent implements OnInit, OnDestroy { | |||
290 | isAutoPlayEnabled () { | 299 | isAutoPlayEnabled () { |
291 | return ( | 300 | return ( |
292 | (this.user && this.user.autoPlayNextVideo) || | 301 | (this.user && this.user.autoPlayNextVideo) || |
293 | peertubeSessionStorage.getItem(RecommendedVideosComponent.SESSION_STORAGE_AUTO_PLAY_NEXT_VIDEO) === 'true' | 302 | this.anonymousUser.autoPlayNextVideo |
294 | ) | 303 | ) |
295 | } | 304 | } |
296 | 305 | ||
@@ -302,7 +311,7 @@ export class VideoWatchComponent implements OnInit, OnDestroy { | |||
302 | isPlaylistAutoPlayEnabled () { | 311 | isPlaylistAutoPlayEnabled () { |
303 | return ( | 312 | return ( |
304 | (this.user && this.user.autoPlayNextVideoPlaylist) || | 313 | (this.user && this.user.autoPlayNextVideoPlaylist) || |
305 | peertubeSessionStorage.getItem(VideoWatchPlaylistComponent.SESSION_STORAGE_AUTO_PLAY_NEXT_VIDEO_PLAYLIST) === 'true' | 314 | this.anonymousUser.autoPlayNextVideoPlaylist |
306 | ) | 315 | ) |
307 | } | 316 | } |
308 | 317 | ||
diff --git a/client/src/app/videos/+video-watch/video-watch.module.ts b/client/src/app/videos/+video-watch/video-watch.module.ts index 5fa50ecbb..9b445269d 100644 --- a/client/src/app/videos/+video-watch/video-watch.module.ts +++ b/client/src/app/videos/+video-watch/video-watch.module.ts | |||
@@ -12,7 +12,6 @@ import { NgbTooltipModule } from '@ng-bootstrap/ng-bootstrap' | |||
12 | import { RecommendationsModule } from '@app/videos/recommendations/recommendations.module' | 12 | import { RecommendationsModule } from '@app/videos/recommendations/recommendations.module' |
13 | import { VideoWatchPlaylistComponent } from '@app/videos/+video-watch/video-watch-playlist.component' | 13 | import { VideoWatchPlaylistComponent } from '@app/videos/+video-watch/video-watch-playlist.component' |
14 | import { QRCodeModule } from 'angularx-qrcode' | 14 | import { QRCodeModule } from 'angularx-qrcode' |
15 | import { InputSwitchModule } from 'primeng/inputswitch' | ||
16 | import { TimestampRouteTransformerDirective } from '@app/shared/angular/timestamp-route-transformer.directive' | 15 | import { TimestampRouteTransformerDirective } from '@app/shared/angular/timestamp-route-transformer.directive' |
17 | 16 | ||
18 | @NgModule({ | 17 | @NgModule({ |
@@ -21,8 +20,7 @@ import { TimestampRouteTransformerDirective } from '@app/shared/angular/timestam | |||
21 | SharedModule, | 20 | SharedModule, |
22 | NgbTooltipModule, | 21 | NgbTooltipModule, |
23 | QRCodeModule, | 22 | QRCodeModule, |
24 | RecommendationsModule, | 23 | RecommendationsModule |
25 | InputSwitchModule | ||
26 | ], | 24 | ], |
27 | 25 | ||
28 | declarations: [ | 26 | declarations: [ |