UI: Improvement event statistics filter

This commit is contained in:
Vladyslav_Prykhodko 2021-04-16 11:57:09 +03:00 committed by Andrew Shvayka
parent 4a6e0c7aae
commit 936171b80b
4 changed files with 24 additions and 4 deletions

View File

@ -29,6 +29,15 @@
</mat-select> </mat-select>
</mat-form-field> </mat-form-field>
</ng-template> </ng-template>
<ng-template [ngSwitchCase]="isNumberFields(column.key)">
<mat-form-field>
<mat-label>{{ column.title | translate}}</mat-label>
<input matInput type="number" min="0" [name]="column.key" [formControlName]="column.key">
<mat-error *ngIf="eventFilterFormGroup.get(column.key).hasError('min')">
{{ 'event.min-value' | translate }}
</mat-error>
</mat-form-field>
</ng-template>
<ng-template [ngSwitchCase]="'isError'"> <ng-template [ngSwitchCase]="'isError'">
<tb-checkbox formControlName="isError" [falseValue]="''"> <tb-checkbox formControlName="isError" [falseValue]="''">
{{ 'event.has-error' | translate }} {{ 'event.has-error' | translate }}

View File

@ -15,7 +15,7 @@
/// ///
import { Component, Inject, InjectionToken } from '@angular/core'; import { Component, Inject, InjectionToken } from '@angular/core';
import { FormBuilder, FormGroup } from '@angular/forms'; import { FormBuilder, FormGroup, Validators } from '@angular/forms';
import { OverlayRef } from '@angular/cdk/overlay'; import { OverlayRef } from '@angular/cdk/overlay';
import { EntityType } from '@shared/models/entity-type.models'; import { EntityType } from '@shared/models/entity-type.models';
import { FilterEventBody } from '@shared/models/event.models'; import { FilterEventBody } from '@shared/models/event.models';
@ -59,7 +59,11 @@ export class EventFilterPanelComponent {
this.eventFilterFormGroup = this.fb.group({}); this.eventFilterFormGroup = this.fb.group({});
this.data.columns.forEach((column) => { this.data.columns.forEach((column) => {
this.showColumns.push(column); this.showColumns.push(column);
this.eventFilterFormGroup.addControl(column.key, this.fb.control(this.data.filterParams[column.key] || '')); const validators = [];
if (this.isNumberFields(column.key)) {
validators.push(Validators.min(0));
}
this.eventFilterFormGroup.addControl(column.key, this.fb.control(this.data.filterParams[column.key] || '', validators));
if (column.key === 'isError') { if (column.key === 'isError') {
this.conditionError = true; this.conditionError = true;
} }
@ -70,6 +74,10 @@ export class EventFilterPanelComponent {
return ['msgDirectionType', 'status', 'entityName'].includes(key) ? key : ''; return ['msgDirectionType', 'status', 'entityName'].includes(key) ? key : '';
} }
isNumberFields(key: string): string {
return ['messagesProcessed', 'errorsOccurred'].includes(key) ? key : '';
}
selectorValues(key: string): string[] { selectorValues(key: string): string[] {
switch (key) { switch (key) {
case 'msgDirectionType': case 'msgDirectionType':

View File

@ -295,8 +295,8 @@ export class EventTableConfig extends EntityTableConfig<Event, TimePageLink> {
break; break;
case EventType.STATS: case EventType.STATS:
this.filterColumns.push( this.filterColumns.push(
{key: 'messagesProcessed', title: 'event.messages-processed'}, {key: 'messagesProcessed', title: 'event.min-messages-processed'},
{key: 'errorsOccurred', title: 'event.errors-occurred'} {key: 'errorsOccurred', title: 'event.min-errors-occurred'}
); );
break; break;
case DebugEventType.DEBUG_RULE_NODE: case DebugEventType.DEBUG_RULE_NODE:

View File

@ -1641,7 +1641,10 @@
"success": "Success", "success": "Success",
"failed": "Failed", "failed": "Failed",
"messages-processed": "Messages processed", "messages-processed": "Messages processed",
"min-messages-processed": "Minimum messages processed",
"errors-occurred": "Errors occurred", "errors-occurred": "Errors occurred",
"min-errors-occurred": "Minimum errors occurred",
"min-value": "Minimum value is 0.",
"all-events": "All", "all-events": "All",
"has-error": "Has error", "has-error": "Has error",
"entity-id": "Entity Id", "entity-id": "Entity Id",