handling for RED-2651
This commit is contained in:
parent
dac628afaf
commit
a81e22c083
@ -28,6 +28,7 @@ import { FormsModule, ReactiveFormsModule } from '@angular/forms';
|
|||||||
import { MatButtonModule } from '@angular/material/button';
|
import { MatButtonModule } from '@angular/material/button';
|
||||||
import { MatDialogModule } from '@angular/material/dialog';
|
import { MatDialogModule } from '@angular/material/dialog';
|
||||||
import { CapitalizePipe } from './utils/pipes/capitalize.pipe';
|
import { CapitalizePipe } from './utils/pipes/capitalize.pipe';
|
||||||
|
import {KeycloakAngularModule} from 'keycloak-angular';
|
||||||
|
|
||||||
const matModules = [MatIconModule, MatProgressSpinnerModule, MatButtonModule, MatDialogModule];
|
const matModules = [MatIconModule, MatProgressSpinnerModule, MatButtonModule, MatDialogModule];
|
||||||
const modules = [
|
const modules = [
|
||||||
@ -55,7 +56,7 @@ const pipes = [SortByPipe, HumanizePipe, CapitalizePipe];
|
|||||||
|
|
||||||
@NgModule({
|
@NgModule({
|
||||||
declarations: [...components, ...pipes, LogPipe],
|
declarations: [...components, ...pipes, LogPipe],
|
||||||
imports: [CommonModule, ...matModules, ...modules, FormsModule, ReactiveFormsModule],
|
imports: [CommonModule, ...matModules, ...modules, FormsModule, ReactiveFormsModule, KeycloakAngularModule],
|
||||||
exports: [...components, ...pipes, ...modules, LogPipe],
|
exports: [...components, ...pipes, ...modules, LogPipe],
|
||||||
})
|
})
|
||||||
export class CommonUiModule {}
|
export class CommonUiModule {}
|
||||||
|
|||||||
@ -1,5 +1,5 @@
|
|||||||
<ng-container *ngIf="errorService.error$ | async as error">
|
<ng-container *ngIf="errorService.error$ | async as error">
|
||||||
<ng-container *ngIf="error.status === 0; else serverError">
|
<ng-container *ngIf="error.status === 0 || error.status === 502; else serverError">
|
||||||
<div class="offline-box flex-align-items-center" [@animateOpenClose]="'open'">
|
<div class="offline-box flex-align-items-center" [@animateOpenClose]="'open'">
|
||||||
<mat-icon svgIcon="iqser:offline"></mat-icon>
|
<mat-icon svgIcon="iqser:offline"></mat-icon>
|
||||||
|
|
||||||
|
|||||||
@ -24,4 +24,5 @@ export class FullPageErrorComponent {
|
|||||||
reload(): void {
|
reload(): void {
|
||||||
window.location.reload();
|
window.location.reload();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -4,6 +4,7 @@ import { MonoTypeOperatorFunction, Observable, throwError, timer } from 'rxjs';
|
|||||||
import { catchError, mergeMap, retryWhen, tap } from 'rxjs/operators';
|
import { catchError, mergeMap, retryWhen, tap } from 'rxjs/operators';
|
||||||
import { MAX_RETRIES_ON_SERVER_ERROR } from './max-retries.token';
|
import { MAX_RETRIES_ON_SERVER_ERROR } from './max-retries.token';
|
||||||
import { ErrorService } from './error.service';
|
import { ErrorService } from './error.service';
|
||||||
|
import { KeycloakService } from 'keycloak-angular';
|
||||||
|
|
||||||
function updateSeconds(seconds: number) {
|
function updateSeconds(seconds: number) {
|
||||||
if (seconds === 0 || seconds === 1) {
|
if (seconds === 0 || seconds === 1) {
|
||||||
@ -35,12 +36,19 @@ function backoffOnServerError(maxRetries = 3): MonoTypeOperatorFunction<HttpEven
|
|||||||
export class ServerErrorInterceptor implements HttpInterceptor {
|
export class ServerErrorInterceptor implements HttpInterceptor {
|
||||||
constructor(
|
constructor(
|
||||||
private readonly _errorService: ErrorService,
|
private readonly _errorService: ErrorService,
|
||||||
|
private readonly _keycloakService: KeycloakService,
|
||||||
@Optional() @Inject(MAX_RETRIES_ON_SERVER_ERROR) private readonly _maxRetries: number,
|
@Optional() @Inject(MAX_RETRIES_ON_SERVER_ERROR) private readonly _maxRetries: number,
|
||||||
) {}
|
) {
|
||||||
|
}
|
||||||
|
|
||||||
intercept(req: HttpRequest<unknown>, next: HttpHandler): Observable<HttpEvent<unknown>> {
|
intercept(req: HttpRequest<unknown>, next: HttpHandler): Observable<HttpEvent<unknown>> {
|
||||||
return next.handle(req).pipe(
|
return next.handle(req).pipe(
|
||||||
catchError((error: HttpErrorResponse) => {
|
catchError((error: HttpErrorResponse) => {
|
||||||
|
// token expired
|
||||||
|
if (error.status === 403) {
|
||||||
|
this._keycloakService.logout();
|
||||||
|
}
|
||||||
|
// server error
|
||||||
if (error.status >= 500 || error.status === 0) {
|
if (error.status >= 500 || error.status === 0) {
|
||||||
this._errorService.set(error);
|
this._errorService.set(error);
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user