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
|
constructor(private router: Router,
|
14
|
private authService: AuthenticationService,
|
15
|
private matomoInjector: MatomoInjector) {
|
16
|
|
17
|
console.log('11-02-2019. First deploy of project upgraded to angular 6');
|
18
|
|
19
|
let piwikUrl;
|
20
|
if (window.location.origin.includes('beta')) {
|
21
|
// piwikUrl = 'https://analytics.openaire.eu/piwik.php?idsite=92&rec=1';
|
22
|
piwikUrl = '92';
|
23
|
} else if (window.location.origin.includes('localhost:4200') ||
|
24
|
window.location.origin.includes('athenarc')) {
|
25
|
// piwikUrl = 'https://analytics.openaire.eu/piwik.php?idsite=92&rec=1';
|
26
|
piwikUrl = '9222222';
|
27
|
} else {
|
28
|
// piwikUrl = 'https://analytics.openaire.eu/piwik.php?idsite=111&rec=1';
|
29
|
piwikUrl = '111';
|
30
|
}
|
31
|
this.matomoInjector.init('https://analytics.openaire.eu/', piwikUrl);
|
32
|
|
33
|
/*disabling console.log in production*/
|
34
|
if ( environment.production === true ) {
|
35
|
console.log = function () {};
|
36
|
}
|
37
|
|
38
|
// URL of the SPA to redirect the user to after login
|
39
|
// this.authService.redirectUrl = "/dashboard";
|
40
|
|
41
|
if (window.location.pathname.includes('/compatibility/browseHistory/')) {
|
42
|
this.authService.redirectUrl = window.location.pathname;
|
43
|
console.log('redirectUrl', this.authService.redirectUrl);
|
44
|
}
|
45
|
|
46
|
this.authService.tryLogin();
|
47
|
}
|
48
|
|
49
|
ngOnInit() {
|
50
|
this.router.events.subscribe((evt) => {
|
51
|
/*if ((evt instanceof RoutesRecognized) && (environment.production === true)) {
|
52
|
let piwikUrl;
|
53
|
if (window.location.origin.includes('beta')) {
|
54
|
// piwikUrl = 'https://analytics.openaire.eu/piwik.php?idsite=92&rec=1';
|
55
|
piwikUrl = '92';
|
56
|
} else if (window.location.origin.includes('localhost:4200') ||
|
57
|
window.location.origin.includes('athenarc')) {
|
58
|
// piwikUrl = 'https://analytics.openaire.eu/piwik.php?idsite=92&rec=1';
|
59
|
piwikUrl = '9222222';
|
60
|
} else {
|
61
|
// piwikUrl = 'https://analytics.openaire.eu/piwik.php?idsite=111&rec=1';
|
62
|
piwikUrl = '111';
|
63
|
}
|
64
|
this.matomoInjector.init('https://analytics.openaire.eu/', piwikUrl);
|
65
|
}*/
|
66
|
|
67
|
if (!(evt instanceof NavigationEnd)) {
|
68
|
return;
|
69
|
}
|
70
|
window.scrollTo(0, 0);
|
71
|
});
|
72
|
}
|
73
|
|
74
|
}
|