rsanchez
2017-03-02 3a29297e886c8f4cc247e065df9a60d6177514a2
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
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: `<router-outlet></router-outlet>` 
})
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'));
  }
}