1
0
mirror of https://github.com/xuthus83/pigallery2.git synced 2025-01-14 14:43:17 +08: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 * cleaning up temp folder
* indexing db * indexing db
* folder ignoring [#87](https://github.com/bpatrik/pigallery2/issues/87) * 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 * Dockerized
* **Markdown based blogging support** - `future plan` * **Markdown based blogging support** - `future plan`
* you can write some note in the blog.md for every directory * 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' 'ogg'
], ],
MetaFiles: [ MetaFiles: [
'gpx' 'gpx', 'pg2conf'
], ],
// These formats need to be transcoded (with the build-in ffmpeg support) // These formats need to be transcoded (with the build-in ffmpeg support)
TranscodeNeed: { TranscodeNeed: {

View File

@ -24,6 +24,7 @@ import {LoginComponent} from './ui/login/login.component';
import {AdminComponent} from './ui/admin/admin.component'; import {AdminComponent} from './ui/admin/admin.component';
import {GalleryComponent} from './ui/gallery/gallery.component'; import {GalleryComponent} from './ui/gallery/gallery.component';
import {StringifyRole} from './pipes/StringifyRolePipe'; import {StringifyRole} from './pipes/StringifyRolePipe';
import {GPXFilesFilterPipe} from './pipes/GPXFilesFilterPipe';
import {GalleryMapComponent} from './ui/gallery/map/map.gallery.component'; import {GalleryMapComponent} from './ui/gallery/map/map.gallery.component';
import {GalleryMapLightboxComponent} from './ui/gallery/map/lightbox/lightbox.map.gallery.component'; import {GalleryMapLightboxComponent} from './ui/gallery/map/lightbox/lightbox.map.gallery.component';
import {ThumbnailManagerService} from './ui/gallery/thumbnailManager.service'; import {ThumbnailManagerService} from './ui/gallery/thumbnailManager.service';
@ -211,7 +212,8 @@ export function translationsFactory(locale: string) {
IconizeSortingMethod, IconizeSortingMethod,
StringifySortingMethod, StringifySortingMethod,
DurationPipe, DurationPipe,
FileSizePipe FileSizePipe,
GPXFilesFilterPipe
], ],
providers: [ providers: [
{provide: HTTP_INTERCEPTORS, useClass: CSRFInterceptor, multi: true}, {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" <app-gallery-map *ngIf="isPhotoWithLocation && mapEnabled"
[photos]="_galleryService.content.value.directory.media" [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" <app-gallery-grid [media]="_galleryService.content.value.directory.media"
[lightbox]="lightbox"></app-gallery-grid> [lightbox]="lightbox"></app-gallery-grid>
</div> </div>
@ -48,7 +48,7 @@
<app-gallery-map *ngIf="isPhotoWithLocation && mapEnabled" <app-gallery-map *ngIf="isPhotoWithLocation && mapEnabled"
[photos]="_galleryService.content.value.searchResult.media" [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> <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 {QueryParams} from '../../../../common/QueryParams';
import {SeededRandomService} from '../../model/seededRandom.service'; import {SeededRandomService} from '../../model/seededRandom.service';
import {take} from 'rxjs/operators'; import {take} from 'rxjs/operators';
import {FileDTO} from '../../../../common/entities/FileDTO';
@Component({ @Component({
selector: 'app-gallery', selector: 'app-gallery',
@ -57,6 +58,7 @@ export class GalleryComponent implements OnInit, OnDestroy {
PageHelper.showScrollY(); PageHelper.showScrollY();
} }
updateTimer(t: number) { updateTimer(t: number) {
if (this.shareService.sharingSubject.value == null) { if (this.shareService.sharingSubject.value == null) {
return; 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 {NavigationService} from '../../model/navigation.service';
import {SortingMethods} from '../../../../common/entities/SortingMethods'; import {SortingMethods} from '../../../../common/entities/SortingMethods';
import {QueryParams} from '../../../../common/QueryParams'; import {QueryParams} from '../../../../common/QueryParams';
import {PG2ConfMap} from '../../../../common/PG2ConfMap';
@Injectable() @Injectable()
@ -40,10 +41,21 @@ export class GalleryService {
this.sorting = new BehaviorSubject<SortingMethods>(Config.Client.Other.defaultPhotoSortingMethod); 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 { setSorting(sorting: SortingMethods): void {
this.sorting.next(sorting); this.sorting.next(sorting);
if (this.content.value.directory) { 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); this.galleryCacheService.setSorting(this.content.value.directory, sorting);
} else { } else {
this.galleryCacheService.removeSorting(this.content.value.directory); this.galleryCacheService.removeSorting(this.content.value.directory);
@ -59,7 +71,7 @@ export class GalleryService {
if (sort !== null) { if (sort !== null) {
this.sorting.next(sort); this.sorting.next(sort);
} else { } else {
this.sorting.next(Config.Client.Other.defaultPhotoSortingMethod); this.sorting.next(this.getDefaultSorting(content.directory));
} }
} }
} }
@ -199,7 +211,6 @@ export class GalleryService {
} }
isSearchResult(): boolean { isSearchResult(): boolean {
return !!this.content.value.searchResult; return !!this.content.value.searchResult;
} }

View File

@ -1,5 +1,5 @@
<ng-template [ngIf]="mapPhotos.length>0"> <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> <div id="map" #map>
<yaga-map #yagaMap <yaga-map #yagaMap

View File

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

View File

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