frontend code clean up

This commit is contained in:
amentis 2024-07-10 13:10:28 +03:00
parent b026dbb4a5
commit ee00fb2c53
13 changed files with 0 additions and 212 deletions

View File

@ -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) {

View File

@ -69,7 +69,6 @@ export class DescriptionTemplateEditorResolver extends BaseEditorResolver {
[nameof<DescriptionTemplate>(x => x.definition), nameof<DescriptionTemplateDefinition>(x => x.pages), nameof<DescriptionTemplatePage>(x => x.sections), nameof<DescriptionTemplateSection>(x => x.fieldSets), nameof<DescriptionTemplateFieldSet>(x => x.fields), nameof<DescriptionTemplateField>(x => x.defaultValue), nameof<DescriptionTemplateDefaultValue>(x => x.textValue)].join('.'),
[nameof<DescriptionTemplate>(x => x.definition), nameof<DescriptionTemplateDefinition>(x => x.pages), nameof<DescriptionTemplatePage>(x => x.sections), nameof<DescriptionTemplateSection>(x => x.fieldSets), nameof<DescriptionTemplateFieldSet>(x => x.fields), nameof<DescriptionTemplateField>(x => x.defaultValue), nameof<DescriptionTemplateDefaultValue>(x => x.dateValue)].join('.'),
[nameof<DescriptionTemplate>(x => x.definition), nameof<DescriptionTemplateDefinition>(x => x.pages), nameof<DescriptionTemplatePage>(x => x.sections), nameof<DescriptionTemplateSection>(x => x.fieldSets), nameof<DescriptionTemplateFieldSet>(x => x.fields), nameof<DescriptionTemplateField>(x => x.defaultValue), nameof<DescriptionTemplateDefaultValue>(x => x.booleanValue)].join('.'),
// [nameof<DescriptionTemplate>(x => x.definition), nameof<DescriptionTemplatePage>(x => x.sections), nameof<DescriptionTemplateSection>(x => x.fieldSets), nameof<DescriptionTemplateFieldSet>(x => x.fields), nameof<DescriptionTemplateField>(x => x.fieldType)].join('.'),
[nameof<DescriptionTemplate>(x => x.definition), nameof<DescriptionTemplateDefinition>(x => x.pages), nameof<DescriptionTemplatePage>(x => x.sections), nameof<DescriptionTemplateSection>(x => x.fieldSets), nameof<DescriptionTemplateFieldSet>(x => x.fields), nameof<DescriptionTemplateField>(x => x.includeInExport)].join('.'),
[nameof<DescriptionTemplate>(x => x.definition), nameof<DescriptionTemplateDefinition>(x => x.pages), nameof<DescriptionTemplatePage>(x => x.sections), nameof<DescriptionTemplateSection>(x => x.fieldSets), nameof<DescriptionTemplateFieldSet>(x => x.fields), nameof<DescriptionTemplateField>(x => x.validations)].join('.'),

View File

@ -16,7 +16,6 @@ import { TenantUsersRoutingModule, UsersRoutingModule } from './user.routing';
@NgModule({
declarations: [
UserListingComponent,
// UserEditorComponent,
UserRoleEditorComponent,
UserListingFiltersComponent
],

View File

@ -705,10 +705,6 @@ export class DescriptionEditorComponent extends BaseEditor<DescriptionEditorMode
return [];
}
public cancel(): void { //not used
this.router.navigate([this.routerUtils.generateUrl('/descriptions')]);
}
finalize() {
this.formService.removeAllBackEndErrors(this.formGroup);
this.formService.touchAllFormFields(this.formGroup);

View File

@ -535,7 +535,6 @@ export class PlanUserEditorModel implements PlanUserPersist {
fromModel(item: PlanUser): PlanUserEditorModel {
if (item?.user?.id) this.user = item.user.id;
this.role = item.role;
// TODO this.email = item.email;
this.userType = (item == null || this.user != null) ? PlanUserType.Internal : PlanUserType.External;
this.sectionId = item.sectionId?.toString() || ''; //Trick to allow a null option for all items.

View File

@ -1,34 +0,0 @@
<div class="row error-container">
<div class="col"></div>
<div class="col-12">
<div *ngIf="data?.error">
<h1>ERROR {{ data?.error}}</h1>
<h5 *ngIf="data?.error === 404">Not found :(</h5>
<a mat-raised-button [routerLink]="'/'">
<h5>Go Home</h5>
</a>
</div>
<div *ngIf="routeParams.message">
<h1 *ngIf="routeParams?.status"> ERROR {{ routeParams?.status }}</h1><br />
<h3 *ngIf="routeParams?.message">{{ routeParams?.message }}</h3><br />
<h1 *ngIf="routeParams?.url && routeParams?.url !== '/'">Error in {{ routeParams?.url }} page, sorry :(</h1>
<h4 *ngIf="routeParams?.id">This error has been reported to the Administrator with the ID:<br> {{ routeParams?.id}}</h4>
<a mat-raised-button [routerLink]="routeParams?.url" *ngIf="routeParams?.url && routeParams.status !== '404'">
<h5>Go Back to {{routeParams?.url}}</h5>
</a>
<a mat-raised-button routerLink="/" *ngIf="!routeParams.url || routeParams.status === '404'">
<h5>Go Back to home</h5>
</a>
</div>
<div *ngIf="!routeParams && !data">
<h1>Unknown error, sorry :(</h1>
<a mat-raised-button [routerLink]="'/login'">
<h5>Go Home</h5>
</a>
</div>
</div>
<div class="col"></div>
</div>

View File

@ -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;
}

View File

@ -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;
}
}

View File

@ -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 });
// });
}
}
}

View File

@ -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 { }

View File

@ -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

View File

@ -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
}

View File

@ -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<any>, next: HttpHandler): Observable<HttpEvent<any>> {
return next.handle(request); //TODO: possibly we want to retry here using: .pipe(retry(5));
}
}