Commit 21dde24c4854b4c477ee829d981d866f5a8344ce

Authored by Igor Kulikov
2 parents 4550302c fb184f34

Merge branch 'master' of github.com:thingsboard/thingsboard

@@ -434,7 +434,7 @@ public class AssetController extends BaseController { @@ -434,7 +434,7 @@ public class AssetController extends BaseController {
434 Edge edge = checkEdgeId(edgeId, Operation.READ); 434 Edge edge = checkEdgeId(edgeId, Operation.READ);
435 435
436 AssetId assetId = new AssetId(toUUID(strAssetId)); 436 AssetId assetId = new AssetId(toUUID(strAssetId));
437 - checkAssetId(assetId, Operation.ASSIGN_TO_EDGE); 437 + checkAssetId(assetId, Operation.READ);
438 438
439 Asset savedAsset = checkNotNull(assetService.assignAssetToEdge(getTenantId(), assetId, edgeId)); 439 Asset savedAsset = checkNotNull(assetService.assignAssetToEdge(getTenantId(), assetId, edgeId));
440 440
@@ -467,7 +467,7 @@ public class AssetController extends BaseController { @@ -467,7 +467,7 @@ public class AssetController extends BaseController {
467 Edge edge = checkEdgeId(edgeId, Operation.READ); 467 Edge edge = checkEdgeId(edgeId, Operation.READ);
468 468
469 AssetId assetId = new AssetId(toUUID(strAssetId)); 469 AssetId assetId = new AssetId(toUUID(strAssetId));
470 - Asset asset = checkAssetId(assetId, Operation.UNASSIGN_FROM_EDGE); 470 + Asset asset = checkAssetId(assetId, Operation.READ);
471 471
472 Asset savedAsset = checkNotNull(assetService.unassignAssetFromEdge(getTenantId(), assetId, edgeId)); 472 Asset savedAsset = checkNotNull(assetService.unassignAssetFromEdge(getTenantId(), assetId, edgeId));
473 473
@@ -657,7 +657,7 @@ public class DashboardController extends BaseController { @@ -657,7 +657,7 @@ public class DashboardController extends BaseController {
657 Edge edge = checkEdgeId(edgeId, Operation.READ); 657 Edge edge = checkEdgeId(edgeId, Operation.READ);
658 658
659 DashboardId dashboardId = new DashboardId(toUUID(strDashboardId)); 659 DashboardId dashboardId = new DashboardId(toUUID(strDashboardId));
660 - checkDashboardId(dashboardId, Operation.ASSIGN_TO_EDGE); 660 + checkDashboardId(dashboardId, Operation.READ);
661 661
662 Dashboard savedDashboard = checkNotNull(dashboardService.assignDashboardToEdge(getCurrentUser().getTenantId(), dashboardId, edgeId)); 662 Dashboard savedDashboard = checkNotNull(dashboardService.assignDashboardToEdge(getCurrentUser().getTenantId(), dashboardId, edgeId));
663 663
@@ -689,7 +689,7 @@ public class DashboardController extends BaseController { @@ -689,7 +689,7 @@ public class DashboardController extends BaseController {
689 EdgeId edgeId = new EdgeId(toUUID(strEdgeId)); 689 EdgeId edgeId = new EdgeId(toUUID(strEdgeId));
690 Edge edge = checkEdgeId(edgeId, Operation.READ); 690 Edge edge = checkEdgeId(edgeId, Operation.READ);
691 DashboardId dashboardId = new DashboardId(toUUID(strDashboardId)); 691 DashboardId dashboardId = new DashboardId(toUUID(strDashboardId));
692 - Dashboard dashboard = checkDashboardId(dashboardId, Operation.UNASSIGN_FROM_EDGE); 692 + Dashboard dashboard = checkDashboardId(dashboardId, Operation.READ);
693 693
694 Dashboard savedDashboard = checkNotNull(dashboardService.unassignDashboardFromEdge(getCurrentUser().getTenantId(), dashboardId, edgeId)); 694 Dashboard savedDashboard = checkNotNull(dashboardService.unassignDashboardFromEdge(getCurrentUser().getTenantId(), dashboardId, edgeId));
695 695
@@ -682,7 +682,7 @@ public class DeviceController extends BaseController { @@ -682,7 +682,7 @@ public class DeviceController extends BaseController {
682 Edge edge = checkEdgeId(edgeId, Operation.READ); 682 Edge edge = checkEdgeId(edgeId, Operation.READ);
683 683
684 DeviceId deviceId = new DeviceId(toUUID(strDeviceId)); 684 DeviceId deviceId = new DeviceId(toUUID(strDeviceId));
685 - checkDeviceId(deviceId, Operation.ASSIGN_TO_EDGE); 685 + checkDeviceId(deviceId, Operation.READ);
686 686
687 Device savedDevice = checkNotNull(deviceService.assignDeviceToEdge(getCurrentUser().getTenantId(), deviceId, edgeId)); 687 Device savedDevice = checkNotNull(deviceService.assignDeviceToEdge(getCurrentUser().getTenantId(), deviceId, edgeId));
688 688
@@ -716,7 +716,7 @@ public class DeviceController extends BaseController { @@ -716,7 +716,7 @@ public class DeviceController extends BaseController {
716 Edge edge = checkEdgeId(edgeId, Operation.READ); 716 Edge edge = checkEdgeId(edgeId, Operation.READ);
717 717
718 DeviceId deviceId = new DeviceId(toUUID(strDeviceId)); 718 DeviceId deviceId = new DeviceId(toUUID(strDeviceId));
719 - Device device = checkDeviceId(deviceId, Operation.UNASSIGN_FROM_EDGE); 719 + Device device = checkDeviceId(deviceId, Operation.READ);
720 720
721 Device savedDevice = checkNotNull(deviceService.unassignDeviceFromEdge(getCurrentUser().getTenantId(), deviceId, edgeId)); 721 Device savedDevice = checkNotNull(deviceService.unassignDeviceFromEdge(getCurrentUser().getTenantId(), deviceId, edgeId));
722 722
@@ -80,7 +80,7 @@ public class EdgeController extends BaseController { @@ -80,7 +80,7 @@ public class EdgeController extends BaseController {
80 EdgeId edgeId = new EdgeId(toUUID(strEdgeId)); 80 EdgeId edgeId = new EdgeId(toUUID(strEdgeId));
81 Edge edge = checkEdgeId(edgeId, Operation.READ); 81 Edge edge = checkEdgeId(edgeId, Operation.READ);
82 if (Authority.CUSTOMER_USER.equals(getCurrentUser().getAuthority())) { 82 if (Authority.CUSTOMER_USER.equals(getCurrentUser().getAuthority())) {
83 - cleanUpSensitiveData(edge); 83 + cleanUpLicenseKey(edge);
84 } 84 }
85 return edge; 85 return edge;
86 } catch (Exception e) { 86 } catch (Exception e) {
@@ -97,7 +97,7 @@ public class EdgeController extends BaseController { @@ -97,7 +97,7 @@ public class EdgeController extends BaseController {
97 EdgeId edgeId = new EdgeId(toUUID(strEdgeId)); 97 EdgeId edgeId = new EdgeId(toUUID(strEdgeId));
98 EdgeInfo edgeInfo = checkEdgeInfoId(edgeId, Operation.READ); 98 EdgeInfo edgeInfo = checkEdgeInfoId(edgeId, Operation.READ);
99 if (Authority.CUSTOMER_USER.equals(getCurrentUser().getAuthority())) { 99 if (Authority.CUSTOMER_USER.equals(getCurrentUser().getAuthority())) {
100 - cleanUpSensitiveData(edgeInfo); 100 + cleanUpLicenseKey(edgeInfo);
101 } 101 }
102 return edgeInfo; 102 return edgeInfo;
103 } catch (Exception e) { 103 } catch (Exception e) {
@@ -404,7 +404,7 @@ public class EdgeController extends BaseController { @@ -404,7 +404,7 @@ public class EdgeController extends BaseController {
404 } 404 }
405 if (Authority.CUSTOMER_USER.equals(user.getAuthority())) { 405 if (Authority.CUSTOMER_USER.equals(user.getAuthority())) {
406 for (Edge edge : result.getData()) { 406 for (Edge edge : result.getData()) {
407 - cleanUpSensitiveData(edge); 407 + cleanUpLicenseKey(edge);
408 } 408 }
409 } 409 }
410 return checkNotNull(result); 410 return checkNotNull(result);
@@ -439,7 +439,7 @@ public class EdgeController extends BaseController { @@ -439,7 +439,7 @@ public class EdgeController extends BaseController {
439 } 439 }
440 if (Authority.CUSTOMER_USER.equals(user.getAuthority())) { 440 if (Authority.CUSTOMER_USER.equals(user.getAuthority())) {
441 for (Edge edge : result.getData()) { 441 for (Edge edge : result.getData()) {
442 - cleanUpSensitiveData(edge); 442 + cleanUpLicenseKey(edge);
443 } 443 }
444 } 444 }
445 return checkNotNull(result); 445 return checkNotNull(result);
@@ -471,7 +471,7 @@ public class EdgeController extends BaseController { @@ -471,7 +471,7 @@ public class EdgeController extends BaseController {
471 List<Edge> edges = edgesFuture.get(); 471 List<Edge> edges = edgesFuture.get();
472 if (Authority.CUSTOMER_USER.equals(user.getAuthority())) { 472 if (Authority.CUSTOMER_USER.equals(user.getAuthority())) {
473 for (Edge edge : edges) { 473 for (Edge edge : edges) {
474 - cleanUpSensitiveData(edge); 474 + cleanUpLicenseKey(edge);
475 } 475 }
476 } 476 }
477 return checkNotNull(edges); 477 return checkNotNull(edges);
@@ -502,7 +502,7 @@ public class EdgeController extends BaseController { @@ -502,7 +502,7 @@ public class EdgeController extends BaseController {
502 }).collect(Collectors.toList()); 502 }).collect(Collectors.toList());
503 if (Authority.CUSTOMER_USER.equals(user.getAuthority())) { 503 if (Authority.CUSTOMER_USER.equals(user.getAuthority())) {
504 for (Edge edge : edges) { 504 for (Edge edge : edges) {
505 - cleanUpSensitiveData(edge); 505 + cleanUpLicenseKey(edge);
506 } 506 }
507 } 507 }
508 return edges; 508 return edges;
@@ -580,11 +580,7 @@ public class EdgeController extends BaseController { @@ -580,11 +580,7 @@ public class EdgeController extends BaseController {
580 } 580 }
581 } 581 }
582 582
583 - private void cleanUpSensitiveData(Edge edge) { 583 + private void cleanUpLicenseKey(Edge edge) {
584 edge.setEdgeLicenseKey(null); 584 edge.setEdgeLicenseKey(null);
585 - edge.setRoutingKey(null);  
586 - edge.setSecret(null);  
587 - edge.setCloudEndpoint(null);  
588 - edge.setRootRuleChainId(null);  
589 } 585 }
590 } 586 }
@@ -626,7 +626,7 @@ public class EntityViewController extends BaseController { @@ -626,7 +626,7 @@ public class EntityViewController extends BaseController {
626 Edge edge = checkEdgeId(edgeId, Operation.READ); 626 Edge edge = checkEdgeId(edgeId, Operation.READ);
627 627
628 EntityViewId entityViewId = new EntityViewId(toUUID(strEntityViewId)); 628 EntityViewId entityViewId = new EntityViewId(toUUID(strEntityViewId));
629 - checkEntityViewId(entityViewId, Operation.ASSIGN_TO_EDGE); 629 + checkEntityViewId(entityViewId, Operation.READ);
630 630
631 EntityView savedEntityView = checkNotNull(entityViewService.assignEntityViewToEdge(getTenantId(), entityViewId, edgeId)); 631 EntityView savedEntityView = checkNotNull(entityViewService.assignEntityViewToEdge(getTenantId(), entityViewId, edgeId));
632 logEntityAction(entityViewId, savedEntityView, 632 logEntityAction(entityViewId, savedEntityView,
@@ -656,7 +656,7 @@ public class EntityViewController extends BaseController { @@ -656,7 +656,7 @@ public class EntityViewController extends BaseController {
656 Edge edge = checkEdgeId(edgeId, Operation.READ); 656 Edge edge = checkEdgeId(edgeId, Operation.READ);
657 657
658 EntityViewId entityViewId = new EntityViewId(toUUID(strEntityViewId)); 658 EntityViewId entityViewId = new EntityViewId(toUUID(strEntityViewId));
659 - EntityView entityView = checkEntityViewId(entityViewId, Operation.UNASSIGN_FROM_EDGE); 659 + EntityView entityView = checkEntityViewId(entityViewId, Operation.READ);
660 660
661 EntityView savedEntityView = checkNotNull(entityViewService.unassignEntityViewFromEdge(getTenantId(), entityViewId, edgeId)); 661 EntityView savedEntityView = checkNotNull(entityViewService.unassignEntityViewFromEdge(getTenantId(), entityViewId, edgeId));
662 logEntityAction(entityViewId, entityView, 662 logEntityAction(entityViewId, entityView,
@@ -506,7 +506,7 @@ public class RuleChainController extends BaseController { @@ -506,7 +506,7 @@ public class RuleChainController extends BaseController {
506 Edge edge = checkEdgeId(edgeId, Operation.READ); 506 Edge edge = checkEdgeId(edgeId, Operation.READ);
507 507
508 RuleChainId ruleChainId = new RuleChainId(toUUID(strRuleChainId)); 508 RuleChainId ruleChainId = new RuleChainId(toUUID(strRuleChainId));
509 - checkRuleChain(ruleChainId, Operation.ASSIGN_TO_EDGE); 509 + checkRuleChain(ruleChainId, Operation.READ);
510 510
511 RuleChain savedRuleChain = checkNotNull(ruleChainService.assignRuleChainToEdge(getCurrentUser().getTenantId(), ruleChainId, edgeId)); 511 RuleChain savedRuleChain = checkNotNull(ruleChainService.assignRuleChainToEdge(getCurrentUser().getTenantId(), ruleChainId, edgeId));
512 512
@@ -538,7 +538,7 @@ public class RuleChainController extends BaseController { @@ -538,7 +538,7 @@ public class RuleChainController extends BaseController {
538 EdgeId edgeId = new EdgeId(toUUID(strEdgeId)); 538 EdgeId edgeId = new EdgeId(toUUID(strEdgeId));
539 Edge edge = checkEdgeId(edgeId, Operation.READ); 539 Edge edge = checkEdgeId(edgeId, Operation.READ);
540 RuleChainId ruleChainId = new RuleChainId(toUUID(strRuleChainId)); 540 RuleChainId ruleChainId = new RuleChainId(toUUID(strRuleChainId));
541 - RuleChain ruleChain = checkRuleChain(ruleChainId, Operation.UNASSIGN_FROM_EDGE); 541 + RuleChain ruleChain = checkRuleChain(ruleChainId, Operation.READ);
542 542
543 RuleChain savedRuleChain = checkNotNull(ruleChainService.unassignRuleChainFromEdge(getCurrentUser().getTenantId(), ruleChainId, edgeId, false)); 543 RuleChain savedRuleChain = checkNotNull(ruleChainService.unassignRuleChainFromEdge(getCurrentUser().getTenantId(), ruleChainId, edgeId, false));
544 544
@@ -19,6 +19,6 @@ public enum Operation { @@ -19,6 +19,6 @@ public enum Operation {
19 19
20 ALL, CREATE, READ, WRITE, DELETE, ASSIGN_TO_CUSTOMER, UNASSIGN_FROM_CUSTOMER, RPC_CALL, 20 ALL, CREATE, READ, WRITE, DELETE, ASSIGN_TO_CUSTOMER, UNASSIGN_FROM_CUSTOMER, RPC_CALL,
21 READ_CREDENTIALS, WRITE_CREDENTIALS, READ_ATTRIBUTES, WRITE_ATTRIBUTES, READ_TELEMETRY, WRITE_TELEMETRY, CLAIM_DEVICES, 21 READ_CREDENTIALS, WRITE_CREDENTIALS, READ_ATTRIBUTES, WRITE_ATTRIBUTES, READ_TELEMETRY, WRITE_TELEMETRY, CLAIM_DEVICES,
22 - ASSIGN_TO_TENANT, ASSIGN_TO_EDGE, UNASSIGN_FROM_EDGE 22 + ASSIGN_TO_TENANT
23 23
24 } 24 }
@@ -86,7 +86,6 @@ @@ -86,7 +86,6 @@
86 [matAutocompleteDisabled]="isEntityCountDatasource" 86 [matAutocompleteDisabled]="isEntityCountDatasource"
87 [matChipInputFor]="chipList" 87 [matChipInputFor]="chipList"
88 [matChipInputSeparatorKeyCodes]="separatorKeysCodes" 88 [matChipInputSeparatorKeyCodes]="separatorKeysCodes"
89 - matChipInputAddOnBlur  
90 (matChipInputTokenEnd)="add($event)"> 89 (matChipInputTokenEnd)="add($event)">
91 </mat-chip-list> 90 </mat-chip-list>
92 <mat-autocomplete #keyAutocomplete="matAutocomplete" 91 <mat-autocomplete #keyAutocomplete="matAutocomplete"
@@ -40,12 +40,6 @@ @@ -40,12 +40,6 @@
40 </fieldset> 40 </fieldset>
41 </div> 41 </div>
42 <div mat-dialog-actions fxLayoutAlign="end center"> 42 <div mat-dialog-actions fxLayoutAlign="end center">
43 - <button mat-raised-button color="primary"  
44 - type="submit"  
45 - [disabled]="(isLoading$ | async) || addEntitiesToEdgeFormGroup.invalid  
46 - || !addEntitiesToEdgeFormGroup.dirty">  
47 - {{ 'action.assign' | translate }}  
48 - </button>  
49 <button mat-button color="primary" 43 <button mat-button color="primary"
50 style="margin-right: 20px;" 44 style="margin-right: 20px;"
51 type="button" 45 type="button"
@@ -53,5 +47,11 @@ @@ -53,5 +47,11 @@
53 (click)="cancel()"> 47 (click)="cancel()">
54 {{ 'action.cancel' | translate }} 48 {{ 'action.cancel' | translate }}
55 </button> 49 </button>
  50 + <button mat-raised-button color="primary"
  51 + type="submit"
  52 + [disabled]="(isLoading$ | async) || addEntitiesToEdgeFormGroup.invalid
  53 + || !addEntitiesToEdgeFormGroup.dirty">
  54 + {{ 'action.assign' | translate }}
  55 + </button>
56 </div> 56 </div>
57 </form> 57 </form>
@@ -69,7 +69,7 @@ export class AddEntitiesToEdgeDialogComponent extends @@ -69,7 +69,7 @@ export class AddEntitiesToEdgeDialogComponent extends
69 public dialogRef: MatDialogRef<AddEntitiesToEdgeDialogComponent, boolean>, 69 public dialogRef: MatDialogRef<AddEntitiesToEdgeDialogComponent, boolean>,
70 public fb: FormBuilder) { 70 public fb: FormBuilder) {
71 super(store, router, dialogRef); 71 super(store, router, dialogRef);
72 - this.entityType = data.entityType; 72 + this.entityType = this.data.entityType;
73 } 73 }
74 74
75 ngOnInit(): void { 75 ngOnInit(): void {
@@ -77,7 +77,7 @@ export class AddEntitiesToEdgeDialogComponent extends @@ -77,7 +77,7 @@ export class AddEntitiesToEdgeDialogComponent extends
77 entityIds: [null, [Validators.required]] 77 entityIds: [null, [Validators.required]]
78 }); 78 });
79 this.subType = ''; 79 this.subType = '';
80 - switch (this.data.entityType) { 80 + switch (this.entityType) {
81 case EntityType.DEVICE: 81 case EntityType.DEVICE:
82 this.assignToEdgeTitle = 'device.assign-device-to-edge-title'; 82 this.assignToEdgeTitle = 'device.assign-device-to-edge-title';
83 this.assignToEdgeText = 'device.assign-device-to-edge-text'; 83 this.assignToEdgeText = 'device.assign-device-to-edge-text';
@@ -118,7 +118,7 @@ export class AddEntitiesToEdgeDialogComponent extends @@ -118,7 +118,7 @@ export class AddEntitiesToEdgeDialogComponent extends
118 const tasks: Observable<any>[] = []; 118 const tasks: Observable<any>[] = [];
119 entityIds.forEach( 119 entityIds.forEach(
120 (entityId) => { 120 (entityId) => {
121 - tasks.push(this.getAssignToEdgeTask(this.data.edgeId, entityId)); 121 + tasks.push(this.getAssignToEdgeTask(this.data.edgeId, entityId, this.entityType));
122 } 122 }
123 ); 123 );
124 forkJoin(tasks).subscribe( 124 forkJoin(tasks).subscribe(
@@ -128,8 +128,8 @@ export class AddEntitiesToEdgeDialogComponent extends @@ -128,8 +128,8 @@ export class AddEntitiesToEdgeDialogComponent extends
128 ); 128 );
129 } 129 }
130 130
131 - private getAssignToEdgeTask(edgeId: string, entityId: string): Observable<any> {  
132 - switch (this.data.entityType) { 131 + private getAssignToEdgeTask(edgeId: string, entityId: string, entityType: EntityType): Observable<any> {
  132 + switch (entityType) {
133 case EntityType.DEVICE: 133 case EntityType.DEVICE:
134 return this.deviceService.assignDeviceToEdge(edgeId, entityId); 134 return this.deviceService.assignDeviceToEdge(edgeId, entityId);
135 case EntityType.ASSET: 135 case EntityType.ASSET:
@@ -121,14 +121,7 @@ export class WidgetsBundlesTableConfigResolver implements Resolve<EntityTableCon @@ -121,14 +121,7 @@ export class WidgetsBundlesTableConfigResolver implements Resolve<EntityTableCon
121 this.config.entitySelectionEnabled = (widgetsBundle) => this.isWidgetsBundleEditable(widgetsBundle, authUser.authority); 121 this.config.entitySelectionEnabled = (widgetsBundle) => this.isWidgetsBundleEditable(widgetsBundle, authUser.authority);
122 this.config.detailsReadonly = (widgetsBundle) => !this.isWidgetsBundleEditable(widgetsBundle, authUser.authority); 122 this.config.detailsReadonly = (widgetsBundle) => !this.isWidgetsBundleEditable(widgetsBundle, authUser.authority);
123 const authState = getCurrentAuthState(this.store); 123 const authState = getCurrentAuthState(this.store);
124 - this.config.entitiesFetchFunction = pageLink => this.widgetsService.getWidgetBundles(pageLink).pipe(  
125 - map((widgetBundles) => {  
126 - if (!authState.edgesSupportEnabled) {  
127 - widgetBundles.data = widgetBundles.data.filter(widgetBundle => widgetBundle.alias !== 'edge_widgets');  
128 - }  
129 - return widgetBundles;  
130 - })  
131 - ); 124 + this.config.entitiesFetchFunction = pageLink => this.widgetsService.getWidgetBundles(pageLink);
132 return this.config; 125 return this.config;
133 } 126 }
134 127