mirror of
https://github.com/xuthus83/pigallery2.git
synced 2024-11-03 21:04:03 +08:00
41 lines
1.1 KiB
TypeScript
41 lines
1.1 KiB
TypeScript
import {Component, OnInit} 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";
|
|
|
|
|
|
@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) {
|
|
}
|
|
|
|
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"]);
|
|
}
|
|
}
|
|
|
|
});
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|