From ee00fb2c53cbb725ce715c7bbc8e8675c140bbcc Mon Sep 17 00:00:00 2001 From: amentis Date: Wed, 10 Jul 2024 13:10:28 +0300 Subject: [PATCH] frontend code clean up --- frontend/src/app/app.component.ts | 4 -- .../description-template-editor.resolver.ts | 1 - frontend/src/app/ui/admin/user/user.module.ts | 1 - .../editor/description-editor.component.ts | 4 -- .../plan-editor.model.ts | 1 - .../errors-component/errors.component.html | 34 ------------- .../errors-component/errors.component.scss | 14 ----- .../errors-component/errors.component.ts | 21 -------- .../errors/errors-handler/errors-handler.ts | 51 ------------------- .../errors-routing/errors-routing.module.ts | 14 ----- .../common/modules/errors/errors.module.ts | 34 ------------- .../external-tracing/external-trace-entry.ts | 20 -------- .../server-errors.interceptor.ts | 13 ----- 13 files changed, 212 deletions(-) delete mode 100644 frontend/src/common/modules/errors/errors-component/errors.component.html delete mode 100644 frontend/src/common/modules/errors/errors-component/errors.component.scss delete mode 100644 frontend/src/common/modules/errors/errors-component/errors.component.ts delete mode 100644 frontend/src/common/modules/errors/errors-handler/errors-handler.ts delete mode 100644 frontend/src/common/modules/errors/errors-routing/errors-routing.module.ts delete mode 100644 frontend/src/common/modules/errors/errors.module.ts delete mode 100644 frontend/src/common/modules/errors/external-tracing/external-trace-entry.ts delete mode 100644 frontend/src/common/modules/errors/server-errors-interceptor/server-errors.interceptor.ts diff --git a/frontend/src/app/app.component.ts b/frontend/src/app/app.component.ts index 008a58f39..b8808fd64 100644 --- a/frontend/src/app/app.component.ts +++ b/frontend/src/app/app.component.ts @@ -252,10 +252,6 @@ export class AppComponent implements OnInit, AfterViewInit { return this.authentication.currentAccountIsAuthenticated(); } - goToPlans() { //not used - this.router.navigate(['/plans'], { queryParams: { /*refresh : Math.random() ,returnUrl: this.state.url*/ } }); - } - initializeServices() { if (!this.authentication.currentAccountIsAuthenticated() && this.configurationService.cssColorsTenantConfiguration) { diff --git a/frontend/src/app/ui/admin/description-template/editor/description-template-editor.resolver.ts b/frontend/src/app/ui/admin/description-template/editor/description-template-editor.resolver.ts index 143319a6b..0d5487c09 100644 --- a/frontend/src/app/ui/admin/description-template/editor/description-template-editor.resolver.ts +++ b/frontend/src/app/ui/admin/description-template/editor/description-template-editor.resolver.ts @@ -69,7 +69,6 @@ export class DescriptionTemplateEditorResolver extends BaseEditorResolver { [nameof(x => x.definition), nameof(x => x.pages), nameof(x => x.sections), nameof(x => x.fieldSets), nameof(x => x.fields), nameof(x => x.defaultValue), nameof(x => x.textValue)].join('.'), [nameof(x => x.definition), nameof(x => x.pages), nameof(x => x.sections), nameof(x => x.fieldSets), nameof(x => x.fields), nameof(x => x.defaultValue), nameof(x => x.dateValue)].join('.'), [nameof(x => x.definition), nameof(x => x.pages), nameof(x => x.sections), nameof(x => x.fieldSets), nameof(x => x.fields), nameof(x => x.defaultValue), nameof(x => x.booleanValue)].join('.'), - // [nameof(x => x.definition), nameof(x => x.sections), nameof(x => x.fieldSets), nameof(x => x.fields), nameof(x => x.fieldType)].join('.'), [nameof(x => x.definition), nameof(x => x.pages), nameof(x => x.sections), nameof(x => x.fieldSets), nameof(x => x.fields), nameof(x => x.includeInExport)].join('.'), [nameof(x => x.definition), nameof(x => x.pages), nameof(x => x.sections), nameof(x => x.fieldSets), nameof(x => x.fields), nameof(x => x.validations)].join('.'), diff --git a/frontend/src/app/ui/admin/user/user.module.ts b/frontend/src/app/ui/admin/user/user.module.ts index f9677b978..27347f5a0 100644 --- a/frontend/src/app/ui/admin/user/user.module.ts +++ b/frontend/src/app/ui/admin/user/user.module.ts @@ -16,7 +16,6 @@ import { TenantUsersRoutingModule, UsersRoutingModule } from './user.routing'; @NgModule({ declarations: [ UserListingComponent, - // UserEditorComponent, UserRoleEditorComponent, UserListingFiltersComponent ], diff --git a/frontend/src/app/ui/description/editor/description-editor.component.ts b/frontend/src/app/ui/description/editor/description-editor.component.ts index edb1312d3..319eaf744 100644 --- a/frontend/src/app/ui/description/editor/description-editor.component.ts +++ b/frontend/src/app/ui/description/editor/description-editor.component.ts @@ -705,10 +705,6 @@ export class DescriptionEditorComponent extends BaseEditor -
-
-
-

ERROR {{ data?.error}}

-
Not found :(
- -
Go Home
-
-
- -
- -

ERROR {{ routeParams?.status }}


-

{{ routeParams?.message }}


-

Error in {{ routeParams?.url }} page, sorry :(

-

This error has been reported to the Administrator with the ID:
{{ routeParams?.id}}

- -
Go Back to {{routeParams?.url}}
-
- -
Go Back to home
-
-
- -
-

Unknown error, sorry :(

- -
Go Home
-
-
-
-
- diff --git a/frontend/src/common/modules/errors/errors-component/errors.component.scss b/frontend/src/common/modules/errors/errors-component/errors.component.scss deleted file mode 100644 index b4f6062e5..000000000 --- a/frontend/src/common/modules/errors/errors-component/errors.component.scss +++ /dev/null @@ -1,14 +0,0 @@ -h1, -h3, -h4, -h5 { - margin-bottom: 0; - margin-top: 10px; -} - -.error-container { - margin-top: auto; - margin-bottom: auto; - text-align: center; - overflow-wrap: break-word; -} diff --git a/frontend/src/common/modules/errors/errors-component/errors.component.ts b/frontend/src/common/modules/errors/errors-component/errors.component.ts deleted file mode 100644 index 7b6fc0155..000000000 --- a/frontend/src/common/modules/errors/errors-component/errors.component.ts +++ /dev/null @@ -1,21 +0,0 @@ -import { Component, OnInit } from '@angular/core'; -import { ActivatedRoute } from '@angular/router'; - -@Component({ - selector: 'app-error', - templateUrl: './errors.component.html', - styleUrls: ['./errors.component.scss'] -}) -export class ErrorsComponent implements OnInit { - routeParams; - data; - - constructor( - private activatedRoute: ActivatedRoute, - ) { } - - ngOnInit() { - this.routeParams = this.activatedRoute.snapshot.queryParams; - this.data = this.activatedRoute.snapshot.data; - } -} diff --git a/frontend/src/common/modules/errors/errors-handler/errors-handler.ts b/frontend/src/common/modules/errors/errors-handler/errors-handler.ts deleted file mode 100644 index 77b954a4f..000000000 --- a/frontend/src/common/modules/errors/errors-handler/errors-handler.ts +++ /dev/null @@ -1,51 +0,0 @@ - -import { HttpErrorResponse } from '@angular/common/http'; -import { ErrorHandler, Injectable, Injector } from '@angular/core'; -import { Router } from '@angular/router'; -import { SnackBarNotificationLevel, UiNotificationService } from '@common/modules/notification/ui-notification-service'; -import { TranslateService } from '@ngx-translate/core'; - -@Injectable() -export class ErrorsHandler implements ErrorHandler { - - private _notificationService; - // private _errorService; - private _router; - private _language; - - constructor( - private injector: Injector, - ) { - - } - - handleError(error: Error | HttpErrorResponse) { - this._notificationService = this.injector.get(UiNotificationService); - // this._errorService = this.injector.get(ErrorService); - this._router = this.injector.get(Router); - this._language = this.injector.get(TranslateService); - - if (error instanceof HttpErrorResponse) { - // Server error happened - if (!navigator.onLine) { - // No Internet connection - return this._notificationService.snackBarNotification(this._language.instant('ERROR-HANDLER.GLOBAL.NO-INTERNET'), SnackBarNotificationLevel.Error); - } - // Http Error - // Send the error to the server - // this._errorService.log(error).subscribe(); - // Show notification to the user - return this._notificationService.snackBarNotification(`${error.status} - ${error.message}`, SnackBarNotificationLevel.Error); - } else { - // Client Error Happend - // Send the error to the server and then - // redirect the user to the page with all the info - // this._errorService - // .log(error) - // .subscribe(errorWithContextInfo => { - // this._router.navigate(['/error'], { queryParams: errorWithContextInfo }); - // }); - } - } -} - diff --git a/frontend/src/common/modules/errors/errors-routing/errors-routing.module.ts b/frontend/src/common/modules/errors/errors-routing/errors-routing.module.ts deleted file mode 100644 index c95dd35c7..000000000 --- a/frontend/src/common/modules/errors/errors-routing/errors-routing.module.ts +++ /dev/null @@ -1,14 +0,0 @@ -import { NgModule } from '@angular/core'; -import { RouterModule, Routes } from '@angular/router'; -import { ErrorsComponent } from '@common/modules/errors/errors-component/errors.component'; - -const routes: Routes = [ - { path: 'error', component: ErrorsComponent }, - { path: '**', loadChildren: () => import('@common/modules/page-not-found/page-not-found.module').then(m => m.PageNotFoundModule) }, -]; - -@NgModule({ - imports: [RouterModule.forChild(routes)], - exports: [RouterModule] -}) -export class ErrorRoutingModule { } diff --git a/frontend/src/common/modules/errors/errors.module.ts b/frontend/src/common/modules/errors/errors.module.ts deleted file mode 100644 index 1b883b56e..000000000 --- a/frontend/src/common/modules/errors/errors.module.ts +++ /dev/null @@ -1,34 +0,0 @@ -import { CommonModule } from '@angular/common'; -import { HTTP_INTERCEPTORS } from '@angular/common/http'; -import { ErrorHandler, NgModule } from '@angular/core'; -import { RouterModule } from '@angular/router'; -// import { ExternalTracingService } from '@app/core/services/http/external-tracing.service'; -import { ErrorsComponent } from '@common/modules/errors/errors-component/errors.component'; -import { ErrorsHandler } from '@common/modules/errors/errors-handler/errors-handler'; -import { ErrorRoutingModule } from '@common/modules/errors/errors-routing/errors-routing.module'; -import { ServerErrorsInterceptor } from '@common/modules/errors/server-errors-interceptor/server-errors.interceptor'; - -@NgModule({ - imports: [ - CommonModule, - RouterModule, - ErrorRoutingModule, - ], - declarations: [ - ErrorsComponent - ], - providers: [ - // ErrorService, - // ExternalTracingService, - { - provide: ErrorHandler, - useClass: ErrorsHandler, - }, - { - provide: HTTP_INTERCEPTORS, - useClass: ServerErrorsInterceptor, - multi: true - }, - ] -}) -export class ErrorsModule { } //not used diff --git a/frontend/src/common/modules/errors/external-tracing/external-trace-entry.ts b/frontend/src/common/modules/errors/external-tracing/external-trace-entry.ts deleted file mode 100644 index 8af4afb37..000000000 --- a/frontend/src/common/modules/errors/external-tracing/external-trace-entry.ts +++ /dev/null @@ -1,20 +0,0 @@ -export interface ExternalTraceEntry { - eventId: EventId; - level: ExternalTraceLogLevel; - message: string; - data: any; -} - -export interface EventId { - id: number; -} - -export enum ExternalTraceLogLevel { - Trace = 0, - Debug = 1, - Information = 2, - Warning = 3, - Error = 4, - Critical = 5, - None = 6 -} diff --git a/frontend/src/common/modules/errors/server-errors-interceptor/server-errors.interceptor.ts b/frontend/src/common/modules/errors/server-errors-interceptor/server-errors.interceptor.ts deleted file mode 100644 index c652d028e..000000000 --- a/frontend/src/common/modules/errors/server-errors-interceptor/server-errors.interceptor.ts +++ /dev/null @@ -1,13 +0,0 @@ -import { HttpEvent, HttpHandler, HttpInterceptor, HttpRequest } from '@angular/common/http'; -import { Injectable } from '@angular/core'; -import { Observable } from 'rxjs'; -import { retry } from 'rxjs/operators'; - -@Injectable() -export class ServerErrorsInterceptor implements HttpInterceptor { - constructor() { } - intercept(request: HttpRequest, next: HttpHandler): Observable> { - - return next.handle(request); //TODO: possibly we want to retry here using: .pipe(retry(5)); - } -}