Skip to content

Commit

Permalink
Add slot search page (#114)
Browse files Browse the repository at this point in the history
* feat: build slot search component

* feat: change to slot bff

* feat: make slot tiles visible

* feat: adjust translations and html ids, fix layout

* feat: fix search

* feat: center filter

* feat: finish slot tests

* feat: change page permission

* feat: adjust search tests

* feat: show sort field again

---------

Co-authored-by: Christian Badura <[email protected]>
  • Loading branch information
cbadura and Christian Badura authored May 8, 2024
1 parent 0bdac00 commit a8891bc
Show file tree
Hide file tree
Showing 26 changed files with 1,439 additions and 131 deletions.
2 changes: 2 additions & 0 deletions helm/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ app:
SAVE: Update and save product
SEARCH: Search products
VIEW: View product details
SLOT:
SEARCH: Search slots
# Keycloak
keycloak:
client:
Expand Down
2 changes: 1 addition & 1 deletion src/app/product-store/app-search/app-search.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@
]"
[enableSorting]="true"
[defaultSortOption]="sortField"
[defaultSortDirection]="sortOrder === 1"
[defaultSortDirection]="sortOrder === -1"
[sortingOptions]="[
{ label: 'APP.APP_ID' | translate, value: 'appId' },
{ label: 'APP.APP_TYPE' | translate, value: 'appType' },
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,6 @@ export class ProductPropertyComponent implements OnChanges, OnInit {
let imageType: RefType = RefType.Logo

requestParameters = {
contentLength: files.length,
refId: this.formGroup.controls['name'].value!,
refType: imageType,
body: blob
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@
{ label: 'PRODUCT.DISPLAY_NAME' | translate, value: 'displayName' }
]"
[defaultSortOption]="sortField"
[defaultSortDirection]="sortOrder === 1"
[defaultSortDirection]="sortOrder === -1"
(dataViewChange)="onLayoutChange($event)"
(filterChange)="onFilterChange($event)"
[filterColumns]="[
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@ describe('ProductSearchComponent', () => {
fixture = TestBed.createComponent(ProductSearchComponent)
component = fixture.componentInstance
router = TestBed.inject(Router)
//fixture.detectChanges()
fixture.componentInstance.ngOnInit() // solved ExpressionChangedAfterItHasBeenCheckedError
})

Expand All @@ -61,6 +60,7 @@ describe('ProductSearchComponent', () => {

it('should prepare action buttons on init', () => {
spyOn(component, 'onAppSearch')
spyOn(component, 'onSlotSearch')
spyOn(component, 'onNewProduct')

component.ngOnInit()
Expand All @@ -70,8 +70,10 @@ describe('ProductSearchComponent', () => {

actions[0].actionCallback()
actions[1].actionCallback()
actions[2].actionCallback()

expect(component.onAppSearch).toHaveBeenCalled()
expect(component.onSlotSearch).toHaveBeenCalled()
expect(component.onNewProduct).toHaveBeenCalled()
})

Expand Down Expand Up @@ -186,6 +188,14 @@ describe('ProductSearchComponent', () => {
expect(routerSpy).toHaveBeenCalledWith(['./apps'], jasmine.any(Object))
})

it('should navigate to slots onSlotSearch', () => {
const routerSpy = spyOn(router, 'navigate')

component.onSlotSearch()

expect(routerSpy).toHaveBeenCalledWith(['./slots'], jasmine.any(Object))
})

it('should sort products by display name', () => {
const p1 = { displayName: 'b product' }
const p2 = { displayName: 'a product' }
Expand Down
15 changes: 14 additions & 1 deletion src/app/product-store/product-search/product-search.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,9 @@ export class ProductSearchComponent implements OnInit {
'ACTIONS.CREATE.PRODUCT.LABEL',
'ACTIONS.CREATE.PRODUCT.TOOLTIP',
'DIALOG.SEARCH.APPS.LABEL',
'DIALOG.SEARCH.APPS.TOOLTIP'
'DIALOG.SEARCH.APPS.TOOLTIP',
'DIALOG.SEARCH.SLOTS.LABEL',
'DIALOG.SEARCH.SLOTS.TOOLTIP'
])
.pipe(
map((data) => {
Expand All @@ -136,6 +138,14 @@ export class ProductSearchComponent implements OnInit {
icon: 'pi pi-bars',
show: 'always'
},
{
label: data['DIALOG.SEARCH.SLOTS.LABEL'],
title: data['DIALOG.SEARCH.SLOTS.TOOLTIP'],
actionCallback: () => this.onSlotSearch(),
permission: 'APP#SEARCH',
icon: 'pi pi-bars',
show: 'always'
},
{
label: data['ACTIONS.CREATE.PRODUCT.LABEL'],
title: data['ACTIONS.CREATE.PRODUCT.TOOLTIP'],
Expand Down Expand Up @@ -175,6 +185,9 @@ export class ProductSearchComponent implements OnInit {
public onAppSearch() {
this.router.navigate(['./apps'], { relativeTo: this.route })
}
public onSlotSearch() {
this.router.navigate(['./slots'], { relativeTo: this.route })
}
public onNewProduct() {
this.router.navigate(['./new'], { relativeTo: this.route })
}
Expand Down
10 changes: 9 additions & 1 deletion src/app/product-store/product-store.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import { ProductDetailComponent } from './product-detail/product-detail.componen
import { ProductPropertyComponent } from './product-detail/product-props/product-props.component'
import { ProductInternComponent } from './product-detail/product-intern/product-intern.component'
import { ProductAppsComponent } from './product-detail/product-apps/product-apps.component'
import { SlotSearchComponent } from './slot-search/slot-search.component'

const routes: Routes = [
{
Expand All @@ -32,6 +33,12 @@ const routes: Routes = [
data: { breadcrumb: 'BREADCRUMBS.APPS', breadcrumbFn: (data: any) => `${data.labeli18n}` },
resolve: { labeli18n: LabelResolver }
},
{
path: 'slots',
component: SlotSearchComponent,
data: { breadcrumb: 'BREADCRUMBS.SLOTS', breadcrumbFn: (data: any) => `${data.labeli18n}` },
resolve: { labeli18n: LabelResolver }
},
{
path: 'new',
component: ProductDetailComponent,
Expand All @@ -54,7 +61,8 @@ const routes: Routes = [
ProductDetailComponent,
ProductPropertyComponent,
ProductInternComponent,
ProductAppsComponent
ProductAppsComponent,
SlotSearchComponent
],
imports: [
CommonModule,
Expand Down
99 changes: 99 additions & 0 deletions src/app/product-store/slot-search/slot-search.component.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
<ocx-portal-page permission="SLOT#SEARCH" helpArticleId="PAGE_SLOT_SEARCH">
<ocx-search-header
[header]="'DIALOG.SEARCH.SLOTS.HEADER' | translate"
[subheader]="'DIALOG.SEARCH.SLOTS.SUBHEADER' | translate"
(searched)="onSearch()"
(resetted)="onSearchReset()"
[manualBreadcrumbs]="false"
[actions]="(actions$ | async) ?? []"
>
<div id="slot_search_criteria" [formGroup]="slotSearchCriteriaGroup" class="flex flex-wrap gap-4 row-gap-3 px-2">
<span class="p-float-label">
<input
pInputText
id="slot_search_criteria_slot_name"
type="text"
formControlName="slotName"
class="w-18rem"
[clear]="true"
[title]="'SLOT.TOOLTIPS.NAME' | translate"
/>
<label for="slot_search_criteria_slot_name">{{ 'SLOT.NAME' | translate }}</label>
</span>
</div>
</ocx-search-header>

<ocx-page-content>
<div *ngIf="exceptionKey" id="slot_search_criteria_error" class="card px-3 align-items-center">
<p-message
id="slot_search_criteria_error_message"
severity="error"
styleClass="p-2"
[text]="exceptionKey | translate"
></p-message>
</div>
<p-dataView
*ngIf="!exceptionKey"
id="slot_search_dataview"
[value]="(slots$ | async)?.stream!.sort(sortSlotsByName)"
[paginator]="true"
[alwaysShowPaginator]="false"
[rowsPerPageOptions]="[10, 20, 50]"
[rows]="12"
[layout]="viewMode"
[emptyMessage]="'ACTIONS.SEARCH.NOT_FOUND' | translate"
filterBy="name"
[sortField]="sortField"
[sortOrder]="sortOrder"
>
<ng-template pTemplate="header">
<ocx-data-view-controls
id="slot_search_dataview_controls"
[enableFiltering]="true"
[enableSorting]="true"
[supportedViews]="['grid']"
[initialViewMode]="viewMode"
[defaultSortOption]="sortField"
[sortingOptions]="[
{ label: 'PRODUCT.NAME' | translate, value: 'name' },
{ label: 'APP.APP_ID' | translate, value: 'appId' }
]"
[defaultSortDirection]="sortOrder === -1"
(sortChange)="onSortChange($event)"
(sortDirectionChange)="onSortDirChange($event)"
(filterChange)="onFilterChange($event)"
[filterColumns]="['SLOT.NAME' | translate]"
[translations]="dataViewControlsTranslations"
>
</ocx-data-view-controls>
</ng-template>
<ng-template let-slot let-idx="rowIndex" pTemplate="gridItem">
<div [id]="'slot_search_data_grid_' + idx" class="col-12 sm:col-6 md:col-4 lg:col-4 xl:col-3 p-3">
<div class="card relative p-2 flex flex-column justify-content-center hover:bg-gray-200 cursor-pointer">
<div class="h-5rem flex flex-column justify-content-between gap-1 text-center">
<div
[id]="'slot_search_data_grid_' + idx + '_slot_name'"
class="mt-2 font-bold text-lg"
[title]="('SLOT.NAME' | translate) + ': ' + slot.name"
>
{{ limitText(slot.name, 25) }}
</div>
<div
[id]="'slot_search_data_grid_' + idx + '_slot_app_id'"
[title]="('APP.APP_ID' | translate) + ': ' + slot.appId"
>
{{ limitText(slot.appId, 25) }}
</div>
<div
[id]="'slot_search_data_grid_' + idx + '_product_name'"
[title]="('SLOT.PRODUCT_NAME' | translate) + ': ' + limitText(slot.productName, 100)"
>
{{ limitText(slot.productName, 20) }}
</div>
</div>
</div>
</div>
</ng-template>
</p-dataView>
</ocx-page-content>
</ocx-portal-page>
20 changes: 20 additions & 0 deletions src/app/product-store/slot-search/slot-search.component.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
@import '/src/_mixins.scss';

@include correct-data-view-control;
@include correct-search-criteria;
@include card-badges;
@include danger-action;

:host ::ng-deep {
.p-dataview-content .p-grid > div {
min-height: 60px;
&.listview-row {
&:nth-child(odd) {
background-color: #f8f9fa;
}
}
}
.h-05rem {
height: 0.5rem;
}
}
Loading

0 comments on commit a8891bc

Please sign in to comment.