Make entity view public again:

This commit is contained in:
Volodymyr Babak 2019-02-01 17:45:58 +02:00
parent ced63c4e70
commit aa7deb2f3e
9 changed files with 61 additions and 2 deletions

View File

@ -333,4 +333,28 @@ public class EntityViewController extends BaseController {
throw handleException(e); 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);
}
}
} }

View File

@ -34,7 +34,8 @@ function EntityViewService($http, $q, $window, userService, attributeService, cu
subscribeForEntityViewAttributes: subscribeForEntityViewAttributes, subscribeForEntityViewAttributes: subscribeForEntityViewAttributes,
unsubscribeForEntityViewAttributes: unsubscribeForEntityViewAttributes, unsubscribeForEntityViewAttributes: unsubscribeForEntityViewAttributes,
findByQuery: findByQuery, findByQuery: findByQuery,
getEntityViewTypes: getEntityViewTypes getEntityViewTypes: getEntityViewTypes,
makeEntityViewPublic: makeEntityViewPublic
} }
return service; return service;
@ -208,4 +209,16 @@ function EntityViewService($http, $q, $window, userService, attributeService, cu
return deferred.promise; 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;
}
} }

View File

@ -140,6 +140,18 @@ export function EntityViewController($rootScope, userService, entityViewService,
return {"topIndex": vm.topIndex}; 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( entityViewActionsList.push(
{ {
onAction: function ($event, item) { onAction: function ($event, item) {

View File

@ -13,6 +13,7 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
/* /*
.tb-entity-list { .tb-entity-list {
#entity_list_chips { #entity_list_chips {

View File

@ -13,6 +13,7 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
/* /*
.tb-entity-select { .tb-entity-select {
} }

View File

@ -13,6 +13,7 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
/* /*
.tb-entity-subtype-list { .tb-entity-subtype-list {
#entity_subtype_list_chips { #entity_subtype_list_chips {

View File

@ -13,6 +13,7 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
/* /*
.tb-entity-type-list { .tb-entity-type-list {
#entity_type_list_chips { #entity_type_list_chips {

View File

@ -13,6 +13,7 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
/* /*
md-select.tb-entity-type-select { md-select.tb-entity-type-select {
} }

View File

@ -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}}", "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", "select-entity-view": "Select entity view",
"make-public": "Make entity view public", "make-public": "Make entity view public",
"make-private": "Make entity view private",
"start-date": "Start date", "start-date": "Start date",
"start-ts": "Start time", "start-ts": "Start time",
"end-date": "End date", "end-date": "End date",
@ -861,7 +862,11 @@
"attributes-propagation": "Attributes propagation", "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.", "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": "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": {
"event-type": "Event type", "event-type": "Event type",