1
0
mirror of https://github.com/bpatrik/pigallery2.git synced 2025-03-31 22:05:20 +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 lang = 'pigallery2-lang';
public static session = 'pigallery2-session'; public static session = 'pigallery2-session';
public static advancedSettings = 'advanced-settings'; public static advancedSettings = 'advanced-settings';
public static playBackDuration = 'playback-duration';
} }

View File

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

View File

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