1
|
import { Component, OnInit } from '@angular/core';
|
2
|
import { NavigationEnd, Router, RoutesRecognized } from '@angular/router';
|
3
|
import { AuthenticationService } from './services/authentication.service';
|
4
|
import { environment } from '../environments/environment';
|
5
|
import { MatomoInjector } from 'ngx-matomo';
|
6
|
|
7
|
@Component({
|
8
|
selector: 'oa-repo-manager',
|
9
|
templateUrl: './app.component.html',
|
10
|
styleUrls: ['./app.component.css']
|
11
|
})
|
12
|
export class AppComponent implements OnInit {
|
13
|
piwikUrl: string;
|
14
|
|
15
|
constructor(private router: Router,
|
16
|
private authService: AuthenticationService,
|
17
|
private matomoInjector: MatomoInjector) {
|
18
|
|
19
|
/*disabling console.log in production*/
|
20
|
if ( environment.production === true ) {
|
21
|
console.log = function () {};
|
22
|
}
|
23
|
|
24
|
// URL of the SPA to redirect the user to after login
|
25
|
// this.authService.redirectUrl = "/dashboard";
|
26
|
|
27
|
if (window.location.pathname.includes('/compatibility/browseHistory/')) {
|
28
|
this.authService.redirectUrl = window.location.pathname;
|
29
|
console.log('redirectUrl', this.authService.redirectUrl);
|
30
|
}
|
31
|
|
32
|
this.authService.tryLogin();
|
33
|
}
|
34
|
|
35
|
ngOnInit() {
|
36
|
this.router.events.subscribe((evt) => {
|
37
|
if (evt instanceof RoutesRecognized) {
|
38
|
let piwikUrl;
|
39
|
if (window.location.origin.includes('beta')) {
|
40
|
// piwikUrl = 'https://analytics.openaire.eu/piwik.php?idsite=92&rec=1';
|
41
|
piwikUrl = '92';
|
42
|
} else {
|
43
|
// piwikUrl = 'https://analytics.openaire.eu/piwik.php?idsite=111&rec=1';
|
44
|
piwikUrl = '111';
|
45
|
}
|
46
|
this.matomoInjector.init('https://analytics.openaire.eu/', piwikUrl);
|
47
|
}
|
48
|
|
49
|
if (!(evt instanceof NavigationEnd)) {
|
50
|
return;
|
51
|
}
|
52
|
window.scrollTo(0, 0);
|
53
|
});
|
54
|
}
|
55
|
|
56
|
}
|