...
|
...
|
@@ -22,6 +22,7 @@ import { |
22
|
22
|
} from '@home/models/entity/entities-table-config.models';
|
23
|
23
|
import {
|
24
|
24
|
EdgeEvent,
|
|
25
|
+ EdgeEventActionType,
|
25
|
26
|
edgeEventActionTypeTranslations,
|
26
|
27
|
EdgeEventStatus,
|
27
|
28
|
edgeEventStatusColor,
|
...
|
...
|
@@ -33,7 +34,6 @@ import { TranslateService } from '@ngx-translate/core'; |
33
|
34
|
import { DatePipe } from '@angular/common';
|
34
|
35
|
import { MatDialog } from '@angular/material/dialog';
|
35
|
36
|
import { EntityId } from '@shared/models/id/entity-id';
|
36
|
|
-import { EntityTypeResource } from '@shared/models/entity-type.models';
|
37
|
37
|
import { Observable } from 'rxjs';
|
38
|
38
|
import { PageData } from '@shared/models/page/page-data';
|
39
|
39
|
import { Direction } from '@shared/models/page/sort-order';
|
...
|
...
|
@@ -49,18 +49,22 @@ import { EdgeDownlinkTableHeaderComponent } from '@home/components/edge/edge-dow |
49
|
49
|
import { EdgeService } from '@core/http/edge.service';
|
50
|
50
|
import { map } from 'rxjs/operators';
|
51
|
51
|
import { EntityService } from "@core/http/entity.service";
|
|
52
|
+import { Store } from '@ngrx/store';
|
|
53
|
+import { AppState } from '@core/core.state';
|
|
54
|
+import { ActionNotificationShow } from '@core/notification/notification.actions';
|
52
|
55
|
|
53
|
56
|
export class EdgeDownlinkTableConfig extends EntityTableConfig<EdgeEvent, TimePageLink> {
|
54
|
57
|
|
55
|
58
|
queueStartTs: number;
|
56
|
59
|
|
57
|
|
- constructor(private edgeService: EdgeService,
|
58
|
|
- private entityService: EntityService,
|
59
|
|
- private dialogService: DialogService,
|
60
|
|
- private translate: TranslateService,
|
61
|
|
- private attributeService: AttributeService,
|
|
60
|
+ constructor(private attributeService: AttributeService,
|
62
|
61
|
private datePipe: DatePipe,
|
|
62
|
+ private dialogService: DialogService,
|
63
|
63
|
private dialog: MatDialog,
|
|
64
|
+ private edgeService: EdgeService,
|
|
65
|
+ private entityService: EntityService,
|
|
66
|
+ private translate: TranslateService,
|
|
67
|
+ private store: Store<AppState>,
|
64
|
68
|
public entityId: EntityId) {
|
65
|
69
|
super();
|
66
|
70
|
|
...
|
...
|
@@ -74,12 +78,9 @@ export class EdgeDownlinkTableConfig extends EntityTableConfig<EdgeEvent, TimePa |
74
|
78
|
this.entitiesDeleteEnabled = false;
|
75
|
79
|
|
76
|
80
|
this.headerComponent = EdgeDownlinkTableHeaderComponent;
|
77
|
|
- this.entityTranslations = {
|
78
|
|
- noEntities: 'edge.no-downlinks-prompt'
|
79
|
|
- };
|
80
|
|
- this.entityResources = {} as EntityTypeResource<EdgeEvent>;
|
|
81
|
+ this.entityTranslations = { noEntities: 'edge.no-downlinks-prompt' };
|
81
|
82
|
this.entitiesFetchFunction = pageLink => this.fetchEvents(pageLink);
|
82
|
|
- this.defaultSortOrder = {property: 'createdTime', direction: Direction.DESC};
|
|
83
|
+ this.defaultSortOrder = { property: 'createdTime', direction: Direction.DESC };
|
83
|
84
|
|
84
|
85
|
this.updateColumns();
|
85
|
86
|
}
|
...
|
...
|
@@ -96,7 +97,7 @@ export class EdgeDownlinkTableConfig extends EntityTableConfig<EdgeEvent, TimePa |
96
|
97
|
);
|
97
|
98
|
}
|
98
|
99
|
|
99
|
|
- onUpdate(attributes) {
|
|
100
|
+ onUpdate(attributes): void {
|
100
|
101
|
this.queueStartTs = 0;
|
101
|
102
|
let edge = attributes.reduce(function (map, attribute) {
|
102
|
103
|
map[attribute.key] = attribute;
|
...
|
...
|
@@ -126,12 +127,13 @@ export class EdgeDownlinkTableConfig extends EntityTableConfig<EdgeEvent, TimePa |
126
|
127
|
{
|
127
|
128
|
name: this.translate.instant('action.view'),
|
128
|
129
|
icon: 'more_horiz',
|
129
|
|
- isEnabled: (entity) => this.isEdgeEventHasData(entity.type),
|
|
130
|
+ isEnabled: (entity) => this.isEdgeEventHasData(entity),
|
130
|
131
|
onAction: ($event, entity) =>
|
131
|
132
|
{
|
132
|
|
- this.prepareEdgeEventContent(entity).subscribe((content) => {
|
133
|
|
- this.showEdgeEventContent($event, content,'event.data');
|
134
|
|
- });
|
|
133
|
+ this.prepareEdgeEventContent(entity).subscribe(
|
|
134
|
+ (content) => this.showEdgeEventContent($event, content,'event.data'),
|
|
135
|
+ () => this.showEntityNotFoundError()
|
|
136
|
+ );
|
135
|
137
|
}
|
136
|
138
|
},
|
137
|
139
|
'40px'),
|
...
|
...
|
@@ -141,7 +143,7 @@ export class EdgeDownlinkTableConfig extends EntityTableConfig<EdgeEvent, TimePa |
141
|
143
|
}
|
142
|
144
|
}
|
143
|
145
|
|
144
|
|
- updateEdgeEventStatus(createdTime): string {
|
|
146
|
+ updateEdgeEventStatus(createdTime: number): string {
|
145
|
147
|
if (this.queueStartTs && createdTime < this.queueStartTs) {
|
146
|
148
|
return this.translate.instant('edge.deployed');
|
147
|
149
|
} else {
|
...
|
...
|
@@ -149,21 +151,17 @@ export class EdgeDownlinkTableConfig extends EntityTableConfig<EdgeEvent, TimePa |
149
|
151
|
}
|
150
|
152
|
}
|
151
|
153
|
|
152
|
|
- isPending(createdTime): boolean {
|
|
154
|
+ isPending(createdTime: number): boolean {
|
153
|
155
|
return createdTime > this.queueStartTs;
|
154
|
156
|
}
|
155
|
157
|
|
156
|
|
- isEdgeEventHasData(edgeEventType: EdgeEventType): boolean {
|
157
|
|
- switch (edgeEventType) {
|
158
|
|
- case EdgeEventType.ADMIN_SETTINGS:
|
159
|
|
- return false;
|
160
|
|
- default:
|
161
|
|
- return true;
|
162
|
|
- }
|
|
158
|
+ isEdgeEventHasData(entity: EdgeEvent): boolean {
|
|
159
|
+ return !(entity.type === EdgeEventType.ADMIN_SETTINGS ||
|
|
160
|
+ entity.action === EdgeEventActionType.DELETED);
|
163
|
161
|
}
|
164
|
162
|
|
165
|
|
- prepareEdgeEventContent(entity: any): Observable<string> {
|
166
|
|
- return this.entityService.getEdgeEventContentByEntityType(entity).pipe(
|
|
163
|
+ prepareEdgeEventContent(entity: EdgeEvent): Observable<string> {
|
|
164
|
+ return this.entityService.getEdgeEventContent(entity).pipe(
|
167
|
165
|
map((result) => JSON.stringify(result))
|
168
|
166
|
);
|
169
|
167
|
}
|
...
|
...
|
@@ -182,4 +180,15 @@ export class EdgeDownlinkTableConfig extends EntityTableConfig<EdgeEvent, TimePa |
182
|
180
|
}
|
183
|
181
|
});
|
184
|
182
|
}
|
|
183
|
+
|
|
184
|
+ showEntityNotFoundError(): void {
|
|
185
|
+ this.store.dispatch(new ActionNotificationShow(
|
|
186
|
+ {
|
|
187
|
+ message: this.translate.instant('edge.load-entity-error'),
|
|
188
|
+ type: 'error',
|
|
189
|
+ verticalPosition: 'top',
|
|
190
|
+ horizontalPosition: 'left'
|
|
191
|
+ }
|
|
192
|
+ ));
|
|
193
|
+ }
|
185
|
194
|
} |
...
|
...
|
|