| .. | .. |
|---|
| 1 | | -import { Component } from '@angular/core'; |
|---|
| 1 | +import { Component, AfterViewInit } from '@angular/core'; |
|---|
| 2 | 2 | import { DomSanitizer } from '@angular/platform-browser'; |
|---|
| 3 | 3 | import { MdIconRegistry } from '@angular/material'; |
|---|
| 4 | +import { UserService } from './user.service'; |
|---|
| 5 | +import { LocalStorageService } from 'angular-2-local-storage'; |
|---|
| 6 | +import { TdMediaService } from '@covalent/core'; |
|---|
| 7 | +import { Router } from '@angular/router'; |
|---|
| 4 | 8 | |
|---|
| 5 | 9 | // https://github.com/Teradata/covalent-quickstart/tree/develop/src/app |
|---|
| 6 | 10 | // https://teradata.github.io/covalent-quickstart/#/ |
|---|
| .. | .. |
|---|
| 11 | 15 | }) |
|---|
| 12 | 16 | |
|---|
| 13 | 17 | |
|---|
| 14 | | -export class AppComponent { |
|---|
| 18 | +export class AppComponent implements AfterViewInit { |
|---|
| 15 | 19 | |
|---|
| 16 | | - constructor(private _iconRegistry: MdIconRegistry, |
|---|
| 17 | | - private _domSanitizer: DomSanitizer) { |
|---|
| 18 | | - |
|---|
| 20 | + constructor(private userService: UserService, |
|---|
| 21 | + private router: Router, |
|---|
| 22 | + private media: TdMediaService, |
|---|
| 23 | + private _iconRegistry: MdIconRegistry, |
|---|
| 24 | + private _domSanitizer: DomSanitizer, |
|---|
| 25 | + private store: LocalStorageService) { |
|---|
| 26 | + this.registerIcons(); |
|---|
| 27 | + } |
|---|
| 28 | + |
|---|
| 29 | + private registerIcons() : void { |
|---|
| 19 | 30 | this._iconRegistry.addSvgIconInNamespace('assets', 'covalent', |
|---|
| 20 | 31 | this._domSanitizer.bypassSecurityTrustResourceUrl('https://raw.githubusercontent.com/Teradata/covalent-quickstart/develop/src/assets/icons/covalent.svg')); |
|---|
| 21 | 32 | this._iconRegistry.addSvgIconInNamespace('assets', 'teradata', |
|---|
| .. | .. |
|---|
| 36 | 47 | this._domSanitizer.bypassSecurityTrustResourceUrl('assets/icons/querygrid.svg')); |
|---|
| 37 | 48 | } |
|---|
| 38 | 49 | |
|---|
| 50 | + ngAfterViewInit(): void { |
|---|
| 51 | + this.media.broadcast(); |
|---|
| 52 | + this.userService.isLoggedIn().subscribe(authOk => { |
|---|
| 53 | + this.router.navigateByUrl(authOk ? 'packs' : 'login'); |
|---|
| 54 | + }, |
|---|
| 55 | + err => /* Show message */ this.router.navigateByUrl('login')); |
|---|
| 56 | + } |
|---|
| 39 | 57 | } |
|---|