From 41d3c006d478d048473c3f4166be2548d1105792 Mon Sep 17 00:00:00 2001 From: Volha Mardvilka Date: Tue, 4 Feb 2025 09:59:41 +0000 Subject: [PATCH] 391372198: (feat) [GM3] add risk profile search --- .../list-layout/list-layout.component.ts | 25 ++++++++++++++++--- 1 file changed, 21 insertions(+), 4 deletions(-) diff --git a/modules/ui/src/app/components/list-layout/list-layout.component.ts b/modules/ui/src/app/components/list-layout/list-layout.component.ts index 6a787cd4e..ce5bd9d80 100644 --- a/modules/ui/src/app/components/list-layout/list-layout.component.ts +++ b/modules/ui/src/app/components/list-layout/list-layout.component.ts @@ -16,12 +16,13 @@ import { Component, computed, + inject, input, output, signal, TemplateRef, } from '@angular/core'; -import { CommonModule } from '@angular/common'; +import { CommonModule, DatePipe } from '@angular/common'; import { MatButtonModule } from '@angular/material/button'; import { MatSidenavModule } from '@angular/material/sidenav'; import { MatToolbarModule } from '@angular/material/toolbar'; @@ -30,6 +31,7 @@ import { ListItemComponent } from '../list-item/list-item.component'; import { EntityAction, EntityActionResult } from '../../model/entity-action'; import { Device } from '../../model/device'; import { LayoutType } from '../../model/layout-type'; +import { Profile } from '../../model/profile'; @Component({ selector: 'app-list-layout', @@ -41,10 +43,12 @@ import { LayoutType } from '../../model/layout-type'; MatIconModule, ListItemComponent, ], + providers: [DatePipe], templateUrl: './list-layout.component.html', styleUrl: './list-layout.component.scss', }) export class ListLayoutComponent { + private datePipe = inject(DatePipe); readonly LayoutType = LayoutType; title = input(''); addEntityText = input(''); @@ -96,16 +100,29 @@ export class ListLayoutComponent { // eslint-disable-next-line @typescript-eslint/no-explicit-any getObjectForFilter(item: any) { if (this.title() === LayoutType.Device) { - const newObj1 = item as Device; + const device = item as Device; return { - model: newObj1.model, - manufacturer: newObj1.manufacturer, + model: device.model, + manufacturer: device.manufacturer, + }; + } else if (this.title() === LayoutType.Profile) { + const profile = item as Profile; + return { + name: profile.name, + risk: profile.risk, + created: this.getFormattedDateString(profile.created), }; } else { return item; } } + getFormattedDateString(createdDate: string | undefined) { + return createdDate + ? this.datePipe.transform(createdDate, 'dd MMM yyyy') + : ''; + } + onMenuItemClick(action: string, entity: T, index: number) { this.menuItemClicked.emit({ action,