1
0
mirror of https://github.com/bpatrik/pigallery2.git synced 2024-12-23 01:27:14 +02:00

added (session) cookie for playback duration; reverted some unnecessary css-changes;

This commit is contained in:
crypt-o-warrior 2022-12-17 01:07:39 +01:00
parent 16a7934ace
commit 640aec03dd
No known key found for this signature in database
GPG Key ID: 95194045885EFFFF
3 changed files with 23 additions and 6 deletions

View File

@ -2,4 +2,5 @@ export class CookieNames {
public static lang = 'pigallery2-lang';
public static session = 'pigallery2-session';
public static advancedSettings = 'advanced-settings';
public static playBackDuration = 'playback-duration';
}

View File

@ -65,14 +65,12 @@
.controls .control-button {
margin-left: 0.2em;
margin-right: 0.2em;
padding: 0 0.5rem;
display: inline-block;
padding: 0 0.5rem;
font-size: 1.5rem;
line-height: 1;
color: white;
background-color: transparent;
cursor: pointer;
vertical-align: middle !important;
}
.controls .button-disabled {

View File

@ -11,6 +11,7 @@ import {
ViewChild,
} from '@angular/core';
import {MediaDTOUtils} from '../../../../../../common/entities/MediaDTO';
import {CookieNames} from '../../../../../../common/CookieNames';
import {FullScreenService} from '../../fullscreen.service';
import {GalleryPhotoComponent} from '../../grid/photo/photo.grid.gallery.component';
import {Observable, Subscription, timer} from 'rxjs';
@ -25,6 +26,7 @@ import {
} from '../../../../../../common/entities/SearchQueryDTO';
import {AuthenticationService} from '../../../../model/network/authentication.service';
import {LightboxService} from '../lightbox.service';
import {CookieService} from 'ngx-cookie-service';
export enum PlayBackStates {
Paused = 1,
@ -57,7 +59,7 @@ export class ControlsLightboxComponent implements OnDestroy, OnInit, OnChanges {
public playBackState: PlayBackStates = PlayBackStates.Paused;
public PlayBackStates = PlayBackStates;
public playBackDurations = [2,5,10,15,20,30,60];
public selectedPlayBackDuration = 5;
public selectedPlayBackDuration: number = null;
public controllersDimmed = false;
public controllersVisible = true;
@ -70,11 +72,13 @@ export class ControlsLightboxComponent implements OnDestroy, OnInit, OnChanges {
private timerSub: Subscription;
private prevDrag = {x: 0, y: 0};
private prevZoom = 1;
private defaultPlayBackDuration = 5;
constructor(
public lightboxService: LightboxService,
public fullScreenService: FullScreenService,
private authService: AuthenticationService
private authService: AuthenticationService,
private cookieService:CookieService
) {
this.searchEnabled =
Config.Client.Search.enabled && this.authService.canSearch();
@ -121,6 +125,11 @@ export class ControlsLightboxComponent implements OnDestroy, OnInit, OnChanges {
ngOnInit(): void {
this.timer = timer(1000, 1000);
if (this.cookieService.check(CookieNames.playBackDuration)) {
this.selectedPlayBackDuration = +this.cookieService.get(CookieNames.playBackDuration);
} else {
this.selectedPlayBackDuration = this.defaultPlayBackDuration;
}
}
ngOnDestroy(): void {
@ -295,7 +304,7 @@ export class ControlsLightboxComponent implements OnDestroy, OnInit, OnChanges {
public play(duration?: number): void {
this.pause();
if (duration) {
this.selectedPlayBackDuration = duration;
this.setPlayBackDuration(duration);
}
this.timerSub = this.timer
.pipe(filter((t) => t % this.selectedPlayBackDuration === 0))
@ -303,6 +312,15 @@ export class ControlsLightboxComponent implements OnDestroy, OnInit, OnChanges {
this.playBackState = PlayBackStates.Play;
}
public setPlayBackDuration(duration: number) {
this.selectedPlayBackDuration = duration;
if (duration) {
this.cookieService.set(CookieNames.playBackDuration, duration + '');
} else {
this.cookieService.delete(CookieNames.playBackDuration);
}
}
@HostListener('mousemove')
onMouseMove(): void {
this.showControls();