mirror of
https://github.com/xuthus83/pigallery2.git
synced 2025-01-14 14:43:17 +08:00
Add sorting by rating #80
This commit is contained in:
parent
41975f72a1
commit
6bcd8ff33c
@ -11,6 +11,8 @@ export const PG2ConfMap = {
|
|||||||
'.order_ascending_name.pg2conf': SortingMethods.ascName,
|
'.order_ascending_name.pg2conf': SortingMethods.ascName,
|
||||||
'.order_descending_date.pg2conf': SortingMethods.descDate,
|
'.order_descending_date.pg2conf': SortingMethods.descDate,
|
||||||
'.order_ascending_date.pg2conf': SortingMethods.ascDate,
|
'.order_ascending_date.pg2conf': SortingMethods.ascDate,
|
||||||
|
'.order_descending_rating.pg2conf': SortingMethods.descRating,
|
||||||
|
'.order_ascending_rating.pg2conf': SortingMethods.ascRating,
|
||||||
'.order_random.pg2conf': SortingMethods.random
|
'.order_random.pg2conf': SortingMethods.random
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -1,3 +1,3 @@
|
|||||||
export enum SortingMethods {
|
export enum SortingMethods {
|
||||||
ascName = 1, descName = 2, ascDate = 3, descDate = 4, random = 5
|
ascName = 1, descName, ascDate, descDate, ascRating, descRating, random
|
||||||
}
|
}
|
||||||
|
@ -6,6 +6,10 @@ import {SortingMethods} from '../../../common/entities/SortingMethods';
|
|||||||
export class IconizeSortingMethod implements PipeTransform {
|
export class IconizeSortingMethod implements PipeTransform {
|
||||||
transform(method: SortingMethods): string {
|
transform(method: SortingMethods): string {
|
||||||
switch (method) {
|
switch (method) {
|
||||||
|
case SortingMethods.ascRating:
|
||||||
|
return '<span class="oi oi-sort-ascending"></span><span class="oi oi-star text-bold"></span>';
|
||||||
|
case SortingMethods.descRating:
|
||||||
|
return '<span class="oi oi-sort-descending"></span><span class="oi oi-star text-bold"></span>';
|
||||||
case SortingMethods.ascName:
|
case SortingMethods.ascName:
|
||||||
return '<span class="oi oi-sort-ascending"></span><strong>A</strong>';
|
return '<span class="oi oi-sort-ascending"></span><strong>A</strong>';
|
||||||
case SortingMethods.descName:
|
case SortingMethods.descName:
|
||||||
|
@ -9,6 +9,10 @@ export class StringifySortingMethod implements PipeTransform {
|
|||||||
|
|
||||||
transform(method: SortingMethods): string {
|
transform(method: SortingMethods): string {
|
||||||
switch (method) {
|
switch (method) {
|
||||||
|
case SortingMethods.ascRating:
|
||||||
|
return $localize`ascending rating`;
|
||||||
|
case SortingMethods.descRating:
|
||||||
|
return $localize`descending rating`;
|
||||||
case SortingMethods.ascName:
|
case SortingMethods.ascName:
|
||||||
return $localize`ascending name`;
|
return $localize`ascending name`;
|
||||||
case SortingMethods.descName:
|
case SortingMethods.descName:
|
||||||
|
@ -165,6 +165,7 @@ export class GalleryComponent implements OnInit, OnDestroy {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
switch (this.galleryService.sorting.value) {
|
switch (this.galleryService.sorting.value) {
|
||||||
|
case SortingMethods.ascRating: // directories does not have rating
|
||||||
case SortingMethods.ascName:
|
case SortingMethods.ascName:
|
||||||
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;
|
||||||
@ -175,6 +176,8 @@ 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.descRating: // directories does not have rating
|
||||||
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;
|
||||||
|
@ -257,6 +257,12 @@ export class GalleryGridComponent implements OnChanges, OnInit, AfterViewInit, O
|
|||||||
return b.metadata.creationDate - a.metadata.creationDate;
|
return b.metadata.creationDate - a.metadata.creationDate;
|
||||||
});
|
});
|
||||||
break;
|
break;
|
||||||
|
case SortingMethods.ascRating:
|
||||||
|
this.media.sort((a: PhotoDTO, b: PhotoDTO) => (a.metadata.rating || 0) - (b.metadata.rating || 0));
|
||||||
|
break;
|
||||||
|
case SortingMethods.descRating:
|
||||||
|
this.media.sort((a: PhotoDTO, b: PhotoDTO) => (b.metadata.rating || 0) - (a.metadata.rating || 0));
|
||||||
|
break;
|
||||||
case SortingMethods.random:
|
case SortingMethods.random:
|
||||||
this.rndService.setSeed(this.media.length);
|
this.rndService.setSeed(this.media.length);
|
||||||
this.media.sort((a: PhotoDTO, b: PhotoDTO): number => {
|
this.media.sort((a: PhotoDTO, b: PhotoDTO): number => {
|
||||||
|
@ -30,7 +30,11 @@ ol {
|
|||||||
}
|
}
|
||||||
|
|
||||||
.dropdown-menu {
|
.dropdown-menu {
|
||||||
min-width: 10rem;
|
min-width: 13rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
.dropdown-item{
|
||||||
|
padding: 0.25rem 0.5rem;
|
||||||
}
|
}
|
||||||
|
|
||||||
.row {
|
.row {
|
||||||
|
@ -43,7 +43,9 @@
|
|||||||
<li class="row dropdown-item" role="menuitem"
|
<li class="row dropdown-item" role="menuitem"
|
||||||
*ngFor="let type of sortingMethodsType"
|
*ngFor="let type of sortingMethodsType"
|
||||||
(click)="setSorting(type.key)">
|
(click)="setSorting(type.key)">
|
||||||
<div class="col-3" [outerHTML]="type.key | iconizeSorting"></div>
|
<div class="col-3">
|
||||||
|
<div [outerHTML]="type.key | iconizeSorting"></div>
|
||||||
|
</div>
|
||||||
<div class="col-9">{{type.key | stringifySorting}}</div>
|
<div class="col-9">{{type.key | stringifySorting}}</div>
|
||||||
</li>
|
</li>
|
||||||
</ul>
|
</ul>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user