From 927c693a6faf86f77f6cbf6dfad4b1b5821df944 Mon Sep 17 00:00:00 2001 From: tanshu Date: Wed, 13 Jun 2018 12:19:46 +0530 Subject: [PATCH] Enabled page refreshing so that ledger and other reports can refresh by clicking show. Fixed: Auth interceptor was swallowing the error. --- overlord/src/app/app-routing.module.ts | 6 ++++-- overlord/src/app/core/error-logger.service.ts | 4 ++-- overlord/src/app/core/http-auth-interceptor.ts | 8 ++++---- 3 files changed, 10 insertions(+), 8 deletions(-) diff --git a/overlord/src/app/app-routing.module.ts b/overlord/src/app/app-routing.module.ts index 8bd37ae3..2ba6099a 100644 --- a/overlord/src/app/app-routing.module.ts +++ b/overlord/src/app/app-routing.module.ts @@ -16,8 +16,10 @@ const appRoutes: Routes = [ CommonModule, RouterModule.forRoot( appRoutes, - // {enableTracing: true} // <-- debugging purposes only - {} // <-- debugging purposes only + { + onSameUrlNavigation: 'reload', + // enableTracing: true <-- debugging purposes only + } ) ], exports: [RouterModule], diff --git a/overlord/src/app/core/error-logger.service.ts b/overlord/src/app/core/error-logger.service.ts index c49cf7ed..1bba940c 100644 --- a/overlord/src/app/core/error-logger.service.ts +++ b/overlord/src/app/core/error-logger.service.ts @@ -1,5 +1,6 @@ import {Injectable} from '@angular/core'; import {Observable} from 'rxjs/internal/Observable'; +import {throwError} from 'rxjs'; @Injectable({ providedIn: 'root' @@ -25,12 +26,11 @@ export class ErrorLoggerService { // // Let the app keep running by returning an empty result. // return of(result as T); - return Observable.create(subscriber => subscriber.error(error)); + return throwError(error); }; } public log(serviceName = 'error-logger', message: string) { console.log(serviceName + 'Service: ' + message); } - } diff --git a/overlord/src/app/core/http-auth-interceptor.ts b/overlord/src/app/core/http-auth-interceptor.ts index d8766067..ca667e8a 100644 --- a/overlord/src/app/core/http-auth-interceptor.ts +++ b/overlord/src/app/core/http-auth-interceptor.ts @@ -1,7 +1,7 @@ import {Injectable} from '@angular/core'; import {HttpEvent, HttpHandler, HttpInterceptor, HttpRequest} from '@angular/common/http'; -import {Observable, ObservableInput, of as observableOf} from 'rxjs'; +import {Observable, throwError} from 'rxjs'; import {catchError} from 'rxjs/operators'; import {ToasterService} from './toaster.service'; import {Router} from '@angular/router'; @@ -18,8 +18,8 @@ export class HttpAuthInterceptor implements HttpInterceptor { Observable> { return next.handle(req) .pipe( - catchError((err: any, caught: Observable): ObservableInput<{}> => { - if (err.status === 401) { + catchError((error: any) => { + if (error.status === 401) { this.toaster.show('Danger', 'User has been logged out'); const dialogRef = this.dialog.open(ConfirmDialogComponent, { width: '250px', @@ -34,7 +34,7 @@ export class HttpAuthInterceptor implements HttpInterceptor { } }); } - return observableOf(caught); + return throwError(error); } ) );