UI: Added to clear event dialog and hide action if table empty
This commit is contained in:
parent
1df1531723
commit
8421eccfd2
@ -52,6 +52,7 @@ import {
|
||||
export class EventTableConfig extends EntityTableConfig<Event, TimePageLink> {
|
||||
|
||||
eventTypeValue: EventType | DebugEventType;
|
||||
hideClearEventAction = false;
|
||||
|
||||
private filterParams: FilterEventBody = {};
|
||||
private filterColumns: FilterEntityColumn[] = [];
|
||||
@ -140,15 +141,30 @@ export class EventTableConfig extends EntityTableConfig<Event, TimePageLink> {
|
||||
{
|
||||
name: this.translate.instant('event.clean-events'),
|
||||
icon: 'delete',
|
||||
isEnabled: () => true,
|
||||
onAction: ($event) => {
|
||||
this.eventService.clearEvents(this.entityId, this.eventType, this.filterParams, this.tenantId, this.table.pageLink as TimePageLink).subscribe(
|
||||
isEnabled: () => !this.hideClearEventAction,
|
||||
onAction: $event => this.clearEvents($event)
|
||||
});
|
||||
}
|
||||
|
||||
clearEvents($event) {
|
||||
if ($event) {
|
||||
$event.stopPropagation();
|
||||
}
|
||||
this.dialogService.confirm(
|
||||
this.translate.instant('event.clear-request-title'),
|
||||
this.translate.instant('event.clear-request-text'),
|
||||
this.translate.instant('action.no'),
|
||||
this.translate.instant('action.yes')
|
||||
).subscribe((res) => {
|
||||
if (res) {
|
||||
this.eventService.clearEvents(this.entityId, this.eventType, this.filterParams,
|
||||
this.tenantId, this.table.pageLink as TimePageLink).subscribe(
|
||||
() => {
|
||||
this.table.paginator.pageIndex = 0;
|
||||
this.table.updateData();
|
||||
}
|
||||
);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@ -14,7 +14,7 @@
|
||||
/// limitations under the License.
|
||||
///
|
||||
|
||||
import { ChangeDetectorRef, Component, Input, OnInit, ViewChild, ViewContainerRef } from '@angular/core';
|
||||
import { AfterViewInit, ChangeDetectorRef, Component, Input, OnInit, ViewChild, ViewContainerRef } from '@angular/core';
|
||||
import { TranslateService } from '@ngx-translate/core';
|
||||
import { DatePipe } from '@angular/common';
|
||||
import { MatDialog } from '@angular/material/dialog';
|
||||
@ -25,13 +25,14 @@ import { EventService } from '@core/http/event.service';
|
||||
import { DialogService } from '@core/services/dialog.service';
|
||||
import { DebugEventType, EventType } from '@shared/models/event.models';
|
||||
import { Overlay } from '@angular/cdk/overlay';
|
||||
import { Subscription } from 'rxjs';
|
||||
|
||||
@Component({
|
||||
selector: 'tb-event-table',
|
||||
templateUrl: './event-table.component.html',
|
||||
styleUrls: ['./event-table.component.scss']
|
||||
})
|
||||
export class EventTableComponent implements OnInit {
|
||||
export class EventTableComponent implements OnInit, AfterViewInit {
|
||||
|
||||
@Input()
|
||||
tenantId: string;
|
||||
@ -77,6 +78,8 @@ export class EventTableComponent implements OnInit {
|
||||
|
||||
eventTableConfig: EventTableConfig;
|
||||
|
||||
private isEmptyData$: Subscription;
|
||||
|
||||
constructor(private eventService: EventService,
|
||||
private dialogService: DialogService,
|
||||
private translate: TranslateService,
|
||||
@ -106,4 +109,14 @@ export class EventTableComponent implements OnInit {
|
||||
);
|
||||
}
|
||||
|
||||
ngAfterViewInit() {
|
||||
this.isEmptyData$ = this.entitiesTable.dataSource.isEmpty().subscribe(value => this.eventTableConfig.hideClearEventAction = value);
|
||||
}
|
||||
|
||||
ngOnDestroy() {
|
||||
if (this.isEmptyData$) {
|
||||
this.isEmptyData$.unsubscribe();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -1887,7 +1887,9 @@
|
||||
"has-error": "Has error",
|
||||
"entity-id": "Entity Id",
|
||||
"entity-type": "Entity type",
|
||||
"clear-filter": "Clear Filter"
|
||||
"clear-filter": "Clear Filter",
|
||||
"clear-request-title": "Clear all events",
|
||||
"clear-request-text": "Are you sure you want to clear all events?"
|
||||
},
|
||||
"extension": {
|
||||
"extensions": "Extensions",
|
||||
|
||||
@ -959,7 +959,9 @@
|
||||
"messages-processed": "Сообщения обработаны",
|
||||
"errors-occurred": "Возникли ошибки",
|
||||
"all-events": "Все",
|
||||
"entity-type": "Тип объекта"
|
||||
"entity-type": "Тип объекта",
|
||||
"clear-request-title": "Удалить все события",
|
||||
"clear-request-text": "Вы точно хотите удалить все события?"
|
||||
},
|
||||
"extension": {
|
||||
"extensions": "Расширение",
|
||||
|
||||
@ -1211,7 +1211,9 @@
|
||||
"messages-processed": "Повідомлення опрацьовані",
|
||||
"errors-occurred": "Виникли помилки",
|
||||
"all-events": "Всі",
|
||||
"entity-type": "Тип сутності"
|
||||
"entity-type": "Тип сутності",
|
||||
"clear-request-title": "Видалити всі події",
|
||||
"clear-request-text": "Ви впевнені, що хочете видалити всі події?"
|
||||
},
|
||||
"extension": {
|
||||
"extensions": "Розширення",
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user