Skip to content

Commit

Permalink
fix logs attrs
Browse files Browse the repository at this point in the history
Signed-off-by: simvalery <[email protected]>

Signed-off-by: simvalery <[email protected]>
  • Loading branch information
simvalery committed Aug 30, 2023
1 parent e760b41 commit 4962851
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 11 deletions.
12 changes: 6 additions & 6 deletions frontend/src/app/views/admin/logs-view/logs-view.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
</mat-date-range-input>
<mat-datepicker-toggle matSuffix [for]="picker"></mat-datepicker-toggle>
<mat-date-range-picker #picker></mat-date-range-picker>

<mat-error *ngIf="searchForm.controls.startDate.hasError('matStartDateInvalid')">Invalid start date</mat-error>
<mat-error *ngIf="searchForm.controls.endDate.hasError('matEndDateInvalid')">Invalid end date</mat-error>
</mat-form-field>
Expand All @@ -36,14 +36,14 @@
<mat-icon>cancel</mat-icon>
</button>
</mat-chip>

<input
#chipInput
matInput
[matAutocomplete]="auto"
[matChipInputFor]="chipList"
placeholder="Attributes"
(matChipInputTokenEnd)="add($event)"
(matChipInputTokenEnd)="add($event, auto); chipInput.value = ''; chipInput.blur();"
[matChipInputFor]="chipList"
placeholder="Attributes"
[formControl]="autoCompleteControl">

<mat-autocomplete #auto="matAutocomplete" (optionSelected)="selected($event); chipInput.value = ''; chipInput.blur()">
Expand Down Expand Up @@ -118,4 +118,4 @@
</table>
<mat-paginator [length]="this.totalCount" [pageSizeOptions]="[10, 20, 30]"></mat-paginator>
</div>
</div>
</div>
22 changes: 17 additions & 5 deletions frontend/src/app/views/admin/logs-view/logs-view.component.ts
Original file line number Diff line number Diff line change
@@ -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';
Expand Down Expand Up @@ -47,6 +47,7 @@ export class LogsViewComponent implements OnInit {

@ViewChild(MatPaginator) paginator!: MatPaginator;
@ViewChild(MatSort) sort!: MatSort;
@ViewChild(MatAutocompleteTrigger) autocomplete: MatAutocompleteTrigger;
onSearch: EventEmitter<any> = new EventEmitter();

constructor(
Expand Down Expand Up @@ -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() {
Expand Down

0 comments on commit 4962851

Please sign in to comment.