blob: e301b46f3d92eb91318501602561e9417af95923 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
|
import { AfterViewInit, Component, OnInit } from '@angular/core';
import { Title } from '@angular/platform-browser';
import { Router, NavigationEnd, ActivatedRoute } from '@angular/router';
import { filter, map } from 'rxjs';
import { AuthService } from './_services/auth.service';
import { SignalRService } from './_services/signal-r.service';
import { HttpClient } from '@angular/common/http';
import Shared from './Shared';
@Component({
selector: 'app-root',
templateUrl: './app.component.html',
styleUrls: ['./app.component.css']
})
export class AppComponent implements OnInit, AfterViewInit {
constructor(private router: Router, private titleService: Title, private authService: AuthService, private signalRService: SignalRService, private http: HttpClient) {
}
ngAfterViewInit(): void {
}
ngOnInit() {
this.router.events
.pipe(
filter((event) => event instanceof NavigationEnd),
map(() => {
let route: ActivatedRoute = this.router.routerState.root;
let routeTitle = '';
while (route!.firstChild) {
route = route.firstChild;
}
if (route.snapshot.data['title']) {
routeTitle = route!.snapshot.data['title'];
}
return routeTitle;
})
)
.subscribe((title: string) => {
if (title) {
this.titleService.setTitle(`${title} - Igrannonica`);
}
});
if (!this.authService.isAuthenticated()) {
if(!this.authService.alreadyGuest())
this.authService.addGuestToken();
}
this.signalRService.startConnection();
//this.startHttpRequest();
}
}
|