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:
parent
cc626d8198
commit
40f83f49cd
@ -376,21 +376,11 @@ export class SettingsMWs {
|
||||
|
||||
try {
|
||||
const settings: OtherConfigDTO = req.body.settings;
|
||||
Config.Client.Other.enableCache = settings.Client.enableCache;
|
||||
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;
|
||||
Config.Client.Other = settings.Client;
|
||||
|
||||
// only updating explicitly set config (not saving config set by the diagnostics)
|
||||
const original = await Config.original();
|
||||
original.Client.Other.enableCache = settings.Client.enableCache;
|
||||
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.Client.Other = settings.Client;
|
||||
original.Server.Threading.enabled = settings.Server.enabled;
|
||||
original.Server.Threading.thumbnailThreads = settings.Server.thumbnailThreads;
|
||||
await original.save();
|
||||
|
@ -99,6 +99,8 @@ export module ClientConfig {
|
||||
enableOnScrollRendering: boolean = true;
|
||||
@ConfigProperty({type: SortingMethods})
|
||||
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()
|
||||
enableOnScrollThumbnailPrioritising: boolean = true;
|
||||
@ConfigProperty()
|
||||
|
@ -166,14 +166,22 @@ export class GalleryComponent implements OnInit, OnDestroy {
|
||||
this.directories.sort((a: DirectoryDTO, b: DirectoryDTO) => compare()(a.name, b.name));
|
||||
break;
|
||||
case SortingMethods.ascDate:
|
||||
if (Config.Client.Other.enableDirectorySortingByDate === true) {
|
||||
this.directories.sort((a: DirectoryDTO, b: DirectoryDTO) => compare()(a.lastModified, b.lastModified));
|
||||
break;
|
||||
}
|
||||
this.directories.sort((a: DirectoryDTO, b: DirectoryDTO) => compare()(a.name, b.name));
|
||||
break;
|
||||
case SortingMethods.descName:
|
||||
this.directories.sort((a: DirectoryDTO, b: DirectoryDTO) => compare({order: 'desc'})(a.name, b.name));
|
||||
break;
|
||||
case SortingMethods.descDate:
|
||||
if (Config.Client.Other.enableDirectorySortingByDate === true) {
|
||||
this.directories.sort((a: DirectoryDTO, b: DirectoryDTO) => compare({order: 'desc'})(a.lastModified, b.lastModified));
|
||||
break;
|
||||
}
|
||||
this.directories.sort((a: DirectoryDTO, b: DirectoryDTO) => compare({order: 'desc'})(a.name, b.name));
|
||||
break;
|
||||
case SortingMethods.random:
|
||||
this.rndService.setSeed(this.directories.length);
|
||||
this.directories.sort((a: DirectoryDTO, b: DirectoryDTO) => {
|
||||
|
@ -77,6 +77,9 @@
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<app-settings-entry
|
||||
name="Default photo sorting method"
|
||||
i18n-name
|
||||
@ -86,6 +89,15 @@
|
||||
required="true">
|
||||
</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"
|
||||
|
Loading…
Reference in New Issue
Block a user