From 5d42e0c23aec082c2ff943c734e15bec77e14f68 Mon Sep 17 00:00:00 2001 From: Braun Patrik Date: Wed, 21 Jun 2017 11:46:23 +0200 Subject: [PATCH] order directories by name --- frontend/app/gallery/gallery.component.html | 46 ++++++++++----------- frontend/app/gallery/gallery.component.ts | 17 ++++++-- package.json | 2 +- 3 files changed, 37 insertions(+), 28 deletions(-) diff --git a/frontend/app/gallery/gallery.component.html b/frontend/app/gallery/gallery.component.html index bb315ca0..6cca827c 100644 --- a/frontend/app/gallery/gallery.component.html +++ b/frontend/app/gallery/gallery.component.html @@ -1,39 +1,39 @@ -
- -
+
+ +
-
- +
+ - + - - -
+ + +
-
- - + -
- -
- +
+
+ +
diff --git a/frontend/app/gallery/gallery.component.ts b/frontend/app/gallery/gallery.component.ts index d0f8c395..79837fb2 100644 --- a/frontend/app/gallery/gallery.component.ts +++ b/frontend/app/gallery/gallery.component.ts @@ -6,6 +6,7 @@ import {GalleryGridComponent} from "./grid/grid.gallery.component"; import {GallerySearchComponent} from "./search/search.gallery.component"; import {SearchTypes} from "../../../common/entities/AutoCompleteItem"; import {Config} from "../../../common/config/public/Config"; +import {DirectoryDTO} from "../../../common/entities/DirectoryDTO"; @Component({ selector: 'gallery', @@ -18,6 +19,7 @@ export class GalleryComponent implements OnInit { @ViewChild(GalleryGridComponent) grid: GalleryGridComponent; public showSearchBar: boolean = true; + public directories: DirectoryDTO[] = []; constructor(public _galleryService: GalleryService, private _authService: AuthenticationService, @@ -33,8 +35,12 @@ export class GalleryComponent implements OnInit { return; } + const dirSorter = (a: DirectoryDTO, b: DirectoryDTO) => { + return a.name.localeCompare(b.name); + }; + this._route.params - .subscribe((params: Params) => { + .subscribe(async (params: Params) => { let searchText = params['searchText']; if (searchText && searchText != "") { console.log("searching"); @@ -43,11 +49,13 @@ export class GalleryComponent implements OnInit { if (typeString && typeString != "") { console.log("with type"); let type: SearchTypes = SearchTypes[typeString]; - this._galleryService.search(searchText, type); + await this._galleryService.search(searchText, type); + this.directories = this._galleryService.content.searchResult.directories.sort(dirSorter); return; } - this._galleryService.search(searchText); + await this._galleryService.search(searchText); + this.directories = this._galleryService.content.searchResult.directories.sort(dirSorter); return; } @@ -55,7 +63,8 @@ export class GalleryComponent implements OnInit { let directoryName = params['directory']; directoryName = directoryName ? directoryName : ""; - this._galleryService.getDirectory(directoryName); + await this._galleryService.getDirectory(directoryName); + this.directories = this._galleryService.content.directory.directories.sort(dirSorter); }); diff --git a/package.json b/package.json index c814cc84..9ba94eaa 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "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)", "author": "Patrik J. Braun", "homepage": "https://github.com/bpatrik/PiGallery2",