1
0
mirror of https://github.com/xuthus83/pigallery2.git synced 2025-01-14 14:43:17 +08:00
pigallery2/frontend/app/app.component.ts

38 lines
904 B
TypeScript
Raw Normal View History

2016-05-09 17:04:56 +02:00
import {Component, OnInit} from "@angular/core";
2016-12-26 23:36:38 +01:00
import {AuthenticationService} from "./model/network/authentication.service";
2016-12-27 16:09:47 +01:00
import {UserDTO} from "../../common/entities/UserDTO";
2016-12-26 23:36:38 +01:00
import {Router} from "@angular/router";
2016-03-12 14:57:22 +01:00
2017-06-21 21:16:04 +02:00
2016-03-12 14:57:22 +01:00
@Component({
selector: 'pi-gallery2-app',
template: `<router-outlet></router-outlet>`,
2016-12-26 23:36:38 +01:00
2016-03-12 14:57:22 +01:00
})
2016-05-09 17:04:56 +02:00
export class AppComponent implements OnInit {
2016-03-13 11:28:29 +01:00
constructor(private _router: Router, private _authenticationService: AuthenticationService) {
}
2016-03-12 18:11:19 +01:00
ngOnInit() {
2017-07-03 19:17:49 +02:00
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"]);
}
}
2016-05-16 23:15:03 +02:00
});
2016-05-09 17:04:56 +02:00
}
2017-06-21 21:16:04 +02:00
}