2022-03-15 10:15:06 +00:00
|
|
|
import { Component } from '@angular/core';
|
2022-03-15 20:45:41 +00:00
|
|
|
import { NavigationEnd, Router } from '@angular/router';
|
2022-03-16 18:52:16 +00:00
|
|
|
import { TokenStorageService } from './Services/token.service';
|
2022-03-15 20:45:41 +00:00
|
|
|
import { filter } from 'rxjs/operators';
|
2022-03-15 10:15:06 +00:00
|
|
|
|
|
|
|
@Component({
|
|
|
|
selector: 'app-root',
|
|
|
|
templateUrl: './app.component.html',
|
2022-03-15 20:45:41 +00:00
|
|
|
styleUrls: ['./app.component.scss'],
|
2022-03-15 10:15:06 +00:00
|
|
|
})
|
|
|
|
export class AppComponent {
|
2022-03-15 20:45:41 +00:00
|
|
|
/**
|
|
|
|
* Application title.
|
|
|
|
*/
|
2022-03-15 10:15:06 +00:00
|
|
|
title = 'Aktienbot';
|
2022-03-15 20:45:41 +00:00
|
|
|
showHeader = false;
|
|
|
|
|
2022-03-16 18:52:16 +00:00
|
|
|
isLoggedIn = false;
|
|
|
|
|
2022-03-15 20:45:41 +00:00
|
|
|
/**
|
|
|
|
* Router import to show router-outlet.
|
|
|
|
*
|
|
|
|
* @param router Router
|
|
|
|
*/
|
2022-03-16 18:52:16 +00:00
|
|
|
constructor(
|
|
|
|
private router: Router,
|
|
|
|
private tokenStorage: TokenStorageService
|
|
|
|
) {
|
2022-03-15 20:45:41 +00:00
|
|
|
this.router.events
|
|
|
|
.pipe(filter((event) => event instanceof NavigationEnd))
|
|
|
|
.subscribe((event) => {
|
|
|
|
this.showHeader = !(
|
|
|
|
(event as NavigationEnd).url === '/login' ||
|
|
|
|
(event as NavigationEnd).url === '/register'
|
|
|
|
);
|
2022-03-19 18:55:42 +00:00
|
|
|
// if (this.tokenStorage.getToken()) {
|
|
|
|
// this.isLoggedIn = true;
|
|
|
|
// } else {
|
|
|
|
// this.isLoggedIn = false;
|
|
|
|
// }
|
|
|
|
// if (
|
|
|
|
// this.isLoggedIn === false &&
|
|
|
|
// (event as NavigationEnd).url != '/register'
|
|
|
|
// ) {
|
|
|
|
// this.router.navigate(['/login']);
|
|
|
|
// }
|
2022-03-15 20:45:41 +00:00
|
|
|
});
|
|
|
|
}
|
2022-03-15 10:15:06 +00:00
|
|
|
}
|