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

76 lines
2.5 KiB
TypeScript
Raw Normal View History

2016-03-14 20:20:29 +08:00
///<reference path="../../browser.d.ts"/>
2016-03-13 18:28:29 +08:00
2016-05-16 17:03:11 +08:00
import {Component, OnInit, ViewChild} from "@angular/core";
import {AuthenticationService} from "../model/network/authentication.service.ts";
2016-05-09 23:04:56 +08:00
import {Router, RouteParams} from "@angular/router-deprecated";
2016-03-20 23:54:30 +08:00
import {GalleryService} from "./gallery.service";
2016-03-21 03:05:51 +08:00
import {GalleryDirectoryComponent} from "./directory/directory.gallery.component";
import {GalleryGridComponent} from "./grid/grid.gallery.component";
import {FrameComponent} from "../frame/frame.component";
import {GalleryLightboxComponent} from "./lightbox/lightbox.gallery.component";
import {GallerySearchComponent} from "./search/search.gallery.component";
import {Config} from "../config/Config";
2016-05-16 17:03:11 +08:00
import {SearchTypes} from "../../../common/entities/AutoCompleteItem";
2016-06-30 01:26:31 +08:00
import {GalleryNavigatorComponent} from "./navigator/navigator.gallery.component";
2016-03-13 18:28:29 +08:00
@Component({
selector: 'gallery',
2016-03-20 23:54:30 +08:00
templateUrl: 'app/gallery/gallery.component.html',
styleUrls: ['app/gallery/gallery.component.css'],
2016-05-09 23:04:56 +08:00
directives: [GalleryGridComponent,
GalleryDirectoryComponent,
GalleryLightboxComponent,
FrameComponent,
2016-06-30 01:26:31 +08:00
GallerySearchComponent,
GalleryNavigatorComponent]
2016-03-13 18:28:29 +08:00
})
2016-05-09 23:04:56 +08:00
export class GalleryComponent implements OnInit {
2016-05-16 17:03:11 +08:00
@ViewChild(GallerySearchComponent) search:GallerySearchComponent;
2016-05-09 23:04:56 +08:00
public showSearchBar:boolean = true;
2016-05-16 17:03:11 +08:00
2016-03-20 23:54:30 +08:00
constructor(private _galleryService:GalleryService,
2016-05-09 23:04:56 +08:00
private _params:RouteParams,
private _authService:AuthenticationService,
private _router:Router) {
this.showSearchBar = Config.Client.Search.searchEnabled;
}
2016-05-09 23:04:56 +08:00
ngOnInit() {
if (!this._authService.isAuthenticated()) {
this._router.navigate(['Login']);
2016-03-20 23:54:30 +08:00
return;
}
2016-05-09 23:04:56 +08:00
2016-05-16 17:03:11 +08:00
let searchText = this._params.get('searchText');
if (searchText && searchText != "") {
console.log("searching");
let typeString = this._params.get('type');
if (typeString && typeString != "") {
console.log("with type");
let type:SearchTypes = SearchTypes[typeString];
this._galleryService.search(searchText, type);
return;
}
this._galleryService.search(searchText);
return;
}
let directoryName = this._params.get('directory');
2016-03-20 23:54:30 +08:00
directoryName = directoryName ? directoryName : "";
this._galleryService.getDirectory(directoryName);
2016-05-16 17:03:11 +08:00
}
2016-03-13 18:28:29 +08:00
}