2019-01-18 18:03:45 +01:00
|
|
|
import { Component, OnInit } from '@angular/core';
|
|
|
|
import { ActivatedRoute, NavigationEnd, Router } from '@angular/router';
|
2017-12-14 11:41:26 +01:00
|
|
|
import { TranslateService } from '@ngx-translate/core';
|
2018-10-12 17:17:31 +02:00
|
|
|
import { Observable } from 'rxjs';
|
2018-08-30 13:09:36 +02:00
|
|
|
import { environment } from '../environments/environment';
|
2019-01-18 18:03:45 +01:00
|
|
|
import { AuthService } from './core/services/auth/auth.service';
|
|
|
|
import { CultureService } from './core/services/culture/culture-service';
|
|
|
|
import { BreadCrumbResolverService } from './ui/misc/breadcrumb/service/breadcrumb.service';
|
2017-09-14 12:37:36 +02:00
|
|
|
|
2017-11-08 14:33:14 +01:00
|
|
|
|
2017-11-27 11:52:52 +01:00
|
|
|
declare const gapi: any;
|
2017-12-19 18:34:00 +01:00
|
|
|
declare var $: any;
|
2019-01-18 18:03:45 +01:00
|
|
|
|
2017-09-14 12:37:36 +02:00
|
|
|
@Component({
|
2018-10-05 17:00:54 +02:00
|
|
|
selector: 'app-root',
|
|
|
|
templateUrl: './app.component.html',
|
2019-01-18 18:03:45 +01:00
|
|
|
styleUrls: ['./app.component.scss']
|
2017-09-14 12:37:36 +02:00
|
|
|
})
|
2017-11-02 15:19:12 +01:00
|
|
|
export class AppComponent implements OnInit {
|
2017-11-14 15:06:00 +01:00
|
|
|
|
2018-10-05 17:00:54 +02:00
|
|
|
hasBreadCrumb = Observable.of(false);
|
|
|
|
sideNavOpen = false;
|
2018-10-08 16:58:52 +02:00
|
|
|
helpContentEnabled = environment.HelpService.Enabled;
|
2018-10-05 17:00:54 +02:00
|
|
|
|
|
|
|
constructor(
|
|
|
|
private router: Router,
|
|
|
|
private route: ActivatedRoute,
|
|
|
|
private authentication: AuthService,
|
|
|
|
private translate: TranslateService,
|
|
|
|
private breadCrumbResolverService: BreadCrumbResolverService,
|
|
|
|
private cultureService: CultureService
|
|
|
|
) {
|
|
|
|
this.initializeServices();
|
|
|
|
}
|
|
|
|
|
|
|
|
onActivate(event: any) {
|
|
|
|
this.breadCrumbResolverService.push(event);
|
|
|
|
}
|
|
|
|
|
|
|
|
onDeactivate(event: any) {
|
|
|
|
//this.breadCrumbResolverService.clear()
|
|
|
|
}
|
|
|
|
|
|
|
|
ngOnInit() {
|
|
|
|
this.hasBreadCrumb = this.router.events
|
|
|
|
.filter(event => event instanceof NavigationEnd)
|
|
|
|
.map(() => this.route)
|
|
|
|
.map(route => route.firstChild)
|
|
|
|
.switchMap(route => route.data)
|
|
|
|
.map(data => data['breadcrumb']);
|
|
|
|
}
|
|
|
|
|
|
|
|
login() {
|
|
|
|
//redirect to login page
|
|
|
|
this.router.navigate(['/login'], { queryParams: { /*refresh : Math.random() ,returnUrl: this.state.url*/ } });
|
|
|
|
}
|
|
|
|
|
|
|
|
logout() {
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
public isAuthenticated(): boolean {
|
|
|
|
return !(!this.authentication.current());
|
|
|
|
}
|
|
|
|
|
|
|
|
goToDMPs() {
|
2019-01-18 18:03:45 +01:00
|
|
|
this.router.navigate(['/plans'], { queryParams: { /*refresh : Math.random() ,returnUrl: this.state.url*/ } });
|
2018-10-05 17:00:54 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
goToProjects() {
|
|
|
|
this.router.navigate(['/projects'], { queryParams: { /*refresh : Math.random() ,returnUrl: this.state.url*/ } });
|
|
|
|
}
|
|
|
|
|
|
|
|
initializeServices() {
|
|
|
|
this.translate.setDefaultLang('en');
|
|
|
|
this.authentication.current() && this.authentication.current().culture ? this.cultureService.cultureSelected(this.authentication.current().culture) : this.cultureService.cultureSelected(environment.defaultCulture);
|
|
|
|
}
|
2017-09-14 12:37:36 +02:00
|
|
|
}
|
2017-11-01 18:18:27 +01:00
|
|
|
|