Added 'clean' button for rule-node events

This commit is contained in:
Kalutka Zhenya 2021-11-05 17:29:46 +02:00 committed by Viacheslav Klimov
parent 144da0367a
commit c3d86624ed
5 changed files with 19 additions and 5 deletions

View File

@ -84,7 +84,7 @@
[fxShow]="actionDescriptor.isEnabled()" *ngFor="let actionDescriptor of headerActionDescriptors" [fxShow]="actionDescriptor.isEnabled()" *ngFor="let actionDescriptor of headerActionDescriptors"
matTooltip="{{ actionDescriptor.name }}" matTooltip="{{ actionDescriptor.name }}"
matTooltipPosition="above" matTooltipPosition="above"
(click)="actionDescriptor.onAction($event)"> (click)="actionDescriptor.onAction($event, entitiesTableConfig)">
<mat-icon *ngIf="actionDescriptor.isMdiIcon" [svgIcon]="actionDescriptor.icon"></mat-icon> <mat-icon *ngIf="actionDescriptor.isMdiIcon" [svgIcon]="actionDescriptor.icon"></mat-icon>
<mat-icon *ngIf="!actionDescriptor.isMdiIcon">{{actionDescriptor.icon}}</mat-icon> <mat-icon *ngIf="!actionDescriptor.isMdiIcon">{{actionDescriptor.icon}}</mat-icon>
</button> </button>

View File

@ -48,6 +48,7 @@ import {
EventFilterPanelData, EventFilterPanelData,
FilterEntityColumn FilterEntityColumn
} from '@home/components/event/event-filter-panel.component'; } from '@home/components/event/event-filter-panel.component';
import { HttpClient } from '@angular/common/http';
export class EventTableConfig extends EntityTableConfig<Event, TimePageLink> { export class EventTableConfig extends EntityTableConfig<Event, TimePageLink> {
@ -82,7 +83,8 @@ export class EventTableConfig extends EntityTableConfig<Event, TimePageLink> {
private debugEventTypes: Array<DebugEventType> = null, private debugEventTypes: Array<DebugEventType> = null,
private overlay: Overlay, private overlay: Overlay,
private viewContainerRef: ViewContainerRef, private viewContainerRef: ViewContainerRef,
private cd: ChangeDetectorRef) { private cd: ChangeDetectorRef,
private http: HttpClient) {
super(); super();
this.loadDataOnInit = false; this.loadDataOnInit = false;
this.tableTitle = ''; this.tableTitle = '';
@ -135,6 +137,14 @@ export class EventTableConfig extends EntityTableConfig<Event, TimePageLink> {
onAction: ($event) => { onAction: ($event) => {
this.editEventFilter($event); this.editEventFilter($event);
} }
},
{
name: this.translate.instant('event.clean-events'),
icon: 'delete',
isEnabled: () => true,
onAction: ($event, entity) => {
this.http.delete(`/events/${entity.entityId.entityType}/${entity.entityId.id}/${entity.eventTypeValue}/clear`).subscribe();
}
}); });
} }

View File

@ -25,6 +25,7 @@ import { EventService } from '@core/http/event.service';
import { DialogService } from '@core/services/dialog.service'; import { DialogService } from '@core/services/dialog.service';
import { DebugEventType, EventType } from '@shared/models/event.models'; import { DebugEventType, EventType } from '@shared/models/event.models';
import { Overlay } from '@angular/cdk/overlay'; import { Overlay } from '@angular/cdk/overlay';
import { HttpClient } from '@angular/common/http';
@Component({ @Component({
selector: 'tb-event-table', selector: 'tb-event-table',
@ -84,7 +85,8 @@ export class EventTableComponent implements OnInit {
private dialog: MatDialog, private dialog: MatDialog,
private overlay: Overlay, private overlay: Overlay,
private viewContainerRef: ViewContainerRef, private viewContainerRef: ViewContainerRef,
private cd: ChangeDetectorRef) { private cd: ChangeDetectorRef,
private http: HttpClient) {
} }
ngOnInit() { ngOnInit() {
@ -102,7 +104,8 @@ export class EventTableComponent implements OnInit {
this.debugEventTypes, this.debugEventTypes,
this.overlay, this.overlay,
this.viewContainerRef, this.viewContainerRef,
this.cd this.cd,
this.http
); );
} }

View File

@ -75,7 +75,7 @@ export interface HeaderActionDescriptor {
icon: string; icon: string;
isMdiIcon?: boolean; isMdiIcon?: boolean;
isEnabled: () => boolean; isEnabled: () => boolean;
onAction: ($event: MouseEvent) => void; onAction: ($event: MouseEvent, entity?) => void;
} }
export type EntityTableColumnType = 'content' | 'action'; export type EntityTableColumnType = 'content' | 'action';

View File

@ -1853,6 +1853,7 @@
"event": { "event": {
"event-type": "Event type", "event-type": "Event type",
"events-filter": "Events Filter", "events-filter": "Events Filter",
"clean-events": "Clean Events",
"type-error": "Error", "type-error": "Error",
"type-lc-event": "Lifecycle event", "type-lc-event": "Lifecycle event",
"type-stats": "Statistics", "type-stats": "Statistics",