From 49628515d746ad5f5b21df0f41a3b7e9edaaaed1 Mon Sep 17 00:00:00 2001 From: simvalery Date: Wed, 30 Aug 2023 14:31:54 +0400 Subject: [PATCH] fix logs attrs Signed-off-by: simvalery Signed-off-by: simvalery --- .../admin/logs-view/logs-view.component.html | 12 +++++----- .../admin/logs-view/logs-view.component.ts | 22 ++++++++++++++----- 2 files changed, 23 insertions(+), 11 deletions(-) diff --git a/frontend/src/app/views/admin/logs-view/logs-view.component.html b/frontend/src/app/views/admin/logs-view/logs-view.component.html index d7c57bf30..7a0874cee 100644 --- a/frontend/src/app/views/admin/logs-view/logs-view.component.html +++ b/frontend/src/app/views/admin/logs-view/logs-view.component.html @@ -23,7 +23,7 @@ - + Invalid start date Invalid end date @@ -36,14 +36,14 @@ cancel - + @@ -118,4 +118,4 @@ - \ No newline at end of file + diff --git a/frontend/src/app/views/admin/logs-view/logs-view.component.ts b/frontend/src/app/views/admin/logs-view/logs-view.component.ts index 9e3332c7a..47774e17f 100644 --- a/frontend/src/app/views/admin/logs-view/logs-view.component.ts +++ b/frontend/src/app/views/admin/logs-view/logs-view.component.ts @@ -1,6 +1,6 @@ import { Component, EventEmitter, OnInit, ViewChild } from '@angular/core'; import { FormBuilder } from '@angular/forms'; -import { MatAutocompleteSelectedEvent } from '@angular/material/autocomplete'; +import { MatAutocompleteSelectedEvent, MatAutocompleteTrigger } from '@angular/material/autocomplete'; import { MatChipInputEvent } from '@angular/material/chips'; import { MatDialog } from '@angular/material/dialog'; import { MatPaginator } from '@angular/material/paginator'; @@ -47,6 +47,7 @@ export class LogsViewComponent implements OnInit { @ViewChild(MatPaginator) paginator!: MatPaginator; @ViewChild(MatSort) sort!: MatSort; + @ViewChild(MatAutocompleteTrigger) autocomplete: MatAutocompleteTrigger; onSearch: EventEmitter = new EventEmitter(); constructor( @@ -128,15 +129,26 @@ export class LogsViewComponent implements OnInit { this.onApply(); } - add(event: MatChipInputEvent): void { + add(event: MatChipInputEvent, auto: any): void { const value = (event.value || '').trim(); const attributes = this.searchForm.get('attributes')!.value; if (value) { - attributes.push(value); + const attrList = this.logService.getAttributes(value, this.searchForm?.get('attributes')?.value).subscribe(attrs => { + const firstAttr = attrs[0]; + if (firstAttr) { + attributes.push(firstAttr); + } + event.chipInput!.clear(); + this.autocomplete.closePanel(); + this.autoCompleteControl.patchValue(''); + this.onApply(); + attrList.unsubscribe(); + }) + } else { + event.chipInput!.clear(); + this.onApply(); } - - event.chipInput!.clear(); } onApply() {