// #docregion
import { Component, OnInit }    from '@angular/core';
import { ActivatedRoute }       from '@angular/router';
import { Observable }           from 'rxjs/Observable';
import { PreloadSelectedModules } from '../selective-preload-strategy';
import 'rxjs/add/operator/map';
@Component({
  template:  `
    
Dashboard
    Session ID: {{ sessionId | async }}
    
    Token: {{ token | async }}
    Preloaded Modules
    
  `
})
export class AdminDashboardComponent implements OnInit {
  sessionId: Observable;
  token: Observable;
  modules: string[];
  constructor(
    private route: ActivatedRoute,
    private preloadStrategy: PreloadSelectedModules
  ) {
    this.modules = preloadStrategy.preloadedModules;
  }
  ngOnInit() {
    // Capture the session ID if available
    this.sessionId = this.route
      .queryParams
      .map(params => params['session_id'] || 'None');
    // Capture the fragment if available
    this.token = this.route
      .fragment
      .map(fragment => fragment || 'None');
  }
}