|
|
|
@ -56,6 +56,11 @@ import { EntityViewComponent } from '@modules/home/pages/entity-view/entity-view |
|
|
|
import { EntityViewTableHeaderComponent } from '@modules/home/pages/entity-view/entity-view-table-header.component'; |
|
|
|
import { EntityViewId } from '@shared/models/id/entity-view-id'; |
|
|
|
import { EntityViewTabsComponent } from '@home/pages/entity-view/entity-view-tabs.component'; |
|
|
|
import { EdgeService } from "@core/http/edge.service"; |
|
|
|
import { |
|
|
|
AddEntitiesToEdgeDialogComponent, |
|
|
|
AddEntitiesToEdgeDialogData |
|
|
|
} from "@home/dialogs/add-entities-to-edge-dialog.component"; |
|
|
|
|
|
|
|
@Injectable() |
|
|
|
export class EntityViewsTableConfigResolver implements Resolve<EntityTableConfig<EntityViewInfo>> { |
|
|
|
@ -63,11 +68,13 @@ export class EntityViewsTableConfigResolver implements Resolve<EntityTableConfig |
|
|
|
private readonly config: EntityTableConfig<EntityViewInfo> = new EntityTableConfig<EntityViewInfo>(); |
|
|
|
|
|
|
|
private customerId: string; |
|
|
|
private edgeId: string; |
|
|
|
|
|
|
|
constructor(private store: Store<AppState>, |
|
|
|
private broadcast: BroadcastService, |
|
|
|
private entityViewService: EntityViewService, |
|
|
|
private customerService: CustomerService, |
|
|
|
private edgeService: EdgeService, |
|
|
|
private dialogService: DialogService, |
|
|
|
private translate: TranslateService, |
|
|
|
private datePipe: DatePipe, |
|
|
|
@ -111,6 +118,7 @@ export class EntityViewsTableConfigResolver implements Resolve<EntityTableConfig |
|
|
|
entityViewType: '' |
|
|
|
}; |
|
|
|
this.customerId = routeParams.customerId; |
|
|
|
this.edgeId = routeParams.edgeId; |
|
|
|
return this.store.pipe(select(selectAuthUser), take(1)).pipe( |
|
|
|
tap((authUser) => { |
|
|
|
if (authUser.authority === Authority.CUSTOMER_USER) { |
|
|
|
@ -128,7 +136,11 @@ export class EntityViewsTableConfigResolver implements Resolve<EntityTableConfig |
|
|
|
} else { |
|
|
|
this.config.tableTitle = parentCustomer.title + ': ' + this.translate.instant('entity-view.entity-views'); |
|
|
|
} |
|
|
|
} else { |
|
|
|
} else if (this.config.componentsData.entityViewScope === 'edge') { |
|
|
|
this.edgeService.getEdge(this.edgeId).pipe(map(edge => |
|
|
|
this.config.tableTitle = edge.name + ': ' + this.translate.instant('entity-view.entity-views'))).subscribe(); |
|
|
|
} |
|
|
|
else { |
|
|
|
this.config.tableTitle = this.translate.instant('entity-view.entity-views'); |
|
|
|
} |
|
|
|
this.config.columns = this.configureColumns(this.config.componentsData.entityViewScope); |
|
|
|
@ -167,6 +179,9 @@ export class EntityViewsTableConfigResolver implements Resolve<EntityTableConfig |
|
|
|
this.config.entitiesFetchFunction = pageLink => |
|
|
|
this.entityViewService.getTenantEntityViewInfos(pageLink, this.config.componentsData.entityViewType); |
|
|
|
this.config.deleteEntity = id => this.entityViewService.deleteEntityView(id.id); |
|
|
|
} else if (entityViewScope === 'edge') { |
|
|
|
this.config.entitiesFetchFunction = pageLink => |
|
|
|
this.entityViewService.getEdgeEntityViews(this.edgeId, pageLink, this.config.componentsData.entityViewType); |
|
|
|
} else { |
|
|
|
this.config.entitiesFetchFunction = pageLink => |
|
|
|
this.entityViewService.getCustomerEntityViewInfos(this.customerId, pageLink, this.config.componentsData.entityViewType); |
|
|
|
@ -220,6 +235,16 @@ export class EntityViewsTableConfigResolver implements Resolve<EntityTableConfig |
|
|
|
} |
|
|
|
); |
|
|
|
} |
|
|
|
if (entityViewScope === '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; |
|
|
|
} |
|
|
|
|
|
|
|
@ -245,6 +270,16 @@ export class EntityViewsTableConfigResolver implements Resolve<EntityTableConfig |
|
|
|
} |
|
|
|
); |
|
|
|
} |
|
|
|
if (entityViewScope === 'edge') { |
|
|
|
actions.push( |
|
|
|
{ |
|
|
|
name: this.translate.instant('entity-view.unassign-entity-views-from-edge'), |
|
|
|
icon: 'portable_wifi_off', |
|
|
|
isEnabled: true, |
|
|
|
onAction: ($event, entities) => this.unassignEntityViewsFromEdge($event, entities) |
|
|
|
} |
|
|
|
); |
|
|
|
} |
|
|
|
return actions; |
|
|
|
} |
|
|
|
|
|
|
|
@ -260,6 +295,16 @@ export class EntityViewsTableConfigResolver implements Resolve<EntityTableConfig |
|
|
|
} |
|
|
|
); |
|
|
|
} |
|
|
|
if (entityViewScope === 'edge') { |
|
|
|
actions.push( |
|
|
|
{ |
|
|
|
name: this.translate.instant('entity-view.assign-new-entity-view'), |
|
|
|
icon: 'add', |
|
|
|
isEnabled: () => true, |
|
|
|
onAction: ($event) => this.addEntityViewsToEdge($event) |
|
|
|
} |
|
|
|
); |
|
|
|
} |
|
|
|
return actions; |
|
|
|
} |
|
|
|
|
|
|
|
@ -400,4 +445,74 @@ export class EntityViewsTableConfigResolver implements Resolve<EntityTableConfig |
|
|
|
return false; |
|
|
|
} |
|
|
|
|
|
|
|
addEntityViewsToEdge($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.ENTITY_VIEW |
|
|
|
} |
|
|
|
}).afterClosed() |
|
|
|
.subscribe((res) => { |
|
|
|
if (res) { |
|
|
|
this.config.table.updateData(); |
|
|
|
} |
|
|
|
}); |
|
|
|
} |
|
|
|
|
|
|
|
unassignFromEdge($event: Event, entityView: EntityViewInfo) { |
|
|
|
if ($event) { |
|
|
|
$event.stopPropagation(); |
|
|
|
} |
|
|
|
this.dialogService.confirm( |
|
|
|
this.translate.instant('entity-view.unassign-entity-view-from-edge-title', {entityViewName: entityView.name}), |
|
|
|
this.translate.instant('entity-view.unassign-entity-view-from-edge-text'), |
|
|
|
this.translate.instant('action.no'), |
|
|
|
this.translate.instant('action.yes'), |
|
|
|
true |
|
|
|
).subscribe((res) => { |
|
|
|
if (res) { |
|
|
|
this.entityViewService.unassignEntityViewFromEdge(this.edgeId, entityView.id.id).subscribe( |
|
|
|
() => { |
|
|
|
this.config.table.updateData(); |
|
|
|
} |
|
|
|
); |
|
|
|
} |
|
|
|
} |
|
|
|
); |
|
|
|
} |
|
|
|
|
|
|
|
unassignEntityViewsFromEdge($event: Event, entityViews: Array<EntityViewInfo>) { |
|
|
|
if ($event) { |
|
|
|
$event.stopPropagation(); |
|
|
|
} |
|
|
|
this.dialogService.confirm( |
|
|
|
this.translate.instant('entity-view.unassign-entity-views-from-edge-title', {count: entityViews.length}), |
|
|
|
this.translate.instant('entity-view.unassign-entity-views-from-edge-text'), |
|
|
|
this.translate.instant('action.no'), |
|
|
|
this.translate.instant('action.yes'), |
|
|
|
true |
|
|
|
).subscribe((res) => { |
|
|
|
if (res) { |
|
|
|
const tasks: Observable<any>[] = []; |
|
|
|
entityViews.forEach( |
|
|
|
(entityView) => { |
|
|
|
tasks.push(this.entityViewService.unassignEntityViewFromEdge(this.edgeId, entityView.id.id)); |
|
|
|
} |
|
|
|
); |
|
|
|
forkJoin(tasks).subscribe( |
|
|
|
() => { |
|
|
|
this.config.table.updateData(); |
|
|
|
} |
|
|
|
); |
|
|
|
} |
|
|
|
} |
|
|
|
); |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|