Commit 936171b80bd285f0b3d069e8b82a3ffb74c0cd7c
Committed by
Andrew Shvayka
1 parent
4a6e0c7a
UI: Improvement event statistics filter
Showing
4 changed files
with
24 additions
and
4 deletions
... | ... | @@ -29,6 +29,15 @@ |
29 | 29 | </mat-select> |
30 | 30 | </mat-form-field> |
31 | 31 | </ng-template> |
32 | + <ng-template [ngSwitchCase]="isNumberFields(column.key)"> | |
33 | + <mat-form-field> | |
34 | + <mat-label>{{ column.title | translate}}</mat-label> | |
35 | + <input matInput type="number" min="0" [name]="column.key" [formControlName]="column.key"> | |
36 | + <mat-error *ngIf="eventFilterFormGroup.get(column.key).hasError('min')"> | |
37 | + {{ 'event.min-value' | translate }} | |
38 | + </mat-error> | |
39 | + </mat-form-field> | |
40 | + </ng-template> | |
32 | 41 | <ng-template [ngSwitchCase]="'isError'"> |
33 | 42 | <tb-checkbox formControlName="isError" [falseValue]="''"> |
34 | 43 | {{ 'event.has-error' | translate }} | ... | ... |
... | ... | @@ -15,7 +15,7 @@ |
15 | 15 | /// |
16 | 16 | |
17 | 17 | import { Component, Inject, InjectionToken } from '@angular/core'; |
18 | -import { FormBuilder, FormGroup } from '@angular/forms'; | |
18 | +import { FormBuilder, FormGroup, Validators } from '@angular/forms'; | |
19 | 19 | import { OverlayRef } from '@angular/cdk/overlay'; |
20 | 20 | import { EntityType } from '@shared/models/entity-type.models'; |
21 | 21 | import { FilterEventBody } from '@shared/models/event.models'; |
... | ... | @@ -59,7 +59,11 @@ export class EventFilterPanelComponent { |
59 | 59 | this.eventFilterFormGroup = this.fb.group({}); |
60 | 60 | this.data.columns.forEach((column) => { |
61 | 61 | this.showColumns.push(column); |
62 | - this.eventFilterFormGroup.addControl(column.key, this.fb.control(this.data.filterParams[column.key] || '')); | |
62 | + const validators = []; | |
63 | + if (this.isNumberFields(column.key)) { | |
64 | + validators.push(Validators.min(0)); | |
65 | + } | |
66 | + this.eventFilterFormGroup.addControl(column.key, this.fb.control(this.data.filterParams[column.key] || '', validators)); | |
63 | 67 | if (column.key === 'isError') { |
64 | 68 | this.conditionError = true; |
65 | 69 | } |
... | ... | @@ -70,6 +74,10 @@ export class EventFilterPanelComponent { |
70 | 74 | return ['msgDirectionType', 'status', 'entityName'].includes(key) ? key : ''; |
71 | 75 | } |
72 | 76 | |
77 | + isNumberFields(key: string): string { | |
78 | + return ['messagesProcessed', 'errorsOccurred'].includes(key) ? key : ''; | |
79 | + } | |
80 | + | |
73 | 81 | selectorValues(key: string): string[] { |
74 | 82 | switch (key) { |
75 | 83 | case 'msgDirectionType': | ... | ... |
... | ... | @@ -295,8 +295,8 @@ export class EventTableConfig extends EntityTableConfig<Event, TimePageLink> { |
295 | 295 | break; |
296 | 296 | case EventType.STATS: |
297 | 297 | this.filterColumns.push( |
298 | - {key: 'messagesProcessed', title: 'event.messages-processed'}, | |
299 | - {key: 'errorsOccurred', title: 'event.errors-occurred'} | |
298 | + {key: 'messagesProcessed', title: 'event.min-messages-processed'}, | |
299 | + {key: 'errorsOccurred', title: 'event.min-errors-occurred'} | |
300 | 300 | ); |
301 | 301 | break; |
302 | 302 | case DebugEventType.DEBUG_RULE_NODE: | ... | ... |
... | ... | @@ -1641,7 +1641,10 @@ |
1641 | 1641 | "success": "Success", |
1642 | 1642 | "failed": "Failed", |
1643 | 1643 | "messages-processed": "Messages processed", |
1644 | + "min-messages-processed": "Minimum messages processed", | |
1644 | 1645 | "errors-occurred": "Errors occurred", |
1646 | + "min-errors-occurred": "Minimum errors occurred", | |
1647 | + "min-value": "Minimum value is 0.", | |
1645 | 1648 | "all-events": "All", |
1646 | 1649 | "has-error": "Has error", |
1647 | 1650 | "entity-id": "Entity Id", | ... | ... |