Partial fix Edge dashboards page
This commit is contained in:
parent
c242446a86
commit
f035bbd941
@ -164,8 +164,8 @@ export class DashboardService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public assignDashboardToEdge(edgeId: string, dashboardId: string, config?: RequestConfig): Observable<Dashboard> {
|
public assignDashboardToEdge(edgeId: string, dashboardId: string, config?: RequestConfig): Observable<Dashboard> {
|
||||||
return this.http.post<Dashboard>(`/api/edge/${edgeId}/dashboard/${dashboardId}`, null,
|
return this.http.post<Dashboard>(`/api/edge/${edgeId}/dashboard/${dashboardId}`,
|
||||||
defaultHttpOptionsFromConfig(config));
|
null, defaultHttpOptionsFromConfig(config));
|
||||||
}
|
}
|
||||||
|
|
||||||
public unassignDashboardFromEdge(edgeId: string, dashboardId: string, config?: RequestConfig) {
|
public unassignDashboardFromEdge(edgeId: string, dashboardId: string, config?: RequestConfig) {
|
||||||
|
|||||||
@ -64,15 +64,22 @@ import {
|
|||||||
} from '@modules/home/pages/dashboard/make-dashboard-public-dialog.component';
|
} from '@modules/home/pages/dashboard/make-dashboard-public-dialog.component';
|
||||||
import { DashboardTabsComponent } from '@home/pages/dashboard/dashboard-tabs.component';
|
import { DashboardTabsComponent } from '@home/pages/dashboard/dashboard-tabs.component';
|
||||||
import { ImportExportService } from '@home/components/import-export/import-export.service';
|
import { ImportExportService } from '@home/components/import-export/import-export.service';
|
||||||
|
import { EdgeService } from "@core/http/edge.service";
|
||||||
|
import {
|
||||||
|
AddEntitiesToEdgeDialogComponent,
|
||||||
|
AddEntitiesToEdgeDialogData
|
||||||
|
} from "@home/dialogs/add-entities-to-edge-dialog.component";
|
||||||
|
|
||||||
@Injectable()
|
@Injectable()
|
||||||
export class DashboardsTableConfigResolver implements Resolve<EntityTableConfig<DashboardInfo | Dashboard>> {
|
export class DashboardsTableConfigResolver implements Resolve<EntityTableConfig<DashboardInfo | Dashboard>> {
|
||||||
|
|
||||||
private readonly config: EntityTableConfig<DashboardInfo | Dashboard> = new EntityTableConfig<DashboardInfo | Dashboard>();
|
private readonly config: EntityTableConfig<DashboardInfo | Dashboard> = new EntityTableConfig<DashboardInfo | Dashboard>();
|
||||||
|
private edgeId: string;
|
||||||
|
|
||||||
constructor(private store: Store<AppState>,
|
constructor(private store: Store<AppState>,
|
||||||
private dashboardService: DashboardService,
|
private dashboardService: DashboardService,
|
||||||
private customerService: CustomerService,
|
private customerService: CustomerService,
|
||||||
|
private edgeService: EdgeService,
|
||||||
private dialogService: DialogService,
|
private dialogService: DialogService,
|
||||||
private importExport: ImportExportService,
|
private importExport: ImportExportService,
|
||||||
private translate: TranslateService,
|
private translate: TranslateService,
|
||||||
@ -106,6 +113,7 @@ export class DashboardsTableConfigResolver implements Resolve<EntityTableConfig<
|
|||||||
dashboardScope: route.data.dashboardsType,
|
dashboardScope: route.data.dashboardsType,
|
||||||
customerId: routeParams.customerId
|
customerId: routeParams.customerId
|
||||||
};
|
};
|
||||||
|
this.edgeId = routeParams.edgeId;
|
||||||
return this.store.pipe(select(selectAuthUser), take(1)).pipe(
|
return this.store.pipe(select(selectAuthUser), take(1)).pipe(
|
||||||
tap((authUser) => {
|
tap((authUser) => {
|
||||||
if (authUser.authority === Authority.CUSTOMER_USER) {
|
if (authUser.authority === Authority.CUSTOMER_USER) {
|
||||||
@ -124,6 +132,9 @@ export class DashboardsTableConfigResolver implements Resolve<EntityTableConfig<
|
|||||||
} else {
|
} else {
|
||||||
this.config.tableTitle = parentCustomer.title + ': ' + this.translate.instant('dashboard.dashboards');
|
this.config.tableTitle = parentCustomer.title + ': ' + this.translate.instant('dashboard.dashboards');
|
||||||
}
|
}
|
||||||
|
} else if (this.config.componentsData.dashboardScope === 'edge') {
|
||||||
|
this.edgeService.getEdge(this.edgeId).pipe(map(edge =>
|
||||||
|
this.config.tableTitle = edge.name + ': ' + this.translate.instant('dashboard.dashboards'))).subscribe();
|
||||||
} else {
|
} else {
|
||||||
this.config.tableTitle = this.translate.instant('dashboard.dashboards');
|
this.config.tableTitle = this.translate.instant('dashboard.dashboards');
|
||||||
}
|
}
|
||||||
@ -165,6 +176,9 @@ export class DashboardsTableConfigResolver implements Resolve<EntityTableConfig<
|
|||||||
this.config.entitiesFetchFunction = pageLink =>
|
this.config.entitiesFetchFunction = pageLink =>
|
||||||
this.dashboardService.getTenantDashboards(pageLink);
|
this.dashboardService.getTenantDashboards(pageLink);
|
||||||
this.config.deleteEntity = id => this.dashboardService.deleteDashboard(id.id);
|
this.config.deleteEntity = id => this.dashboardService.deleteDashboard(id.id);
|
||||||
|
} else if (dashboardScope === 'edge') {
|
||||||
|
this.config.entitiesFetchFunction = pageLink =>
|
||||||
|
this.dashboardService.getEdgeDashboards(this.edgeId, pageLink, this.config.componentsData.dashboardsType);
|
||||||
} else {
|
} else {
|
||||||
this.config.entitiesFetchFunction = pageLink =>
|
this.config.entitiesFetchFunction = pageLink =>
|
||||||
this.dashboardService.getCustomerDashboards(this.config.componentsData.customerId, pageLink);
|
this.dashboardService.getCustomerDashboards(this.config.componentsData.customerId, pageLink);
|
||||||
@ -233,6 +247,16 @@ export class DashboardsTableConfigResolver implements Resolve<EntityTableConfig<
|
|||||||
}
|
}
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
if (dashboardScope === 'edge') {
|
||||||
|
actions.push(
|
||||||
|
{
|
||||||
|
name: this.translate.instant('edge.unassign-from-edge'),
|
||||||
|
icon: 'portable_wifi_off',
|
||||||
|
isEnabled: (entity) => true,
|
||||||
|
onAction: ($event, entity) => this.unassignFromEdge($event, entity)
|
||||||
|
}
|
||||||
|
);
|
||||||
|
}
|
||||||
return actions;
|
return actions;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -267,6 +291,16 @@ export class DashboardsTableConfigResolver implements Resolve<EntityTableConfig<
|
|||||||
}
|
}
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
if (dashboardScope === 'edge') {
|
||||||
|
actions.push(
|
||||||
|
{
|
||||||
|
name: this.translate.instant('dashboard.unassign-dashboards-from-edge'),
|
||||||
|
icon: 'portable_wifi_off',
|
||||||
|
isEnabled: true,
|
||||||
|
onAction: ($event, entities) => this.unassignDashboardsFromEdge($event, entities)
|
||||||
|
}
|
||||||
|
);
|
||||||
|
}
|
||||||
return actions;
|
return actions;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -298,6 +332,16 @@ export class DashboardsTableConfigResolver implements Resolve<EntityTableConfig<
|
|||||||
}
|
}
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
if (dashboardScope === 'edge') {
|
||||||
|
actions.push(
|
||||||
|
{
|
||||||
|
name: this.translate.instant('dashboard.assign-new-dashboard'),
|
||||||
|
icon: 'add',
|
||||||
|
isEnabled: () => true,
|
||||||
|
onAction: ($event) => this.addDashboardsToEdge($event)
|
||||||
|
}
|
||||||
|
);
|
||||||
|
}
|
||||||
return actions;
|
return actions;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -503,4 +547,74 @@ export class DashboardsTableConfigResolver implements Resolve<EntityTableConfig<
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
addDashboardsToEdge($event: Event) {
|
||||||
|
if ($event) {
|
||||||
|
$event.stopPropagation();
|
||||||
|
}
|
||||||
|
this.dialog.open<AddEntitiesToEdgeDialogComponent, AddEntitiesToEdgeDialogData,
|
||||||
|
boolean>(AddEntitiesToEdgeDialogComponent, {
|
||||||
|
disableClose: true,
|
||||||
|
panelClass: ['tb-dialog', 'tb-fullscreen-dialog'],
|
||||||
|
data: {
|
||||||
|
edgeId: this.edgeId,
|
||||||
|
entityType: EntityType.DASHBOARD
|
||||||
|
}
|
||||||
|
}).afterClosed()
|
||||||
|
.subscribe((res) => {
|
||||||
|
if (res) {
|
||||||
|
this.config.table.updateData();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
unassignFromEdge($event: Event, dashboard: DashboardInfo) {
|
||||||
|
if ($event) {
|
||||||
|
$event.stopPropagation();
|
||||||
|
}
|
||||||
|
this.dialogService.confirm(
|
||||||
|
this.translate.instant('dashboard.unassign-dashboard-from-edge-title', {dashboardName: dashboard.name}),
|
||||||
|
this.translate.instant('dashboard.unassign-dashboard-from-edge-text'),
|
||||||
|
this.translate.instant('action.no'),
|
||||||
|
this.translate.instant('action.yes'),
|
||||||
|
true
|
||||||
|
).subscribe((res) => {
|
||||||
|
if (res) {
|
||||||
|
this.dashboardService.unassignDashboardFromEdge(this.edgeId, dashboard.id.id).subscribe(
|
||||||
|
() => {
|
||||||
|
this.config.table.updateData();
|
||||||
|
}
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
unassignDashboardsFromEdge($event: Event, dashboards: Array<DashboardInfo>) {
|
||||||
|
if ($event) {
|
||||||
|
$event.stopPropagation();
|
||||||
|
}
|
||||||
|
this.dialogService.confirm(
|
||||||
|
this.translate.instant('dashboard.unassign-dashboards-from-edge-title', {count: dashboards.length}),
|
||||||
|
this.translate.instant('dashboard.unassign-dashboards-from-edge-text'),
|
||||||
|
this.translate.instant('action.no'),
|
||||||
|
this.translate.instant('action.yes'),
|
||||||
|
true
|
||||||
|
).subscribe((res) => {
|
||||||
|
if (res) {
|
||||||
|
const tasks: Observable<any>[] = [];
|
||||||
|
dashboards.forEach(
|
||||||
|
(dashboard) => {
|
||||||
|
tasks.push(this.dashboardService.unassignDashboardFromEdge(this.edgeId, dashboard.id.id));
|
||||||
|
}
|
||||||
|
);
|
||||||
|
forkJoin(tasks).subscribe(
|
||||||
|
() => {
|
||||||
|
this.config.table.updateData();
|
||||||
|
}
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -468,6 +468,8 @@
|
|||||||
"add": "Add Dashboard",
|
"add": "Add Dashboard",
|
||||||
"assign-dashboard-to-customer": "Assign Dashboard(s) To Customer",
|
"assign-dashboard-to-customer": "Assign Dashboard(s) To Customer",
|
||||||
"assign-dashboard-to-customer-text": "Please select the dashboards to assign to the customer",
|
"assign-dashboard-to-customer-text": "Please select the dashboards to assign to the customer",
|
||||||
|
"assign-dashboard-to-edge-title": "Assign Dashboard(s) To Edge",
|
||||||
|
"assign-dashboard-to-edge-text": "Please select the dashboards to assign to the edge",
|
||||||
"assign-to-customer-text": "Please select the customer to assign the dashboard(s)",
|
"assign-to-customer-text": "Please select the customer to assign the dashboard(s)",
|
||||||
"assign-to-customer": "Assign to customer",
|
"assign-to-customer": "Assign to customer",
|
||||||
"unassign-from-customer": "Unassign from customer",
|
"unassign-from-customer": "Unassign from customer",
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user