...
|
...
|
@@ -64,15 +64,22 @@ import { |
64
|
64
|
} from '@modules/home/pages/dashboard/make-dashboard-public-dialog.component';
|
65
|
65
|
import { DashboardTabsComponent } from '@home/pages/dashboard/dashboard-tabs.component';
|
66
|
66
|
import { ImportExportService } from '@home/components/import-export/import-export.service';
|
|
67
|
+import { EdgeService } from "@core/http/edge.service";
|
|
68
|
+import {
|
|
69
|
+ AddEntitiesToEdgeDialogComponent,
|
|
70
|
+ AddEntitiesToEdgeDialogData
|
|
71
|
+} from "@home/dialogs/add-entities-to-edge-dialog.component";
|
67
|
72
|
|
68
|
73
|
@Injectable()
|
69
|
74
|
export class DashboardsTableConfigResolver implements Resolve<EntityTableConfig<DashboardInfo | Dashboard>> {
|
70
|
75
|
|
71
|
76
|
private readonly config: EntityTableConfig<DashboardInfo | Dashboard> = new EntityTableConfig<DashboardInfo | Dashboard>();
|
|
77
|
+ private edgeId: string;
|
72
|
78
|
|
73
|
79
|
constructor(private store: Store<AppState>,
|
74
|
80
|
private dashboardService: DashboardService,
|
75
|
81
|
private customerService: CustomerService,
|
|
82
|
+ private edgeService: EdgeService,
|
76
|
83
|
private dialogService: DialogService,
|
77
|
84
|
private importExport: ImportExportService,
|
78
|
85
|
private translate: TranslateService,
|
...
|
...
|
@@ -106,6 +113,7 @@ export class DashboardsTableConfigResolver implements Resolve<EntityTableConfig< |
106
|
113
|
dashboardScope: route.data.dashboardsType,
|
107
|
114
|
customerId: routeParams.customerId
|
108
|
115
|
};
|
|
116
|
+ this.edgeId = routeParams.edgeId;
|
109
|
117
|
return this.store.pipe(select(selectAuthUser), take(1)).pipe(
|
110
|
118
|
tap((authUser) => {
|
111
|
119
|
if (authUser.authority === Authority.CUSTOMER_USER) {
|
...
|
...
|
@@ -124,6 +132,9 @@ export class DashboardsTableConfigResolver implements Resolve<EntityTableConfig< |
124
|
132
|
} else {
|
125
|
133
|
this.config.tableTitle = parentCustomer.title + ': ' + this.translate.instant('dashboard.dashboards');
|
126
|
134
|
}
|
|
135
|
+ } else if (this.config.componentsData.dashboardScope === 'edge') {
|
|
136
|
+ this.edgeService.getEdge(this.edgeId).pipe(map(edge =>
|
|
137
|
+ this.config.tableTitle = edge.name + ': ' + this.translate.instant('dashboard.dashboards'))).subscribe();
|
127
|
138
|
} else {
|
128
|
139
|
this.config.tableTitle = this.translate.instant('dashboard.dashboards');
|
129
|
140
|
}
|
...
|
...
|
@@ -165,6 +176,9 @@ export class DashboardsTableConfigResolver implements Resolve<EntityTableConfig< |
165
|
176
|
this.config.entitiesFetchFunction = pageLink =>
|
166
|
177
|
this.dashboardService.getTenantDashboards(pageLink);
|
167
|
178
|
this.config.deleteEntity = id => this.dashboardService.deleteDashboard(id.id);
|
|
179
|
+ } else if (dashboardScope === 'edge') {
|
|
180
|
+ this.config.entitiesFetchFunction = pageLink =>
|
|
181
|
+ this.dashboardService.getEdgeDashboards(this.edgeId, pageLink, this.config.componentsData.dashboardsType);
|
168
|
182
|
} else {
|
169
|
183
|
this.config.entitiesFetchFunction = pageLink =>
|
170
|
184
|
this.dashboardService.getCustomerDashboards(this.config.componentsData.customerId, pageLink);
|
...
|
...
|
@@ -233,6 +247,16 @@ export class DashboardsTableConfigResolver implements Resolve<EntityTableConfig< |
233
|
247
|
}
|
234
|
248
|
);
|
235
|
249
|
}
|
|
250
|
+ if (dashboardScope === 'edge') {
|
|
251
|
+ actions.push(
|
|
252
|
+ {
|
|
253
|
+ name: this.translate.instant('edge.unassign-from-edge'),
|
|
254
|
+ icon: 'portable_wifi_off',
|
|
255
|
+ isEnabled: (entity) => true,
|
|
256
|
+ onAction: ($event, entity) => this.unassignFromEdge($event, entity)
|
|
257
|
+ }
|
|
258
|
+ );
|
|
259
|
+ }
|
236
|
260
|
return actions;
|
237
|
261
|
}
|
238
|
262
|
|
...
|
...
|
@@ -267,6 +291,16 @@ export class DashboardsTableConfigResolver implements Resolve<EntityTableConfig< |
267
|
291
|
}
|
268
|
292
|
);
|
269
|
293
|
}
|
|
294
|
+ if (dashboardScope === 'edge') {
|
|
295
|
+ actions.push(
|
|
296
|
+ {
|
|
297
|
+ name: this.translate.instant('dashboard.unassign-dashboards-from-edge'),
|
|
298
|
+ icon: 'portable_wifi_off',
|
|
299
|
+ isEnabled: true,
|
|
300
|
+ onAction: ($event, entities) => this.unassignDashboardsFromEdge($event, entities)
|
|
301
|
+ }
|
|
302
|
+ );
|
|
303
|
+ }
|
270
|
304
|
return actions;
|
271
|
305
|
}
|
272
|
306
|
|
...
|
...
|
@@ -298,6 +332,16 @@ export class DashboardsTableConfigResolver implements Resolve<EntityTableConfig< |
298
|
332
|
}
|
299
|
333
|
);
|
300
|
334
|
}
|
|
335
|
+ if (dashboardScope === 'edge') {
|
|
336
|
+ actions.push(
|
|
337
|
+ {
|
|
338
|
+ name: this.translate.instant('dashboard.assign-new-dashboard'),
|
|
339
|
+ icon: 'add',
|
|
340
|
+ isEnabled: () => true,
|
|
341
|
+ onAction: ($event) => this.addDashboardsToEdge($event)
|
|
342
|
+ }
|
|
343
|
+ );
|
|
344
|
+ }
|
301
|
345
|
return actions;
|
302
|
346
|
}
|
303
|
347
|
|
...
|
...
|
@@ -503,4 +547,74 @@ export class DashboardsTableConfigResolver implements Resolve<EntityTableConfig< |
503
|
547
|
return false;
|
504
|
548
|
}
|
505
|
549
|
|
|
550
|
+ addDashboardsToEdge($event: Event) {
|
|
551
|
+ if ($event) {
|
|
552
|
+ $event.stopPropagation();
|
|
553
|
+ }
|
|
554
|
+ this.dialog.open<AddEntitiesToEdgeDialogComponent, AddEntitiesToEdgeDialogData,
|
|
555
|
+ boolean>(AddEntitiesToEdgeDialogComponent, {
|
|
556
|
+ disableClose: true,
|
|
557
|
+ panelClass: ['tb-dialog', 'tb-fullscreen-dialog'],
|
|
558
|
+ data: {
|
|
559
|
+ edgeId: this.edgeId,
|
|
560
|
+ entityType: EntityType.DASHBOARD
|
|
561
|
+ }
|
|
562
|
+ }).afterClosed()
|
|
563
|
+ .subscribe((res) => {
|
|
564
|
+ if (res) {
|
|
565
|
+ this.config.table.updateData();
|
|
566
|
+ }
|
|
567
|
+ });
|
|
568
|
+ }
|
|
569
|
+
|
|
570
|
+ unassignFromEdge($event: Event, dashboard: DashboardInfo) {
|
|
571
|
+ if ($event) {
|
|
572
|
+ $event.stopPropagation();
|
|
573
|
+ }
|
|
574
|
+ this.dialogService.confirm(
|
|
575
|
+ this.translate.instant('dashboard.unassign-dashboard-from-edge-title', {dashboardName: dashboard.name}),
|
|
576
|
+ this.translate.instant('dashboard.unassign-dashboard-from-edge-text'),
|
|
577
|
+ this.translate.instant('action.no'),
|
|
578
|
+ this.translate.instant('action.yes'),
|
|
579
|
+ true
|
|
580
|
+ ).subscribe((res) => {
|
|
581
|
+ if (res) {
|
|
582
|
+ this.dashboardService.unassignDashboardFromEdge(this.edgeId, dashboard.id.id).subscribe(
|
|
583
|
+ () => {
|
|
584
|
+ this.config.table.updateData();
|
|
585
|
+ }
|
|
586
|
+ );
|
|
587
|
+ }
|
|
588
|
+ }
|
|
589
|
+ );
|
|
590
|
+ }
|
|
591
|
+
|
|
592
|
+ unassignDashboardsFromEdge($event: Event, dashboards: Array<DashboardInfo>) {
|
|
593
|
+ if ($event) {
|
|
594
|
+ $event.stopPropagation();
|
|
595
|
+ }
|
|
596
|
+ this.dialogService.confirm(
|
|
597
|
+ this.translate.instant('dashboard.unassign-dashboards-from-edge-title', {count: dashboards.length}),
|
|
598
|
+ this.translate.instant('dashboard.unassign-dashboards-from-edge-text'),
|
|
599
|
+ this.translate.instant('action.no'),
|
|
600
|
+ this.translate.instant('action.yes'),
|
|
601
|
+ true
|
|
602
|
+ ).subscribe((res) => {
|
|
603
|
+ if (res) {
|
|
604
|
+ const tasks: Observable<any>[] = [];
|
|
605
|
+ dashboards.forEach(
|
|
606
|
+ (dashboard) => {
|
|
607
|
+ tasks.push(this.dashboardService.unassignDashboardFromEdge(this.edgeId, dashboard.id.id));
|
|
608
|
+ }
|
|
609
|
+ );
|
|
610
|
+ forkJoin(tasks).subscribe(
|
|
611
|
+ () => {
|
|
612
|
+ this.config.table.updateData();
|
|
613
|
+ }
|
|
614
|
+ );
|
|
615
|
+ }
|
|
616
|
+ }
|
|
617
|
+ );
|
|
618
|
+ }
|
|
619
|
+
|
506
|
620
|
} |
...
|
...
|
|