1
0
mirror of https://github.com/bpatrik/pigallery2.git synced 2024-12-16 11:37:13 +02:00
pigallery2/frontend/app/gallery/gallery.component.ts

74 lines
2.3 KiB
TypeScript
Raw Normal View History

2016-05-16 11:03:11 +02:00
import {Component, OnInit, ViewChild} from "@angular/core";
2016-12-27 00:36:38 +02:00
import {AuthenticationService} from "../model/network/authentication.service";
2017-06-04 15:25:08 +02:00
import {ActivatedRoute, Params, Router} from "@angular/router";
2016-03-20 17:54:30 +02:00
import {GalleryService} from "./gallery.service";
import {GalleryGridComponent} from "./grid/grid.gallery.component";
import {GallerySearchComponent} from "./search/search.gallery.component";
2016-05-16 11:03:11 +02:00
import {SearchTypes} from "../../../common/entities/AutoCompleteItem";
2017-06-04 15:25:08 +02:00
import {Config} from "../../../common/config/public/Config";
2016-03-13 12:28:29 +02:00
@Component({
selector: 'gallery',
2016-03-20 17:54:30 +02:00
templateUrl: 'app/gallery/gallery.component.html',
2016-12-27 00:36:38 +02:00
styleUrls: ['app/gallery/gallery.component.css']
2016-03-13 12:28:29 +02:00
})
2016-05-09 17:04:56 +02:00
export class GalleryComponent implements OnInit {
2016-12-27 00:36:38 +02:00
@ViewChild(GallerySearchComponent) search: GallerySearchComponent;
@ViewChild(GalleryGridComponent) grid: GalleryGridComponent;
2016-05-09 17:04:56 +02:00
2016-12-27 00:36:38 +02:00
public showSearchBar: boolean = true;
2016-05-16 11:03:11 +02:00
2016-12-27 00:36:38 +02:00
constructor(private _galleryService: GalleryService,
private _authService: AuthenticationService,
private _router: Router,
private _route: ActivatedRoute) {
this.showSearchBar = Config.Client.Search.searchEnabled;
}
2016-05-09 17:04:56 +02:00
ngOnInit() {
if (!this._authService.isAuthenticated()) {
2016-12-27 00:36:38 +02:00
this._router.navigate(['login']);
2016-03-20 17:54:30 +02:00
return;
}
2016-05-09 17:04:56 +02:00
2016-12-27 00:36:38 +02:00
this._route.params
.subscribe((params: Params) => {
let searchText = params['searchText'];
if (searchText && searchText != "") {
console.log("searching");
let typeString = params['type'];
2016-05-16 11:03:11 +02:00
2016-12-27 00:36:38 +02:00
if (typeString && typeString != "") {
console.log("with type");
let type: SearchTypes = <any>SearchTypes[typeString];
this._galleryService.search(searchText, type);
return;
}
2016-05-16 11:03:11 +02:00
2016-12-27 00:36:38 +02:00
this._galleryService.search(searchText);
return;
}
2016-05-16 11:03:11 +02:00
2016-12-27 00:36:38 +02:00
let directoryName = params['directory'];
directoryName = directoryName ? directoryName : "";
this._galleryService.getDirectory(directoryName);
});
2016-05-16 11:03:11 +02:00
2016-05-16 11:03:11 +02:00
}
onLightboxLastElement() {
this.grid.renderARow();
}
2016-03-13 12:28:29 +02:00
}