import { Component } from '@angular/core' ; import { OAuthService } from 'angular2-oauth2/oauth-service' ; import { Router , NavigationStart , NavigationEnd , NavigationCancel , NavigationError } from '@angular/router' ; import { LeaveComponentGuard } from "./shared/deactivation/leave-component-guard" ; import { CustomReuseStrategy } from "./shared/router/custom-reuse-strategy" ; @ Component ( { selector : 'flight-app' , templateUrl : './app.component.html' , styleUrls : [ './app.component.css' ] } ) export class AppComponent { public info : string = 'Welt' ; public showWaitInfo : boolean = false ; constructor ( private router , private oauthService , private leaveComponentGuard ) { router . events . subscribe ( ( event ) => { console . debug ( 'router-event' , event ) ; if ( event instanceof NavigationStart ) { this . showWaitInfo = true ; } if ( event instanceof NavigationEnd || event instanceof NavigationCancel || event instanceof NavigationError ) { this . showWaitInfo = false ; } } ) ; leaveComponentGuard . guardStated . subscribe ( _ => { this . showWaitInfo = false ; } ) ; leaveComponentGuard . guardFinished . subscribe ( _ => { this . showWaitInfo = true ; } ) ; oauthService . loginUrl = '' ; this . oauthService . loginUrl = 'https://steyer-identity-server.azurewebsites.net/identity/connect/authorize' ; this . oauthService . redirectUri = window . location . origin + '/index.html' ; this . oauthService . clientId = 'spa-demo' ; this . oauthService . issuer = 'https://steyer-identity-server.azurewebsites.net/identity' ; this . oauthService . scope = 'openid profile email voucher' ; this . oauthService . oidc = true ; this . oauthService . setStorage ( sessionStorage ) ; this . oauthService . logoutUrl = 'https://steyer-identity-server.azurewebsites.net/identity/connect/endsession?id_token={{id_token}}' ; this . oauthService . tryLogin ( { } ) ; } goHome ( ) { this . router . navigate ( [ '/home' ] ) ; } activateExpertMode ( ) { let queryParams = { expertMode : 'true' } ; this . router . navigate ( [ ] , { queryParams } ) ; } deactivateExpertMode ( ) { let queryParams = { expertMode : 'false' } ; this . router . navigate ( [ ] , { queryParams } ) ; } }