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

order directories by name

This commit is contained in:
Braun Patrik 2017-06-21 11:46:23 +02:00
parent e8d96ea700
commit 5d42e0c23a
3 changed files with 37 additions and 28 deletions

View File

@ -1,39 +1,39 @@
<gallery-lightbox #lightbox (onLastElement)="onLightboxLastElement()"></gallery-lightbox> <gallery-lightbox #lightbox (onLastElement)="onLightboxLastElement()"></gallery-lightbox>
<app-frame> <app-frame>
<div navbar> <div navbar>
<gallery-search #search *ngIf="showSearchBar"></gallery-search> <gallery-search #search *ngIf="showSearchBar"></gallery-search>
</div> </div>
<div body class="container" style="width: 100%; padding:0" *ngIf="_galleryService.content.directory"> <div body class="container" style="width: 100%; padding:0" *ngIf="_galleryService.content.directory">
<gallery-navbar [directory]="_galleryService.content.directory"></gallery-navbar> <gallery-navbar [directory]="_galleryService.content.directory"></gallery-navbar>
<gallery-directory *ngFor="let directory of _galleryService.content.directory.directories" <gallery-directory *ngFor="let directory of directories"
[directory]="directory"></gallery-directory> [directory]="directory"></gallery-directory>
<gallery-map [photos]="_galleryService.content.directory.photos"></gallery-map> <gallery-map [photos]="_galleryService.content.directory.photos"></gallery-map>
<gallery-grid [photos]="_galleryService.content.directory.photos" [lightbox]="lightbox"></gallery-grid> <gallery-grid [photos]="_galleryService.content.directory.photos" [lightbox]="lightbox"></gallery-grid>
</div> </div>
<div body class="container" style="width: 100%; padding:0" *ngIf="_galleryService.content.searchResult"> <div body class="container" style="width: 100%; padding:0" *ngIf="_galleryService.content.searchResult">
<ol class="breadcrumb"> <ol class="breadcrumb">
<li class="active"> <li class="active">
Searching for: Searching for:
<span [ngSwitch]="_galleryService.content.searchResult.searchType"> <span [ngSwitch]="_galleryService.content.searchResult.searchType">
<span *ngSwitchCase="0" class="glyphicon glyphicon-picture"></span> <span *ngSwitchCase="0" class="glyphicon glyphicon-picture"></span>
<span *ngSwitchCase="1" class="glyphicon glyphicon-folder-open"></span> <span *ngSwitchCase="1" class="glyphicon glyphicon-folder-open"></span>
<span *ngSwitchCase="2" class="glyphicon glyphicon-tag"></span> <span *ngSwitchCase="2" class="glyphicon glyphicon-tag"></span>
<span *ngSwitchCase="3" class="glyphicon glyphicon-map-marker"></span> <span *ngSwitchCase="3" class="glyphicon glyphicon-map-marker"></span>
</span> </span>
<strong>{{_galleryService.content.searchResult.searchText}}</strong> <strong>{{_galleryService.content.searchResult.searchText}}</strong>
</li> </li>
</ol> </ol>
<gallery-map [photos]="_galleryService.content.searchResult.photos"></gallery-map> <gallery-map [photos]="_galleryService.content.searchResult.photos"></gallery-map>
<div *ngFor="let directory of _galleryService.content.searchResult.directories"> <div *ngFor="let directory of directories">
<gallery-directory *ngIf="directory" [directory]="directory"></gallery-directory> <gallery-directory *ngIf="directory" [directory]="directory"></gallery-directory>
</div>
<gallery-grid [photos]="_galleryService.content.searchResult.photos" [lightbox]="lightbox"></gallery-grid>
</div> </div>
<gallery-grid [photos]="_galleryService.content.searchResult.photos" [lightbox]="lightbox"></gallery-grid>
</div>
</app-frame> </app-frame>

View File

@ -6,6 +6,7 @@ import {GalleryGridComponent} from "./grid/grid.gallery.component";
import {GallerySearchComponent} from "./search/search.gallery.component"; import {GallerySearchComponent} from "./search/search.gallery.component";
import {SearchTypes} from "../../../common/entities/AutoCompleteItem"; import {SearchTypes} from "../../../common/entities/AutoCompleteItem";
import {Config} from "../../../common/config/public/Config"; import {Config} from "../../../common/config/public/Config";
import {DirectoryDTO} from "../../../common/entities/DirectoryDTO";
@Component({ @Component({
selector: 'gallery', selector: 'gallery',
@ -18,6 +19,7 @@ export class GalleryComponent implements OnInit {
@ViewChild(GalleryGridComponent) grid: GalleryGridComponent; @ViewChild(GalleryGridComponent) grid: GalleryGridComponent;
public showSearchBar: boolean = true; public showSearchBar: boolean = true;
public directories: DirectoryDTO[] = [];
constructor(public _galleryService: GalleryService, constructor(public _galleryService: GalleryService,
private _authService: AuthenticationService, private _authService: AuthenticationService,
@ -33,8 +35,12 @@ export class GalleryComponent implements OnInit {
return; return;
} }
const dirSorter = (a: DirectoryDTO, b: DirectoryDTO) => {
return a.name.localeCompare(b.name);
};
this._route.params this._route.params
.subscribe((params: Params) => { .subscribe(async (params: Params) => {
let searchText = params['searchText']; let searchText = params['searchText'];
if (searchText && searchText != "") { if (searchText && searchText != "") {
console.log("searching"); console.log("searching");
@ -43,11 +49,13 @@ export class GalleryComponent implements OnInit {
if (typeString && typeString != "") { if (typeString && typeString != "") {
console.log("with type"); console.log("with type");
let type: SearchTypes = <any>SearchTypes[typeString]; let type: SearchTypes = <any>SearchTypes[typeString];
this._galleryService.search(searchText, type); await this._galleryService.search(searchText, type);
this.directories = this._galleryService.content.searchResult.directories.sort(dirSorter);
return; return;
} }
this._galleryService.search(searchText); await this._galleryService.search(searchText);
this.directories = this._galleryService.content.searchResult.directories.sort(dirSorter);
return; return;
} }
@ -55,7 +63,8 @@ export class GalleryComponent implements OnInit {
let directoryName = params['directory']; let directoryName = params['directory'];
directoryName = directoryName ? directoryName : ""; directoryName = directoryName ? directoryName : "";
this._galleryService.getDirectory(directoryName); await this._galleryService.getDirectory(directoryName);
this.directories = this._galleryService.content.directory.directories.sort(dirSorter);
}); });

View File

@ -1,6 +1,6 @@
{ {
"name": "pigallery2", "name": "pigallery2",
"version": "1.0.0-beta.0.1", "version": "1.0.0-beta.1",
"description": "This is a photo gallery optimised for running low resource servers (especially on raspberry pi)", "description": "This is a photo gallery optimised for running low resource servers (especially on raspberry pi)",
"author": "Patrik J. Braun", "author": "Patrik J. Braun",
"homepage": "https://github.com/bpatrik/PiGallery2", "homepage": "https://github.com/bpatrik/PiGallery2",