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
    this.authService.tryLogin();
25
  }
26

    
27
  ngOnInit() {
28
    this.router.events.subscribe((evt) => {
29
      if (!(evt instanceof NavigationEnd)) {
30
        return;
31
      }
32
      window.scrollTo(0, 0);
33
    });
34
  }
35
}
(2-2/7)