Project

General

Profile

1
/**
2
 * Created by stefania on 10/3/16.
3
 */
4
import {Component, OnInit} from "@angular/core";
5
import {NavigationEnd, Router} from "@angular/router";
6
import { AuthenticationService } from './services/authentication.service';
7

    
8
@Component({
9
  selector: 'openaire-dashboard',
10
  templateUrl: './app.component.html',
11
})
12

    
13
export class AppComponent implements OnInit {
14

    
15
  constructor(private router: Router,private authService: AuthenticationService) {
16
    /*disabling console.log in production*/
17
    if ( process.env.PRODUCTION === true ) {
18
      console.log = function () {};
19
    }
20

    
21
    // URL of the SPA to redirect the user to after login
22
    //this.authService.redirectUrl = "/dashboard";
23

    
24
    if (window.location.pathname.includes('/compatibility/browseHistory/')) {
25
      this.authService.redirectUrl = window.location.pathname;
26
      console.log('redirectUrl', this.authService.redirectUrl);
27
    }
28

    
29
    this.authService.tryLogin();
30
  }
31

    
32
  ngOnInit() {
33
    this.router.events.subscribe((evt) => {
34
      if (!(evt instanceof NavigationEnd)) {
35
        return;
36
      }
37
      window.scrollTo(0, 0);
38
    });
39
  }
40
}
(2-2/7)