2016-03-14 14:20:29 +02:00
|
|
|
///<reference path="../../browser.d.ts"/>
|
2016-03-13 12:28:29 +02:00
|
|
|
|
2016-05-16 11:03:11 +02:00
|
|
|
import {Component, OnInit, ViewChild} from "@angular/core";
|
2016-04-30 18:01:54 +02:00
|
|
|
import {AuthenticationService} from "../model/network/authentication.service.ts";
|
2016-05-09 17:04:56 +02:00
|
|
|
import {Router, RouteParams} from "@angular/router-deprecated";
|
2016-03-20 17:54:30 +02:00
|
|
|
import {GalleryService} from "./gallery.service";
|
2016-03-20 21:05:51 +02:00
|
|
|
import {GalleryDirectoryComponent} from "./directory/directory.gallery.component";
|
2016-04-09 15:19:25 +02:00
|
|
|
import {GalleryGridComponent} from "./grid/grid.gallery.component";
|
2016-04-26 15:10:05 +02:00
|
|
|
import {FrameComponent} from "../frame/frame.component";
|
2016-04-30 18:01:54 +02:00
|
|
|
import {GalleryLightboxComponent} from "./lightbox/lightbox.gallery.component";
|
2016-05-03 21:04:57 +02:00
|
|
|
import {GallerySearchComponent} from "./search/search.gallery.component";
|
2016-05-10 21:33:58 +02:00
|
|
|
import {Config} from "../config/Config";
|
2016-05-16 11:03:11 +02:00
|
|
|
import {SearchTypes} from "../../../common/entities/AutoCompleteItem";
|
2016-06-29 19:26:31 +02:00
|
|
|
import {GalleryNavigatorComponent} from "./navigator/navigator.gallery.component";
|
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-04-18 21:27:15 +02:00
|
|
|
styleUrls: ['app/gallery/gallery.component.css'],
|
2016-05-09 17:04:56 +02:00
|
|
|
directives: [GalleryGridComponent,
|
|
|
|
GalleryDirectoryComponent,
|
|
|
|
GalleryLightboxComponent,
|
|
|
|
FrameComponent,
|
2016-06-29 19:26:31 +02:00
|
|
|
GallerySearchComponent,
|
|
|
|
GalleryNavigatorComponent]
|
2016-03-13 12:28:29 +02:00
|
|
|
})
|
2016-05-09 17:04:56 +02:00
|
|
|
export class GalleryComponent implements OnInit {
|
2016-03-19 10:58:27 +02:00
|
|
|
|
2016-05-16 11:03:11 +02:00
|
|
|
@ViewChild(GallerySearchComponent) search:GallerySearchComponent;
|
2016-05-09 17:04:56 +02:00
|
|
|
|
2016-05-10 21:33:58 +02:00
|
|
|
public showSearchBar:boolean = true;
|
2016-05-16 11:03:11 +02:00
|
|
|
|
2016-03-20 17:54:30 +02:00
|
|
|
constructor(private _galleryService:GalleryService,
|
2016-05-09 17:04:56 +02:00
|
|
|
private _params:RouteParams,
|
|
|
|
private _authService:AuthenticationService,
|
|
|
|
private _router:Router) {
|
2016-05-10 21:33:58 +02:00
|
|
|
|
|
|
|
this.showSearchBar = Config.Client.Search.searchEnabled;
|
2016-03-19 10:58:27 +02:00
|
|
|
}
|
|
|
|
|
2016-05-09 17:04:56 +02:00
|
|
|
ngOnInit() {
|
2016-03-19 10:58:27 +02:00
|
|
|
if (!this._authService.isAuthenticated()) {
|
|
|
|
this._router.navigate(['Login']);
|
2016-03-20 17:54:30 +02:00
|
|
|
return;
|
2016-03-19 10:58:27 +02:00
|
|
|
}
|
2016-05-09 17:04:56 +02:00
|
|
|
|
2016-05-16 11:03:11 +02: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 17:54:30 +02:00
|
|
|
directoryName = directoryName ? directoryName : "";
|
2016-06-22 16:34:44 +02:00
|
|
|
|
2016-05-09 19:14:33 +02:00
|
|
|
this._galleryService.getDirectory(directoryName);
|
2016-05-16 11:03:11 +02:00
|
|
|
|
|
|
|
|
2016-03-19 10:58:27 +02:00
|
|
|
}
|
2016-04-30 18:01:54 +02:00
|
|
|
|
2016-04-26 15:10:05 +02:00
|
|
|
|
2016-03-13 12:28:29 +02:00
|
|
|
}
|
|
|
|
|