frontend code clean up

This commit is contained in:
amentis 2024-07-11 14:53:25 +03:00
parent 81092adc13
commit cccce8de88
19 changed files with 4 additions and 69 deletions

View File

@ -7,7 +7,6 @@ import { TranslateService } from '@ngx-translate/core';
import { filter, map, switchMap } from 'rxjs/operators';
import { AuthService, LoginStatus } from './core/services/auth/auth.service';
import { CultureService } from './core/services/culture/culture-service';
// import { BreadCrumbResolverService } from './ui/misc/breadcrumb/service/breadcrumb.service';
import { DomSanitizer, Title } from '@angular/platform-browser';
import { CookieService } from "ngx-cookie-service";
import { NgcCookieConsentService, NgcStatusChangeEvent } from "ngx-cookieconsent";
@ -34,7 +33,6 @@ declare var $: any;
export class AppComponent implements OnInit, AfterViewInit {
hasBreadCrumb = observableOf(false);
// sideNavOpen = false;
private sideNavSubscription: Subscription;
helpContentEnabled: boolean;
private statusChangeSubscription: Subscription;
@ -48,7 +46,6 @@ export class AppComponent implements OnInit, AfterViewInit {
private route: ActivatedRoute,
private authentication: AuthService,
private translate: TranslateService,
// private breadCrumbResolverService: BreadCrumbResolverService,
private titleService: Title,
private cultureService: CultureService,
private timezoneService: TimezoneService,
@ -106,16 +103,13 @@ export class AppComponent implements OnInit, AfterViewInit {
}
onActivate(event: any) {
// this.breadCrumbResolverService.push(event);
}
onDeactivate(event: any) {
//this.breadCrumbResolverService.clear()
}
ngOnInit() {
if (!this.cookieService.check("cookiesConsent")) {
// this.cookieService.set("cookiesConsent", "false", 356);
this.cookieService.set("cookiesConsent", "false", 356, null, null, false, 'Lax');
}
@ -179,16 +173,10 @@ export class AppComponent implements OnInit, AfterViewInit {
if (this.authentication.getSelectedTenantName() && this.authentication.getSelectedTenantName() !== '')
this.breadcrumbService.addIdResolvedValue(this.authentication.selectedTenant(), this.authentication.getSelectedTenantName());
// const enrichedUrl = this.tenantHandlingService.getUrlEnrichedWithTenantCode(event.url, this.authentication.selectedTenant() ?? 'default');
// if (event.url != enrichedUrl) {
// this.router.navigateByUrl(enrichedUrl);
// }
});
this.statusChangeSubscription = this.ccService.statusChange$.subscribe((event: NgcStatusChangeEvent) => {
if (event.status == "dismiss") {
// this.cookieService.set("cookiesConsent", "true", 365);
this.cookieService.set("cookiesConsent", "true", 356, null, null, false, 'Lax');
}
});

View File

@ -8,7 +8,7 @@ export interface PreprocessingPlanModel {
preprocessingDescriptionModels: PreprocessingDescriptionModel[];
}
// rda config
// common config
export interface PlanCommonModelConfig {
fileId: Guid;
label: string;

View File

@ -65,7 +65,6 @@ export class LanguageInfoService {
if (selectedLocale) {
registerLocaleData(selectedLocale.default);
} else {
// locale = newCulture.code.split('-')[0];
import(`/node_modules/@angular/common/locales/${locale}.mjs`).catch(reason => {
this.logger.error('Could not load locale: ' + locale);
}).then(selectedDefaultLocale => {

View File

@ -43,9 +43,6 @@ export class MatomoService {
var principalid = this.authService.userId();
if (principalid != null) { this.matomoTracker.setUserId(principalid.toString()); }
this.matomoTracker.trackLink(this.configurationService.server + category + "/" + type + "/" + id, "download");
// this.matomoTracker.trackLink(url, "download");
// this.matomoTracker.trackEvent(category, "Downloaded", type);
}
}
}

View File

@ -149,11 +149,6 @@ export class UserSettingsService extends BaseService {
}
return this.userSettingsHttpService.getSingle(userSettingsInformation.key).pipe(
// catchError(() => {
// const result: UserSettings<T> = this.defaultValue(userSettingsInformation);
// this.persistUserSettings(userSettingsInformation.key, result, userSettingsInformation, false);
// return observableOf(result);
// }),
map(x => {
const result: UserSettings<T> = (x ? this.toTypedUserSettings<T>(x as UserSettingsObject) : null);
this.persistUserSettings(userSettingsInformation.key, result, userSettingsInformation, false);

View File

@ -26,7 +26,6 @@
<span *ngIf="_groupedItems">
<mat-optgroup *ngFor="let group of _groupedItems | async" [label]="group.title">
<mat-option *ngFor="let item of group.items" [value]="item" class="option autocomplete-option" [class.two-line-mat-option]="_subtitleFn(item) && !_optionTemplate(item) && !_optionComponent(item)" (optionActivated)="clickedOnPanel()">
<!-- <img style="vertical-align:middle;" aria-hidden src="{{state.flag}}" height="25" /> -->
<ng-container *ngIf="_optionComponent(item)">
<ng-container *ngComponentOutlet="_optionComponent(item); inputs: { item };" />
</ng-container>
@ -59,7 +58,6 @@
<div *ngIf="_items | async as autocompleteItems; else loading">
<ng-container *ngIf="autocompleteItems.length; else noItems">
<mat-option *ngFor="let item of autocompleteItems" class="option autocomplete-option" [value]="item" [class.two-line-mat-option]="_subtitleFn(item) && !_optionTemplate(item) && !_optionComponent(item)" (optionActivated)="clickedOnPanel()">
<!-- <img style="vertical-align:middle;" aria-hidden src="{{state.flag}}" height="25" /> -->
<ng-container *ngIf="_optionComponent(item)">
<ng-container *ngComponentOutlet="_optionComponent(item); inputs: { item };" />
</ng-container>

View File

@ -8,7 +8,6 @@
<span *ngIf="_groupedItems">
<mat-optgroup *ngFor="let group of _groupedItems | async" [label]="group.title">
<mat-option *ngFor="let item of group.items" [value]="item" class="autocomplete-option" [class.two-line-mat-option]="_subtitleFn(item) && !_optionTemplate(item)">
<!-- <img style="vertical-align:middle;" aria-hidden src="{{state.flag}}" height="25" /> -->
<ng-template #cellTemplate *ngIf="_optionTemplate(item)" [ngTemplateOutlet]="_optionTemplate(item)" [ngTemplateOutletContext]="{
item: item
}"></ng-template>
@ -29,7 +28,6 @@
<div *ngIf="_items | async as autocompleteItems; else loading">
<ng-container *ngIf="autocompleteItems.length; else noItems">
<mat-option *ngFor="let item of autocompleteItems" [value]="item" class="autocomplete-option" [class.two-line-mat-option]="_subtitleFn(item) && !_optionTemplate(item)">
<!-- <img style="vertical-align:middle;" aria-hidden src="{{state.flag}}" height="25" /> -->
<ng-template #cellTemplate *ngIf="_optionTemplate(item)" [ngTemplateOutlet]="_optionTemplate(item)" [ngTemplateOutletContext]="{
item: item
}"></ng-template>

View File

@ -375,7 +375,4 @@ export class SingleAutoCompleteComponent extends _CustomComponentMixinBase imple
this.configuration.valueAssign != null ? this.configuration.valueAssign(item) : item
)
}
// get forceFocus(): boolean {
// return this.configuration.forceFocus != null ? this.configuration.forceFocus : false;
// }
}

View File

@ -30,7 +30,6 @@ export class CanDeactivateGuard extends BaseComponent implements CanDeactivate<C
warning: this.language.instant('GENERAL.CONFIRMATION-DIALOG.LEAVE-WARNING'),
cancelButton: this.language.instant('GENERAL.CONFIRMATION-DIALOG.ACTIONS.CANCEL'),
confirmButton: this.language.instant('GENERAL.CONFIRMATION-DIALOG.ACTIONS.LEAVE'),
// icon: 'error_outline'
}
});
return dialogRef.afterClosed().pipe(map(x => x ? true : false));

