mirror of
https://github.com/xuthus83/pigallery2.git
synced 2024-11-03 21:04:03 +08:00
Merge pull request #230 from bruce30262/fix_gallery_order_issue
Fix gallery order issue
This commit is contained in:
commit
0f40bb67e5
@ -172,13 +172,17 @@ export class GalleryComponent implements OnInit, OnDestroy {
|
|||||||
}
|
}
|
||||||
switch (this._galleryService.sorting.value) {
|
switch (this._galleryService.sorting.value) {
|
||||||
case SortingMethods.ascName:
|
case SortingMethods.ascName:
|
||||||
case SortingMethods.ascDate:
|
|
||||||
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:
|
||||||
|
this.directories.sort((a: DirectoryDTO, b: DirectoryDTO) => compare()(a.lastModified, b.lastModified));
|
||||||
|
break;
|
||||||
case SortingMethods.descName:
|
case SortingMethods.descName:
|
||||||
case SortingMethods.descDate:
|
|
||||||
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:
|
||||||
|
this.directories.sort((a: DirectoryDTO, b: DirectoryDTO) => compare({ order: 'desc' })(a.lastModified, b.lastModified));
|
||||||
|
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) => {
|
||||||
|
@ -28,6 +28,7 @@ import {SortingMethods} from '../../../../../common/entities/SortingMethods';
|
|||||||
import {MediaDTO} from '../../../../../common/entities/MediaDTO';
|
import {MediaDTO} from '../../../../../common/entities/MediaDTO';
|
||||||
import {QueryParams} from '../../../../../common/QueryParams';
|
import {QueryParams} from '../../../../../common/QueryParams';
|
||||||
import {SeededRandomService} from '../../../model/seededRandom.service';
|
import {SeededRandomService} from '../../../model/seededRandom.service';
|
||||||
|
import { compare } from 'natural-orderby';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'app-gallery-grid',
|
selector: 'app-gallery-grid',
|
||||||
@ -230,26 +231,10 @@ export class GalleryGridComponent implements OnChanges, OnInit, AfterViewInit, O
|
|||||||
private sortPhotos() {
|
private sortPhotos() {
|
||||||
switch (this.galleryService.sorting.value) {
|
switch (this.galleryService.sorting.value) {
|
||||||
case SortingMethods.ascName:
|
case SortingMethods.ascName:
|
||||||
this.media.sort((a: PhotoDTO, b: PhotoDTO) => {
|
this.media.sort((a: PhotoDTO, b: PhotoDTO) => compare()(a.name, b.name));
|
||||||
if (a.name.toLowerCase() < b.name.toLowerCase()) {
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
if (a.name.toLowerCase() > b.name.toLowerCase()) {
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
return 0;
|
|
||||||
});
|
|
||||||
break;
|
break;
|
||||||
case SortingMethods.descName:
|
case SortingMethods.descName:
|
||||||
this.media.sort((a: PhotoDTO, b: PhotoDTO) => {
|
this.media.sort((a: PhotoDTO, b: PhotoDTO) => compare({order: 'desc' })(a.name, b.name));
|
||||||
if (a.name.toLowerCase() < b.name.toLowerCase()) {
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
if (a.name.toLowerCase() > b.name.toLowerCase()) {
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
return 0;
|
|
||||||
});
|
|
||||||
break;
|
break;
|
||||||
case SortingMethods.ascDate:
|
case SortingMethods.ascDate:
|
||||||
this.media.sort((a: PhotoDTO, b: PhotoDTO) => {
|
this.media.sort((a: PhotoDTO, b: PhotoDTO) => {
|
||||||
|
Loading…
Reference in New Issue
Block a user