From 407a3a282a21782c3c89147d999941fa542524be Mon Sep 17 00:00:00 2001 From: JWittmeyer Date: Mon, 25 Jul 2022 12:23:51 +0200 Subject: [PATCH 1/5] Removes retry from http failure --- src/app/base/interceptors/exception.interceptor.ts | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/app/base/interceptors/exception.interceptor.ts b/src/app/base/interceptors/exception.interceptor.ts index 023973e0..9719b3c0 100644 --- a/src/app/base/interceptors/exception.interceptor.ts +++ b/src/app/base/interceptors/exception.interceptor.ts @@ -9,17 +9,15 @@ import { import { Observable, throwError } from 'rxjs'; import { catchError, retry } from 'rxjs/operators'; import { NotificationService } from '../services/notification.service'; - @Injectable() export class ExceptionInterceptor implements HttpInterceptor { - constructor(private notificationService: NotificationService) {} + constructor(private notificationService: NotificationService) { } intercept( request: HttpRequest, next: HttpHandler ): Observable> { return next.handle(request).pipe( - retry(1), catchError((error: HttpErrorResponse) => { let message = ''; if (error.error instanceof ErrorEvent) { From 66bfa53ebe079c810da0e130527aa9db9acba6e1 Mon Sep 17 00:00:00 2001 From: JWittmeyer Date: Mon, 25 Jul 2022 16:03:15 +0200 Subject: [PATCH 2/5] Adds check for demo application --- src/app/app.component.ts | 11 +++++- src/app/app.module.ts | 4 ++- .../components/header/header.component.html | 2 +- .../components/header/header.component.ts | 4 ++- src/app/base/interceptors/DemoError.ts | 15 ++++++++ .../global-exception.interceptor.ts | 14 ++++++++ src/app/base/services/base/apollo-checker.ts | 36 +++++++++++++++++++ src/app/base/services/config-service.ts | 35 ++++++++++++++++++ .../services/config/config-apollo.service.ts | 32 ++++++++++++++++- .../base/services/config/config-queries.ts | 15 ++++++++ .../knowledge-bases-apollo.service.ts | 4 ++- .../notification-apollo.service.ts | 4 ++- .../organization-apollo.service.ts | 4 ++- .../project/project-apollo.service.ts | 4 ++- .../services/record/record-apollo.service.ts | 4 ++- .../weak-source/weak-source-apollo.service.ts | 4 ++- 16 files changed, 181 insertions(+), 11 deletions(-) create mode 100644 src/app/base/interceptors/DemoError.ts create mode 100644 src/app/base/interceptors/global-exception.interceptor.ts create mode 100644 src/app/base/services/base/apollo-checker.ts diff --git a/src/app/app.component.ts b/src/app/app.component.ts index 237978d0..9a41aa8f 100644 --- a/src/app/app.component.ts +++ b/src/app/app.component.ts @@ -38,7 +38,7 @@ export class AppComponent implements OnDestroy, OnInit { ) { } ngOnInit(): void { - this.configService.isManaged().pipe(first()).subscribe((v) => ConfigManager.initConfigManager(this.http, this.configService, v)); + this.initalRequests(); NotificationService.subscribeToNotification(this, { whitelist: ['notification_created', 'project_deleted', 'config_updated'], func: this.handleWebsocketNotification @@ -46,6 +46,15 @@ export class AppComponent implements OnDestroy, OnInit { this.initializeNotificationService(); this.initWithConfigManager(); } + + initalRequests() { + this.configService.isManaged().pipe(first()).subscribe((v) => ConfigManager.initConfigManager(this.http, this.configService, v)); + this.configService.isDemo().pipe(first()).subscribe((v) => ConfigManager.setIsDemo(v)); + this.configService.isAdmin().pipe(first()).subscribe((v) => ConfigManager.setIsAdmin(v)); + this.configService.getBlackWhiteDemo().pipe(first()).subscribe((v) => ConfigManager.setBlackWhiteListDemo(v)); + } + + initWithConfigManager() { if (!ConfigManager.isInit()) { diff --git a/src/app/app.module.ts b/src/app/app.module.ts index 9a00f549..87573ec5 100644 --- a/src/app/app.module.ts +++ b/src/app/app.module.ts @@ -1,10 +1,11 @@ import { HTTP_INTERCEPTORS, HttpClientModule } from '@angular/common/http'; -import { NgModule } from '@angular/core'; +import { ErrorHandler, NgModule } from '@angular/core'; import { BrowserModule } from '@angular/platform-browser'; import { AppRoutingModule } from './app-routing.module'; import { AppComponent } from './app.component'; import { BaseModule } from './base/base.module'; import { ExceptionInterceptor } from './base/interceptors/exception.interceptor'; +import { GlobalErrorHandler } from './base/interceptors/global-exception.interceptor'; import { NotificationService } from './base/services/notification.service'; import { DataModule } from './data/data.module'; import { ProjectsModule } from './projects/projects.module'; @@ -50,6 +51,7 @@ import { RecordIDEModule } from './record-ide/record-ide.module'; ], providers: [ { provide: HTTP_INTERCEPTORS, useClass: ExceptionInterceptor, multi: true }, + { provide: ErrorHandler, useClass: GlobalErrorHandler }, NotificationService, ], bootstrap: [AppComponent], diff --git a/src/app/base/components/header/header.component.html b/src/app/base/components/header/header.component.html index cca0133f..fef9fddd 100644 --- a/src/app/base/components/header/header.component.html +++ b/src/app/base/components/header/header.component.html @@ -59,7 +59,7 @@
-