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 { MatDialogModule } from '@angular/material/dialog';
|
||||
import { CapitalizePipe } from './utils/pipes/capitalize.pipe';
|
||||
import {KeycloakAngularModule} from 'keycloak-angular';
|
||||
|
||||
const matModules = [MatIconModule, MatProgressSpinnerModule, MatButtonModule, MatDialogModule];
|
||||
const modules = [
|
||||
@ -55,7 +56,7 @@ const pipes = [SortByPipe, HumanizePipe, CapitalizePipe];
|
||||
|
||||
@NgModule({
|
||||
declarations: [...components, ...pipes, LogPipe],
|
||||
imports: [CommonModule, ...matModules, ...modules, FormsModule, ReactiveFormsModule],
|
||||
imports: [CommonModule, ...matModules, ...modules, FormsModule, ReactiveFormsModule, KeycloakAngularModule],
|
||||
exports: [...components, ...pipes, ...modules, LogPipe],
|
||||
})
|
||||
export class CommonUiModule {}
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
<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'">
|
||||
<mat-icon svgIcon="iqser:offline"></mat-icon>
|
||||
|
||||
|
||||
@ -24,4 +24,5 @@ export class FullPageErrorComponent {
|
||||
reload(): void {
|
||||
window.location.reload();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -4,6 +4,7 @@ import { MonoTypeOperatorFunction, Observable, throwError, timer } from 'rxjs';
|
||||
import { catchError, mergeMap, retryWhen, tap } from 'rxjs/operators';
|
||||
import { MAX_RETRIES_ON_SERVER_ERROR } from './max-retries.token';
|
||||
import { ErrorService } from './error.service';
|
||||
import { KeycloakService } from 'keycloak-angular';
|
||||
|
||||
function updateSeconds(seconds: number) {
|
||||
if (seconds === 0 || seconds === 1) {
|
||||
@ -35,12 +36,19 @@ function backoffOnServerError(maxRetries = 3): MonoTypeOperatorFunction<HttpEven
|
||||
export class ServerErrorInterceptor implements HttpInterceptor {
|
||||
constructor(
|
||||
private readonly _errorService: ErrorService,
|
||||
private readonly _keycloakService: KeycloakService,
|
||||
@Optional() @Inject(MAX_RETRIES_ON_SERVER_ERROR) private readonly _maxRetries: number,
|
||||
) {}
|
||||
) {
|
||||
}
|
||||
|
||||
intercept(req: HttpRequest<unknown>, next: HttpHandler): Observable<HttpEvent<unknown>> {
|
||||
return next.handle(req).pipe(
|
||||
catchError((error: HttpErrorResponse) => {
|
||||
// token expired
|
||||
if (error.status === 403) {
|
||||
this._keycloakService.logout();
|
||||
}
|
||||
// server error
|
||||
if (error.status >= 500 || error.status === 0) {
|
||||
this._errorService.set(error);
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user