From cccce8de88ca93579e29c35d2cbb3b2be2f8c5c2 Mon Sep 17 00:00:00 2001 From: amentis Date: Thu, 11 Jul 2024 14:53:25 +0300 Subject: [PATCH] frontend code clean up --- frontend/src/app/app.component.ts | 12 ------------ frontend/src/app/core/model/plan/plan-import.ts | 2 +- .../core/services/culture/language-info-service.ts | 1 - .../src/app/core/services/matomo/matomo-service.ts | 3 --- .../services/user-settings/user-settings.service.ts | 5 ----- .../multiple/multiple-auto-complete.component.html | 2 -- .../single/single-auto-complete.component.html | 2 -- .../single/single-auto-complete.component.ts | 3 --- .../app/library/deactivate/can-deactivate.guard.ts | 1 - frontend/src/app/services/pagination.service.ts | 1 - ...tion-template-editor-visibility-rule.component.ts | 6 ------ .../editor/description-template-editor.resolver.ts | 2 +- .../filters/lock-listing-filters.component.ts | 4 ---- .../editor/plan-blueprint-editor.component.ts | 1 - .../language/language-content/language.component.ts | 11 ----------- .../http/interceptors/status-code.interceptor.ts | 8 -------- .../expandable-search-field.component.ts | 1 - .../editor/inapp-notification-editor.component.ts | 2 -- .../user-profile-notifier-list-editor.component.ts | 6 ++---- 19 files changed, 4 insertions(+), 69 deletions(-) diff --git a/frontend/src/app/app.component.ts b/frontend/src/app/app.component.ts index b8808fd64..4edf2e9aa 100644 --- a/frontend/src/app/app.component.ts +++ b/frontend/src/app/app.component.ts @@ -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'); } }); diff --git a/frontend/src/app/core/model/plan/plan-import.ts b/frontend/src/app/core/model/plan/plan-import.ts index 25feda261..8b711e24f 100644 --- a/frontend/src/app/core/model/plan/plan-import.ts +++ b/frontend/src/app/core/model/plan/plan-import.ts @@ -8,7 +8,7 @@ export interface PreprocessingPlanModel { preprocessingDescriptionModels: PreprocessingDescriptionModel[]; } -// rda config +// common config export interface PlanCommonModelConfig { fileId: Guid; label: string; diff --git a/frontend/src/app/core/services/culture/language-info-service.ts b/frontend/src/app/core/services/culture/language-info-service.ts index c6ef06823..7dfe8d609 100644 --- a/frontend/src/app/core/services/culture/language-info-service.ts +++ b/frontend/src/app/core/services/culture/language-info-service.ts @@ -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 => { diff --git a/frontend/src/app/core/services/matomo/matomo-service.ts b/frontend/src/app/core/services/matomo/matomo-service.ts index 5921401e7..55178ffed 100644 --- a/frontend/src/app/core/services/matomo/matomo-service.ts +++ b/frontend/src/app/core/services/matomo/matomo-service.ts @@ -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); } } } diff --git a/frontend/src/app/core/services/user-settings/user-settings.service.ts b/frontend/src/app/core/services/user-settings/user-settings.service.ts index 1cf18e6d6..13280502f 100644 --- a/frontend/src/app/core/services/user-settings/user-settings.service.ts +++ b/frontend/src/app/core/services/user-settings/user-settings.service.ts @@ -149,11 +149,6 @@ export class UserSettingsService extends BaseService { } return this.userSettingsHttpService.getSingle(userSettingsInformation.key).pipe( - // catchError(() => { - // const result: UserSettings = this.defaultValue(userSettingsInformation); - // this.persistUserSettings(userSettingsInformation.key, result, userSettingsInformation, false); - // return observableOf(result); - // }), map(x => { const result: UserSettings = (x ? this.toTypedUserSettings(x as UserSettingsObject) : null); this.persistUserSettings(userSettingsInformation.key, result, userSettingsInformation, false); diff --git a/frontend/src/app/library/auto-complete/multiple/multiple-auto-complete.component.html b/frontend/src/app/library/auto-complete/multiple/multiple-auto-complete.component.html index b817622f1..4d025718b 100644 --- a/frontend/src/app/library/auto-complete/multiple/multiple-auto-complete.component.html +++ b/frontend/src/app/library/auto-complete/multiple/multiple-auto-complete.component.html @@ -26,7 +26,6 @@ - @@ -59,7 +58,6 @@
- diff --git a/frontend/src/app/library/auto-complete/single/single-auto-complete.component.html b/frontend/src/app/library/auto-complete/single/single-auto-complete.component.html index bb9cfcb5b..631b2bf9a 100644 --- a/frontend/src/app/library/auto-complete/single/single-auto-complete.component.html +++ b/frontend/src/app/library/auto-complete/single/single-auto-complete.component.html @@ -8,7 +8,6 @@ - @@ -29,7 +28,6 @@
- diff --git a/frontend/src/app/library/auto-complete/single/single-auto-complete.component.ts b/frontend/src/app/library/auto-complete/single/single-auto-complete.component.ts index 7e2295771..212f31722 100644 --- a/frontend/src/app/library/auto-complete/single/single-auto-complete.component.ts +++ b/frontend/src/app/library/auto-complete/single/single-auto-complete.component.ts @@ -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; - // } } diff --git a/frontend/src/app/library/deactivate/can-deactivate.guard.ts b/frontend/src/app/library/deactivate/can-deactivate.guard.ts index 8e6df7ff9..d35a8308a 100644 --- a/frontend/src/app/library/deactivate/can-deactivate.guard.ts +++ b/frontend/src/app/library/deactivate/can-deactivate.guard.ts @@ -30,7 +30,6 @@ export class CanDeactivateGuard extends BaseComponent implements CanDeactivate x ? true : false)); diff --git a/frontend/src/app/services/pagination.service.ts b/frontend/src/app/services/pagination.service.ts index 72f238384..edee64c3e 100644 --- a/frontend/src/app/services/pagination.service.ts +++ b/frontend/src/app/services/pagination.service.ts @@ -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 => { diff --git a/frontend/src/app/ui/admin/description-template/editor/components/visibility-rule/description-template-editor-visibility-rule.component.ts b/frontend/src/app/ui/admin/description-template/editor/components/visibility-rule/description-template-editor-visibility-rule.component.ts index d03771546..62370cec1 100644 --- a/frontend/src/app/ui/admin/description-template/editor/components/visibility-rule/description-template-editor-visibility-rule.component.ts +++ b/frontend/src/app/ui/admin/description-template/editor/components/visibility-rule/description-template-editor-visibility-rule.component.ts @@ -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: [] 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 0d5487c09..d06bf4c5b 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 @@ -49,7 +49,7 @@ export class DescriptionTemplateEditorResolver extends BaseEditorResolver { [nameof(x => x.definition), nameof(x => x.pages), nameof(x => x.sections), nameof(x => x.title)].join('.'), [nameof(x => x.definition), nameof(x => x.pages), nameof(x => x.sections), nameof(x => x.description)].join('.'), [nameof(x => x.definition), nameof(x => x.pages), nameof(x => x.sections), nameof(x => x.ordinal)].join('.'), - [nameof(x => x.definition), nameof(x => x.pages), nameof(x => x.sections), nameof(x => x.sections)].join('.'), // TODO: it is recursive here + [nameof(x => x.definition), nameof(x => x.pages), nameof(x => x.sections), nameof(x => x.sections)].join('.'), [nameof(x => x.definition), nameof(x => x.pages), nameof(x => x.sections), nameof(x => x.fieldSets), nameof(x => x.id)].join('.'), [nameof(x => x.definition), nameof(x => x.pages), nameof(x => x.sections), nameof(x => x.fieldSets), nameof(x => x.ordinal)].join('.'), diff --git a/frontend/src/app/ui/admin/entity-locks/filters/lock-listing-filters.component.ts b/frontend/src/app/ui/admin/entity-locks/filters/lock-listing-filters.component.ts index d2b9a971e..15e1f30bf 100644 --- a/frontend/src/app/ui/admin/entity-locks/filters/lock-listing-filters.component.ts +++ b/frontend/src/app/ui/admin/entity-locks/filters/lock-listing-filters.component.ts @@ -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; } diff --git a/frontend/src/app/ui/admin/plan-blueprint/editor/plan-blueprint-editor.component.ts b/frontend/src/app/ui/admin/plan-blueprint/editor/plan-blueprint-editor.component.ts index b7b5f8ca7..aa4dd4a01 100644 --- a/frontend/src/app/ui/admin/plan-blueprint/editor/plan-blueprint-editor.component.ts +++ b/frontend/src/app/ui/admin/plan-blueprint/editor/plan-blueprint-editor.component.ts @@ -536,7 +536,6 @@ export class PlanBlueprintEditorComponent extends BaseEditor(); 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 { diff --git a/frontend/src/common/http/interceptors/status-code.interceptor.ts b/frontend/src/common/http/interceptors/status-code.interceptor.ts index 9e737cae8..d09e2b943 100644 --- a/frontend/src/common/http/interceptors/status-code.interceptor.ts +++ b/frontend/src/common/http/interceptors/status-code.interceptor.ts @@ -16,14 +16,6 @@ export class StatusCodeInterceptor extends BaseInterceptor { type: InterceptorType; interceptRequest(req: HttpRequest, next: HttpHandler): Observable> { 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(['/']); - // } })); } diff --git a/frontend/src/common/modules/text-filter/expandable-search-field/expandable-search-field.component.ts b/frontend/src/common/modules/text-filter/expandable-search-field/expandable-search-field.component.ts index 0e582af76..9bf4a1496 100644 --- a/frontend/src/common/modules/text-filter/expandable-search-field/expandable-search-field.component.ts +++ b/frontend/src/common/modules/text-filter/expandable-search-field/expandable-search-field.component.ts @@ -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) diff --git a/frontend/src/notification-service/ui/inapp-notification/editor/inapp-notification-editor.component.ts b/frontend/src/notification-service/ui/inapp-notification/editor/inapp-notification-editor.component.ts index 907a5642c..359f79dd1 100644 --- a/frontend/src/notification-service/ui/inapp-notification/editor/inapp-notification-editor.component.ts +++ b/frontend/src/notification-service/ui/inapp-notification/editor/inapp-notification-editor.component.ts @@ -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']); } } diff --git a/frontend/src/notification-service/ui/user-profile/notifier-list/user-profile-notifier-list-editor.component.ts b/frontend/src/notification-service/ui/user-profile/notifier-list/user-profile-notifier-list-editor.component.ts index ac6659be2..02ef39579 100644 --- a/frontend/src/notification-service/ui/user-profile/notifier-list/user-profile-notifier-list-editor.component.ts +++ b/frontend/src/notification-service/ui/user-profile/notifier-list/user-profile-notifier-list-editor.component.ts @@ -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(); }