import { Component, AfterViewInit } 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'; // https://github.com/Teradata/covalent-quickstart/tree/develop/src/app // https://teradata.github.io/covalent-quickstart/#/ @Component({ selector: 'my-app', template: `` }) export class AppComponent implements AfterViewInit { constructor(private userService: UserService, private router: Router, private media: TdMediaService, private _iconRegistry: MdIconRegistry, private _domSanitizer: DomSanitizer, private store: LocalStorageService) { this.registerIcons(); } private registerIcons() : void { this._iconRegistry.addSvgIconInNamespace('assets', 'covalent', this._domSanitizer.bypassSecurityTrustResourceUrl('https://raw.githubusercontent.com/Teradata/covalent-quickstart/develop/src/assets/icons/covalent.svg')); this._iconRegistry.addSvgIconInNamespace('assets', 'teradata', this._domSanitizer.bypassSecurityTrustResourceUrl('assets/icons/teradata.svg')); this._iconRegistry.addSvgIconInNamespace('assets', 'github', this._domSanitizer.bypassSecurityTrustResourceUrl('assets/icons/github.svg')); this._iconRegistry.addSvgIconInNamespace('assets', 'covalent', this._domSanitizer.bypassSecurityTrustResourceUrl('assets/icons/covalent.svg')); this._iconRegistry.addSvgIconInNamespace('assets', 'covalent-mark', this._domSanitizer.bypassSecurityTrustResourceUrl('assets/icons/covalent-mark.svg')); this._iconRegistry.addSvgIconInNamespace('assets', 'teradata-ux', this._domSanitizer.bypassSecurityTrustResourceUrl('assets/icons/teradata-ux.svg')); this._iconRegistry.addSvgIconInNamespace('assets', 'appcenter', this._domSanitizer.bypassSecurityTrustResourceUrl('assets/icons/appcenter.svg')); this._iconRegistry.addSvgIconInNamespace('assets', 'listener', this._domSanitizer.bypassSecurityTrustResourceUrl('assets/icons/listener.svg')); this._iconRegistry.addSvgIconInNamespace('assets', 'querygrid', this._domSanitizer.bypassSecurityTrustResourceUrl('assets/icons/querygrid.svg')); } ngAfterViewInit(): void { this.media.broadcast(); this.userService.isLoggedIn().subscribe(authOk => { this.router.navigateByUrl(authOk ? 'packs' : 'login'); }, err => /* Show message */ this.router.navigateByUrl('login')); } }