Commit 6e564de948ff6212b79834f50bb5a90bcaced557

Authored by Volodymyr Babak
1 parent c89849c3

Moved edge downlinks to a separate TAB

@@ -21,9 +21,8 @@ import { HttpClient } from '@angular/common/http'; @@ -21,9 +21,8 @@ import { HttpClient } from '@angular/common/http';
21 import { PageLink, TimePageLink } from '@shared/models/page/page-link'; 21 import { PageLink, TimePageLink } from '@shared/models/page/page-link';
22 import { PageData } from '@shared/models/page/page-data'; 22 import { PageData } from '@shared/models/page/page-data';
23 import { EntitySubtype } from '@app/shared/models/entity-type.models'; 23 import { EntitySubtype } from '@app/shared/models/entity-type.models';
24 -import { Edge, EdgeInfo, EdgeSearchQuery } from "@shared/models/edge.models"; 24 +import { Edge, EdgeEvent, EdgeInfo, EdgeSearchQuery } from "@shared/models/edge.models";
25 import { EntityId } from "@shared/models/id/entity-id"; 25 import { EntityId } from "@shared/models/id/entity-id";
26 -import { Event } from "@shared/models/event.models";  
27 @Injectable({ 26 @Injectable({
28 providedIn: 'root' 27 providedIn: 'root'
29 }) 28 })
@@ -92,8 +91,8 @@ export class EdgeService { @@ -92,8 +91,8 @@ export class EdgeService {
92 } 91 }
93 92
94 public getEdgeEvents(entityId: EntityId, pageLink: TimePageLink, 93 public getEdgeEvents(entityId: EntityId, pageLink: TimePageLink,
95 - config?: RequestConfig): Observable<PageData<Event>> {  
96 - return this.http.get<PageData<Event>>(`/api/edge/${entityId.id}/events` + `${pageLink.toQuery()}`, 94 + config?: RequestConfig): Observable<PageData<EdgeEvent>> {
  95 + return this.http.get<PageData<EdgeEvent>>(`/api/edge/${entityId.id}/events` + `${pageLink.toQuery()}`,
97 defaultHttpOptionsFromConfig(config)); 96 defaultHttpOptionsFromConfig(config));
98 } 97 }
99 } 98 }
@@ -39,9 +39,4 @@ export class EventService { @@ -39,9 +39,4 @@ export class EventService {
39 defaultHttpOptionsFromConfig(config)); 39 defaultHttpOptionsFromConfig(config));
40 } 40 }
41 41
42 - public getEdgeEvents(entityId: EntityId, pageLink: TimePageLink,  
43 - config?: RequestConfig): Observable<PageData<Event>> {  
44 - return this.http.get<PageData<Event>>(`/api/edge/${entityId.id}/events` + `${pageLink.toQuery()}`,  
45 - defaultHttpOptionsFromConfig(config));  
46 - }  
47 } 42 }
  1 +///
  2 +/// Copyright © 2016-2020 The Thingsboard Authors
  3 +///
  4 +/// Licensed under the Apache License, Version 2.0 (the "License");
  5 +/// you may not use this file except in compliance with the License.
  6 +/// You may obtain a copy of the License at
  7 +///
  8 +/// http://www.apache.org/licenses/LICENSE-2.0
  9 +///
  10 +/// Unless required by applicable law or agreed to in writing, software
  11 +/// distributed under the License is distributed on an "AS IS" BASIS,
  12 +/// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13 +/// See the License for the specific language governing permissions and
  14 +/// limitations under the License.
  15 +///
  16 +
  17 +import {
  18 + DateEntityTableColumn,
  19 + EntityActionTableColumn,
  20 + EntityTableColumn,
  21 + EntityTableConfig
  22 +} from '@home/models/entity/entities-table-config.models';
  23 +import {
  24 + EdgeEvent, edgeEventActionTypeTranslations,
  25 + EdgeEventStatus,
  26 + edgeEventStatusColor,
  27 + EdgeEventType,
  28 + edgeEventTypeTranslations
  29 +} from '@shared/models/edge.models';
  30 +import { TimePageLink } from '@shared/models/page/page-link';
  31 +import { TranslateService } from '@ngx-translate/core';
  32 +import { DatePipe } from '@angular/common';
  33 +import { MatDialog } from '@angular/material/dialog';
  34 +import { EntityId } from '@shared/models/id/entity-id';
  35 +import { EntityTypeResource } from '@shared/models/entity-type.models';
  36 +import { Observable, of } from 'rxjs';
  37 +import { PageData } from '@shared/models/page/page-data';
  38 +import { Direction } from '@shared/models/page/sort-order';
  39 +import { DialogService } from '@core/services/dialog.service';
  40 +import { ContentType } from '@shared/models/constants';
  41 +import {
  42 + EventContentDialogComponent,
  43 + EventContentDialogData
  44 +} from '@home/components/event/event-content-dialog.component';
  45 +import { sortObjectKeys } from '@core/utils';
  46 +import { RuleChainService } from "@core/http/rule-chain.service";
  47 +import { AttributeService } from "@core/http/attribute.service";
  48 +import { AttributeScope } from "@shared/models/telemetry/telemetry.models";
  49 +import { EdgeDownlinkTableHeaderComponent } from "@home/components/edge/edge-downlink-table-header.component";
  50 +import { EdgeService } from "@core/http/edge.service";
  51 +import { map } from "rxjs/operators";
  52 +import { AssetService } from "@core/http/asset.service";
  53 +import { DeviceService } from "@core/http/device.service";
  54 +import { EntityViewService } from "@core/http/entity-view.service";
  55 +import { actionTypeTranslations } from "@shared/models/audit-log.models";
  56 +
  57 +export class EdgeDownlinkTableConfig extends EntityTableConfig<EdgeEvent, TimePageLink> {
  58 +
  59 + queueStartTs: number;
  60 +
  61 + constructor(private edgeService: EdgeService,
  62 + private dialogService: DialogService,
  63 + private translate: TranslateService,
  64 + private deviceService: DeviceService,
  65 + private assetService: AssetService,
  66 + private entityViewService: EntityViewService,
  67 + private ruleChainService: RuleChainService,
  68 + private attributeService: AttributeService,
  69 + private datePipe: DatePipe,
  70 + private dialog: MatDialog,
  71 + public entityId: EntityId,
  72 + public tenantId: string) {
  73 + super();
  74 + this.loadDataOnInit = false;
  75 + this.tableTitle = '';
  76 + this.useTimePageLink = true;
  77 + this.detailsPanelEnabled = false;
  78 + this.selectionEnabled = false;
  79 + this.searchEnabled = false;
  80 + this.addEnabled = false;
  81 + this.entitiesDeleteEnabled = false;
  82 +
  83 + this.headerComponent = EdgeDownlinkTableHeaderComponent;
  84 +
  85 + this.entityTranslations = {
  86 + noEntities: 'edge.no-downlinks-prompt'
  87 + };
  88 + this.entityResources = {} as EntityTypeResource<EdgeEvent>;
  89 + this.entitiesFetchFunction = pageLink => this.fetchEvents(pageLink);
  90 +
  91 + this.defaultSortOrder = {property: 'createdTime', direction: Direction.DESC};
  92 +
  93 + this.updateColumns();
  94 + }
  95 +
  96 + fetchEvents(pageLink: TimePageLink): Observable<PageData<EdgeEvent>> {
  97 + this.loadEdgeInfo();
  98 + return this.edgeService.getEdgeEvents(this.entityId, pageLink);
  99 + }
  100 +
  101 + updateColumns(updateTableColumns: boolean = false): void {
  102 + this.columns = [];
  103 + this.columns.push(
  104 + new DateEntityTableColumn<EdgeEvent>('createdTime', 'event.event-time', this.datePipe, '120px'),
  105 + new EntityTableColumn<EdgeEvent>('type', 'event.type', '25%',
  106 + entity => this.translate.instant(edgeEventTypeTranslations.get(entity.type)), entity => ({}), false),
  107 + new EntityTableColumn<EdgeEvent>('action', 'edge.event-action', '25%',
  108 + entity => this.translate.instant(edgeEventActionTypeTranslations.get(entity.action)), entity => ({}), false),
  109 + new EntityTableColumn<EdgeEvent>('entityId', 'edge.entity-id', '40%',
  110 + (entity) => entity.entityId, entity => ({}), false),
  111 + new EntityTableColumn<EdgeEvent>('status', 'event.status', '10%',
  112 + (entity) => this.updateEdgeEventStatus(entity.createdTime),
  113 + entity => ({
  114 + color: this.isPending(entity.createdTime) ? edgeEventStatusColor.get(EdgeEventStatus.PENDING) : edgeEventStatusColor.get(EdgeEventStatus.DEPLOYED)
  115 + }), false),
  116 + new EntityActionTableColumn<EdgeEvent>('data', 'event.data',
  117 + {
  118 + name: this.translate.instant('action.view'),
  119 + icon: 'more_horiz',
  120 + isEnabled: (entity) => this.isEdgeEventHasData(entity.type),
  121 + onAction: ($event, entity) =>
  122 + {
  123 + this.prepareEdgeEventContent(entity).subscribe((content) => {
  124 + this.showEdgeEventContent($event, content,'event.data');
  125 + });
  126 + }
  127 + },
  128 + '40px'),
  129 + );
  130 + if (updateTableColumns) {
  131 + this.table.columnsUpdated(true);
  132 + }
  133 + }
  134 +
  135 + showContent($event: MouseEvent, content: string, title: string, contentType: ContentType = null, sortKeys = false): void {
  136 + if ($event) {
  137 + $event.stopPropagation();
  138 + }
  139 + if (contentType === ContentType.JSON && sortKeys) {
  140 + try {
  141 + content = JSON.stringify(sortObjectKeys(JSON.parse(content)));
  142 + } catch (e) {
  143 + }
  144 + }
  145 + this.dialog.open<EventContentDialogComponent, EventContentDialogData>(EventContentDialogComponent, {
  146 + disableClose: true,
  147 + panelClass: ['tb-dialog', 'tb-fullscreen-dialog'],
  148 + data: {
  149 + content,
  150 + title,
  151 + contentType
  152 + }
  153 + });
  154 + }
  155 +
  156 + isEdgeEventHasData(edgeEventType: EdgeEventType) {
  157 + switch (edgeEventType) {
  158 + case EdgeEventType.WIDGET_TYPE:
  159 + case EdgeEventType.WIDGETS_BUNDLE:
  160 + case EdgeEventType.ADMIN_SETTINGS:
  161 + return false;
  162 + default:
  163 + return true;
  164 + }
  165 + }
  166 +
  167 + prepareEdgeEventContent(entity) {
  168 + // TODO: voba - extend this function with different cases based on action and entity type
  169 + switch (entity.type) {
  170 + case EdgeEventType.RELATION:
  171 + return of(JSON.stringify(entity.body));
  172 + case EdgeEventType.ASSET:
  173 + return this.assetService.getAsset(entity.entityId, null).pipe(
  174 + map((asset) => {
  175 + return JSON.stringify(asset);
  176 + })
  177 + );
  178 + case EdgeEventType.DEVICE:
  179 + return this.deviceService.getDevice(entity.entityId, null).pipe(
  180 + map((device) => {
  181 + return JSON.stringify(device);
  182 + })
  183 + );
  184 + case EdgeEventType.ENTITY_VIEW:
  185 + return this.entityViewService.getEntityView(entity.entityId, null).pipe(
  186 + map((entityView) => {
  187 + return JSON.stringify(entityView);
  188 + })
  189 + );
  190 + case EdgeEventType.RULE_CHAIN_METADATA:
  191 + return this.ruleChainService.getRuleChainMetadata(entity.entityId, null).pipe(
  192 + map((ruleChainMetaData) => {
  193 + return JSON.stringify(ruleChainMetaData.nodes);
  194 + })
  195 + );
  196 + default:
  197 + return of(JSON.stringify(entity));
  198 + }
  199 + }
  200 +
  201 + showEdgeEventContent($event: MouseEvent, content: string, title: string, sortKeys = false): void {
  202 + if ($event) {
  203 + $event.stopPropagation();
  204 + }
  205 + var contentType = ContentType.JSON;
  206 + if (contentType === ContentType.JSON && sortKeys) {
  207 + try {
  208 + content = JSON.stringify(sortObjectKeys(JSON.parse(content)));
  209 + } catch (e) {
  210 + }
  211 + }
  212 + this.dialog.open<EventContentDialogComponent, EventContentDialogData>(EventContentDialogComponent, {
  213 + disableClose: true,
  214 + panelClass: ['tb-dialog', 'tb-fullscreen-dialog'],
  215 + data: {
  216 + content,
  217 + title,
  218 + contentType
  219 + }
  220 + });
  221 + }
  222 +
  223 + updateEdgeEventStatus(createdTime) {
  224 + if (this.queueStartTs && createdTime < this.queueStartTs) {
  225 + return this.translate.instant('edge.success');
  226 + } else {
  227 + return this.translate.instant('edge.failed');
  228 + }
  229 + }
  230 +
  231 + isPending(createdTime) {
  232 + return createdTime > this.queueStartTs;
  233 + }
  234 +
  235 + loadEdgeInfo() {
  236 + this.attributeService.getEntityAttributes(this.entityId, AttributeScope.SERVER_SCOPE, ['queueStartTs'])
  237 + .subscribe(
  238 + attributes => this.onUpdate(attributes)
  239 + );
  240 + }
  241 +
  242 + onUpdate(attributes) {
  243 + this.queueStartTs = 0;
  244 + let edge = attributes.reduce(function (map, attribute) {
  245 + map[attribute.key] = attribute;
  246 + return map;
  247 + }, {});
  248 + if (edge.queueStartTs) {
  249 + this.queueStartTs = edge.queueStartTs.lastUpdateTs;
  250 + }
  251 + }
  252 +}
  253 +
  1 +<!--
  2 +
  3 + Copyright © 2016-2020 The Thingsboard Authors
  4 +
  5 + Licensed under the Apache License, Version 2.0 (the "License");
  6 + you may not use this file except in compliance with the License.
  7 + You may obtain a copy of the License at
  8 +
  9 + http://www.apache.org/licenses/LICENSE-2.0
  10 +
  11 + Unless required by applicable law or agreed to in writing, software
  12 + distributed under the License is distributed on an "AS IS" BASIS,
  13 + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  14 + See the License for the specific language governing permissions and
  15 + limitations under the License.
  16 +
  17 +-->
  18 +<mat-form-field class="mat-block">
  19 +</mat-form-field>
  1 +/**
  2 + * Copyright © 2016-2020 The Thingsboard Authors
  3 + *
  4 + * Licensed under the Apache License, Version 2.0 (the "License");
  5 + * you may not use this file except in compliance with the License.
  6 + * You may obtain a copy of the License at
  7 + *
  8 + * http://www.apache.org/licenses/LICENSE-2.0
  9 + *
  10 + * Unless required by applicable law or agreed to in writing, software
  11 + * distributed under the License is distributed on an "AS IS" BASIS,
  12 + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13 + * See the License for the specific language governing permissions and
  14 + * limitations under the License.
  15 + */
  16 +@import '../../../../../scss/constants';
  17 +
  18 +:host {
  19 + padding-right: 8px;
  20 +}
  21 +
  22 +:host ::ng-deep {
  23 + mat-form-field {
  24 +
  25 + .mat-form-field-wrapper {
  26 + padding-bottom: 0;
  27 + }
  28 +
  29 + .mat-form-field-underline {
  30 + bottom: 0;
  31 + }
  32 +
  33 + @media #{$mat-xs} {
  34 + width: 100%;
  35 +
  36 + .mat-form-field-infix {
  37 + width: auto !important;
  38 + }
  39 + }
  40 + }
  41 +}
  1 +///
  2 +/// Copyright © 2016-2020 The Thingsboard Authors
  3 +///
  4 +/// Licensed under the Apache License, Version 2.0 (the "License");
  5 +/// you may not use this file except in compliance with the License.
  6 +/// You may obtain a copy of the License at
  7 +///
  8 +/// http://www.apache.org/licenses/LICENSE-2.0
  9 +///
  10 +/// Unless required by applicable law or agreed to in writing, software
  11 +/// distributed under the License is distributed on an "AS IS" BASIS,
  12 +/// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13 +/// See the License for the specific language governing permissions and
  14 +/// limitations under the License.
  15 +///
  16 +
  17 +import { Component } from '@angular/core';
  18 +import { Store } from '@ngrx/store';
  19 +import { AppState } from '@core/core.state';
  20 +import { EntityTableHeaderComponent } from '../../components/entity/entity-table-header.component';
  21 +import { EdgeEvent } from "@shared/models/edge.models";
  22 +import { EdgeDownlinkTableConfig } from "@home/components/edge/edge-downlink-table-config";
  23 +
  24 +@Component({
  25 + selector: 'tb-edge-downlink-table-header',
  26 + templateUrl: './edge-downlink-table-header.component.html',
  27 + styleUrls: ['./edge-downlink-table-header.component.scss']
  28 +})
  29 +export class EdgeDownlinkTableHeaderComponent extends EntityTableHeaderComponent<EdgeEvent> {
  30 +
  31 + get eventTableConfig(): EdgeDownlinkTableConfig {
  32 + return this.entitiesTableConfig as EdgeDownlinkTableConfig;
  33 + }
  34 +
  35 + constructor(protected store: Store<AppState>) {
  36 + super(store);
  37 + }
  38 +
  39 + eventTypeChanged() {
  40 + this.eventTableConfig.table.resetSortAndFilter(true, true);
  41 + }
  42 +}
  1 +<!--
  2 +
  3 + Copyright © 2016-2020 The Thingsboard Authors
  4 +
  5 + Licensed under the Apache License, Version 2.0 (the "License");
  6 + you may not use this file except in compliance with the License.
  7 + You may obtain a copy of the License at
  8 +
  9 + http://www.apache.org/licenses/LICENSE-2.0
  10 +
  11 + Unless required by applicable law or agreed to in writing, software
  12 + distributed under the License is distributed on an "AS IS" BASIS,
  13 + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  14 + See the License for the specific language governing permissions and
  15 + limitations under the License.
  16 +
  17 +-->
  18 +<tb-entities-table [entitiesTableConfig]="edgeDownlinkTableConfig"></tb-entities-table>
  1 +/**
  2 + * Copyright © 2016-2020 The Thingsboard Authors
  3 + *
  4 + * Licensed under the Apache License, Version 2.0 (the "License");
  5 + * you may not use this file except in compliance with the License.
  6 + * You may obtain a copy of the License at
  7 + *
  8 + * http://www.apache.org/licenses/LICENSE-2.0
  9 + *
  10 + * Unless required by applicable law or agreed to in writing, software
  11 + * distributed under the License is distributed on an "AS IS" BASIS,
  12 + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13 + * See the License for the specific language governing permissions and
  14 + * limitations under the License.
  15 + */
  16 +:host ::ng-deep {
  17 + tb-entities-table {
  18 + .mat-drawer-container {
  19 + background-color: white;
  20 + }
  21 + }
  22 +}
  1 +///
  2 +/// Copyright © 2016-2020 The Thingsboard Authors
  3 +///
  4 +/// Licensed under the Apache License, Version 2.0 (the "License");
  5 +/// you may not use this file except in compliance with the License.
  6 +/// You may obtain a copy of the License at
  7 +///
  8 +/// http://www.apache.org/licenses/LICENSE-2.0
  9 +///
  10 +/// Unless required by applicable law or agreed to in writing, software
  11 +/// distributed under the License is distributed on an "AS IS" BASIS,
  12 +/// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13 +/// See the License for the specific language governing permissions and
  14 +/// limitations under the License.
  15 +///
  16 +
  17 +import { Component, Input, OnInit, ViewChild } from '@angular/core';
  18 +import { TranslateService } from '@ngx-translate/core';
  19 +import { DatePipe } from '@angular/common';
  20 +import { MatDialog } from '@angular/material/dialog';
  21 +import { EntityId } from '@shared/models/id/entity-id';
  22 +import { EntitiesTableComponent } from '@home/components/entity/entities-table.component';
  23 +import { EdgeDownlinkTableConfig } from './edge-downlink-table-config';
  24 +import { DialogService } from '@core/services/dialog.service';
  25 +import { RuleChainService } from "@core/http/rule-chain.service";
  26 +import { AttributeService } from "@core/http/attribute.service";
  27 +import { EdgeService } from "@core/http/edge.service";
  28 +import { DeviceService } from "@core/http/device.service";
  29 +import { AssetService } from "@core/http/asset.service";
  30 +import { EntityViewService } from "@core/http/entity-view.service";
  31 +
  32 +@Component({
  33 + selector: 'tb-edge-downlink-table',
  34 + templateUrl: './edge-downlink-table.component.html',
  35 + styleUrls: ['./edge-downlink-table.component.scss']
  36 +})
  37 +export class EdgeDownlinkTableComponent implements OnInit {
  38 +
  39 + @Input()
  40 + tenantId: string;
  41 +
  42 + activeValue = false;
  43 + dirtyValue = false;
  44 + entityIdValue: EntityId;
  45 +
  46 + @Input()
  47 + set active(active: boolean) {
  48 + if (this.activeValue !== active) {
  49 + this.activeValue = active;
  50 + if (this.activeValue && this.dirtyValue) {
  51 + this.dirtyValue = false;
  52 + this.entitiesTable.updateData();
  53 + }
  54 + }
  55 + }
  56 +
  57 + @Input()
  58 + set entityId(entityId: EntityId) {
  59 + this.entityIdValue = entityId;
  60 + if (this.edgeDownlinkTableConfig && this.edgeDownlinkTableConfig.entityId !== entityId) {
  61 + this.edgeDownlinkTableConfig.entityId = entityId;
  62 + this.entitiesTable.resetSortAndFilter(this.activeValue);
  63 + if (!this.activeValue) {
  64 + this.dirtyValue = true;
  65 + }
  66 + }
  67 + }
  68 +
  69 + @ViewChild(EntitiesTableComponent, {static: true}) entitiesTable: EntitiesTableComponent;
  70 +
  71 + edgeDownlinkTableConfig: EdgeDownlinkTableConfig;
  72 +
  73 + constructor(private edgeService: EdgeService,
  74 + private deviceService: DeviceService,
  75 + private assetService: AssetService,
  76 + private entityViewService: EntityViewService,
  77 + private dialogService: DialogService,
  78 + private translate: TranslateService,
  79 + private attributeService: AttributeService,
  80 + private ruleChainService: RuleChainService,
  81 + private datePipe: DatePipe,
  82 + private dialog: MatDialog) {
  83 + }
  84 +
  85 + ngOnInit() {
  86 + this.dirtyValue = !this.activeValue;
  87 + this.edgeDownlinkTableConfig = new EdgeDownlinkTableConfig(
  88 + this.edgeService,
  89 + this.dialogService,
  90 + this.translate,
  91 + this.deviceService,
  92 + this.assetService,
  93 + this.entityViewService,
  94 + this.ruleChainService,
  95 + this.attributeService,
  96 + this.datePipe,
  97 + this.dialog,
  98 + this.entityIdValue,
  99 + this.tenantId
  100 + );
  101 + }
  102 +
  103 +}
