From d9c91a6a643eb23ef36d9b16116c1458d4440443 Mon Sep 17 00:00:00 2001 From: Henry Taeschner Date: Fri, 23 Feb 2024 07:05:26 +0100 Subject: [PATCH] fix: optimize code --- .../app-search/app-search.component.html | 8 ++- .../app-search/app-search.component.spec.ts | 2 +- .../app-search/app-search.component.ts | 50 +++++++++++++++++-- .../product-apps/product-apps.component.html | 9 ++-- .../product-apps/product-apps.component.ts | 7 +-- .../product-detail.component.html | 6 ++- .../product-detail.component.ts | 10 +++- .../product-search.component.scss | 6 +++ 8 files changed, 78 insertions(+), 20 deletions(-) diff --git a/src/app/product-store/app-search/app-search.component.html b/src/app/product-store/app-search/app-search.component.html index da51079..fa5eb0b 100644 --- a/src/app/product-store/app-search/app-search.component.html +++ b/src/app/product-store/app-search/app-search.component.html @@ -22,7 +22,7 @@ /> - + @@ -72,7 +72,6 @@ [initialViewMode]="viewMode" [sortingOptions]="[ { label: 'APP.APP_ID' | translate, value: 'appId' }, - { label: 'APP.APP_NAME' | translate, value: 'appName' }, { label: 'APP.APP_TYPE' | translate, value: 'appType' }, { label: 'APP.PRODUCT_NAME' | translate, value: 'productName' } ]" @@ -82,7 +81,6 @@ (filterChange)="onFilterChange($event)" [filterColumns]="[ 'APP.APP_ID' | translate, - 'APP.APP_NAME' | translate, 'APP.APP_TYPE' | translate, 'APP.PRODUCT_NAME' | translate, 'APP.CLASSIFICATIONS' | translate diff --git a/src/app/product-store/app-search/app-search.component.spec.ts b/src/app/product-store/app-search/app-search.component.spec.ts index 3200cb4..e73c8ea 100644 --- a/src/app/product-store/app-search/app-search.component.spec.ts +++ b/src/app/product-store/app-search/app-search.component.spec.ts @@ -13,7 +13,7 @@ import { MicrofrontendsAPIService } from 'src/app/shared/generated' const form = new FormGroup({ appId: new FormControl(null, Validators.minLength(2)), - appName: new FormControl(null), + //appName: new FormControl(null), productName: new FormControl(null) }) diff --git a/src/app/product-store/app-search/app-search.component.ts b/src/app/product-store/app-search/app-search.component.ts index 320b9ef..0bb8434 100644 --- a/src/app/product-store/app-search/app-search.component.ts +++ b/src/app/product-store/app-search/app-search.component.ts @@ -18,8 +18,8 @@ import { limitText } from 'src/app/shared/utils' export interface AppSearchCriteria { appId: FormControl - appName: FormControl - // appType: FormControl + // appName: FormControl + // appType: FormControl productName: FormControl } export type AppType = 'MS' | 'MFE' @@ -69,12 +69,13 @@ export class AppSearchComponent implements OnInit, OnDestroy { this.hasDeletePermission = this.user.hasPermission('APP#DELETE') this.appSearchCriteriaGroup = new FormGroup({ appId: new FormControl(null), - appName: new FormControl(null), + //appName: new FormControl(null), productName: new FormControl(null) }) } ngOnInit(): void { + this.prepareDialogTranslations() this.prepareActionButtons() this.searchApps() } @@ -95,7 +96,7 @@ export class AppSearchComponent implements OnInit, OnDestroy { .searchMicrofrontends({ mfeAndMsSearchCriteria: { appId: this.appSearchCriteriaGroup.controls['appId'].value, - appName: this.appSearchCriteriaGroup.controls['appName'].value, + //appName: this.appSearchCriteriaGroup.controls['appName'].value, productName: this.appSearchCriteriaGroup.controls['productName'].value, pageSize: 100 } @@ -114,7 +115,7 @@ export class AppSearchComponent implements OnInit, OnDestroy { .searchMicroservice({ mfeAndMsSearchCriteria: { appId: this.appSearchCriteriaGroup.controls['appId'].value, - appName: this.appSearchCriteriaGroup.controls['appName'].value, + // appName: this.appSearchCriteriaGroup.controls['appName'].value, productName: this.appSearchCriteriaGroup.controls['productName'].value, pageSize: 100 } @@ -191,6 +192,45 @@ export class AppSearchComponent implements OnInit, OnDestroy { ) } + private prepareDialogTranslations(): void { + this.translate + .get([ + 'APP.APP_ID', + 'APP.APP_TYPE', + 'PRODUCT.NAME', + 'ACTIONS.DATAVIEW.VIEW_MODE_GRID', + 'ACTIONS.DATAVIEW.VIEW_MODE_LIST', + 'ACTIONS.DATAVIEW.VIEW_MODE_TABLE', + 'ACTIONS.DATAVIEW.SORT_BY', + 'ACTIONS.DATAVIEW.FILTER', + 'ACTIONS.DATAVIEW.FILTER_OF', + 'ACTIONS.DATAVIEW.SORT_DIRECTION_ASC', + 'ACTIONS.DATAVIEW.SORT_DIRECTION_DESC' + ]) + .subscribe((data) => { + this.dataViewControlsTranslations = { + sortDropdownPlaceholder: data['ACTIONS.DATAVIEW.SORT_BY'], + filterInputPlaceholder: data['ACTIONS.DATAVIEW.FILTER'], + filterInputTooltip: + data['ACTIONS.DATAVIEW.FILTER_OF'] + + data['APP.APP_ID'] + + ', ' + + data['APP.APP_TYPE'] + + ', ' + + data['PRODUCT.NAME'], + viewModeToggleTooltips: { + grid: data['ACTIONS.DATAVIEW.VIEW_MODE_GRID'], + list: data['ACTIONS.DATAVIEW.VIEW_MODE_LIST'] + }, + sortOrderTooltips: { + ascending: data['ACTIONS.DATAVIEW.SORT_DIRECTION_ASC'], + descending: data['ACTIONS.DATAVIEW.SORT_DIRECTION_DESC'] + }, + sortDropdownTooltip: data['ACTIONS.DATAVIEW.SORT_BY'] + } + }) + } + public onLayoutChange(viewMode: string): void { this.viewMode = viewMode } diff --git a/src/app/product-store/product-detail/product-apps/product-apps.component.html b/src/app/product-store/product-detail/product-apps/product-apps.component.html index 67b21be..486f303 100644 --- a/src/app/product-store/product-detail/product-apps/product-apps.component.html +++ b/src/app/product-store/product-detail/product-apps/product-apps.component.html @@ -13,7 +13,7 @@ [rows]="viewMode === 'grid' ? 12 : 10" [layout]="viewMode" [emptyMessage]="'ACTIONS.SEARCH.NOT_FOUND' | translate" - filterBy="app_name" + filterBy="appId,appType" [sortField]="sortField" [sortOrder]="sortOrder" > @@ -23,12 +23,15 @@ [enableSorting]="true" [supportedViews]="['grid']" [initialViewMode]="viewMode" - [sortingOptions]="[{ label: 'APP.APP_NAME' | translate, value: 'app_name' }]" + [sortingOptions]="[ + { label: 'APP.APP_ID' | translate, value: 'appId' }, + { label: 'APP.APP_TYPE' | translate, value: 'appType' } + ]" [defaultSortOption]="sortField" [defaultSortDirection]="sortOrder === 1" (dataViewChange)="onLayoutChange($event)" (filterChange)="onFilterChange($event)" - [filterColumns]="['APP.APP_NAME' | translate]" + [filterColumns]="['APP.APP_ID' | translate, 'APP.APP_TYPE' | translate]" (sortChange)="onSortChange($event)" (sortDirectionChange)="onSortDirChange($event)" [translations]="dataViewControlsTranslations" diff --git a/src/app/product-store/product-detail/product-apps/product-apps.component.ts b/src/app/product-store/product-detail/product-apps/product-apps.component.ts index 9913ba2..f8c1c56 100644 --- a/src/app/product-store/product-detail/product-apps/product-apps.component.ts +++ b/src/app/product-store/product-detail/product-apps/product-apps.component.ts @@ -1,6 +1,7 @@ import { Component, Input, OnChanges, ViewChild } from '@angular/core' import { SelectItem } from 'primeng/api' import { combineLatest, finalize, map, of, Observable, startWith, catchError } from 'rxjs' +import { DataView } from 'primeng/dataview' import { DataViewControlTranslations, UserService } from '@onecx/portal-integration-angular' import { @@ -35,7 +36,7 @@ export class ProductAppsComponent implements OnChanges { public iconItems: SelectItem[] = [{ label: '', value: null }] public filter: string | undefined public viewMode = 'grid' - public sortField = 'name' + public sortField = 'appId' public sortOrder = 1 public searchInProgress = false public displayDetailDialog = false @@ -43,8 +44,8 @@ export class ProductAppsComponent implements OnChanges { public hasCreatePermission = false public hasDeletePermission = false - @ViewChild(DataView) dv: DataView | undefined public dataViewControlsTranslations: DataViewControlTranslations = {} + @ViewChild(DataView) dv: DataView | undefined public limitText = limitText constructor( @@ -123,7 +124,7 @@ export class ProductAppsComponent implements OnChanges { } public onFilterChange(filter: string): void { this.filter = filter - //this.dv?.filter(filter, 'contains') + this.dv?.filter(filter, 'contains') } public onSortChange(field: string): void { this.sortField = field diff --git a/src/app/product-store/product-detail/product-detail.component.html b/src/app/product-store/product-detail/product-detail.component.html index 6c9adc8..ee54b3e 100644 --- a/src/app/product-store/product-detail/product-detail.component.html +++ b/src/app/product-store/product-detail/product-detail.component.html @@ -12,7 +12,11 @@
- + div { min-height: 60px; &.listview-row {