2016-03-14 14:20:29 +02:00
|
|
|
///<reference path="../browser.d.ts"/>
|
2016-03-12 19:11:19 +02:00
|
|
|
|
2016-03-12 15:57:22 +02:00
|
|
|
import { Component } from 'angular2/core';
|
2016-03-26 17:25:48 +02:00
|
|
|
import {RouteConfig, ROUTER_DIRECTIVES, ROUTER_PROVIDERS, RouterLink} from 'angular2/router';
|
2016-03-12 15:57:22 +02:00
|
|
|
import {LoginComponent} from "./login/login.component";
|
2016-03-13 12:28:29 +02:00
|
|
|
import {AuthenticationService} from "./model/authentication.service";
|
|
|
|
import {GalleryComponent} from "./gallery/gallery.component";
|
|
|
|
import {OnInit} from "angular2/core";
|
|
|
|
import {User} from "../../common/entities/User";
|
2016-04-26 12:03:44 +02:00
|
|
|
import {Router} from "angular2/router";
|
2016-03-19 10:58:27 +02:00
|
|
|
import {HTTP_PROVIDERS} from "angular2/http";
|
|
|
|
import {UserService} from "./model/user.service";
|
2016-03-20 17:54:30 +02:00
|
|
|
import {GalleryService} from "./gallery/gallery.service";
|
2016-04-18 21:27:15 +02:00
|
|
|
import {MATERIAL_BROWSER_PROVIDERS} from "ng2-material/all";
|
|
|
|
import {ViewportHelper} from "ng2-material/core/util/viewport";
|
2016-03-12 15:57:22 +02:00
|
|
|
|
2016-04-18 21:27:15 +02:00
|
|
|
|
2016-03-12 15:57:22 +02:00
|
|
|
@Component({
|
|
|
|
selector: 'pi-gallery2-app',
|
|
|
|
template: `<router-outlet></router-outlet>`,
|
2016-04-18 21:27:15 +02:00
|
|
|
directives: [ROUTER_DIRECTIVES, RouterLink],
|
2016-03-12 15:57:22 +02:00
|
|
|
providers: [
|
2016-03-19 10:58:27 +02:00
|
|
|
HTTP_PROVIDERS,
|
2016-03-12 23:19:24 +02:00
|
|
|
ROUTER_PROVIDERS,
|
2016-03-19 10:58:27 +02:00
|
|
|
UserService,
|
2016-03-20 17:54:30 +02:00
|
|
|
GalleryService,
|
2016-04-18 21:27:15 +02:00
|
|
|
AuthenticationService,MATERIAL_BROWSER_PROVIDERS,ViewportHelper
|
|
|
|
|
2016-03-12 15:57:22 +02:00
|
|
|
]
|
|
|
|
})
|
|
|
|
@RouteConfig([
|
2016-04-09 18:06:29 +02:00
|
|
|
{
|
|
|
|
path: '/',
|
|
|
|
redirectTo: ["Login"]
|
|
|
|
},
|
2016-03-12 15:57:22 +02:00
|
|
|
{
|
|
|
|
path: '/login',
|
|
|
|
name: 'Login',
|
|
|
|
component: LoginComponent,
|
|
|
|
useAsDefault: true
|
2016-03-27 21:21:47 +02:00
|
|
|
},
|
2016-03-13 12:28:29 +02:00
|
|
|
{
|
2016-03-27 21:21:47 +02:00
|
|
|
path: '/gallery',
|
2016-04-09 18:06:29 +02:00
|
|
|
redirectTo: ["Gallery",{directory:""}]
|
|
|
|
},
|
|
|
|
{
|
|
|
|
path: '/gallery/:directory',
|
2016-03-13 12:28:29 +02:00
|
|
|
name: 'Gallery',
|
|
|
|
component: GalleryComponent
|
2016-04-09 18:06:29 +02:00
|
|
|
},
|
2016-03-12 15:57:22 +02:00
|
|
|
])
|
2016-03-13 12:28:29 +02:00
|
|
|
export class AppComponent implements OnInit{
|
|
|
|
|
2016-04-26 12:03:44 +02:00
|
|
|
constructor(private _router: Router, private _authenticationService: AuthenticationService){
|
2016-03-13 12:28:29 +02:00
|
|
|
}
|
2016-03-12 19:11:19 +02:00
|
|
|
|
2016-03-13 12:28:29 +02:00
|
|
|
ngOnInit() {
|
2016-04-09 18:06:29 +02:00
|
|
|
this._authenticationService.OnAuthenticated.on((user:User) => {
|
|
|
|
if (this._router.isRouteActive(this._router.generate(['Login']))) {
|
|
|
|
console.log("routing");
|
|
|
|
this._router.navigate(["Gallery",{directory:""}]);
|
|
|
|
}
|
2016-03-13 12:28:29 +02:00
|
|
|
});
|
2016-04-18 21:27:15 +02:00
|
|
|
|
2016-03-19 10:58:27 +02:00
|
|
|
|
2016-03-12 19:11:19 +02:00
|
|
|
}
|
2016-03-12 15:57:22 +02:00
|
|
|
}
|