@@ -20,35 +20,25 @@ import { @@ -20,35 +20,25 @@ import {
20 EntityTableColumn, 20 EntityTableColumn,
21 EntityTableConfig 21 EntityTableConfig
22 } from '@home/models/entity/entities-table-config.models'; 22 } from '@home/models/entity/entities-table-config.models';
23 -import {  
24 - DebugEventType,  
25 - Event,  
26 - EventType,  
27 - EdgeEventType,  
28 - EdgeEventStatus,  
29 - edgeEventStatusColor  
30 -} from '@shared/models/event.models';  
31 -import {TimePageLink} from '@shared/models/page/page-link';  
32 -import {TranslateService} from '@ngx-translate/core';  
33 -import {DatePipe} from '@angular/common';  
34 -import {MatDialog} from '@angular/material/dialog';  
35 -import {EntityId} from '@shared/models/id/entity-id';  
36 -import {EventService} from '@app/core/http/event.service';  
37 -import {EventTableHeaderComponent} from '@home/components/event/event-table-header.component';  
38 -import {EntityType, EntityTypeResource} from '@shared/models/entity-type.models';  
39 -import {Observable} from 'rxjs';  
40 -import {PageData} from '@shared/models/page/page-data';  
41 -import {Direction} from '@shared/models/page/sort-order';  
42 -import {DialogService} from '@core/services/dialog.service';  
43 -import {ContentType} from '@shared/models/constants'; 23 +import { DebugEventType, Event, EventType } from '@shared/models/event.models';
  24 +import { TimePageLink } from '@shared/models/page/page-link';
  25 +import { TranslateService } from '@ngx-translate/core';
  26 +import { DatePipe } from '@angular/common';
  27 +import { MatDialog } from '@angular/material/dialog';
  28 +import { EntityId } from '@shared/models/id/entity-id';
  29 +import { EventService } from '@app/core/http/event.service';
  30 +import { EventTableHeaderComponent } from '@home/components/event/event-table-header.component';
  31 +import { EntityTypeResource } from '@shared/models/entity-type.models';
  32 +import { Observable } from 'rxjs';
  33 +import { PageData } from '@shared/models/page/page-data';
  34 +import { Direction } from '@shared/models/page/sort-order';
  35 +import { DialogService } from '@core/services/dialog.service';
  36 +import { ContentType } from '@shared/models/constants';
