1
0
mirror of https://github.com/bpatrik/pigallery2.git synced 2025-01-02 03:37:54 +02:00

Implementing custom folder sorting, by adding support for pg2conf metafiles. Fixes: #177

This commit is contained in:
Patrik J. Braun 2020-09-06 17:07:40 +02:00
parent cdd1139bab
commit 73a8c4202a
11 changed files with 54 additions and 10 deletions

View File

@ -201,6 +201,9 @@ apt-get install build-essential libkrb5-dev gcc g++
* cleaning up temp folder
* indexing db
* folder ignoring [#87](https://github.com/bpatrik/pigallery2/issues/87)
* `.pg2conf` UI modifying files. [#177](https://github.com/bpatrik/pigallery2/issues/177).
* List of these files are passed down to the UI modify its behaviour.
* Currently, supported custom, per folder sorting.
* Dockerized
* **Markdown based blogging support** - `future plan`
* you can write some note in the blog.md for every directory

16
src/common/PG2ConfMap.ts Normal file
View File

@ -0,0 +1,16 @@
import {SortingMethods} from './entities/SortingMethods';
/**
* This contains the action of the supported list of *.pg2conf files.
* These files are passed down to the client as metaFiles (like photos and directories)
*/
export const PG2ConfMap = {
sorting: {
'.order_descending_name.pg2conf': SortingMethods.descName,
'.order_ascending_name.pg2conf': SortingMethods.ascName,
'.order_descending_date.pg2conf': SortingMethods.descDate,
'.order_ascending_date.pg2conf': SortingMethods.ascDate,
'.order_random.pg2conf': SortingMethods.random
}
};

View File

@ -15,7 +15,7 @@ export const SupportedFormats = {
'ogg'
],
MetaFiles: [
'gpx'
'gpx', 'pg2conf'
],
// These formats need to be transcoded (with the build-in ffmpeg support)
TranscodeNeed: {

View File

@ -24,6 +24,7 @@ import {LoginComponent} from './ui/login/login.component';
import {AdminComponent} from './ui/admin/admin.component';
import {GalleryComponent} from './ui/gallery/gallery.component';
import {StringifyRole} from './pipes/StringifyRolePipe';
import {GPXFilesFilterPipe} from './pipes/GPXFilesFilterPipe';
import {GalleryMapComponent} from './ui/gallery/map/map.gallery.component';
import {GalleryMapLightboxComponent} from './ui/gallery/map/lightbox/lightbox.map.gallery.component';
import {ThumbnailManagerService} from './ui/gallery/thumbnailManager.service';
@ -211,7 +212,8 @@ export function translationsFactory(locale: string) {
IconizeSortingMethod,
StringifySortingMethod,
DurationPipe,
FileSizePipe
FileSizePipe,
GPXFilesFilterPipe
],
providers: [
{provide: HTTP_INTERCEPTORS, useClass: CSRFInterceptor, multi: true},

View File

@ -0,0 +1,10 @@
import {Pipe, PipeTransform} from '@angular/core';
import {FileDTO} from '../../../common/entities/FileDTO';
@Pipe({name: 'gpxFiles'})
export class GPXFilesFilterPipe implements PipeTransform {
transform(metaFiles: FileDTO[]) {
return metaFiles.filter((f: FileDTO) => f.name.toLocaleLowerCase().endsWith('.gpx'));
}
}

View File

@ -34,7 +34,7 @@
<app-gallery-map *ngIf="isPhotoWithLocation && mapEnabled"
[photos]="_galleryService.content.value.directory.media"
[metaFiles]="_galleryService.content.value.directory.metaFile"></app-gallery-map>
[gpxFiles]="_galleryService.content.value.directory.metaFile | gpxFiles"></app-gallery-map>
<app-gallery-grid [media]="_galleryService.content.value.directory.media"
[lightbox]="lightbox"></app-gallery-grid>
</div>
@ -48,7 +48,7 @@
<app-gallery-map *ngIf="isPhotoWithLocation && mapEnabled"
[photos]="_galleryService.content.value.searchResult.media"
[metaFiles]="_galleryService.content.value.searchResult.metaFile"></app-gallery-map>
[gpxFiles]="_galleryService.content.value.searchResult.metaFile | gpxFiles"></app-gallery-map>
<app-gallery-directories class="directories" [directories]="directories"></app-gallery-directories>

View File

@ -18,6 +18,7 @@ import {PhotoDTO} from '../../../../common/entities/PhotoDTO';
import {QueryParams} from '../../../../common/QueryParams';
import {SeededRandomService} from '../../model/seededRandom.service';
import {take} from 'rxjs/operators';
import {FileDTO} from '../../../../common/entities/FileDTO';
@Component({
selector: 'app-gallery',
@ -57,6 +58,7 @@ export class GalleryComponent implements OnInit, OnDestroy {
PageHelper.showScrollY();
}
updateTimer(t: number) {
if (this.shareService.sharingSubject.value == null) {
return;
@ -210,6 +212,5 @@ export class GalleryComponent implements OnInit, OnDestroy {
}
}
}

View File

@ -10,6 +10,7 @@ import {ShareService} from './share.service';
import {NavigationService} from '../../model/navigation.service';
import {SortingMethods} from '../../../../common/entities/SortingMethods';
import {QueryParams} from '../../../../common/QueryParams';
import {PG2ConfMap} from '../../../../common/PG2ConfMap';
@Injectable()
@ -40,10 +41,21 @@ export class GalleryService {
this.sorting = new BehaviorSubject<SortingMethods>(Config.Client.Other.defaultPhotoSortingMethod);
}
getDefaultSorting(directory: DirectoryDTO): SortingMethods {
if (directory && directory.metaFile) {
for (const file in PG2ConfMap.sorting) {
if (directory.metaFile.some(f => f.name === file)) {
return (<any>PG2ConfMap.sorting)[file];
}
}
}
return Config.Client.Other.defaultPhotoSortingMethod;
}
setSorting(sorting: SortingMethods): void {
this.sorting.next(sorting);
if (this.content.value.directory) {
if (sorting !== Config.Client.Other.defaultPhotoSortingMethod) {
if (sorting !== this.getDefaultSorting(this.content.value.directory)) {
this.galleryCacheService.setSorting(this.content.value.directory, sorting);
} else {
this.galleryCacheService.removeSorting(this.content.value.directory);
@ -59,7 +71,7 @@ export class GalleryService {
if (sort !== null) {
this.sorting.next(sort);
} else {
this.sorting.next(Config.Client.Other.defaultPhotoSortingMethod);
this.sorting.next(this.getDefaultSorting(content.directory));
}
}
}
@ -199,7 +211,6 @@ export class GalleryService {
}
isSearchResult(): boolean {
return !!this.content.value.searchResult;
}

View File

@ -1,5 +1,5 @@
<ng-template [ngIf]="mapPhotos.length>0">
<app-gallery-map-lightbox [photos]="photos" [gpxFiles]="metaFiles"></app-gallery-map-lightbox>
<app-gallery-map-lightbox [photos]="photos" [gpxFiles]="gpxFiles"></app-gallery-map-lightbox>
<div id="map" #map>
<yaga-map #yagaMap

View File

@ -14,7 +14,7 @@ import {MapComponent} from '@yaga/leaflet-ng2';
export class GalleryMapComponent implements OnChanges, IRenderable, AfterViewInit {
@Input() photos: PhotoDTO[];
@Input() metaFiles: FileDTO[];
@Input() gpxFiles: FileDTO[];
@ViewChild(GalleryMapLightboxComponent, {static: false}) mapLightbox: GalleryMapLightboxComponent;
mapPhotos: Array<{ lat: number, lng: number }> = [];

View File

@ -45,6 +45,7 @@ export class GalleryNavigatorComponent implements OnChanges {
ngOnChanges() {
this.getPath();
this.DefaultSorting = this.galleryService.getDefaultSorting(this.directory);
}
getPath(): any {