2016-03-14 20:20:29 +08:00
|
|
|
///<reference path="../../browser.d.ts"/>
|
2016-03-13 18:28:29 +08:00
|
|
|
|
2016-03-19 16:58:27 +08:00
|
|
|
import {Component, OnInit} from 'angular2/core';
|
|
|
|
import {AuthenticationService} from "../model/authentication.service";
|
2016-03-20 23:54:30 +08:00
|
|
|
import {Router, Location, RouteParams} from "angular2/router";
|
|
|
|
import {GalleryService} from "./gallery.service";
|
|
|
|
import {Directory} from "../../../common/entities/Directory";
|
|
|
|
import {Message} from "../../../common/entities/Message";
|
|
|
|
import {GalleryPhotoComponent} from "./photo/photo.gallery.component";
|
2016-03-21 03:05:51 +08:00
|
|
|
import {GalleryDirectoryComponent} from "./directory/directory.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',
|
2016-03-21 03:05:51 +08:00
|
|
|
directives:[GalleryPhotoComponent,
|
|
|
|
GalleryDirectoryComponent]
|
2016-03-13 18:28:29 +08:00
|
|
|
})
|
2016-03-19 16:58:27 +08:00
|
|
|
export class GalleryComponent implements OnInit{
|
|
|
|
|
2016-03-20 23:54:30 +08:00
|
|
|
directory:Directory = new Directory(-1,"","/",new Date(),[],[]);
|
|
|
|
|
|
|
|
constructor(private _galleryService:GalleryService,
|
|
|
|
private _params: RouteParams,
|
|
|
|
private _authService: AuthenticationService,
|
|
|
|
private _router: Router,
|
|
|
|
private _location:Location) {
|
2016-03-19 16:58:27 +08:00
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
ngOnInit(){
|
|
|
|
if (!this._authService.isAuthenticated()) {
|
|
|
|
this._location.replaceState('/'); // clears browser history so they can't navigate with back button
|
|
|
|
this._router.navigate(['Login']);
|
2016-03-20 23:54:30 +08:00
|
|
|
return;
|
2016-03-19 16:58:27 +08:00
|
|
|
}
|
2016-03-20 23:54:30 +08:00
|
|
|
let directoryName = this._params.get('directory');
|
|
|
|
directoryName = directoryName ? directoryName : "";
|
|
|
|
this._galleryService.getDirectory(directoryName).then(( message:Message<Directory>) => {
|
2016-03-26 18:19:10 +08:00
|
|
|
if(message.error){
|
2016-03-20 23:54:30 +08:00
|
|
|
//TODO: implement
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
this.directory = message.result;
|
|
|
|
});
|
2016-03-19 16:58:27 +08:00
|
|
|
}
|
|
|
|
|
2016-03-13 18:28:29 +08:00
|
|
|
}
|
|
|
|
|