1
0
mirror of https://github.com/xuthus83/pigallery2.git synced 2024-11-03 21:04:03 +08:00
pigallery2/frontend/app/app.component.ts
2017-07-08 12:43:42 +02:00

46 lines
1.3 KiB
TypeScript

import {Component, OnInit, ViewContainerRef} from "@angular/core";
import {AuthenticationService} from "./model/network/authentication.service";
import {UserDTO} from "../../common/entities/UserDTO";
import {Router} from "@angular/router";
import {Config} from "../../common/config/public/Config";
import {Title} from "@angular/platform-browser";
import {NotificationService} from "./model/notification.service";
@Component({
selector: 'pi-gallery2-app',
template: `<router-outlet></router-outlet>`,
})
export class AppComponent implements OnInit {
constructor(private _router: Router,
private _authenticationService: AuthenticationService,
private _title: Title, vcr: ViewContainerRef,
notificatin: NotificationService) {
notificatin.setRootViewContainerRef(vcr);
}
ngOnInit() {
this._title.setTitle(Config.Client.applicationTitle);
this._authenticationService.user.subscribe((user: UserDTO) => {
if (user != null) {
if (this._router.isActive('login', true)) {
console.log("routing");
this._router.navigate(["gallery", ""]);
}
} else {
if (!this._router.isActive('login', true)) {
console.log("routing");
this._router.navigate(["login"]);
}
}
});
}
}