Commit 1b469df40c801a1df9c10ed159ca6ef484051e25
1 parent
ec39c15e
Fix permissions for Rules and Plugins details
Showing
7 changed files
with
49 additions
and
17 deletions
... | ... | @@ -326,7 +326,19 @@ public final class PluginProcessingContext implements PluginContext { |
326 | 326 | callback.onSuccess(this, Boolean.FALSE); |
327 | 327 | } else { |
328 | 328 | ListenableFuture<RuleMetaData> ruleFuture = pluginCtx.ruleService.findRuleByIdAsync(new RuleId(entityId.getId())); |
329 | - Futures.addCallback(ruleFuture, getCallback(callback, rule -> rule != null && rule.getTenantId().equals(ctx.getTenantId()))); | |
329 | + Futures.addCallback(ruleFuture, getCallback(callback, rule -> { | |
330 | + if (rule == null) { | |
331 | + return Boolean.FALSE; | |
332 | + } else { | |
333 | + if (ctx.isTenantAdmin() && !rule.getTenantId().equals(ctx.getTenantId())) { | |
334 | + return Boolean.FALSE; | |
335 | + } else if (ctx.isSystemAdmin() && !rule.getTenantId().isNullUid()) { | |
336 | + return Boolean.FALSE; | |
337 | + } else { | |
338 | + return Boolean.TRUE; | |
339 | + } | |
340 | + } | |
341 | + })); | |
330 | 342 | } |
331 | 343 | return; |
332 | 344 | case PLUGIN: |
... | ... | @@ -334,7 +346,19 @@ public final class PluginProcessingContext implements PluginContext { |
334 | 346 | callback.onSuccess(this, Boolean.FALSE); |
335 | 347 | } else { |
336 | 348 | ListenableFuture<PluginMetaData> pluginFuture = pluginCtx.pluginService.findPluginByIdAsync(new PluginId(entityId.getId())); |
337 | - Futures.addCallback(pluginFuture, getCallback(callback, plugin -> plugin != null && plugin.getTenantId().equals(ctx.getTenantId()))); | |
349 | + Futures.addCallback(pluginFuture, getCallback(callback, plugin -> { | |
350 | + if (plugin == null) { | |
351 | + return Boolean.FALSE; | |
352 | + } else { | |
353 | + if (ctx.isTenantAdmin() && !plugin.getTenantId().equals(ctx.getTenantId())) { | |
354 | + return Boolean.FALSE; | |
355 | + } else if (ctx.isSystemAdmin() && !plugin.getTenantId().isNullUid()) { | |
356 | + return Boolean.FALSE; | |
357 | + } else { | |
358 | + return Boolean.TRUE; | |
359 | + } | |
360 | + } | |
361 | + })); | |
338 | 362 | } |
339 | 363 | return; |
340 | 364 | case CUSTOMER: | ... | ... |
... | ... | @@ -51,7 +51,6 @@ export default function AttributeTableDirective($compile, $templateCache, $rootS |
51 | 51 | scope.types = types; |
52 | 52 | |
53 | 53 | scope.entityType = attrs.entityType; |
54 | - scope.attributeScope = getAttributeScopeByValue(attrs.defaultAttributeScope); | |
55 | 54 | |
56 | 55 | if (scope.entityType === types.entityType.device) { |
57 | 56 | scope.attributeScopes = types.attributesScope; |
... | ... | @@ -60,8 +59,13 @@ export default function AttributeTableDirective($compile, $templateCache, $rootS |
60 | 59 | scope.attributeScopes = {}; |
61 | 60 | scope.attributeScopes.server = types.attributesScope.server; |
62 | 61 | scope.attributeScopeSelectionReadonly = true; |
62 | + } | |
63 | + | |
64 | + scope.attributeScope = getAttributeScopeByValue(attrs.defaultAttributeScope); | |
65 | + | |
66 | + if (scope.entityType != types.entityType.device) { | |
63 | 67 | if (scope.attributeScope != types.latestTelemetry) { |
64 | - scope.attributeScope = scope.attributeScopes.server.value; | |
68 | + scope.attributeScope = scope.attributeScopes.server; | |
65 | 69 | } |
66 | 70 | } |
67 | 71 | |
... | ... | @@ -81,8 +85,8 @@ export default function AttributeTableDirective($compile, $templateCache, $rootS |
81 | 85 | search: null |
82 | 86 | }; |
83 | 87 | |
84 | - scope.$watch("entityId", function(newVal, prevVal) { | |
85 | - if (newVal && !angular.equals(newVal, prevVal)) { | |
88 | + scope.$watch("entityId", function(newVal) { | |
89 | + if (newVal) { | |
86 | 90 | scope.resetFilter(); |
87 | 91 | scope.getEntityAttributes(false, true); |
88 | 92 | } | ... | ... |
... | ... | @@ -171,7 +171,7 @@ export default angular.module('thingsboard.locale', []) |
171 | 171 | "attribute": { |
172 | 172 | "attributes": "Attributes", |
173 | 173 | "latest-telemetry": "Latest telemetry", |
174 | - "attributes-scope": "Device attributes scope", | |
174 | + "attributes-scope": "Entity attributes scope", | |
175 | 175 | "scope-latest-telemetry": "Latest telemetry", |
176 | 176 | "scope-client": "Client attributes", |
177 | 177 | "scope-server": "Server attributes", | ... | ... |
... | ... | @@ -138,6 +138,8 @@ export default function PluginController(pluginService, userService, importExpor |
138 | 138 | vm.pluginGridConfig.topIndex = $stateParams.topIndex; |
139 | 139 | } |
140 | 140 | |
141 | + vm.isPluginEditable = isPluginEditable; | |
142 | + | |
141 | 143 | vm.activatePlugin = activatePlugin; |
142 | 144 | vm.suspendPlugin = suspendPlugin; |
143 | 145 | vm.exportPlugin = exportPlugin; | ... | ... |
... | ... | @@ -19,7 +19,7 @@ |
19 | 19 | <details-buttons tb-help="vm.helpLinkIdForPlugin()" help-container-id="help-container"> |
20 | 20 | <div id="help-container"></div> |
21 | 21 | </details-buttons> |
22 | - <md-tabs ng-class="{'tb-headless': vm.grid.detailsConfig.isDetailsEditMode}" | |
22 | + <md-tabs ng-class="{'tb-headless': (vm.grid.detailsConfig.isDetailsEditMode || !vm.isPluginEditable(vm.grid.operatingItem()))}" | |
23 | 23 | id="tabs" md-border-bottom flex class="tb-absolute-fill"> |
24 | 24 | <md-tab label="{{ 'plugin.details' | translate }}"> |
25 | 25 | <tb-plugin plugin="vm.grid.operatingItem()" |
... | ... | @@ -31,7 +31,7 @@ |
31 | 31 | on-export-plugin="vm.exportPlugin(event, vm.grid.detailsConfig.currentItem)" |
32 | 32 | on-delete-plugin="vm.grid.deleteItem(event, vm.grid.detailsConfig.currentItem)"></tb-plugin> |
33 | 33 | </md-tab> |
34 | - <md-tab ng-if="!vm.grid.detailsConfig.isDetailsEditMode" label="{{ 'attribute.attributes' | translate }}"> | |
34 | + <md-tab ng-if="!vm.grid.detailsConfig.isDetailsEditMode && vm.isPluginEditable(vm.grid.operatingItem())" label="{{ 'attribute.attributes' | translate }}"> | |
35 | 35 | <tb-attribute-table flex |
36 | 36 | entity-id="vm.grid.operatingItem().id.id" |
37 | 37 | entity-type="{{vm.types.entityType.plugin}}" |
... | ... | @@ -39,7 +39,7 @@ |
39 | 39 | default-attribute-scope="{{vm.types.attributesScope.server.value}}"> |
40 | 40 | </tb-attribute-table> |
41 | 41 | </md-tab> |
42 | - <md-tab ng-if="!vm.grid.detailsConfig.isDetailsEditMode" label="{{ 'attribute.latest-telemetry' | translate }}"> | |
42 | + <md-tab ng-if="!vm.grid.detailsConfig.isDetailsEditMode && vm.isPluginEditable(vm.grid.operatingItem())" label="{{ 'attribute.latest-telemetry' | translate }}"> | |
43 | 43 | <tb-attribute-table flex |
44 | 44 | entity-id="vm.grid.operatingItem().id.id" |
45 | 45 | entity-type="{{vm.types.entityType.plugin}}" |
... | ... | @@ -48,7 +48,7 @@ |
48 | 48 | disable-attribute-scope-selection="true"> |
49 | 49 | </tb-attribute-table> |
50 | 50 | </md-tab> |
51 | - <md-tab ng-if="!vm.grid.detailsConfig.isDetailsEditMode" label="{{ 'plugin.events' | translate }}"> | |
51 | + <md-tab ng-if="!vm.grid.detailsConfig.isDetailsEditMode && vm.isPluginEditable(vm.grid.operatingItem())" label="{{ 'plugin.events' | translate }}"> | |
52 | 52 | <tb-event-table flex entity-type="vm.types.entityType.plugin" |
53 | 53 | entity-id="vm.grid.operatingItem().id.id" |
54 | 54 | tenant-id="vm.grid.operatingItem().tenantId.id" |
... | ... | @@ -56,7 +56,7 @@ |
56 | 56 | disabled-event-types="{{vm.types.eventType.alarm.value}}"> |
57 | 57 | </tb-event-table> |
58 | 58 | </md-tab> |
59 | - <md-tab ng-if="!vm.grid.detailsConfig.isDetailsEditMode" label="{{ 'relation.relations' | translate }}"> | |
59 | + <md-tab ng-if="!vm.grid.detailsConfig.isDetailsEditMode && vm.isPluginEditable(vm.grid.operatingItem())" label="{{ 'relation.relations' | translate }}"> | |
60 | 60 | <tb-relation-table flex |
61 | 61 | entity-id="vm.grid.operatingItem().id.id" |
62 | 62 | entity-type="{{vm.types.entityType.plugin}}"> | ... | ... |
... | ... | @@ -134,6 +134,8 @@ export default function RuleController(ruleService, userService, importExport, $ |
134 | 134 | vm.ruleGridConfig.topIndex = $stateParams.topIndex; |
135 | 135 | } |
136 | 136 | |
137 | + vm.isRuleEditable = isRuleEditable; | |
138 | + | |
137 | 139 | vm.activateRule = activateRule; |
138 | 140 | vm.suspendRule = suspendRule; |
139 | 141 | vm.exportRule = exportRule; | ... | ... |
... | ... | @@ -19,7 +19,7 @@ |
19 | 19 | <details-buttons tb-help="'rules'" help-container-id="help-container"> |
20 | 20 | <div id="help-container"></div> |
21 | 21 | </details-buttons> |
22 | - <md-tabs ng-class="{'tb-headless': vm.grid.detailsConfig.isDetailsEditMode}" | |
22 | + <md-tabs ng-class="{'tb-headless': (vm.grid.detailsConfig.isDetailsEditMode || !vm.isRuleEditable(vm.grid.operatingItem()))}" | |
23 | 23 | id="tabs" md-border-bottom flex class="tb-absolute-fill"> |
24 | 24 | <md-tab label="{{ 'rule.details' | translate }}"> |
25 | 25 | <tb-rule rule="vm.grid.operatingItem()" |
... | ... | @@ -31,7 +31,7 @@ |
31 | 31 | on-export-rule="vm.exportRule(event, vm.grid.detailsConfig.currentItem)" |
32 | 32 | on-delete-rule="vm.grid.deleteItem(event, vm.grid.detailsConfig.currentItem)"></tb-rule> |
33 | 33 | </md-tab> |
34 | - <md-tab ng-if="!vm.grid.detailsConfig.isDetailsEditMode" label="{{ 'attribute.attributes' | translate }}"> | |
34 | + <md-tab ng-if="!vm.grid.detailsConfig.isDetailsEditMode && vm.isRuleEditable(vm.grid.operatingItem())" label="{{ 'attribute.attributes' | translate }}"> | |
35 | 35 | <tb-attribute-table flex |
36 | 36 | entity-id="vm.grid.operatingItem().id.id" |
37 | 37 | entity-type="{{vm.types.entityType.rule}}" |
... | ... | @@ -39,7 +39,7 @@ |
39 | 39 | default-attribute-scope="{{vm.types.attributesScope.server.value}}"> |
40 | 40 | </tb-attribute-table> |
41 | 41 | </md-tab> |
42 | - <md-tab ng-if="!vm.grid.detailsConfig.isDetailsEditMode" label="{{ 'attribute.latest-telemetry' | translate }}"> | |
42 | + <md-tab ng-if="!vm.grid.detailsConfig.isDetailsEditMode && vm.isRuleEditable(vm.grid.operatingItem())" label="{{ 'attribute.latest-telemetry' | translate }}"> | |
43 | 43 | <tb-attribute-table flex |
44 | 44 | entity-id="vm.grid.operatingItem().id.id" |
45 | 45 | entity-type="{{vm.types.entityType.rule}}" |
... | ... | @@ -48,7 +48,7 @@ |
48 | 48 | disable-attribute-scope-selection="true"> |
49 | 49 | </tb-attribute-table> |
50 | 50 | </md-tab> |
51 | - <md-tab ng-if="!vm.grid.detailsConfig.isDetailsEditMode" label="{{ 'rule.events' | translate }}"> | |
51 | + <md-tab ng-if="!vm.grid.detailsConfig.isDetailsEditMode && vm.isRuleEditable(vm.grid.operatingItem())" label="{{ 'rule.events' | translate }}"> | |
52 | 52 | <tb-event-table flex entity-type="vm.types.entityType.rule" |
53 | 53 | entity-id="vm.grid.operatingItem().id.id" |
54 | 54 | tenant-id="vm.grid.operatingItem().tenantId.id" |
... | ... | @@ -56,7 +56,7 @@ |
56 | 56 | disabled-event-types="{{vm.types.eventType.alarm.value}}"> |
57 | 57 | </tb-event-table> |
58 | 58 | </md-tab> |
59 | - <md-tab ng-if="!vm.grid.detailsConfig.isDetailsEditMode" label="{{ 'relation.relations' | translate }}"> | |
59 | + <md-tab ng-if="!vm.grid.detailsConfig.isDetailsEditMode && vm.isRuleEditable(vm.grid.operatingItem())" label="{{ 'relation.relations' | translate }}"> | |
60 | 60 | <tb-relation-table flex |
61 | 61 | entity-id="vm.grid.operatingItem().id.id" |
62 | 62 | entity-type="{{vm.types.entityType.rule}}"> | ... | ... |