44 import { 37 import {
45 EventContentDialogComponent, 38 EventContentDialogComponent,
46 EventContentDialogData 39 EventContentDialogData
47 } from '@home/components/event/event-content-dialog.component'; 40 } from '@home/components/event/event-content-dialog.component';
48 -import {sortObjectKeys} from '@core/utils';  
49 -import {RuleChainService} from "@core/http/rule-chain.service";  
50 -import {AttributeService} from "@core/http/attribute.service";  
51 -import {AttributeScope} from "@shared/models/telemetry/telemetry.models"; 41 +import { sortObjectKeys } from '@core/utils';
52 42
53 export class EventTableConfig extends EntityTableConfig<Event, TimePageLink> { 43 export class EventTableConfig extends EntityTableConfig<Event, TimePageLink> {
54 44
@@ -66,13 +56,10 @@ export class EventTableConfig extends EntityTableConfig<Event, TimePageLink> { @@ -66,13 +56,10 @@ export class EventTableConfig extends EntityTableConfig<Event, TimePageLink> {
66 } 56 }
67 57
68 eventTypes: Array<EventType | DebugEventType>; 58 eventTypes: Array<EventType | DebugEventType>;
69 - queueStartTs: number;  
70 59
71 constructor(private eventService: EventService, 60 constructor(private eventService: EventService,
72 private dialogService: DialogService, 61 private dialogService: DialogService,
73 private translate: TranslateService, 62 private translate: TranslateService,
74 - private ruleChainService: RuleChainService,  
75 - private attributeService: AttributeService,  
76 private datePipe: DatePipe, 63 private datePipe: DatePipe,
77 private dialog: MatDialog, 64 private dialog: MatDialog,
78 public entityId: EntityId, 65 public entityId: EntityId,
@@ -94,10 +81,6 @@ export class EventTableConfig extends EntityTableConfig<Event, TimePageLink> { @@ -94,10 +81,6 @@ export class EventTableConfig extends EntityTableConfig<Event, TimePageLink> {
94 81
95 this.eventTypes = Object.keys(EventType).map(type => EventType[type]); 82 this.eventTypes = Object.keys(EventType).map(type => EventType[type]);
96 83
97 - if (this.entityId.entityType !== EntityType.EDGE) {  
98 - this.eventTypes.pop();  
99 - }  
100 -  
101 if (disabledEventTypes && disabledEventTypes.length) { 84 if (disabledEventTypes && disabledEventTypes.length) {
102 this.eventTypes = this.eventTypes.filter(type => disabledEventTypes.indexOf(type) === -1); 85 this.eventTypes = this.eventTypes.filter(type => disabledEventTypes.indexOf(type) === -1);
103 } 86 }
@@ -121,25 +104,15 @@ export class EventTableConfig extends EntityTableConfig<Event, TimePageLink> { @@ -121,25 +104,15 @@ export class EventTableConfig extends EntityTableConfig<Event, TimePageLink> {
121 } 104 }
122 105
123 fetchEvents(pageLink: TimePageLink): Observable<PageData<Event>> { 106 fetchEvents(pageLink: TimePageLink): Observable<PageData<Event>> {
124 - if (this.eventTypeValue === EventType.EDGE_EVENT) {  
125 - this.loadEdgeInfo();  
126 - return this.eventService.getEdgeEvents(this.entityId, pageLink);  
127 - } else {  
128 - return this.eventService.getEvents(this.entityId, this.eventType, this.tenantId, pageLink);  
129 - } 107 + return this.eventService.getEvents(this.entityId, this.eventType, this.tenantId, pageLink);
130 } 108 }
131 109
132 updateColumns(updateTableColumns: boolean = false): void { 110 updateColumns(updateTableColumns: boolean = false): void {
133 this.columns = []; 111 this.columns = [];
134 this.columns.push( 112 this.columns.push(
135 new DateEntityTableColumn<Event>('createdTime', 'event.event-time', this.datePipe, '120px'), 113 new DateEntityTableColumn<Event>('createdTime', 'event.event-time', this.datePipe, '120px'),
136 - );  
137 - if (this.eventType !== EventType.EDGE_EVENT) {  
138 - this.columns.push(  
139 - new EntityTableColumn<Event>('server', 'event.server', '100px',  
140 - (entity) => entity.body.server, entity => ({}), false)  
141 - );  
142 - } 114 + new EntityTableColumn<Event>('server', 'event.server', '100px',
  115 + (entity) => entity.body.server, entity => ({}), false));
143 switch (this.eventType) { 116 switch (this.eventType) {
144 case EventType.ERROR: 117 case EventType.ERROR:
145 this.columns.push( 118 this.columns.push(
@@ -186,30 +159,6 @@ export class EventTableConfig extends EntityTableConfig<Event, TimePageLink> { @@ -186,30 +159,6 @@ export class EventTableConfig extends EntityTableConfig<Event, TimePageLink> {
186 () => ({}), () => undefined, true) 159 () => ({}), () => undefined, true)
187 ); 160 );
188 break; 161 break;
189 - case EventType.EDGE_EVENT:  
190 - this.columns.push(  
191 - new EntityTableColumn<Event>('type', 'event.type', '100%',  
192 - (entity) => entity.type, entity => ({}), false),  
193 - new EntityTableColumn<Event>('action', 'edge.event-action', '100%',  
194 - (entity) => entity.action, entity => ({}), false),  
195 - new EntityTableColumn<Event>('entityId', 'edge.entity-id', '100%',  
196 - (entity) => entity.id.id, entity => ({}), false), //TODO: replace this to entity.entityId because of conflict wiht entityId model  
197 - new EntityTableColumn<Event>('status', 'event.status', '100%',  
198 - (entity) => this.updateEdgeEventStatus(entity.createdTime),  
199 - entity => ({  
200 - color: this.isPending(entity.createdTime) ? edgeEventStatusColor.get(EdgeEventStatus.PENDING) : edgeEventStatusColor.get(EdgeEventStatus.DEPLOYED)  
201 - }), false),  
202 - new EntityActionTableColumn<Event>('data', 'event.data',  
203 - {  
204 - name: this.translate.instant('action.view'),  
205 - icon: 'more_horiz',  
206 - isEnabled: (entity) => this.checkEdgeEventType(entity),  
207 - onAction: ($event, entity) => this.showEdgeEventContent($event, this.manageEdgeEventContent(entity),  
208 - 'event.data')  
209 - },  
210 - '40px'),  
211 - );  
212 - break;  
213 case DebugEventType.DEBUG_RULE_NODE: 162 case DebugEventType.DEBUG_RULE_NODE:
214 case DebugEventType.DEBUG_RULE_CHAIN: 163 case DebugEventType.DEBUG_RULE_CHAIN:
215 this.columns[0].width = '100px'; 164 this.columns[0].width = '100px';
@@ -300,82 +249,5 @@ export class EventTableConfig extends EntityTableConfig<Event, TimePageLink> { @@ -300,82 +249,5 @@ export class EventTableConfig extends EntityTableConfig<Event, TimePageLink> {
300 } 249 }
301 }); 250 });
302 } 251 }
303 -  
304 - checkEdgeEventType(entity) {  
305 - return !( entity.type === EdgeEventType.WIDGET_TYPE ||  
306 - entity.type === EdgeEventType.ADMIN_SETTINGS ||  
307 - entity.type === EdgeEventType.WIDGETS_BUNDLE );  
308 - }  
309 -  
310 - manageEdgeEventContent(entity) {  
311 - var content: string;  
312 - switch (entity.type) {  
313 - case EdgeEventType.RELATION:  
314 - content = entity.body;  
315 - break;  
316 - // case EdgeEventType.RULE_CHAIN_METADATA:  
317 - // this.ruleChainService.getRuleChainMetadata(entity.entityId, null).pipe(  
318 - // map(ruleChainMetaData => content = ruleChainMetaData.nodes)  
319 - // );  
320 - // break;  
321 - default:  
322 - content = entity;  
323 - break;  
324 - }  
325 - return JSON.stringify(content);  
326 - }  
327 -  
328 - showEdgeEventContent($event: MouseEvent, content: string, title: string, sortKeys = false): void {  
329 - if ($event) {  
330 - $event.stopPropagation();  
331 - }  
332 - var contentType = ContentType.JSON;  
333 - if (contentType === ContentType.JSON && sortKeys) {  
334 - try {  
335 - content = JSON.stringify(sortObjectKeys(JSON.parse(content)));  
336 - } catch (e) {}  
337 - }  
338 - this.dialog.open<EventContentDialogComponent, EventContentDialogData>(EventContentDialogComponent, {  
339 - disableClose: true,  
340 - panelClass: ['tb-dialog', 'tb-fullscreen-dialog'],  
341 - data: {  
342 - content,  
343 - title,  
344 - contentType  
345 - }  
346 - });  
347 - }  
348 -  
349 - updateEdgeEventStatus(createdTime) {  
350 - if (this.queueStartTs && createdTime < this.queueStartTs) {  
351 - return this.translate.instant('edge.success');  
352 - } else {  
353 - return this.translate.instant('edge.failed');  
354 - }  
355 - }  
356 -  
357 - isPending(createdTime) {  
358 - return createdTime > this.queueStartTs;  
359 - }  
360 -  
361 - loadEdgeInfo() {  
362 - this.attributeService.getEntityAttributes(this.entityId, AttributeScope.SERVER_SCOPE, ['queueStartTs'])  
363 - .subscribe(  
364 - attributes => this.onUpdate(attributes)  
365 - );  
366 - }  
367 -  
368 - onUpdate(attributes) {  
369 - this.queueStartTs = 0;  
370 - let edge = attributes.reduce(function (map, attribute) {  
371 - map[attribute.key] = attribute;  
372 - return map;  
373 - }, {});  
374 - if (edge.queueStartTs) {  
375 - this.queueStartTs = edge.queueStartTs.lastUpdateTs;  
376 - }  
377 - }  
378 -  
379 -  
380 } 252 }
381 253
@@ -24,8 +24,6 @@ import { EventTableConfig } from './event-table-config'; @@ -24,8 +24,6 @@ import { EventTableConfig } from './event-table-config';
24 import { EventService } from '@core/http/event.service'; 24 import { EventService } from '@core/http/event.service';
25 import { DialogService } from '@core/services/dialog.service'; 25 import { DialogService } from '@core/services/dialog.service';
26 import { DebugEventType, EventType } from '@shared/models/event.models'; 26 import { DebugEventType, EventType } from '@shared/models/event.models';
27 -import { RuleChainService } from "@core/http/rule-chain.service";  
28 -import { AttributeService } from "@core/http/attribute.service";  
29 27
30 @Component({ 28 @Component({
31 selector: 'tb-event-table', 29 selector: 'tb-event-table',
@@ -81,8 +79,6 @@ export class EventTableComponent implements OnInit { @@ -81,8 +79,6 @@ export class EventTableComponent implements OnInit {
81 constructor(private eventService: EventService, 79 constructor(private eventService: EventService,
82 private dialogService: DialogService, 80 private dialogService: DialogService,
83 private translate: TranslateService, 81 private translate: TranslateService,
84 - private attributeService: AttributeService,  
85 - private ruleChainService: RuleChainService,  
86 private datePipe: DatePipe, 82 private datePipe: DatePipe,
87 private dialog: MatDialog) { 83 private dialog: MatDialog) {
88 } 84 }
@@ -93,8 +89,6 @@ export class EventTableComponent implements OnInit { @@ -93,8 +89,6 @@ export class EventTableComponent implements OnInit {
93 this.eventService, 89 this.eventService,
94 this.dialogService, 90 this.dialogService,
95 this.translate, 91 this.translate,
96 - this.ruleChainService,  
97 - this.attributeService,  
98 this.datePipe, 92 this.datePipe,
99 this.dialog, 93 this.dialog,
100 this.entityIdValue, 94 this.entityIdValue,
@@ -119,6 +119,7 @@ import { SmsProviderConfigurationComponent } from '@home/components/sms/sms-prov @@ -119,6 +119,7 @@ import { SmsProviderConfigurationComponent } from '@home/components/sms/sms-prov
119 import { AwsSnsProviderConfigurationComponent } from '@home/components/sms/aws-sns-provider-configuration.component'; 119 import { AwsSnsProviderConfigurationComponent } from '@home/components/sms/aws-sns-provider-configuration.component';
120 import { TwilioSmsProviderConfigurationComponent } from '@home/components/sms/twilio-sms-provider-configuration.component'; 120 import { TwilioSmsProviderConfigurationComponent } from '@home/components/sms/twilio-sms-provider-configuration.component';
121 import { CopyDeviceCredentialsComponent } from '@home/components/device/copy-device-credentials.component'; 121 import { CopyDeviceCredentialsComponent } from '@home/components/device/copy-device-credentials.component';
  122 +import {EdgeDownlinkTableComponent} from "@home/components/edge/edge-downlink-table.component";
122 123
123 @NgModule({ 124 @NgModule({
124 declarations: 125 declarations:
@@ -132,6 +133,7 @@ import { CopyDeviceCredentialsComponent } from '@home/components/device/copy-dev @@ -132,6 +133,7 @@ import { CopyDeviceCredentialsComponent } from '@home/components/device/copy-dev
132 EventContentDialogComponent, 133 EventContentDialogComponent,
133 EventTableHeaderComponent, 134 EventTableHeaderComponent,
134 EventTableComponent, 135 EventTableComponent,
  136 + EdgeDownlinkTableComponent,
135 RelationTableComponent, 137 RelationTableComponent,
136 RelationDialogComponent, 138 RelationDialogComponent,
137 RelationFiltersComponent, 139 RelationFiltersComponent,
@@ -234,6 +236,7 @@ import { CopyDeviceCredentialsComponent } from '@home/components/device/copy-dev @@ -234,6 +236,7 @@ import { CopyDeviceCredentialsComponent } from '@home/components/device/copy-dev
234 EntityDetailsPanelComponent, 236 EntityDetailsPanelComponent,
235 AuditLogTableComponent, 237 AuditLogTableComponent,
236 EventTableComponent, 238 EventTableComponent,
  239 + EdgeDownlinkTableComponent,
237 RelationTableComponent, 240 RelationTableComponent,
238 RelationFiltersComponent, 241 RelationFiltersComponent,
239 AlarmTableComponent, 242 AlarmTableComponent,
@@ -42,6 +42,11 @@ @@ -42,6 +42,11 @@
42 [entityId]="entity.id"></tb-event-table> 42 [entityId]="entity.id"></tb-event-table>
43 </mat-tab> 43 </mat-tab>
44 <mat-tab *ngIf="entity" 44 <mat-tab *ngIf="entity"
  45 + label="{{ 'edge.downlinks' | translate }}" #downLinksTab="matTab">
  46 + <tb-edge-downlink-table [active]="downLinksTab.isActive" [tenantId]="entity.tenantId.id"
  47 + [entityId]="entity.id"></tb-edge-downlink-table>
  48 +</mat-tab>
  49 +<mat-tab *ngIf="entity"
45 label="{{ 'relation.relations' | translate }}" #relationsTab="matTab"> 50 label="{{ 'relation.relations' | translate }}" #relationsTab="matTab">
46 <tb-relation-table [active]="relationsTab.isActive" [entityId]="entity.id"></tb-relation-table> 51 <tb-relation-table [active]="relationsTab.isActive" [entityId]="entity.id"></tb-relation-table>
47 </mat-tab> 52 </mat-tab>
@@ -44,6 +44,7 @@ export class EdgeComponent extends EntityComponent<EdgeInfo> { @@ -44,6 +44,7 @@ export class EdgeComponent extends EntityComponent<EdgeInfo> {
44 @Inject('entity') protected entityValue: EdgeInfo, 44 @Inject('entity') protected entityValue: EdgeInfo,
45 @Inject('entitiesTableConfig') protected entitiesTableConfigValue: EntityTableConfig<EdgeInfo>, 45 @Inject('entitiesTableConfig') protected entitiesTableConfigValue: EntityTableConfig<EdgeInfo>,
46 public fb: FormBuilder, 46 public fb: FormBuilder,
  47 + // TODO: voba - discuss with Vlad how properly add window to subclass
47 @Inject(WINDOW) protected window: Window) { 48 @Inject(WINDOW) protected window: Window) {
48 super(store, fb, entityValue, entitiesTableConfigValue, window); 49 super(store, fb, entityValue, entitiesTableConfigValue, window);
49 } 50 }
@@ -36,6 +36,9 @@ import { EdgeTabsComponent } from "@home/pages/edge/edge-tabs.component"; @@ -36,6 +36,9 @@ import { EdgeTabsComponent } from "@home/pages/edge/edge-tabs.component";
36 HomeDialogsModule, 36 HomeDialogsModule,
37 HomeComponentsModule, 37 HomeComponentsModule,
38 EdgeRoutingModule 38 EdgeRoutingModule
  39 + ],
  40 + exports: [
  41 + EdgeComponent
39 ] 42 ]
40 }) 43 })
41 44
@@ -20,6 +20,8 @@ import { CustomerId } from '@shared/models/id/customer-id'; @@ -20,6 +20,8 @@ import { CustomerId } from '@shared/models/id/customer-id';
20 import { EdgeId } from '@shared/models/id/edge-id'; 20 import { EdgeId } from '@shared/models/id/edge-id';
21 import { EntitySearchQuery } from '@shared/models/relation.models'; 21 import { EntitySearchQuery } from '@shared/models/relation.models';
22 import { RuleChainId } from "@shared/models/id/rule-chain-id"; 22 import { RuleChainId } from "@shared/models/id/rule-chain-id";
  23 +import { BaseEventBody } from "@shared/models/event.models";
  24 +import { EventId } from "@shared/models/id/event-id";
23 25
24 export interface Edge extends BaseData<EdgeId> { 26 export interface Edge extends BaseData<EdgeId> {
25 tenantId?: TenantId; 27 tenantId?: TenantId;
@@ -43,3 +45,115 @@ export interface EdgeInfo extends Edge { @@ -43,3 +45,115 @@ export interface EdgeInfo extends Edge {
43 export interface EdgeSearchQuery extends EntitySearchQuery { 45 export interface EdgeSearchQuery extends EntitySearchQuery {
44 edgeTypes: Array<string>; 46 edgeTypes: Array<string>;
45 } 47 }
  48 +
  49 +export enum EdgeEventType {
  50 + DASHBOARD = "DASHBOARD",
  51 + ASSET = "ASSET",
  52 + DEVICE = "DEVICE",
  53 + DEVICE_PROFILE = "DEVICE_PROFILE",
  54 + ENTITY_VIEW = "ENTITY_VIEW",
  55 + ALARM = "ALARM",
  56 + RULE_CHAIN = "RULE_CHAIN",
  57 + RULE_CHAIN_METADATA = "RULE_CHAIN_METADATA",
  58 + EDGE = "EDGE",
  59 + USER = "USER",
  60 + CUSTOMER = "CUSTOMER",
  61 + RELATION = "RELATION",
  62 + WIDGETS_BUNDLE = "WIDGETS_BUNDLE",
  63 + WIDGET_TYPE = "WIDGET_TYPE",
  64 + ADMIN_SETTINGS = "ADMIN_SETTINGS"
  65 +}
  66 +
  67 +export enum EdgeEventActionType {
  68 + ADDED = "ADDED",
  69 + DELETED = "DELETED",
  70 + UPDATED = "UPDATED",
  71 + POST_ATTRIBUTES = "POST_ATTRIBUTES",
  72 + ATTRIBUTES_UPDATED = "ATTRIBUTES_UPDATED",
  73 + ATTRIBUTES_DELETED = "ATTRIBUTES_DELETED",
  74 + TIMESERIES_UPDATED = "TIMESERIES_UPDATED",
  75 + CREDENTIALS_UPDATED = "CREDENTIALS_UPDATED",
  76 + ASSIGNED_TO_CUSTOMER = "ASSIGNED_TO_CUSTOMER",
  77 + UNASSIGNED_FROM_CUSTOMER = "UNASSIGNED_FROM_CUSTOMER",
  78 + RELATION_ADD_OR_UPDATE = "RELATION_ADD_OR_UPDATE",
  79 + RELATION_DELETED = "RELATION_DELETED",
  80 + RPC_CALL = "RPC_CALL",
  81 + ALARM_ACK = "ALARM_ACK",
  82 + ALARM_CLEAR = "ALARM_CLEAR",
  83 + ASSIGNED_TO_EDGE = "ASSIGNED_TO_EDGE",
  84 + UNASSIGNED_FROM_EDGE = "UNASSIGNED_FROM_EDGE",
  85 + CREDENTIALS_REQUEST = "CREDENTIALS_REQUEST",
  86 + ENTITY_MERGE_REQUEST = "ENTITY_MERGE_REQUEST"
  87 +}
  88 +
  89 +export enum EdgeEventStatus {
  90 + DEPLOYED = "DEPLOYED",
  91 + PENDING = "PENDING"
  92 +}
  93 +
  94 +export const edgeEventTypeTranslations = new Map<EdgeEventType, string>(
  95 + [
  96 + [EdgeEventType.DASHBOARD, 'edge.edge-event-type-dashboard'],
  97 + [EdgeEventType.ASSET, 'edge.edge-event-type-asset'],
  98 + [EdgeEventType.DEVICE, 'edge.edge-event-type-device'],
  99 + [EdgeEventType.DEVICE_PROFILE, 'edge.edge-event-type-device-profile'],
  100 + [EdgeEventType.ENTITY_VIEW, 'edge.edge-event-type-entity-view'],
  101 + [EdgeEventType.ALARM, 'edge.edge-event-type-alarm'],
  102 + [EdgeEventType.RULE_CHAIN, 'edge.edge-event-type-rule-chain'],
  103 + [EdgeEventType.RULE_CHAIN_METADATA, 'edge.edge-event-type-rule-chain-metadata'],
  104 + [EdgeEventType.EDGE, 'edge.edge-event-type-edge'],
  105 + [EdgeEventType.USER, 'edge.edge-event-type-user'],
  106 + [EdgeEventType.CUSTOMER, 'edge.edge-event-type-customer'],
  107 + [EdgeEventType.RELATION, 'edge.edge-event-type-relation'],
  108 + [EdgeEventType.WIDGETS_BUNDLE, 'edge.edge-event-type-widgets-bundle'],
  109 + [EdgeEventType.WIDGET_TYPE, 'edge.edge-event-type-widgets-type'],
  110 + [EdgeEventType.ADMIN_SETTINGS, 'edge.edge-event-type-admin-settings']
  111 + ]
  112 +);
  113 +
  114 +export const edgeEventActionTypeTranslations = new Map<EdgeEventActionType, string>(
  115 + [
  116 + [EdgeEventActionType.ADDED, 'edge.edge-event-action-type-added'],
  117 + [EdgeEventActionType.DELETED, 'edge.edge-event-action-type-deleted'],
  118 + [EdgeEventActionType.UPDATED, 'edge.edge-event-action-type-updated'],
  119 + [EdgeEventActionType.POST_ATTRIBUTES, 'edge.edge-event-action-type-post-attributes'],
  120 + [EdgeEventActionType.ATTRIBUTES_UPDATED, 'edge.edge-event-action-type-attributes-updated'],
  121 + [EdgeEventActionType.ATTRIBUTES_DELETED, 'edge.edge-event-action-type-attributes-deleted'],
  122 + [EdgeEventActionType.TIMESERIES_UPDATED, 'edge.edge-event-action-type-timeseries-updated'],
  123 + [EdgeEventActionType.CREDENTIALS_UPDATED, 'edge.edge-event-action-type-credentials-updated'],
  124 + [EdgeEventActionType.ASSIGNED_TO_CUSTOMER, 'edge.edge-event-action-type-assigned-to-customer'],
  125 + [EdgeEventActionType.UNASSIGNED_FROM_CUSTOMER, 'edge.edge-event-action-type-unassigned-from-customer'],
  126 + [EdgeEventActionType.RELATION_ADD_OR_UPDATE, 'edge.edge-event-action-type-relation-add-or-update'],
  127 + [EdgeEventActionType.RELATION_DELETED, 'edge.edge-event-action-type-relation-deleted'],
  128 + [EdgeEventActionType.RPC_CALL, 'edge.edge-event-action-type-rpc-call'],
  129 + [EdgeEventActionType.ALARM_ACK, 'edge.edge-event-action-type-alarm-ack'],
  130 + [EdgeEventActionType.ALARM_CLEAR, 'edge.edge-event-action-type-alarm-clear'],
  131 + [EdgeEventActionType.ASSIGNED_TO_EDGE, 'edge.edge-event-action-type-assigned-to-edge'],
  132 + [EdgeEventActionType.UNASSIGNED_FROM_EDGE, 'edge.edge-event-action-type-unassigned-from-edge'],
  133 + [EdgeEventActionType.CREDENTIALS_REQUEST, 'edge.edge-event-action-type-credentials-request'],
  134 + [EdgeEventActionType.ENTITY_MERGE_REQUEST, 'edge.edge-event-action-type-entity-merge-request']
  135 + ]
  136 +);
  137 +
  138 +export const edgeEventStatusColor = new Map<EdgeEventStatus, string>(
  139 + [
  140 + [EdgeEventStatus.DEPLOYED, '#000000'],
  141 + [EdgeEventStatus.PENDING, '#9e9e9e']
  142 + ]
  143 +);
  144 +
  145 +export interface EdgeEventBody extends BaseEventBody {
  146 + type: string;
  147 + action: string;
  148 + entityId: string;
  149 +}
  150 +
  151 +export interface EdgeEvent extends BaseData<EventId> {
  152 + tenantId: TenantId;
  153 + entityId: string;
  154 + edgeId: EdgeId;
  155 + action: EdgeEventActionType;
  156 + type: EdgeEventType;
  157 + uid: string;
  158 + body: string;
  159 +}
@@ -23,8 +23,7 @@ import { ContentType } from '@shared/models/constants'; @@ -23,8 +23,7 @@ import { ContentType } from '@shared/models/constants';
23 export enum EventType { 23 export enum EventType {
24 ERROR = 'ERROR', 24 ERROR = 'ERROR',
25 LC_EVENT = 'LC_EVENT', 25 LC_EVENT = 'LC_EVENT',
26 - STATS = 'STATS',  
27 - EDGE_EVENT = 'EDGE_EVENT' 26 + STATS = 'STATS'
28 } 27 }
29 28
30 export enum DebugEventType { 29 export enum DebugEventType {
@@ -32,41 +31,11 @@ export enum DebugEventType { @@ -32,41 +31,11 @@ export enum DebugEventType {
32 DEBUG_RULE_CHAIN = 'DEBUG_RULE_CHAIN' 31 DEBUG_RULE_CHAIN = 'DEBUG_RULE_CHAIN'
33 } 32 }
34 33
35 -export enum EdgeEventType {  
36 - DASHBOARD = "DASHBOARD",  
37 - ASSET = "ASSET",  
38 - DEVICE = "DEVICE",  
39 - ENTITY_VIEW = "ENTITY_VIEW",  
40 - ALARM = "ALARM",  
41 - RULE_CHAIN = "RULE_CHAIN",  
42 - RULE_CHAIN_METADATA = "RULE_CHAIN_METADATA",  
43 - EDGE = "EDGE",  
44 - USER = "USER",  
45 - CUSTOMER = "CUSTOMER",  
46 - RELATION = "RELATION",  
47 - WIDGETS_BUNDLE = "WIDGETS_BUNDLE",  
48 - WIDGET_TYPE = "WIDGET_TYPE",  
49 - ADMIN_SETTINGS = "ADMIN_SETTINGS"  
50 -}  
51 -  
52 -export enum EdgeEventStatus {  
53 - DEPLOYED = "DEPLOYED",  
54 - PENDING = "PENDING"  
55 -}  
56 -  
57 -export const edgeEventStatusColor = new Map<EdgeEventStatus, string> (  
58 - [  
59 - [EdgeEventStatus.DEPLOYED, '#000000'],  
60 - [EdgeEventStatus.PENDING, '#9e9e9e']  
61 - ]  
62 -);  
63 -  
64 export const eventTypeTranslations = new Map<EventType | DebugEventType, string>( 34 export const eventTypeTranslations = new Map<EventType | DebugEventType, string>(
65 [ 35 [
66 [EventType.ERROR, 'event.type-error'], 36 [EventType.ERROR, 'event.type-error'],
67 [EventType.LC_EVENT, 'event.type-lc-event'], 37 [EventType.LC_EVENT, 'event.type-lc-event'],
68 [EventType.STATS, 'event.type-stats'], 38 [EventType.STATS, 'event.type-stats'],
69 - [EventType.EDGE_EVENT, 'event.type-edge-event'],  
70 [DebugEventType.DEBUG_RULE_NODE, 'event.type-debug-rule-node'], 39 [DebugEventType.DEBUG_RULE_NODE, 'event.type-debug-rule-node'],
71 [DebugEventType.DEBUG_RULE_CHAIN, 'event.type-debug-rule-chain'], 40 [DebugEventType.DEBUG_RULE_CHAIN, 'event.type-debug-rule-chain'],
72 ] 41 ]
@@ -92,12 +61,6 @@ export interface StatsEventBody extends BaseEventBody { @@ -92,12 +61,6 @@ export interface StatsEventBody extends BaseEventBody {
92 errorsOccurred: number; 61 errorsOccurred: number;
93 } 62 }
94 63
95 -export interface EdgeEventBody extends BaseEventBody {  
96 - type: string;  
97 - action: string;  
98 - entityId: string;  
99 -}  
100 -  
101 export interface DebugRuleNodeEventBody extends BaseEventBody { 64 export interface DebugRuleNodeEventBody extends BaseEventBody {
102 type: string; 65 type: string;
103 entityId: string; 66 entityId: string;
@@ -111,7 +74,7 @@ export interface DebugRuleNodeEventBody extends BaseEventBody { @@ -111,7 +74,7 @@ export interface DebugRuleNodeEventBody extends BaseEventBody {
111 error: string; 74 error: string;
112 } 75 }
113 76
114 -export type EventBody = ErrorEventBody & LcEventEventBody & StatsEventBody & DebugRuleNodeEventBody & EdgeEventBody; 77 +export type EventBody = ErrorEventBody & LcEventEventBody & StatsEventBody & DebugRuleNodeEventBody;
115 78
116 export interface Event extends BaseData<EventId> { 79 export interface Event extends BaseData<EventId> {
117 tenantId: TenantId; 80 tenantId: TenantId;
@@ -119,5 +82,4 @@ export interface Event extends BaseData<EventId> { @@ -119,5 +82,4 @@ export interface Event extends BaseData<EventId> {
119 type: string; 82 type: string;
120 uid: string; 83 uid: string;
121 body: EventBody; 84 body: EventBody;
122 - action: string; //TODO: refactor edgeEvents - move parameters to the entity.body  
123 } 85 }
@@ -1203,7 +1203,43 @@ @@ -1203,7 +1203,43 @@
1203 "dashboard": "Edge dashboard", 1203 "dashboard": "Edge dashboard",
1204 "enter-edge-type": "Enter edge type", 1204 "enter-edge-type": "Enter edge type",
1205 "deployed": "Deployed", 1205 "deployed": "Deployed",
1206 - "pending": "Pending" 1206 + "pending": "Pending",
  1207 + "downlinks": "Downlinks",
  1208 + "no-downlinks-prompt": "No downlinks found",
  1209 + "edge-event-type-dashboard": "Dashboard",
  1210 + "edge-event-type-asset": "Asset",
  1211 + "edge-event-type-device": "Device",
  1212 + "edge-event-type-device-profile": "Device Profile",
  1213 + "edge-event-type-entity-view": "Entity View",
  1214 + "edge-event-type-alarm": "Alar",
  1215 + "edge-event-type-rule-chain": "Rule Chain",
  1216 + "edge-event-type-rule-chain-metadata": "Rule Chain Metadata",
  1217 + "edge-event-type-edge": "Edge",
  1218 + "edge-event-type-user": "User",
  1219 + "edge-event-type-customer": "Customer",
  1220 + "edge-event-type-relation": "Relation",
  1221 + "edge-event-type-widgets-bundle": "Widgets Bundle",
  1222 + "edge-event-type-widgets-type": "Widgets Type",
  1223 + "edge-event-type-admin-settings": "Admin Settings",
  1224 + "edge-event-action-type-added": "Added",
  1225 + "edge-event-action-type-deleted": "Deleted",
  1226 + "edge-event-action-type-updated": "Updated",
  1227 + "edge-event-action-type-post-attributes": "Post Attributes",
  1228 + "edge-event-action-type-attributes-updated": "Attributes Updated",
  1229 + "edge-event-action-type-attributes-deleted": "Attributes Deleted",
  1230 + "edge-event-action-type-timeseries-updated": "Timeseries Updated",
  1231 + "edge-event-action-type-credentials-updated": "Credentials Updated",
  1232 + "edge-event-action-type-assigned-to-customer": "Assigned to Customer",
  1233 + "edge-event-action-type-unassigned-from-customer": "Unassigned from Customer",
  1234 + "edge-event-action-type-relation-add-or-update": "Relation Add or Update",
  1235 + "edge-event-action-type-relation-deleted": "Relation Deleted",
  1236 + "edge-event-action-type-rpc-call": "RPC Call",
  1237 + "edge-event-action-type-alarm-ack": "Alarm Ack",
  1238 + "edge-event-action-type-alarm-clear": "Alarm Clear",
  1239 + "edge-event-action-type-assigned-to-edge": "Assigned to Edge",
  1240 + "edge-event-action-type-unassigned-from-edge": "Unassigned from Edge",
  1241 + "edge-event-action-type-credentials-request": "Credentials Request",
  1242 + "edge-event-action-type-entity-merge-request": "Entity Merge Request"
1207 }, 1243 },
1208 "error": { 1244 "error": {
1209 "unable-to-connect": "Unable to connect to the server! Please check your internet connection.", 1245 "unable-to-connect": "Unable to connect to the server! Please check your internet connection.",