|
|
|
@ -1,7 +1,9 @@
|
|
|
|
|
import {Component, Inject} from '@angular/core';
|
|
|
|
|
import {TranslateService} from '@ngx-translate/core';
|
|
|
|
|
import {Router} from '@angular/router';
|
|
|
|
|
import {NavigationStart, Router} from '@angular/router';
|
|
|
|
|
import {DOCUMENT} from "@angular/common";
|
|
|
|
|
import {filter} from "rxjs/operators";
|
|
|
|
|
import {ConfigService} from "./services/config.service";
|
|
|
|
|
|
|
|
|
|
@Component({
|
|
|
|
|
selector: 'app-root',
|
|
|
|
@ -22,6 +24,7 @@ export class AppComponent {
|
|
|
|
|
step: string;
|
|
|
|
|
|
|
|
|
|
constructor(private translate: TranslateService,
|
|
|
|
|
private config : ConfigService,
|
|
|
|
|
@Inject(DOCUMENT) private document,
|
|
|
|
|
private route: Router) {
|
|
|
|
|
this.translate.setDefaultLang(this.currentLang);
|
|
|
|
@ -31,20 +34,16 @@ export class AppComponent {
|
|
|
|
|
|
|
|
|
|
detectCurrentTabOnRouteChange() {
|
|
|
|
|
this.route.events.subscribe((event: any) => {
|
|
|
|
|
this.scrollGoToTop();
|
|
|
|
|
|
|
|
|
|
console.log('event', event)
|
|
|
|
|
if (event.url) {
|
|
|
|
|
|
|
|
|
|
const tab = event.url.split('/');
|
|
|
|
|
if (tab && tab[2]) {
|
|
|
|
|
this.step = tab[2];
|
|
|
|
|
} else {
|
|
|
|
|
this.step = 'home';
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
this.route.events.pipe(filter(event => event instanceof NavigationStart)).subscribe((event:NavigationStart) => {
|
|
|
|
|
this.scrollGoToTop();
|
|
|
|
|
this.updateCurrentTab(event);
|
|
|
|
|
// only if there is a poll ID
|
|
|
|
|
this.config.fetchPollFromRoute(event);
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
switchLanguage(language: string) {
|
|
|
|
@ -76,4 +75,15 @@ export class AppComponent {
|
|
|
|
|
scrollGoToTop() {
|
|
|
|
|
this.document.documentElement.scrollTop = 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
updateCurrentTab(event){
|
|
|
|
|
if (event.url) {
|
|
|
|
|
const tab = event.url.split('/');
|
|
|
|
|
if (tab && tab[2]) {
|
|
|
|
|
this.step = tab[2];
|
|
|
|
|
} else {
|
|
|
|
|
this.step = 'home';
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|