2016-05-09 23:04:56 +08:00
|
|
|
import {Component, OnInit} from "@angular/core";
|
2016-12-27 06:36:38 +08:00
|
|
|
import {AuthenticationService} from "./model/network/authentication.service";
|
2016-12-27 23:09:47 +08:00
|
|
|
import {UserDTO} from "../../common/entities/UserDTO";
|
2016-12-27 06:36:38 +08:00
|
|
|
import {Router} from "@angular/router";
|
2016-03-12 21:57:22 +08:00
|
|
|
|
2017-06-22 03:16:04 +08:00
|
|
|
|
2016-03-12 21:57:22 +08:00
|
|
|
@Component({
|
2017-06-11 04:32:56 +08:00
|
|
|
selector: 'pi-gallery2-app',
|
|
|
|
template: `<router-outlet></router-outlet>`,
|
2016-12-27 06:36:38 +08:00
|
|
|
|
2016-03-12 21:57:22 +08:00
|
|
|
})
|
2016-05-09 23:04:56 +08:00
|
|
|
export class AppComponent implements OnInit {
|
2016-03-13 18:28:29 +08:00
|
|
|
|
2017-06-11 04:32:56 +08:00
|
|
|
constructor(private _router: Router, private _authenticationService: AuthenticationService) {
|
|
|
|
}
|
2016-03-13 01:11:19 +08:00
|
|
|
|
2017-06-11 04:32:56 +08:00
|
|
|
ngOnInit() {
|
2017-07-04 01:17:49 +08:00
|
|
|
this._authenticationService.user.subscribe((user: UserDTO) => {
|
2017-06-11 04:32:56 +08:00
|
|
|
if (user != null) {
|
|
|
|
if (this._router.isActive('login', true)) {
|
|
|
|
console.log("routing");
|
|
|
|
this._router.navigate(["gallery", ""]);
|
|
|
|
}
|
|
|
|
} else {
|
2017-07-08 04:54:18 +08:00
|
|
|
if (!this._router.isActive('login', true)) {
|
2017-06-11 04:32:56 +08:00
|
|
|
console.log("routing");
|
|
|
|
this._router.navigate(["login"]);
|
|
|
|
}
|
|
|
|
}
|
2016-05-17 05:15:03 +08:00
|
|
|
|
2017-06-11 04:32:56 +08:00
|
|
|
});
|
2016-05-09 23:04:56 +08:00
|
|
|
|
2016-03-19 16:58:27 +08:00
|
|
|
|
2017-06-11 04:32:56 +08:00
|
|
|
}
|
2017-06-22 03:16:04 +08:00
|
|
|
|
|
|
|
|
2017-06-11 04:32:56 +08:00
|
|
|
}
|