import { Observable } from 'rxjs/Observable'; import { BaseRequestOptions, Http } from '@angular/http'; import { ToastsManager } from 'ng2-toastr/ng2-toastr'; import { AfterViewInit, Component, ViewContainerRef, ViewChild } from '@angular/core'; import { DomSanitizer } from '@angular/platform-browser'; import { MdIconRegistry } from '@angular/material'; import { UserService } from './user.service'; import { LocalStorageService } from 'angular-2-local-storage'; import { TdMediaService } from '@covalent/core'; import { Router } from '@angular/router'; import { TdNavigationDrawerComponent } from '@covalent/core' // https://github.com/Teradata/covalent-quickstart/tree/develop/src/app // https://teradata.github.io/covalent-quickstart/#/ @Component({ selector: 'app-home', templateUrl: 'src/app/home.component.html' }) export class HomeComponent implements AfterViewInit { @ViewChild('varName') child: TdNavigationDrawerComponent; securisVersion : string; showMenu : boolean = false; constructor(private userService: UserService, toaster: ToastsManager, vRef: ViewContainerRef, private router: Router, http: Http, private media: TdMediaService, private _iconRegistry: MdIconRegistry, private _domSanitizer: DomSanitizer, private store: LocalStorageService) { this.registerIcons(); toaster.setRootViewContainerRef(vRef); http.get("version", /* workaround to avoid OPTIONS method request*/ new BaseRequestOptions()) .map((res) => res.json().version) .subscribe( version => this.securisVersion = version, err => this.securisVersion = '0.0.0' ); } private registerIcons() : void { this._iconRegistry.addSvgIconInNamespace('assets', 'logo', this._domSanitizer.bypassSecurityTrustResourceUrl('assets/securis_logo.svg')); this._iconRegistry.addSvgIconInNamespace('assets', 'logo-bw', this._domSanitizer.bypassSecurityTrustResourceUrl('assets/securis_logo_bw.svg')); this._iconRegistry.addSvgIconInNamespace('assets', 'logo-white', this._domSanitizer.bypassSecurityTrustResourceUrl('assets/securis_logo_white.svg')); this._iconRegistry.addSvgIconInNamespace('assets', 'logo-black', this._domSanitizer.bypassSecurityTrustResourceUrl('assets/securis_logo_black.svg')); } public clicked() { //this.child.open(); } ngAfterViewInit(): void { // this.showMenu = true; this.media.broadcast(); this.userService.isLoggedIn().subscribe(authOk => { //this.showMenu = authOk.valueOf(); this.router.navigateByUrl(authOk ? 'packs' : 'login'); }, err => /* Show message */ this.router.navigateByUrl('login')); } }