forked from linnovate/mean
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request linnovate#1969 from arturovt/upgrade-ng8
feat: upgrade Angular to the latest 8 version
- Loading branch information
Showing
18 changed files
with
4,033 additions
and
3,927 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,20 @@ | ||
import {HttpEvent, HttpInterceptor, HttpHandler, HttpRequest} from '@angular/common/http'; | ||
import {Observable} from 'rxjs/Observable'; | ||
import {TokenStorage} from '../auth/token.storage'; | ||
import { Injectable } from '@angular/core'; | ||
import { HttpEvent, HttpInterceptor, HttpHandler, HttpRequest } from '@angular/common/http'; | ||
import { Observable } from 'rxjs'; | ||
|
||
import { TokenStorage } from '../auth/token.storage'; | ||
|
||
@Injectable() | ||
export class AuthHeaderInterceptor implements HttpInterceptor { | ||
intercept(req : HttpRequest <any>, next : HttpHandler) : Observable <HttpEvent<any>> { | ||
// Clone the request to add the new header | ||
const token = new TokenStorage(); | ||
const tokenVal = token.getToken(); | ||
const clonedRequest = req.clone({ | ||
headers: req | ||
.headers | ||
.set('Authorization', tokenVal ? `Bearer ${ tokenVal}` : '') | ||
}); | ||
intercept(req: HttpRequest<any>, next: HttpHandler): Observable<HttpEvent<any>> { | ||
// Clone the request to add the new header | ||
const token = new TokenStorage(); | ||
const tokenVal = token.getToken(); | ||
const clonedRequest = req.clone({ | ||
headers: req.headers.set('Authorization', tokenVal ? `Bearer ${tokenVal}` : '') | ||
}); | ||
|
||
// Pass the cloned request instead of the original request to the next handle | ||
return next.handle(clonedRequest); | ||
} | ||
} | ||
// Pass the cloned request instead of the original request to the next handle | ||
return next.handle(clonedRequest); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,27 @@ | ||
import {HttpEvent, HttpInterceptor, HttpHandler, HttpRequest, HttpErrorResponse} from '@angular/common/http'; | ||
import {Observable} from 'rxjs/Observable'; | ||
|
||
import 'rxjs/add/operator/do'; | ||
import { Injectable } from '@angular/core'; | ||
import { | ||
HttpEvent, | ||
HttpInterceptor, | ||
HttpHandler, | ||
HttpRequest, | ||
HttpErrorResponse | ||
} from '@angular/common/http'; | ||
import { Observable, throwError } from 'rxjs'; | ||
import { catchError } from 'rxjs/operators'; | ||
|
||
@Injectable() | ||
export class CatchErrorInterceptor implements HttpInterceptor { | ||
intercept(request : HttpRequest < any >, next : HttpHandler) : Observable < HttpEvent < any >> { | ||
|
||
return next | ||
.handle(request) | ||
.do | ||
((event : HttpEvent < any >) => {}, (err : any) => { | ||
if (err instanceof HttpErrorResponse) { | ||
let text = (err.error && err.error.message) ? err.error.message : err.statusText; | ||
(<any>window).globalEvents.emit('open error dialog', text); | ||
} | ||
}); | ||
intercept(request: HttpRequest<any>, next: HttpHandler): Observable<HttpEvent<any>> { | ||
return next.handle(request).pipe( | ||
catchError(error => { | ||
if (error instanceof HttpErrorResponse) { | ||
const text = | ||
error.error && error.error.message ? error.error.message : error.statusText; | ||
(<any>window).globalEvents.emit('open error dialog', text); | ||
} | ||
|
||
} | ||
} | ||
return throwError(error); | ||
}) | ||
); | ||
} | ||
} |
Oops, something went wrong.