2016-05-09 17:04:56 +02:00
|
|
|
import {Component, OnInit} from "@angular/core";
|
2016-12-27 00:36:38 +02:00
|
|
|
import {AuthenticationService} from "./model/network/authentication.service";
|
2016-12-27 17:09:47 +02:00
|
|
|
import {UserDTO} from "../../common/entities/UserDTO";
|
2016-12-27 00:36:38 +02:00
|
|
|
import {Router} from "@angular/router";
|
2016-03-12 15:57:22 +02:00
|
|
|
|
|
|
|
@Component({
|
|
|
|
selector: 'pi-gallery2-app',
|
|
|
|
template: `<router-outlet></router-outlet>`,
|
2016-12-27 00:36:38 +02:00
|
|
|
|
2016-03-12 15:57:22 +02:00
|
|
|
})
|
2016-05-09 17:04:56 +02:00
|
|
|
export class AppComponent implements OnInit {
|
2016-03-13 12:28:29 +02:00
|
|
|
|
2016-12-27 00:36:38 +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-12-27 17:09:47 +02:00
|
|
|
this._authenticationService.OnUserChanged.on((user: UserDTO) => {
|
2016-05-16 23:15:03 +02:00
|
|
|
if (user != null) {
|
2016-12-27 00:36:38 +02:00
|
|
|
if (this._router.isActive('login', true)) {
|
2016-05-16 23:15:03 +02:00
|
|
|
console.log("routing");
|
2016-12-27 00:36:38 +02:00
|
|
|
this._router.navigate(["gallery", ""]);
|
2016-05-16 23:15:03 +02:00
|
|
|
}
|
|
|
|
} else {
|
2016-12-27 00:36:38 +02:00
|
|
|
if (this._router.isActive('login', true)) {
|
2016-05-16 23:15:03 +02:00
|
|
|
console.log("routing");
|
2016-12-27 00:36:38 +02:00
|
|
|
this._router.navigate(["login"]);
|
2016-05-16 23:15:03 +02:00
|
|
|
}
|
2016-04-09 18:06:29 +02:00
|
|
|
}
|
2016-05-16 23:15:03 +02:00
|
|
|
|
2016-03-13 12:28:29 +02:00
|
|
|
});
|
2016-05-09 17:04:56 +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
|
|
|
}
|