1
0
mirror of https://github.com/xuthus83/pigallery2.git synced 2024-11-03 21:04:03 +08:00

Making directory sorting by date switchable (off by default) #230

If enabled, directories are sorted by last touched date (not by creation date of photos that are within a given directory). Any change to that directory would reorder the directories.
This commit is contained in:
Patrik J. Braun 2021-04-06 17:30:52 +02:00
parent cc626d8198
commit 40f83f49cd
4 changed files with 26 additions and 14 deletions

View File

@ -376,21 +376,11 @@ export class SettingsMWs {
try { try {
const settings: OtherConfigDTO = req.body.settings; const settings: OtherConfigDTO = req.body.settings;
Config.Client.Other.enableCache = settings.Client.enableCache; Config.Client.Other = settings.Client;
Config.Client.Other.captionFirstNaming = settings.Client.captionFirstNaming;
Config.Client.Other.enableOnScrollRendering = settings.Client.enableOnScrollRendering;
Config.Client.Other.enableOnScrollThumbnailPrioritising = settings.Client.enableOnScrollThumbnailPrioritising;
Config.Client.Other.defaultPhotoSortingMethod = settings.Client.defaultPhotoSortingMethod;
Config.Client.Other.NavBar.showItemCount = settings.Client.NavBar.showItemCount;
// only updating explicitly set config (not saving config set by the diagnostics) // only updating explicitly set config (not saving config set by the diagnostics)
const original = await Config.original(); const original = await Config.original();
original.Client.Other.enableCache = settings.Client.enableCache; original.Client.Other = settings.Client;
original.Client.Other.captionFirstNaming = settings.Client.captionFirstNaming;
original.Client.Other.enableOnScrollRendering = settings.Client.enableOnScrollRendering;
original.Client.Other.enableOnScrollThumbnailPrioritising = settings.Client.enableOnScrollThumbnailPrioritising;
original.Client.Other.defaultPhotoSortingMethod = settings.Client.defaultPhotoSortingMethod;
original.Client.Other.NavBar.showItemCount = settings.Client.NavBar.showItemCount;
original.Server.Threading.enabled = settings.Server.enabled; original.Server.Threading.enabled = settings.Server.enabled;
original.Server.Threading.thumbnailThreads = settings.Server.thumbnailThreads; original.Server.Threading.thumbnailThreads = settings.Server.thumbnailThreads;
await original.save(); await original.save();

View File

@ -99,6 +99,8 @@ export module ClientConfig {
enableOnScrollRendering: boolean = true; enableOnScrollRendering: boolean = true;
@ConfigProperty({type: SortingMethods}) @ConfigProperty({type: SortingMethods})
defaultPhotoSortingMethod: SortingMethods = SortingMethods.ascDate; defaultPhotoSortingMethod: SortingMethods = SortingMethods.ascDate;
@ConfigProperty({description: 'If enabled directories will be sorted by date, like photos, otherwise by name. Directory date is the last modification time of that directory not the creation date of the oldest photo'})
enableDirectorySortingByDate: boolean = false;
@ConfigProperty() @ConfigProperty()
enableOnScrollThumbnailPrioritising: boolean = true; enableOnScrollThumbnailPrioritising: boolean = true;
@ConfigProperty() @ConfigProperty()

View File

@ -166,14 +166,22 @@ export class GalleryComponent implements OnInit, OnDestroy {
this.directories.sort((a: DirectoryDTO, b: DirectoryDTO) => compare()(a.name, b.name)); this.directories.sort((a: DirectoryDTO, b: DirectoryDTO) => compare()(a.name, b.name));
break; break;
case SortingMethods.ascDate: case SortingMethods.ascDate:
if (Config.Client.Other.enableDirectorySortingByDate === true) {
this.directories.sort((a: DirectoryDTO, b: DirectoryDTO) => compare()(a.lastModified, b.lastModified)); this.directories.sort((a: DirectoryDTO, b: DirectoryDTO) => compare()(a.lastModified, b.lastModified));
break; break;
}
this.directories.sort((a: DirectoryDTO, b: DirectoryDTO) => compare()(a.name, b.name));
break;
case SortingMethods.descName: case SortingMethods.descName:
this.directories.sort((a: DirectoryDTO, b: DirectoryDTO) => compare({order: 'desc'})(a.name, b.name)); this.directories.sort((a: DirectoryDTO, b: DirectoryDTO) => compare({order: 'desc'})(a.name, b.name));
break; break;
case SortingMethods.descDate: case SortingMethods.descDate:
if (Config.Client.Other.enableDirectorySortingByDate === true) {
this.directories.sort((a: DirectoryDTO, b: DirectoryDTO) => compare({order: 'desc'})(a.lastModified, b.lastModified)); this.directories.sort((a: DirectoryDTO, b: DirectoryDTO) => compare({order: 'desc'})(a.lastModified, b.lastModified));
break; break;
}
this.directories.sort((a: DirectoryDTO, b: DirectoryDTO) => compare({order: 'desc'})(a.name, b.name));
break;
case SortingMethods.random: case SortingMethods.random:
this.rndService.setSeed(this.directories.length); this.rndService.setSeed(this.directories.length);
this.directories.sort((a: DirectoryDTO, b: DirectoryDTO) => { this.directories.sort((a: DirectoryDTO, b: DirectoryDTO) => {

View File

@ -77,6 +77,9 @@
<app-settings-entry <app-settings-entry
name="Default photo sorting method" name="Default photo sorting method"
i18n-name i18n-name
@ -86,6 +89,15 @@
required="true"> required="true">
</app-settings-entry> </app-settings-entry>
<app-settings-entry
name="Sort directories by date"
description="If enabled, directories will be sorted by date, like photos, otherwise by name. Directory date is the last modification time of that directory not the creation date of the oldest photo."
i18n-description i18n-name
[ngModel]="states.Client.enableDirectorySortingByDate"
[simplifiedMode]="simplifiedMode"
required="true">
</app-settings-entry>
<button class="btn btn-success float-right" <button class="btn btn-success float-right"