1
0
mirror of https://github.com/bpatrik/pigallery2.git synced 2024-12-14 11:23:17 +02:00
pigallery2/frontend/app/app.component.ts

52 lines
1.4 KiB
TypeScript
Raw Normal View History

2016-03-14 12:07:08 +02:00
///<reference path="../../typings/browser.d.ts"/>
2016-03-12 19:11:19 +02:00
2016-03-12 15:57:22 +02:00
import { Component } from 'angular2/core';
import { RouteConfig, ROUTER_DIRECTIVES, ROUTER_PROVIDERS } from 'angular2/router';
import {LoginComponent} from "./login/login.component";
2016-03-12 23:19:24 +02:00
import {NetworkService} from "./model/network.service";
import {LoginService} from "./login/login.service";
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";
import {Router} from "angular2/router";
2016-03-12 15:57:22 +02:00
2016-03-12 19:11:19 +02:00
2016-03-12 15:57:22 +02:00
@Component({
selector: 'pi-gallery2-app',
template: `<router-outlet></router-outlet>`,
directives: [ROUTER_DIRECTIVES],
providers: [
2016-03-12 23:19:24 +02:00
ROUTER_PROVIDERS,
NetworkService,
2016-03-13 12:28:29 +02:00
AuthenticationService,
2016-03-12 23:19:24 +02:00
LoginService
2016-03-12 15:57:22 +02:00
]
})
@RouteConfig([
{
path: '/login',
name: 'Login',
component: LoginComponent,
useAsDefault: true
2016-03-13 12:28:29 +02:00
},
{
path: '/gallery',
name: 'Gallery',
component: GalleryComponent
2016-03-12 15:57:22 +02:00
}
])
2016-03-13 12:28:29 +02:00
export class AppComponent implements OnInit{
constructor(private _router: Router ,private _authenticationService: AuthenticationService){
}
2016-03-12 19:11:19 +02:00
2016-03-13 12:28:29 +02:00
ngOnInit() {
this._authenticationService.OnAuthenticated.on((user:User) =>
{
this._router.navigate(["Gallery"]);
});
2016-03-12 19:11:19 +02:00
}
2016-03-12 15:57:22 +02:00
}