34 changed files with 990 additions and 67 deletions
@ -0,0 +1,41 @@ |
|||
///
|
|||
/// Copyright © 2016-2019 The Thingsboard Authors
|
|||
///
|
|||
/// Licensed under the Apache License, Version 2.0 (the "License");
|
|||
/// you may not use this file except in compliance with the License.
|
|||
/// You may obtain a copy of the License at
|
|||
///
|
|||
/// http://www.apache.org/licenses/LICENSE-2.0
|
|||
///
|
|||
/// Unless required by applicable law or agreed to in writing, software
|
|||
/// distributed under the License is distributed on an "AS IS" BASIS,
|
|||
/// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|||
/// See the License for the specific language governing permissions and
|
|||
/// limitations under the License.
|
|||
///
|
|||
|
|||
import { Injectable } from '@angular/core'; |
|||
import { defaultHttpOptions } from './http-utils'; |
|||
import { Observable } from 'rxjs/index'; |
|||
import { HttpClient } from '@angular/common/http'; |
|||
import { TimePageLink } from '@shared/models/page/page-link'; |
|||
import { PageData } from '@shared/models/page/page-data'; |
|||
import { EntityId } from '@shared/models/id/entity-id'; |
|||
import { DebugEventType, Event, EventType } from '@shared/models/event.models'; |
|||
|
|||
@Injectable({ |
|||
providedIn: 'root' |
|||
}) |
|||
export class EventService { |
|||
|
|||
constructor( |
|||
private http: HttpClient |
|||
) { } |
|||
|
|||
public getEvents(entityId: EntityId, eventType: EventType | DebugEventType, tenantId: string, pageLink: TimePageLink, |
|||
ignoreErrors: boolean = false, ignoreLoading: boolean = false): Observable<PageData<Event>> { |
|||
return this.http.get<PageData<Event>>(`/api/events/${entityId.entityType}/${entityId.id}/${eventType}` + |
|||
`${pageLink.toQuery()}&tenantId=${tenantId}`, |
|||
defaultHttpOptions(ignoreLoading, ignoreErrors)); |
|||
} |
|||
} |
|||
@ -0,0 +1,212 @@ |
|||
///
|
|||
/// Copyright © 2016-2019 The Thingsboard Authors
|
|||
///
|
|||
/// Licensed under the Apache License, Version 2.0 (the "License");
|
|||
/// you may not use this file except in compliance with the License.
|
|||
/// You may obtain a copy of the License at
|
|||
///
|
|||
/// http://www.apache.org/licenses/LICENSE-2.0
|
|||
///
|
|||
/// Unless required by applicable law or agreed to in writing, software
|
|||
/// distributed under the License is distributed on an "AS IS" BASIS,
|
|||
/// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|||
/// See the License for the specific language governing permissions and
|
|||
/// limitations under the License.
|
|||
///
|
|||
|
|||
import { |
|||
DateEntityTableColumn, |
|||
EntityActionTableColumn, |
|||
EntityTableColumn, |
|||
EntityTableConfig |
|||
} from '@home/models/entity/entities-table-config.models'; |
|||
import { DebugEventType, 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'; |
|||
import { MatDialog } from '@angular/material/dialog'; |
|||
import { EntityId } from '@shared/models/id/entity-id'; |
|||
import { EventService } from '@app/core/http/event.service'; |
|||
import { EventTableHeaderComponent } from '@home/components/event/event-table-header.component'; |
|||
import { EntityTypeResource } from '@shared/models/entity-type.models'; |
|||
import { Observable } from 'rxjs'; |
|||
import { PageData } from '@shared/models/page/page-data'; |
|||
import { Direction } from '@shared/models/page/sort-order'; |
|||
import { MsgDataType } from '@shared/models/rule-node.models'; |
|||
import { DialogService } from '@core/services/dialog.service'; |
|||
|
|||
export class EventTableConfig extends EntityTableConfig<Event, TimePageLink> { |
|||
|
|||
eventTypeValue: EventType | DebugEventType; |
|||
|
|||
set eventType(eventType: EventType | DebugEventType) { |
|||
if (this.eventTypeValue !== eventType) { |
|||
this.eventTypeValue = eventType; |
|||
this.updateColumns(true); |
|||
} |
|||
} |
|||
|
|||
get eventType(): EventType | DebugEventType { |
|||
return this.eventTypeValue; |
|||
} |
|||
|
|||
eventTypes: Array<EventType | DebugEventType>; |
|||
|
|||
constructor(private eventService: EventService, |
|||
private dialogService: DialogService, |
|||
private translate: TranslateService, |
|||
private datePipe: DatePipe, |
|||
private dialog: MatDialog, |
|||
public entityId: EntityId, |
|||
public tenantId: string, |
|||
private defaultEventType: EventType | DebugEventType, |
|||
private disabledEventTypes: Array<EventType | DebugEventType> = null, |
|||
private debugEventTypes: Array<DebugEventType> = null) { |
|||
super(); |
|||
this.loadDataOnInit = false; |
|||
this.tableTitle = ''; |
|||
this.useTimePageLink = true; |
|||
this.detailsPanelEnabled = false; |
|||
this.selectionEnabled = false; |
|||
this.searchEnabled = false; |
|||
this.addEnabled = false; |
|||
this.entitiesDeleteEnabled = false; |
|||
|
|||
this.headerComponent = EventTableHeaderComponent; |
|||
|
|||
this.eventTypes = Object.keys(EventType).map(type => EventType[type]); |
|||
|
|||
if (disabledEventTypes && disabledEventTypes.length) { |
|||
this.eventTypes = this.eventTypes.filter(type => disabledEventTypes.indexOf(type) === -1); |
|||
} |
|||
|
|||
if (debugEventTypes && debugEventTypes.length) { |
|||
this.eventTypes = [...this.eventTypes, ...debugEventTypes]; |
|||
} |
|||
|
|||
this.eventTypeValue = defaultEventType; |
|||
|
|||
this.entityTranslations = { |
|||
noEntities: 'event.no-events-prompt' |
|||
}; |
|||
this.entityResources = { |
|||
} as EntityTypeResource; |
|||
this.entitiesFetchFunction = pageLink => this.fetchEvents(pageLink); |
|||
|
|||
this.defaultSortOrder = {property: 'createdTime', direction: Direction.DESC}; |
|||
|
|||
this.updateColumns(); |
|||
} |
|||
|
|||
fetchEvents(pageLink: TimePageLink): Observable<PageData<Event>> { |
|||
return this.eventService.getEvents(this.entityId, this.eventType, this.tenantId, pageLink); |
|||
} |
|||
|
|||
updateColumns(updateTableColumns: boolean = false): void { |
|||
this.columns = []; |
|||
this.columns.push( |
|||
new DateEntityTableColumn<Event>('createdTime', 'event.event-time', this.datePipe, '150px'), |
|||
new EntityTableColumn<Event>('server', 'event.server', '150px', |
|||
(entity) => entity.body.server, entity => ({}), false)); |
|||
switch (this.eventType) { |
|||
case EventType.ERROR: |
|||
this.columns.push( |
|||
new EntityTableColumn<Event>('method', 'event.method', '100%', |
|||
(entity) => entity.body.method, entity => ({}), false), |
|||
new EntityActionTableColumn<Event>('error', 'event.error', |
|||
{ |
|||
name: this.translate.instant('action.view'), |
|||
icon: 'more_horiz', |
|||
isEnabled: (entity) => entity.body.error && entity.body.error.length > 0, |
|||
onAction: ($event, entity) => this.showContent($event, entity.body.error, 'event.error') |
|||
}, |
|||
'100px') |
|||
); |
|||
break; |
|||
case EventType.LC_EVENT: |
|||
this.columns.push( |
|||
new EntityTableColumn<Event>('method', 'event.event', '100%', |
|||
(entity) => entity.body.event, entity => ({}), false), |
|||
new EntityTableColumn<Event>('status', 'event.status', '100%', |
|||
(entity) => |
|||
this.translate.instant(entity.body.success ? 'event.success' : 'event.failed'), entity => ({}), false), |
|||
new EntityActionTableColumn<Event>('error', 'event.error', |
|||
{ |
|||
name: this.translate.instant('action.view'), |
|||
icon: 'more_horiz', |
|||
isEnabled: (entity) => entity.body.error && entity.body.error.length > 0, |
|||
onAction: ($event, entity) => this.showContent($event, entity.body.error, 'event.error') |
|||
}, |
|||
'100px') |
|||
); |
|||
break; |
|||
case EventType.STATS: |
|||
this.columns.push( |
|||
new EntityTableColumn<Event>('messagesProcessed', 'event.messages-processed', '100%', |
|||
(entity) => entity.body.messagesProcessed + '', |
|||
entity => ({justifyContent: 'flex-end'}), |
|||
false, |
|||
key => ({justifyContent: 'flex-end'})), |
|||
new EntityTableColumn<Event>('errorsOccurred', 'event.errors-occurred', '100%', |
|||
(entity) => entity.body.errorsOccurred + '', |
|||
entity => ({justifyContent: 'flex-end'}), |
|||
false, |
|||
key => ({justifyContent: 'flex-end'})) |
|||
); |
|||
break; |
|||
case DebugEventType.DEBUG_RULE_NODE: |
|||
case DebugEventType.DEBUG_RULE_CHAIN: |
|||
this.columns.push( |
|||
new EntityTableColumn<Event>('type', 'event.type', '100%', |
|||
(entity) => entity.body.type, entity => ({}), false), |
|||
new EntityTableColumn<Event>('entity', 'event.entity', '100%', |
|||
(entity) => entity.body.entityName, entity => ({}), false), |
|||
new EntityTableColumn<Event>('msgId', 'event.message-id', '100%', |
|||
(entity) => entity.body.msgId, entity => ({}), false), |
|||
new EntityTableColumn<Event>('msgType', 'event.message-type', '100%', |
|||
(entity) => entity.body.msgType, entity => ({}), false), |
|||
new EntityTableColumn<Event>('relationType', 'event.relation-type', '100%', |
|||
(entity) => entity.body.relationType, entity => ({}), false), |
|||
new EntityActionTableColumn<Event>('data', 'event.data', |
|||
{ |
|||
name: this.translate.instant('action.view'), |
|||
icon: 'more_horiz', |
|||
isEnabled: (entity) => entity.body.data && entity.body.data.length > 0, |
|||
onAction: ($event, entity) => this.showContent($event, entity.body.data, |
|||
'event.data', entity.body.dataType) |
|||
}, |
|||
'60px'), |
|||
new EntityActionTableColumn<Event>('metadata', 'event.metadata', |
|||
{ |
|||
name: this.translate.instant('action.view'), |
|||
icon: 'more_horiz', |
|||
isEnabled: (entity) => entity.body.metadata && entity.body.metadata.length > 0, |
|||
onAction: ($event, entity) => this.showContent($event, entity.body.metadata, |
|||
'event.metadata', MsgDataType.JSON) |
|||
}, |
|||
'60px'), |
|||
new EntityActionTableColumn<Event>('error', 'event.error', |
|||
{ |
|||
name: this.translate.instant('action.view'), |
|||
icon: 'more_horiz', |
|||
isEnabled: (entity) => entity.body.error && entity.body.error.length > 0, |
|||
onAction: ($event, entity) => this.showContent($event, entity.body.error, |
|||
'event.error') |
|||
}, |
|||
'60px') |
|||
); |
|||
break; |
|||
} |
|||
if (updateTableColumns) { |
|||
this.table.columnsUpdated(true); |
|||
} |
|||
} |
|||
|
|||
showContent($event: MouseEvent, content: string, title: string, contentType: MsgDataType = null): void { |
|||
if ($event) { |
|||
$event.stopPropagation(); |
|||
} |
|||
// TODO:
|
|||
this.dialogService.todo(); |
|||
} |
|||
} |
|||
@ -0,0 +1,27 @@ |
|||
<!-- |
|||
|
|||
Copyright © 2016-2019 The Thingsboard Authors |
|||
|
|||
Licensed under the Apache License, Version 2.0 (the "License"); |
|||
you may not use this file except in compliance with the License. |
|||
You may obtain a copy of the License at |
|||
|
|||
http://www.apache.org/licenses/LICENSE-2.0 |
|||
|
|||
Unless required by applicable law or agreed to in writing, software |
|||
distributed under the License is distributed on an "AS IS" BASIS, |
|||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
|||
See the License for the specific language governing permissions and |
|||
limitations under the License. |
|||
|
|||
--> |
|||
|
|||
<mat-form-field class="mat-block" style="width: 200px;"> |
|||
<mat-label translate>event.event-type</mat-label> |
|||
<mat-select matInput [ngModel]="eventTableConfig.eventType" |
|||
(ngModelChange)="eventTypeChanged($event)"> |
|||
<mat-option *ngFor="let type of eventTableConfig.eventTypes" [value]="type"> |
|||
{{ eventTypeTranslationsMap.get(type) | translate }} |
|||
</mat-option> |
|||
</mat-select> |
|||
</mat-form-field> |
|||
@ -0,0 +1,35 @@ |
|||
/** |
|||
* Copyright © 2016-2019 The Thingsboard Authors |
|||
* |
|||
* Licensed under the Apache License, Version 2.0 (the "License"); |
|||
* you may not use this file except in compliance with the License. |
|||
* You may obtain a copy of the License at |
|||
* |
|||
* http://www.apache.org/licenses/LICENSE-2.0 |
|||
* |
|||
* Unless required by applicable law or agreed to in writing, software |
|||
* distributed under the License is distributed on an "AS IS" BASIS, |
|||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
|||
* See the License for the specific language governing permissions and |
|||
* limitations under the License. |
|||
*/ |
|||
:host { |
|||
/* flex: 1; |
|||
display: flex; |
|||
justify-content: flex-start; */ |
|||
padding-right: 8px; |
|||
} |
|||
|
|||
:host ::ng-deep { |
|||
mat-form-field { |
|||
font-size: 16px; |
|||
|
|||
.mat-form-field-wrapper { |
|||
padding-bottom: 0; |
|||
} |
|||
|
|||
.mat-form-field-underline { |
|||
bottom: 0; |
|||
} |
|||
} |
|||
} |
|||
@ -0,0 +1,45 @@ |
|||
///
|
|||
/// Copyright © 2016-2019 The Thingsboard Authors
|
|||
///
|
|||
/// Licensed under the Apache License, Version 2.0 (the "License");
|
|||
/// you may not use this file except in compliance with the License.
|
|||
/// You may obtain a copy of the License at
|
|||
///
|
|||
/// http://www.apache.org/licenses/LICENSE-2.0
|
|||
///
|
|||
/// Unless required by applicable law or agreed to in writing, software
|
|||
/// distributed under the License is distributed on an "AS IS" BASIS,
|
|||
/// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|||
/// See the License for the specific language governing permissions and
|
|||
/// limitations under the License.
|
|||
///
|
|||
|
|||
import { Component } from '@angular/core'; |
|||
import { Store } from '@ngrx/store'; |
|||
import { AppState } from '@core/core.state'; |
|||
import { EntityTableHeaderComponent } from '../../components/entity/entity-table-header.component'; |
|||
import { DebugEventType, Event, EventType, eventTypeTranslations } from '@app/shared/models/event.models'; |
|||
import { EventTableConfig } from '@home/components/event/event-table-config'; |
|||
|
|||
@Component({ |
|||
selector: 'tb-event-table-header', |
|||
templateUrl: './event-table-header.component.html', |
|||
styleUrls: ['./event-table-header.component.scss'] |
|||
}) |
|||
export class EventTableHeaderComponent extends EntityTableHeaderComponent<Event> { |
|||
|
|||
eventTypeTranslationsMap = eventTypeTranslations; |
|||
|
|||
get eventTableConfig(): EventTableConfig { |
|||
return this.entitiesTableConfig as EventTableConfig; |
|||
} |
|||
|
|||
constructor(protected store: Store<AppState>) { |
|||
super(store); |
|||
} |
|||
|
|||
eventTypeChanged(eventType: EventType | DebugEventType) { |
|||
this.eventTableConfig.eventType = eventType; |
|||
this.eventTableConfig.table.updateData(); |
|||
} |
|||
} |
|||
@ -0,0 +1,18 @@ |
|||
<!-- |
|||
|
|||
Copyright © 2016-2019 The Thingsboard Authors |
|||
|
|||
Licensed under the Apache License, Version 2.0 (the "License"); |
|||
you may not use this file except in compliance with the License. |
|||
You may obtain a copy of the License at |
|||
|
|||
http://www.apache.org/licenses/LICENSE-2.0 |
|||
|
|||
Unless required by applicable law or agreed to in writing, software |
|||
distributed under the License is distributed on an "AS IS" BASIS, |
|||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
|||
See the License for the specific language governing permissions and |
|||
limitations under the License. |
|||
|
|||
--> |
|||
<tb-entities-table [entitiesTableConfig]="eventTableConfig"></tb-entities-table> |
|||
@ -0,0 +1,22 @@ |
|||
/** |
|||
* Copyright © 2016-2019 The Thingsboard Authors |
|||
* |
|||
* Licensed under the Apache License, Version 2.0 (the "License"); |
|||
* you may not use this file except in compliance with the License. |
|||
* You may obtain a copy of the License at |
|||
* |
|||
* http://www.apache.org/licenses/LICENSE-2.0 |
|||
* |
|||
* Unless required by applicable law or agreed to in writing, software |
|||
* distributed under the License is distributed on an "AS IS" BASIS, |
|||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
|||
* See the License for the specific language governing permissions and |
|||
* limitations under the License. |
|||
*/ |
|||
:host ::ng-deep { |
|||
tb-entities-table { |
|||
.mat-drawer-container { |
|||
background-color: white; |
|||
} |
|||
} |
|||
} |
|||
@ -0,0 +1,112 @@ |
|||
///
|
|||
/// Copyright © 2016-2019 The Thingsboard Authors
|
|||
///
|
|||
/// Licensed under the Apache License, Version 2.0 (the "License");
|
|||
/// you may not use this file except in compliance with the License.
|
|||
/// You may obtain a copy of the License at
|
|||
///
|
|||
/// http://www.apache.org/licenses/LICENSE-2.0
|
|||
///
|
|||
/// Unless required by applicable law or agreed to in writing, software
|
|||
/// distributed under the License is distributed on an "AS IS" BASIS,
|
|||
/// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|||
/// See the License for the specific language governing permissions and
|
|||
/// limitations under the License.
|
|||
///
|
|||
|
|||
import { Component, Input, OnInit, ViewChild } from '@angular/core'; |
|||
import { AuditLogService } from '@core/http/audit-log.service'; |
|||
import { TranslateService } from '@ngx-translate/core'; |
|||
import { DatePipe } from '@angular/common'; |
|||
import { MatDialog } from '@angular/material'; |
|||
import { AuditLogMode } from '@shared/models/audit-log.models'; |
|||
import { EntityId } from '@shared/models/id/entity-id'; |
|||
import { UserId } from '@shared/models/id/user-id'; |
|||
import { CustomerId } from '@shared/models/id/customer-id'; |
|||
import { AuditLogTableConfig } from '@home/components/audit-log/audit-log-table-config'; |
|||
import { EntitiesTableComponent } from '@home/components/entity/entities-table.component'; |
|||
import { Store } from '@ngrx/store'; |
|||
import { AppState } from '@core/core.state'; |
|||
import { Authority } from '@shared/models/authority.enum'; |
|||
import { getCurrentAuthUser } from '@core/auth/auth.selectors'; |
|||
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'; |
|||
|
|||
@Component({ |
|||
selector: 'tb-event-table', |
|||
templateUrl: './event-table.component.html', |
|||
styleUrls: ['./event-table.component.scss'] |
|||
}) |
|||
export class EventTableComponent implements OnInit { |
|||
|
|||
@Input() |
|||
tenantId: string; |
|||
|
|||
@Input() |
|||
defaultEventType: EventType | DebugEventType; |
|||
|
|||
@Input() |
|||
disabledEventTypes: Array<EventType | DebugEventType>; |
|||
|
|||
@Input() |
|||
debugEventTypes: Array<DebugEventType>; |
|||
|
|||
activeValue = false; |
|||
dirtyValue = false; |
|||
entityIdValue: EntityId; |
|||
|
|||
@Input() |
|||
set active(active: boolean) { |
|||
if (this.activeValue !== active) { |
|||
this.activeValue = active; |
|||
if (this.activeValue && this.dirtyValue) { |
|||
this.dirtyValue = false; |
|||
this.entitiesTable.updateData(); |
|||
} |
|||
} |
|||
} |
|||
|
|||
@Input() |
|||
set entityId(entityId: EntityId) { |
|||
this.entityIdValue = entityId; |
|||
if (this.eventTableConfig && this.eventTableConfig.entityId !== entityId) { |
|||
this.eventTableConfig.eventType = this.defaultEventType; |
|||
this.eventTableConfig.entityId = entityId; |
|||
this.entitiesTable.resetSortAndFilter(this.activeValue); |
|||
if (!this.activeValue) { |
|||
this.dirtyValue = true; |
|||
} |
|||
} |
|||
} |
|||
|
|||
@ViewChild(EntitiesTableComponent, {static: true}) entitiesTable: EntitiesTableComponent; |
|||
|
|||
eventTableConfig: EventTableConfig; |
|||
|
|||
constructor(private eventService: EventService, |
|||
private dialogService: DialogService, |
|||
private translate: TranslateService, |
|||
private datePipe: DatePipe, |
|||
private dialog: MatDialog, |
|||
private store: Store<AppState>) { |
|||
} |
|||
|
|||
ngOnInit() { |
|||
this.dirtyValue = !this.activeValue; |
|||
this.eventTableConfig = new EventTableConfig( |
|||
this.eventService, |
|||
this.dialogService, |
|||
this.translate, |
|||
this.datePipe, |
|||
this.dialog, |
|||
this.entityIdValue, |
|||
this.tenantId, |
|||
this.defaultEventType, |
|||
this.disabledEventTypes, |
|||
this.debugEventTypes |
|||
); |
|||
} |
|||
|
|||
} |
|||
@ -0,0 +1,22 @@ |
|||
<!-- |
|||
|
|||
Copyright © 2016-2019 The Thingsboard Authors |
|||
|
|||
Licensed under the Apache License, Version 2.0 (the "License"); |
|||
you may not use this file except in compliance with the License. |
|||
You may obtain a copy of the License at |
|||
|
|||
http://www.apache.org/licenses/LICENSE-2.0 |
|||
|
|||
Unless required by applicable law or agreed to in writing, software |
|||
distributed under the License is distributed on an "AS IS" BASIS, |
|||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
|||
See the License for the specific language governing permissions and |
|||
limitations under the License. |
|||
|
|||
--> |
|||
<mat-tab *ngIf="entity" |
|||
label="{{ 'tenant.events' | translate }}" #eventsTab="matTab"> |
|||
<tb-event-table [active]="eventsTab.isActive" [defaultEventType]="eventTypes.ERROR" [tenantId]="nullUid" |
|||
[entityId]="entity.id"></tb-event-table> |
|||
</mat-tab> |
|||
@ -0,0 +1,38 @@ |
|||
///
|
|||
/// Copyright © 2016-2019 The Thingsboard Authors
|
|||
///
|
|||
/// Licensed under the Apache License, Version 2.0 (the "License");
|
|||
/// you may not use this file except in compliance with the License.
|
|||
/// You may obtain a copy of the License at
|
|||
///
|
|||
/// http://www.apache.org/licenses/LICENSE-2.0
|
|||
///
|
|||
/// Unless required by applicable law or agreed to in writing, software
|
|||
/// distributed under the License is distributed on an "AS IS" BASIS,
|
|||
/// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|||
/// See the License for the specific language governing permissions and
|
|||
/// limitations under the License.
|
|||
///
|
|||
|
|||
import { Component } from '@angular/core'; |
|||
import { Store } from '@ngrx/store'; |
|||
import { AppState } from '@core/core.state'; |
|||
import { EntityTabsComponent } from '../../components/entity/entity-tabs.component'; |
|||
import { Tenant } from '@shared/models/tenant.model'; |
|||
|
|||
@Component({ |
|||
selector: 'tb-tenant-tabs', |
|||
templateUrl: './tenant-tabs.component.html', |
|||
styleUrls: [] |
|||
}) |
|||
export class TenantTabsComponent extends EntityTabsComponent<Tenant> { |
|||
|
|||
constructor(protected store: Store<AppState>) { |
|||
super(store); |
|||
} |
|||
|
|||
ngOnInit() { |
|||
super.ngOnInit(); |
|||
} |
|||
|
|||
} |
|||
@ -0,0 +1,21 @@ |
|||
<!-- |
|||
|
|||
Copyright © 2016-2019 The Thingsboard Authors |
|||
|
|||
Licensed under the Apache License, Version 2.0 (the "License"); |
|||
you may not use this file except in compliance with the License. |
|||
You may obtain a copy of the License at |
|||
|
|||
http://www.apache.org/licenses/LICENSE-2.0 |
|||
|
|||
Unless required by applicable law or agreed to in writing, software |
|||
distributed under the License is distributed on an "AS IS" BASIS, |
|||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
|||
See the License for the specific language governing permissions and |
|||
limitations under the License. |
|||
|
|||
--> |
|||
<mat-tab *ngIf="entity && authUser.authority === authorities.TENANT_ADMIN" |
|||
label="{{ 'audit-log.audit-logs' | translate }}" #auditLogsTab="matTab"> |
|||
<tb-audit-log-table [active]="auditLogsTab.isActive" [auditLogMode]="auditLogModes.USER" [userId]="entity.id" detailsMode="true"></tb-audit-log-table> |
|||
</mat-tab> |
|||
@ -0,0 +1,38 @@ |
|||
///
|
|||
/// Copyright © 2016-2019 The Thingsboard Authors
|
|||
///
|
|||
/// Licensed under the Apache License, Version 2.0 (the "License");
|
|||
/// you may not use this file except in compliance with the License.
|
|||
/// You may obtain a copy of the License at
|
|||
///
|
|||
/// http://www.apache.org/licenses/LICENSE-2.0
|
|||
///
|
|||
/// Unless required by applicable law or agreed to in writing, software
|
|||
/// distributed under the License is distributed on an "AS IS" BASIS,
|
|||
/// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|||
/// See the License for the specific language governing permissions and
|
|||
/// limitations under the License.
|
|||
///
|
|||
|
|||
import { Component } from '@angular/core'; |
|||
import { Store } from '@ngrx/store'; |
|||
import { AppState } from '@core/core.state'; |
|||
import { EntityTabsComponent } from '../../components/entity/entity-tabs.component'; |
|||
import { User } from '@app/shared/models/user.model'; |
|||
|
|||
@Component({ |
|||
selector: 'tb-user-tabs', |
|||
templateUrl: './user-tabs.component.html', |
|||
styleUrls: [] |
|||
}) |
|||
export class UserTabsComponent extends EntityTabsComponent<User> { |
|||
|
|||
constructor(protected store: Store<AppState>) { |
|||
super(store); |
|||
} |
|||
|
|||
ngOnInit() { |
|||
super.ngOnInit(); |
|||
} |
|||
|
|||
} |
|||
@ -0,0 +1,89 @@ |
|||
///
|
|||
/// Copyright © 2016-2019 The Thingsboard Authors
|
|||
///
|
|||
/// Licensed under the Apache License, Version 2.0 (the "License");
|
|||
/// you may not use this file except in compliance with the License.
|
|||
/// You may obtain a copy of the License at
|
|||
///
|
|||
/// http://www.apache.org/licenses/LICENSE-2.0
|
|||
///
|
|||
/// Unless required by applicable law or agreed to in writing, software
|
|||
/// distributed under the License is distributed on an "AS IS" BASIS,
|
|||
/// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|||
/// See the License for the specific language governing permissions and
|
|||
/// limitations under the License.
|
|||
///
|
|||
|
|||
import { ActionStatus, ActionType } from '@shared/models/audit-log.models'; |
|||
import { BaseData } from '@shared/models/base-data'; |
|||
import { AuditLogId } from '@shared/models/id/audit-log-id'; |
|||
import { TenantId } from '@shared/models/id/tenant-id'; |
|||
import { CustomerId } from '@shared/models/id/customer-id'; |
|||
import { EntityId } from '@shared/models/id/entity-id'; |
|||
import { UserId } from '@shared/models/id/user-id'; |
|||
import { EventId } from './id/event-id'; |
|||
import { MsgDataType } from './rule-node.models'; |
|||
|
|||
export enum EventType { |
|||
ERROR = 'ERROR', |
|||
LC_EVENT = 'LC_EVENT', |
|||
STATS = 'STATS' |
|||
} |
|||
|
|||
export enum DebugEventType { |
|||
DEBUG_RULE_NODE = 'DEBUG_RULE_NODE', |
|||
DEBUG_RULE_CHAIN = 'DEBUG_RULE_CHAIN' |
|||
} |
|||
|
|||
export const eventTypeTranslations = new Map<EventType | DebugEventType, string>( |
|||
[ |
|||
[EventType.ERROR, 'event.type-error'], |
|||
[EventType.LC_EVENT, 'event.type-lc-event'], |
|||
[EventType.STATS, 'event.type-stats'], |
|||
[DebugEventType.DEBUG_RULE_NODE, 'event.type-debug-rule-node'], |
|||
[DebugEventType.DEBUG_RULE_CHAIN, 'event.type-debug-rule-chain'], |
|||
] |
|||
); |
|||
|
|||
export interface BaseEventBody { |
|||
server: string; |
|||
} |
|||
|
|||
export interface ErrorEventBody extends BaseEventBody { |
|||
method: string; |
|||
error: string; |
|||
} |
|||
|
|||
export interface LcEventEventBody extends BaseEventBody { |
|||
event: string; |
|||
success: boolean; |
|||
error: string; |
|||
} |
|||
|
|||
export interface StatsEventBody extends BaseEventBody { |
|||
messagesProcessed: number; |
|||
errorsOccurred: number; |
|||
} |
|||
|
|||
export interface DebugRuleNodeEventBody extends BaseEventBody { |
|||
type: string; |
|||
entityId: string; |
|||
entityName: string; |
|||
msgId: string; |
|||
msgType: string; |
|||
relationType: string; |
|||
dataType: MsgDataType; |
|||
data: string; |
|||
metadata: string; |
|||
error: string; |
|||
} |
|||
|
|||
export type EventBody = ErrorEventBody & LcEventEventBody & StatsEventBody & DebugRuleNodeEventBody; |
|||
|
|||
export interface Event extends BaseData<EventId> { |
|||
tenantId: TenantId; |
|||
entityId: EntityId; |
|||
type: string; |
|||
uid: string; |
|||
body: EventBody; |
|||
} |
|||
@ -0,0 +1,24 @@ |
|||
///
|
|||
/// Copyright © 2016-2019 The Thingsboard Authors
|
|||
///
|
|||
/// Licensed under the Apache License, Version 2.0 (the "License");
|
|||
/// you may not use this file except in compliance with the License.
|
|||
/// You may obtain a copy of the License at
|
|||
///
|
|||
/// http://www.apache.org/licenses/LICENSE-2.0
|
|||
///
|
|||
/// Unless required by applicable law or agreed to in writing, software
|
|||
/// distributed under the License is distributed on an "AS IS" BASIS,
|
|||
/// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|||
/// See the License for the specific language governing permissions and
|
|||
/// limitations under the License.
|
|||
///
|
|||
|
|||
import { HasUUID } from '@shared/models/id/has-uuid'; |
|||
|
|||
export class EventId implements HasUUID { |
|||
id: string; |
|||
constructor(id: string) { |
|||
this.id = id; |
|||
} |
|||
} |
|||
Loading…
Reference in new issue