diff --git a/ui-ngx/src/app/modules/home/components/event/event-table-config.ts b/ui-ngx/src/app/modules/home/components/event/event-table-config.ts index 3b8a8ea171..ceb5acca7b 100644 --- a/ui-ngx/src/app/modules/home/components/event/event-table-config.ts +++ b/ui-ngx/src/app/modules/home/components/event/event-table-config.ts @@ -20,7 +20,7 @@ import { EntityTableColumn, EntityTableConfig } from '@home/models/entity/entities-table-config.models'; -import {DebugEventType, Event, EventType} from '@shared/models/event.models'; +import {DebugEventType, EdgeEventType, Event, EventType} from '@shared/models/event.models'; import {TimePageLink} from '@shared/models/page/page-link'; import {TranslateService} from '@ngx-translate/core'; import {DatePipe} from '@angular/common'; @@ -39,6 +39,7 @@ import { EventContentDialogData } from '@home/components/event/event-content-dialog.component'; import {sortObjectKeys} from '@core/utils'; +import {RuleChainService} from "@core/http/rule-chain.service"; export class EventTableConfig extends EntityTableConfig { @@ -60,6 +61,7 @@ export class EventTableConfig extends EntityTableConfig { constructor(private eventService: EventService, private dialogService: DialogService, private translate: TranslateService, + private ruleChainService: RuleChainService, private datePipe: DatePipe, private dialog: MatDialog, public entityId: EntityId, @@ -119,9 +121,13 @@ export class EventTableConfig extends EntityTableConfig { this.columns = []; this.columns.push( new DateEntityTableColumn('createdTime', 'event.event-time', this.datePipe, '120px'), - // new EntityTableColumn('server', 'event.server', '100px', - // (entity) => entity.body.server, entity => ({}), false) ); + if (this.eventType !== EventType.EDGE_EVENT) { + this.columns.push( + new EntityTableColumn('server', 'event.server', '100px', + (entity) => entity.body.server, entity => ({}), false) + ); + } switch (this.eventType) { case EventType.ERROR: this.columns.push( @@ -175,7 +181,16 @@ export class EventTableConfig extends EntityTableConfig { new EntityTableColumn('action', 'event.action', '100%', (entity) => entity.action, entity => ({}), false), new EntityTableColumn('entityId', 'event.entityId', '100%', - (entity) => entity.id.id, entity => ({}), false) //TODO: replace this to entity.entityId because of conflict wiht entityId model + (entity) => entity.id.id, entity => ({}), false), //TODO: replace this to entity.entityId because of conflict wiht entityId model + new EntityActionTableColumn('data', 'event.data', + { + name: this.translate.instant('action.view'), + icon: 'more_horiz', + isEnabled: (entity) => this.checkEdgeEventType(entity), + onAction: ($event, entity) => this.showEdgeEventContent($event, this.manageEdgeEventContent(entity), + 'event.data') + }, + '40px'), ); break; case DebugEventType.DEBUG_RULE_NODE: @@ -268,4 +283,49 @@ export class EventTableConfig extends EntityTableConfig { } }); } + + checkEdgeEventType(entity) { + return !( entity.type === EdgeEventType.WIDGET_TYPE || + entity.type === EdgeEventType.ADMIN_SETTINGS || + entity.type === EdgeEventType.WIDGETS_BUNDLE ); + } + + manageEdgeEventContent(entity) { + var content = ''; + switch (entity.type) { + case EdgeEventType.RELATION: + content = entity.body; + break; + // case EdgeEventType.RULE_CHAIN_METADATA: + // this.ruleChainService.getRuleChainMetadata(entity.entityId, null).pipe( + // map(ruleChainMetaData => content = ruleChainMetaData.nodes) + // ); + // break; + default: + content = entity; + break; + } + return JSON.stringify(content); + } + + showEdgeEventContent($event: MouseEvent, content: string, title: string, sortKeys = false): void { + if ($event) { + $event.stopPropagation(); + } + var contentType = ContentType.JSON; + if (contentType === ContentType.JSON && sortKeys) { + try { + content = JSON.stringify(sortObjectKeys(JSON.parse(content))); + } catch (e) {} + } + this.dialog.open(EventContentDialogComponent, { + disableClose: true, + panelClass: ['tb-dialog', 'tb-fullscreen-dialog'], + data: { + content, + title, + contentType + } + }); + } } diff --git a/ui-ngx/src/app/modules/home/components/event/event-table.component.ts b/ui-ngx/src/app/modules/home/components/event/event-table.component.ts index aa6ce5dd77..06ed3141a1 100644 --- a/ui-ngx/src/app/modules/home/components/event/event-table.component.ts +++ b/ui-ngx/src/app/modules/home/components/event/event-table.component.ts @@ -24,6 +24,7 @@ import { EventTableConfig } from './event-table-config'; import { EventService } from '@core/http/event.service'; import { DialogService } from '@core/services/dialog.service'; import { DebugEventType, EventType } from '@shared/models/event.models'; +import { RuleChainService } from "@core/http/rule-chain.service"; @Component({ selector: 'tb-event-table', @@ -79,6 +80,7 @@ export class EventTableComponent implements OnInit { constructor(private eventService: EventService, private dialogService: DialogService, private translate: TranslateService, + private ruleChainService: RuleChainService, private datePipe: DatePipe, private dialog: MatDialog) { } @@ -89,6 +91,7 @@ export class EventTableComponent implements OnInit { this.eventService, this.dialogService, this.translate, + this.ruleChainService, this.datePipe, this.dialog, this.entityIdValue, diff --git a/ui-ngx/src/app/shared/models/event.models.ts b/ui-ngx/src/app/shared/models/event.models.ts index 6c6e91a876..73c62f1e74 100644 --- a/ui-ngx/src/app/shared/models/event.models.ts +++ b/ui-ngx/src/app/shared/models/event.models.ts @@ -19,6 +19,7 @@ import { TenantId } from '@shared/models/id/tenant-id'; import { EntityId } from '@shared/models/id/entity-id'; import { EventId } from './id/event-id'; import { ContentType } from '@shared/models/constants'; +import { EntityType } from '@shared/models/entity-type.models' export enum EventType { ERROR = 'ERROR', @@ -31,6 +32,28 @@ export enum DebugEventType { DEBUG_RULE_NODE = 'DEBUG_RULE_NODE', DEBUG_RULE_CHAIN = 'DEBUG_RULE_CHAIN' } +//TODO deaflynx filter CE only event types +export enum EdgeEventType { + DASHBOARD = "DASHBOARD", + ASSET = "ASSET", + DEVICE = "DEVICE", + ENTITY_VIEW = "ENTITY_VIEW", + ALARM = "ALARM", + RULE_CHAIN = "RULE_CHAIN", + RULE_CHAIN_METADATA = "RULE_CHAIN_METADATA", + EDGE = "EDGE", + USER = "USER", + CUSTOMER = "CUSTOMER", + RELATION = "RELATION", + ENTITY_GROUP = "ENTITY_GROUP", + SCHEDULER_EVENT = "SCHEDULER_EVENT", + WHITE_LABELING = "WHITE_LABELING", + LOGIN_WHITE_LABELING = "LOGIN_WHITE_LABELING", + CUSTOM_TRANSLATION = "CUSTOM_TRANSLATION", + WIDGETS_BUNDLE = "WIDGETS_BUNDLE", + WIDGET_TYPE = "WIDGET_TYPE", + ADMIN_SETTINGS = "ADMIN_SETTINGS" +} export const eventTypeTranslations = new Map( [