View File

@ -1,7 +1,6 @@
export class PaginationService {
getPagination(groups, totalGroups: number, currentPage: number = 1, pageSize: number = 3) {
// calculate total pages
//let totalPages = Math.ceil(totalGroups / pageSize);
let totalPages = 0 ; //totalpages based on pages from xml, each group and section has each one page
groups.forEach(group => {

View File

@ -70,10 +70,6 @@ export class DescriptionTemplateEditorRuleComponent implements OnInit {
return type == DescriptionTemplateFieldType.VALIDATION || type == DescriptionTemplateFieldType.DATASET_IDENTIFIER;;
}
targetValidation() {
//TODO
}
deleteRule(index) {
this.form.removeAt(index);
this.form.controls?.forEach(
@ -187,12 +183,10 @@ export class DescriptionTemplateEditorRuleComponent implements OnInit {
const result: OptionItem[] = [];
// parentIds.push(form.get('id').value);
const currentOptionItem: OptionItem = {
id: form.get('id').value,
type: type,
label: type === ToCEntryType.Field ? form.get('data').get('label').value : form.get('title').value,
// parentsIds: [form.get('id').value]
parentsIds: [...parentIds, form.get('id').value],
form: form,
hiddenBy: []

View File

@ -49,7 +49,7 @@ export class DescriptionTemplateEditorResolver extends BaseEditorResolver {
[nameof<DescriptionTemplate>(x => x.definition), nameof<DescriptionTemplateDefinition>(x => x.pages), nameof<DescriptionTemplatePage>(x => x.sections), nameof<DescriptionTemplateSection>(x => x.title)].join('.'),
[nameof<DescriptionTemplate>(x => x.definition), nameof<DescriptionTemplateDefinition>(x => x.pages), nameof<DescriptionTemplatePage>(x => x.sections), nameof<DescriptionTemplateSection>(x => x.description)].join('.'),
[nameof<DescriptionTemplate>(x => x.definition), nameof<DescriptionTemplateDefinition>(x => x.pages), nameof<DescriptionTemplatePage>(x => x.sections), nameof<DescriptionTemplateSection>(x => x.ordinal)].join('.'),
[nameof<DescriptionTemplate>(x => x.definition), nameof<DescriptionTemplateDefinition>(x => x.pages), nameof<DescriptionTemplatePage>(x => x.sections), nameof<DescriptionTemplateSection>(x => x.sections)].join('.'), // TODO: it is recursive here
[nameof<DescriptionTemplate>(x => x.definition), nameof<DescriptionTemplateDefinition>(x => x.pages), nameof<DescriptionTemplatePage>(x => x.sections), nameof<DescriptionTemplateSection>(x => x.sections)].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.id)].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.ordinal)].join('.'),

View File

@ -1,6 +1,5 @@
import { COMMA, ENTER } from '@angular/cdk/keycodes';
import { Component, EventEmitter, Input, OnChanges, OnInit, Output, SimpleChanges } from '@angular/core';
import { IsActive } from '@app/core/common/enum/is-active.enum';
import { LockTargetType } from '@app/core/common/enum/lock-target-type';
import { LockFilter } from '@app/core/query/lock.lookup';
import { UserService } from '@app/core/services/user/user.service';
@ -90,9 +89,6 @@ export class LockListingFiltersComponent extends BaseComponent implements OnInit
private _computeAppliedFilters(filters: LockListingFilters): number {
let count = 0;
// if (filters?.isActive) {
// count++
// }
return count;
}

View File

@ -536,7 +536,6 @@ export class PlanBlueprintEditorComponent extends BaseEditor<PlanBlueprintEditor
checkValidity() {
this.formService.touchAllFormFields(this.formGroup);
// if (!this.isFormValid()) { return false; }
let errorMessages = [];
if (!this.hasTitle()) {
errorMessages.push("Title should be set.");

View File

@ -43,17 +43,6 @@ export class LanguageComponent extends BaseComponent implements OnInit {
if (this.isAuthenticated()) {
const langMap = new Map<string, string>();
langMap.set('language', selectedLanguage.value);
//TODO: refactor - save language selection to user profile
// this.userService.updateUserSettings({ language: this.languages.find(lang => lang === selectedLanguage.value) })
// .pipe(takeUntil(this._destroyed))
// .subscribe((response) => {
// this.languageService.changeLanguage(selectedLanguage.value);
// this.authentication.refresh()
// .pipe(takeUntil(this._destroyed))
// .subscribe(innerResponse => { this.router.navigateByUrl(this.router.url); });
// },
// error => {
// });
this.languageService.changeLanguage(selectedLanguage.value);
this.router.navigateByUrl(this.router.url);
} else {

View File

@ -16,14 +16,6 @@ export class StatusCodeInterceptor extends BaseInterceptor {
type: InterceptorType;
interceptRequest(req: HttpRequest<any>, next: HttpHandler): Observable<HttpEvent <any>> {
return next.handle(req).pipe(tap(event => { }, err => {
// if (err.status === 480) {
// this.router.navigate(['confirmation']);
// }
// const error: HttpError = this.httpErrorHandlingService.getError(err);
// if (error.statusCode === 403 && error.errorCode === 103) {
// this.authService.selectedTenant('default');
// this.router.navigate(['/']);
// }
}));
}

View File

@ -55,7 +55,6 @@ export class ExpandableSearchFieldComponent extends BaseComponent implements OnI
protected a$ = this.subject$.asObservable().pipe(
debounceTime(200),
// delayWhen(x => interval( x ? 0: 3000).pipe(take(1))),
takeUntil(this._destroyed),
shareReplay(),
startWith(false)

View File

@ -121,7 +121,5 @@ export class InAppNotificationEditorComponent extends BaseComponent implements O
}
onCallbackSuccess(data?: any): void {
// this.uiNotificationService.snackBarNotification(this.language.instant('GENERAL.SNACK-BAR.SUCCESSFUL-UPDATE'), SnackBarNotificationLevel.Success);
// this.router.navigate(['/mine-notifications']);
}
}

View File

@ -1,13 +1,12 @@
import { CdkDragDrop, moveItemInArray } from '@angular/cdk/drag-drop';
import { HttpErrorResponse } from '@angular/common/http';
import { Component, EventEmitter, OnInit, Output } from '@angular/core';
import { FormGroup } from '@angular/forms';
import { Component, OnInit } from '@angular/core';
import { AuthService } from '@app/core/services/auth/auth.service';
import { LoggingService } from '@app/core/services/logging/logging-service';
import { SnackBarNotificationLevel, UiNotificationService } from '@app/core/services/notification/ui-notification-service';
import { BaseComponent } from '@common/base/base.component';
import { FormService } from '@common/forms/form-service';
import { HttpError, HttpErrorHandlingService } from '@common/modules/errors/error-handling/http-error-handling.service';
import { HttpErrorHandlingService } from '@common/modules/errors/error-handling/http-error-handling.service';
import { TranslateService } from '@ngx-translate/core';
import { NotificationContactType } from '@notification-service/core/enum/notification-contact-type';
import { NotificationTrackingProcess } from '@notification-service/core/enum/notification-tracking-process.enum';
@ -40,7 +39,6 @@ export class UserProfileNotifierListEditorComponent extends BaseComponent implem
private formService: FormService,
private logger: LoggingService,
public notificationServiceEnumUtils: NotificationServiceEnumUtils,
// private totpService: TotpService
) {
super();
}