diff --git a/application/src/main/java/org/thingsboard/server/controller/AssetController.java b/application/src/main/java/org/thingsboard/server/controller/AssetController.java index 19280716b3..4854c96941 100644 --- a/application/src/main/java/org/thingsboard/server/controller/AssetController.java +++ b/application/src/main/java/org/thingsboard/server/controller/AssetController.java @@ -434,7 +434,7 @@ public class AssetController extends BaseController { Edge edge = checkEdgeId(edgeId, Operation.READ); AssetId assetId = new AssetId(toUUID(strAssetId)); - checkAssetId(assetId, Operation.ASSIGN_TO_EDGE); + checkAssetId(assetId, Operation.READ); Asset savedAsset = checkNotNull(assetService.assignAssetToEdge(getTenantId(), assetId, edgeId)); @@ -467,7 +467,7 @@ public class AssetController extends BaseController { Edge edge = checkEdgeId(edgeId, Operation.READ); AssetId assetId = new AssetId(toUUID(strAssetId)); - Asset asset = checkAssetId(assetId, Operation.UNASSIGN_FROM_EDGE); + Asset asset = checkAssetId(assetId, Operation.READ); Asset savedAsset = checkNotNull(assetService.unassignAssetFromEdge(getTenantId(), assetId, edgeId)); diff --git a/application/src/main/java/org/thingsboard/server/controller/DashboardController.java b/application/src/main/java/org/thingsboard/server/controller/DashboardController.java index 570f925c45..cb4f546556 100644 --- a/application/src/main/java/org/thingsboard/server/controller/DashboardController.java +++ b/application/src/main/java/org/thingsboard/server/controller/DashboardController.java @@ -657,7 +657,7 @@ public class DashboardController extends BaseController { Edge edge = checkEdgeId(edgeId, Operation.READ); DashboardId dashboardId = new DashboardId(toUUID(strDashboardId)); - checkDashboardId(dashboardId, Operation.ASSIGN_TO_EDGE); + checkDashboardId(dashboardId, Operation.READ); Dashboard savedDashboard = checkNotNull(dashboardService.assignDashboardToEdge(getCurrentUser().getTenantId(), dashboardId, edgeId)); @@ -689,7 +689,7 @@ public class DashboardController extends BaseController { EdgeId edgeId = new EdgeId(toUUID(strEdgeId)); Edge edge = checkEdgeId(edgeId, Operation.READ); DashboardId dashboardId = new DashboardId(toUUID(strDashboardId)); - Dashboard dashboard = checkDashboardId(dashboardId, Operation.UNASSIGN_FROM_EDGE); + Dashboard dashboard = checkDashboardId(dashboardId, Operation.READ); Dashboard savedDashboard = checkNotNull(dashboardService.unassignDashboardFromEdge(getCurrentUser().getTenantId(), dashboardId, edgeId)); diff --git a/application/src/main/java/org/thingsboard/server/controller/DeviceController.java b/application/src/main/java/org/thingsboard/server/controller/DeviceController.java index 5c7df50d09..c261d50f23 100644 --- a/application/src/main/java/org/thingsboard/server/controller/DeviceController.java +++ b/application/src/main/java/org/thingsboard/server/controller/DeviceController.java @@ -682,7 +682,7 @@ public class DeviceController extends BaseController { Edge edge = checkEdgeId(edgeId, Operation.READ); DeviceId deviceId = new DeviceId(toUUID(strDeviceId)); - checkDeviceId(deviceId, Operation.ASSIGN_TO_EDGE); + checkDeviceId(deviceId, Operation.READ); Device savedDevice = checkNotNull(deviceService.assignDeviceToEdge(getCurrentUser().getTenantId(), deviceId, edgeId)); @@ -716,7 +716,7 @@ public class DeviceController extends BaseController { Edge edge = checkEdgeId(edgeId, Operation.READ); DeviceId deviceId = new DeviceId(toUUID(strDeviceId)); - Device device = checkDeviceId(deviceId, Operation.UNASSIGN_FROM_EDGE); + Device device = checkDeviceId(deviceId, Operation.READ); Device savedDevice = checkNotNull(deviceService.unassignDeviceFromEdge(getCurrentUser().getTenantId(), deviceId, edgeId)); diff --git a/application/src/main/java/org/thingsboard/server/controller/EdgeController.java b/application/src/main/java/org/thingsboard/server/controller/EdgeController.java index 501febaead..426c899588 100644 --- a/application/src/main/java/org/thingsboard/server/controller/EdgeController.java +++ b/application/src/main/java/org/thingsboard/server/controller/EdgeController.java @@ -80,7 +80,7 @@ public class EdgeController extends BaseController { EdgeId edgeId = new EdgeId(toUUID(strEdgeId)); Edge edge = checkEdgeId(edgeId, Operation.READ); if (Authority.CUSTOMER_USER.equals(getCurrentUser().getAuthority())) { - cleanUpSensitiveData(edge); + cleanUpLicenseKey(edge); } return edge; } catch (Exception e) { @@ -97,7 +97,7 @@ public class EdgeController extends BaseController { EdgeId edgeId = new EdgeId(toUUID(strEdgeId)); EdgeInfo edgeInfo = checkEdgeInfoId(edgeId, Operation.READ); if (Authority.CUSTOMER_USER.equals(getCurrentUser().getAuthority())) { - cleanUpSensitiveData(edgeInfo); + cleanUpLicenseKey(edgeInfo); } return edgeInfo; } catch (Exception e) { @@ -404,7 +404,7 @@ public class EdgeController extends BaseController { } if (Authority.CUSTOMER_USER.equals(user.getAuthority())) { for (Edge edge : result.getData()) { - cleanUpSensitiveData(edge); + cleanUpLicenseKey(edge); } } return checkNotNull(result); @@ -439,7 +439,7 @@ public class EdgeController extends BaseController { } if (Authority.CUSTOMER_USER.equals(user.getAuthority())) { for (Edge edge : result.getData()) { - cleanUpSensitiveData(edge); + cleanUpLicenseKey(edge); } } return checkNotNull(result); @@ -471,7 +471,7 @@ public class EdgeController extends BaseController { List edges = edgesFuture.get(); if (Authority.CUSTOMER_USER.equals(user.getAuthority())) { for (Edge edge : edges) { - cleanUpSensitiveData(edge); + cleanUpLicenseKey(edge); } } return checkNotNull(edges); @@ -502,7 +502,7 @@ public class EdgeController extends BaseController { }).collect(Collectors.toList()); if (Authority.CUSTOMER_USER.equals(user.getAuthority())) { for (Edge edge : edges) { - cleanUpSensitiveData(edge); + cleanUpLicenseKey(edge); } } return edges; @@ -580,11 +580,7 @@ public class EdgeController extends BaseController { } } - private void cleanUpSensitiveData(Edge edge) { + private void cleanUpLicenseKey(Edge edge) { edge.setEdgeLicenseKey(null); - edge.setRoutingKey(null); - edge.setSecret(null); - edge.setCloudEndpoint(null); - edge.setRootRuleChainId(null); } } diff --git a/application/src/main/java/org/thingsboard/server/controller/EntityViewController.java b/application/src/main/java/org/thingsboard/server/controller/EntityViewController.java index 5e9103a66a..63c151b24c 100644 --- a/application/src/main/java/org/thingsboard/server/controller/EntityViewController.java +++ b/application/src/main/java/org/thingsboard/server/controller/EntityViewController.java @@ -626,7 +626,7 @@ public class EntityViewController extends BaseController { Edge edge = checkEdgeId(edgeId, Operation.READ); EntityViewId entityViewId = new EntityViewId(toUUID(strEntityViewId)); - checkEntityViewId(entityViewId, Operation.ASSIGN_TO_EDGE); + checkEntityViewId(entityViewId, Operation.READ); EntityView savedEntityView = checkNotNull(entityViewService.assignEntityViewToEdge(getTenantId(), entityViewId, edgeId)); logEntityAction(entityViewId, savedEntityView, @@ -656,7 +656,7 @@ public class EntityViewController extends BaseController { Edge edge = checkEdgeId(edgeId, Operation.READ); EntityViewId entityViewId = new EntityViewId(toUUID(strEntityViewId)); - EntityView entityView = checkEntityViewId(entityViewId, Operation.UNASSIGN_FROM_EDGE); + EntityView entityView = checkEntityViewId(entityViewId, Operation.READ); EntityView savedEntityView = checkNotNull(entityViewService.unassignEntityViewFromEdge(getTenantId(), entityViewId, edgeId)); logEntityAction(entityViewId, entityView, diff --git a/application/src/main/java/org/thingsboard/server/controller/RuleChainController.java b/application/src/main/java/org/thingsboard/server/controller/RuleChainController.java index 3786caaa33..7b6821d63d 100644 --- a/application/src/main/java/org/thingsboard/server/controller/RuleChainController.java +++ b/application/src/main/java/org/thingsboard/server/controller/RuleChainController.java @@ -506,7 +506,7 @@ public class RuleChainController extends BaseController { Edge edge = checkEdgeId(edgeId, Operation.READ); RuleChainId ruleChainId = new RuleChainId(toUUID(strRuleChainId)); - checkRuleChain(ruleChainId, Operation.ASSIGN_TO_EDGE); + checkRuleChain(ruleChainId, Operation.READ); RuleChain savedRuleChain = checkNotNull(ruleChainService.assignRuleChainToEdge(getCurrentUser().getTenantId(), ruleChainId, edgeId)); @@ -538,7 +538,7 @@ public class RuleChainController extends BaseController { EdgeId edgeId = new EdgeId(toUUID(strEdgeId)); Edge edge = checkEdgeId(edgeId, Operation.READ); RuleChainId ruleChainId = new RuleChainId(toUUID(strRuleChainId)); - RuleChain ruleChain = checkRuleChain(ruleChainId, Operation.UNASSIGN_FROM_EDGE); + RuleChain ruleChain = checkRuleChain(ruleChainId, Operation.READ); RuleChain savedRuleChain = checkNotNull(ruleChainService.unassignRuleChainFromEdge(getCurrentUser().getTenantId(), ruleChainId, edgeId, false)); diff --git a/application/src/main/java/org/thingsboard/server/service/security/permission/Operation.java b/application/src/main/java/org/thingsboard/server/service/security/permission/Operation.java index 074943f1a6..1194c8a745 100644 --- a/application/src/main/java/org/thingsboard/server/service/security/permission/Operation.java +++ b/application/src/main/java/org/thingsboard/server/service/security/permission/Operation.java @@ -19,6 +19,6 @@ public enum Operation { ALL, CREATE, READ, WRITE, DELETE, ASSIGN_TO_CUSTOMER, UNASSIGN_FROM_CUSTOMER, RPC_CALL, READ_CREDENTIALS, WRITE_CREDENTIALS, READ_ATTRIBUTES, WRITE_ATTRIBUTES, READ_TELEMETRY, WRITE_TELEMETRY, CLAIM_DEVICES, - ASSIGN_TO_TENANT, ASSIGN_TO_EDGE, UNASSIGN_FROM_EDGE + ASSIGN_TO_TENANT } diff --git a/ui-ngx/src/app/modules/home/dialogs/add-entities-to-edge-dialog.component.html b/ui-ngx/src/app/modules/home/dialogs/add-entities-to-edge-dialog.component.html index 82f166d71a..64aba5a711 100644 --- a/ui-ngx/src/app/modules/home/dialogs/add-entities-to-edge-dialog.component.html +++ b/ui-ngx/src/app/modules/home/dialogs/add-entities-to-edge-dialog.component.html @@ -40,12 +40,6 @@
- +
diff --git a/ui-ngx/src/app/modules/home/dialogs/add-entities-to-edge-dialog.component.ts b/ui-ngx/src/app/modules/home/dialogs/add-entities-to-edge-dialog.component.ts index 1cd9ba87ba..ec4418403a 100644 --- a/ui-ngx/src/app/modules/home/dialogs/add-entities-to-edge-dialog.component.ts +++ b/ui-ngx/src/app/modules/home/dialogs/add-entities-to-edge-dialog.component.ts @@ -69,7 +69,7 @@ export class AddEntitiesToEdgeDialogComponent extends public dialogRef: MatDialogRef, public fb: FormBuilder) { super(store, router, dialogRef); - this.entityType = data.entityType; + this.entityType = this.data.entityType; } ngOnInit(): void { @@ -77,7 +77,7 @@ export class AddEntitiesToEdgeDialogComponent extends entityIds: [null, [Validators.required]] }); this.subType = ''; - switch (this.data.entityType) { + switch (this.entityType) { case EntityType.DEVICE: this.assignToEdgeTitle = 'device.assign-device-to-edge-title'; this.assignToEdgeText = 'device.assign-device-to-edge-text'; @@ -118,7 +118,7 @@ export class AddEntitiesToEdgeDialogComponent extends const tasks: Observable[] = []; entityIds.forEach( (entityId) => { - tasks.push(this.getAssignToEdgeTask(this.data.edgeId, entityId)); + tasks.push(this.getAssignToEdgeTask(this.data.edgeId, entityId, this.entityType)); } ); forkJoin(tasks).subscribe( @@ -128,8 +128,8 @@ export class AddEntitiesToEdgeDialogComponent extends ); } - private getAssignToEdgeTask(edgeId: string, entityId: string): Observable { - switch (this.data.entityType) { + private getAssignToEdgeTask(edgeId: string, entityId: string, entityType: EntityType): Observable { + switch (entityType) { case EntityType.DEVICE: return this.deviceService.assignDeviceToEdge(edgeId, entityId); case EntityType.ASSET: diff --git a/ui-ngx/src/app/modules/home/pages/widget/widgets-bundles-table-config.resolver.ts b/ui-ngx/src/app/modules/home/pages/widget/widgets-bundles-table-config.resolver.ts index 735b56a783..5a50e4272f 100644 --- a/ui-ngx/src/app/modules/home/pages/widget/widgets-bundles-table-config.resolver.ts +++ b/ui-ngx/src/app/modules/home/pages/widget/widgets-bundles-table-config.resolver.ts @@ -121,14 +121,7 @@ export class WidgetsBundlesTableConfigResolver implements Resolve this.isWidgetsBundleEditable(widgetsBundle, authUser.authority); this.config.detailsReadonly = (widgetsBundle) => !this.isWidgetsBundleEditable(widgetsBundle, authUser.authority); const authState = getCurrentAuthState(this.store); - this.config.entitiesFetchFunction = pageLink => this.widgetsService.getWidgetBundles(pageLink).pipe( - map((widgetBundles) => { - if (!authState.edgesSupportEnabled) { - widgetBundles.data = widgetBundles.data.filter(widgetBundle => widgetBundle.alias !== 'edge_widgets'); - } - return widgetBundles; - }) - ); + this.config.entitiesFetchFunction = pageLink => this.widgetsService.getWidgetBundles(pageLink); return this.config; }