Make entity view public again:
This commit is contained in:
parent
ced63c4e70
commit
aa7deb2f3e
@ -333,4 +333,28 @@ public class EntityViewController extends BaseController {
|
||||
throw handleException(e);
|
||||
}
|
||||
}
|
||||
|
||||
@PreAuthorize("hasAuthority('TENANT_ADMIN')")
|
||||
@RequestMapping(value = "/customer/public/entityView/{entityViewId}", method = RequestMethod.POST)
|
||||
@ResponseBody
|
||||
public EntityView assignEntityViewToPublicCustomer(@PathVariable(ENTITY_VIEW_ID) String strEntityViewId) throws ThingsboardException {
|
||||
checkParameter(ENTITY_VIEW_ID, strEntityViewId);
|
||||
try {
|
||||
EntityViewId entityViewId = new EntityViewId(toUUID(strEntityViewId));
|
||||
EntityView entityView = checkEntityViewId(entityViewId);
|
||||
Customer publicCustomer = customerService.findOrCreatePublicCustomer(entityView.getTenantId());
|
||||
EntityView savedEntityView = checkNotNull(entityViewService.assignEntityViewToCustomer(getCurrentUser().getTenantId(), entityViewId, publicCustomer.getId()));
|
||||
|
||||
logEntityAction(entityViewId, savedEntityView,
|
||||
savedEntityView.getCustomerId(),
|
||||
ActionType.ASSIGNED_TO_CUSTOMER, null, strEntityViewId, publicCustomer.getId().toString(), publicCustomer.getName());
|
||||
|
||||
return savedEntityView;
|
||||
} catch (Exception e) {
|
||||
logEntityAction(emptyId(EntityType.ENTITY_VIEW), null,
|
||||
null,
|
||||
ActionType.ASSIGNED_TO_CUSTOMER, e, strEntityViewId);
|
||||
throw handleException(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -34,7 +34,8 @@ function EntityViewService($http, $q, $window, userService, attributeService, cu
|
||||
subscribeForEntityViewAttributes: subscribeForEntityViewAttributes,
|
||||
unsubscribeForEntityViewAttributes: unsubscribeForEntityViewAttributes,
|
||||
findByQuery: findByQuery,
|
||||
getEntityViewTypes: getEntityViewTypes
|
||||
getEntityViewTypes: getEntityViewTypes,
|
||||
makeEntityViewPublic: makeEntityViewPublic
|
||||
}
|
||||
|
||||
return service;
|
||||
@ -208,4 +209,16 @@ function EntityViewService($http, $q, $window, userService, attributeService, cu
|
||||
return deferred.promise;
|
||||
}
|
||||
|
||||
function makeEntityViewPublic(entityViewId) {
|
||||
var deferred = $q.defer();
|
||||
var url = '/api/customer/public/entityView/' + entityViewId;
|
||||
$http.post(url, null).then(function success(response) {
|
||||
deferred.resolve(response.data);
|
||||
}, function fail() {
|
||||
deferred.reject();
|
||||
});
|
||||
return deferred.promise;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@ -140,6 +140,18 @@ export function EntityViewController($rootScope, userService, entityViewService,
|
||||
return {"topIndex": vm.topIndex};
|
||||
};
|
||||
|
||||
entityViewActionsList.push({
|
||||
onAction: function ($event, item) {
|
||||
makePublic($event, item);
|
||||
},
|
||||
name: function() { return $translate.instant('action.share') },
|
||||
details: function() { return $translate.instant('entity-view.make-public') },
|
||||
icon: "share",
|
||||
isEnabled: function(entityView) {
|
||||
return entityView && (!entityView.customerId || entityView.customerId.id === types.id.nullUid);
|
||||
}
|
||||
});
|
||||
|
||||
entityViewActionsList.push(
|
||||
{
|
||||
onAction: function ($event, item) {
|
||||
|
||||
@ -13,6 +13,7 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
/*
|
||||
.tb-entity-list {
|
||||
#entity_list_chips {
|
||||
|
||||
@ -13,6 +13,7 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
/*
|
||||
.tb-entity-select {
|
||||
}
|
||||
|
||||
@ -13,6 +13,7 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
/*
|
||||
.tb-entity-subtype-list {
|
||||
#entity_subtype_list_chips {
|
||||
|
||||
@ -13,6 +13,7 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
/*
|
||||
.tb-entity-type-list {
|
||||
#entity_type_list_chips {
|
||||
|
||||
@ -13,6 +13,7 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
/*
|
||||
md-select.tb-entity-type-select {
|
||||
}
|
||||
|
||||
@ -844,6 +844,7 @@
|
||||
"unable-entity-view-device-alias-text": "Device alias '{{entityViewAlias}}' can't be deleted as it used by the following widget(s):<br/>{{widgetsList}}",
|
||||
"select-entity-view": "Select entity view",
|
||||
"make-public": "Make entity view public",
|
||||
"make-private": "Make entity view private",
|
||||
"start-date": "Start date",
|
||||
"start-ts": "Start time",
|
||||
"end-date": "End date",
|
||||
@ -861,7 +862,11 @@
|
||||
"attributes-propagation": "Attributes propagation",
|
||||
"attributes-propagation-hint": "Entity View will automatically copy specified attributes from Target Entity each time you save or update this entity view. For performance reasons target entity attributes are not propagated to entity view on each attribute change. You can enable automatic propagation by configuring \"copy to view\" rule node in your rule chain and linking \"Post attributes\" and \"Attributes Updated\" messages to the new rule node.",
|
||||
"timeseries-data": "Timeseries data",
|
||||
"timeseries-data-hint": "Configure timeseries data keys of the target entity that will be accessible to the entity view. This timeseries data is read-only."
|
||||
"timeseries-data-hint": "Configure timeseries data keys of the target entity that will be accessible to the entity view. This timeseries data is read-only.",
|
||||
"make-public-entity-view-title": "Are you sure you want to make the entity view '{{entityViewName}}' public?",
|
||||
"make-public-entity-view-text": "After the confirmation the entity view and all its data will be made public and accessible by others.",
|
||||
"make-private-entity-view-title": "Are you sure you want to make the entity view '{{entityViewName}}' private?",
|
||||
"make-private-entity-view-text": "After the confirmation the entity view and all its data will be made private and won't be accessible by others."
|
||||
},
|
||||
"event": {
|
||||
"event-type": "Event type",
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user