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