Merge pull request #4906 from deaflynx/edge/cleanups-fixes
WIP [3.3.0] Fixed Edge RBAC, widget bundles, UI
This commit is contained in:
commit
fae3a9d9a5
@ -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));
|
||||
|
||||
|
||||
@ -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));
|
||||
|
||||
|
||||
@ -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));
|
||||
|
||||
|
||||
@ -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<Edge> 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);
|
||||
}
|
||||
}
|
||||
|
||||
@ -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,
|
||||
|
||||
@ -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));
|
||||
|
||||
|
||||
@ -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
|
||||
|
||||
}
|
||||
|
||||
@ -40,12 +40,6 @@
|
||||
</fieldset>
|
||||
</div>
|
||||
<div mat-dialog-actions fxLayoutAlign="end center">
|
||||
<button mat-raised-button color="primary"
|
||||
type="submit"
|
||||
[disabled]="(isLoading$ | async) || addEntitiesToEdgeFormGroup.invalid
|
||||
|| !addEntitiesToEdgeFormGroup.dirty">
|
||||
{{ 'action.assign' | translate }}
|
||||
</button>
|
||||
<button mat-button color="primary"
|
||||
style="margin-right: 20px;"
|
||||
type="button"
|
||||
@ -53,5 +47,11 @@
|
||||
(click)="cancel()">
|
||||
{{ 'action.cancel' | translate }}
|
||||
</button>
|
||||
<button mat-raised-button color="primary"
|
||||
type="submit"
|
||||
[disabled]="(isLoading$ | async) || addEntitiesToEdgeFormGroup.invalid
|
||||
|| !addEntitiesToEdgeFormGroup.dirty">
|
||||
{{ 'action.assign' | translate }}
|
||||
</button>
|
||||
</div>
|
||||
</form>
|
||||
|
||||
@ -69,7 +69,7 @@ export class AddEntitiesToEdgeDialogComponent extends
|
||||
public dialogRef: MatDialogRef<AddEntitiesToEdgeDialogComponent, boolean>,
|
||||
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<any>[] = [];
|
||||
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<any> {
|
||||
switch (this.data.entityType) {
|
||||
private getAssignToEdgeTask(edgeId: string, entityId: string, entityType: EntityType): Observable<any> {
|
||||
switch (entityType) {
|
||||
case EntityType.DEVICE:
|
||||
return this.deviceService.assignDeviceToEdge(edgeId, entityId);
|
||||
case EntityType.ASSET:
|
||||
|
||||
@ -121,14 +121,7 @@ export class WidgetsBundlesTableConfigResolver implements Resolve<EntityTableCon
|
||||
this.config.entitySelectionEnabled = (widgetsBundle) => 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;
|
||||
}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user