Commit 33fc8f0ba5167130cfc7bb7752142e2bc70ba2c0

Authored by Volodymyr Babak
1 parent 5139299f

Entity view fixes

@@ -157,7 +157,7 @@ function EntityViewService($http, $q, $window, userService, attributeService, cu @@ -157,7 +157,7 @@ function EntityViewService($http, $q, $window, userService, attributeService, cu
157 var url = '/api/entityView'; 157 var url = '/api/entityView';
158 158
159 entityView.keys = {}; 159 entityView.keys = {};
160 - entityView.keys.timeseries = ['a', 'b']; 160 + entityView.keys.timeseries = ['temp'];
161 161
162 $http.post(url, entityView).then(function success(response) { 162 $http.post(url, entityView).then(function success(response) {
163 deferred.resolve(response.data); 163 deferred.resolve(response.data);
@@ -20,8 +20,9 @@ export default angular.module('thingsboard.api.entity', [thingsboardTypes]) @@ -20,8 +20,9 @@ export default angular.module('thingsboard.api.entity', [thingsboardTypes])
20 .name; 20 .name;
21 21
22 /*@ngInject*/ 22 /*@ngInject*/
23 -function EntityService($http, $q, $filter, $translate, $log, userService, deviceService,  
24 - assetService, tenantService, customerService, ruleChainService, dashboardService, entityRelationService, attributeService, types, utils) { 23 +function EntityService($http, $q, $filter, $translate, $log, userService, deviceService, assetService, tenantService,
  24 + customerService, ruleChainService, dashboardService, entityRelationService, attributeService,
  25 + entityViewService, types, utils) {
25 var service = { 26 var service = {
26 getEntity: getEntity, 27 getEntity: getEntity,
27 getEntities: getEntities, 28 getEntities: getEntities,
@@ -54,6 +55,9 @@ function EntityService($http, $q, $filter, $translate, $log, userService, device @@ -54,6 +55,9 @@ function EntityService($http, $q, $filter, $translate, $log, userService, device
54 case types.entityType.asset: 55 case types.entityType.asset:
55 promise = assetService.getAsset(entityId, true, config); 56 promise = assetService.getAsset(entityId, true, config);
56 break; 57 break;
  58 + case types.entityType.entityView:
  59 + promise = entityViewService.getEntityView(entityId, true, config);
  60 + break;
57 case types.entityType.tenant: 61 case types.entityType.tenant:
58 promise = tenantService.getTenant(entityId, config); 62 promise = tenantService.getTenant(entityId, config);
59 break; 63 break;
@@ -239,6 +243,13 @@ function EntityService($http, $q, $filter, $translate, $log, userService, device @@ -239,6 +243,13 @@ function EntityService($http, $q, $filter, $translate, $log, userService, device
239 promise = assetService.getTenantAssets(pageLink, false, config, subType); 243 promise = assetService.getTenantAssets(pageLink, false, config, subType);
240 } 244 }
241 break; 245 break;
  246 + case types.entityType.entityView:
  247 + if (user.authority === 'CUSTOMER_USER') {
  248 + promise = entityViewService.getCustomerEntityViews(customerId, pageLink, false, config, subType);
  249 + } else {
  250 + promise = entityViewService.getTenantEntityViews(pageLink, false, config, subType);
  251 + }
  252 + break;
242 case types.entityType.tenant: 253 case types.entityType.tenant:
243 if (user.authority === 'TENANT_ADMIN') { 254 if (user.authority === 'TENANT_ADMIN') {
244 promise = getSingleTenantByPageLinkPromise(pageLink, config); 255 promise = getSingleTenantByPageLinkPromise(pageLink, config);
@@ -725,6 +736,7 @@ function EntityService($http, $q, $filter, $translate, $log, userService, device @@ -725,6 +736,7 @@ function EntityService($http, $q, $filter, $translate, $log, userService, device
725 case 'TENANT_ADMIN': 736 case 'TENANT_ADMIN':
726 entityTypes.device = types.entityType.device; 737 entityTypes.device = types.entityType.device;
727 entityTypes.asset = types.entityType.asset; 738 entityTypes.asset = types.entityType.asset;
  739 + entityTypes.entityView = types.entityType.entityView;
728 entityTypes.tenant = types.entityType.tenant; 740 entityTypes.tenant = types.entityType.tenant;
729 entityTypes.customer = types.entityType.customer; 741 entityTypes.customer = types.entityType.customer;
730 entityTypes.dashboard = types.entityType.dashboard; 742 entityTypes.dashboard = types.entityType.dashboard;
@@ -735,6 +747,7 @@ function EntityService($http, $q, $filter, $translate, $log, userService, device @@ -735,6 +747,7 @@ function EntityService($http, $q, $filter, $translate, $log, userService, device
735 case 'CUSTOMER_USER': 747 case 'CUSTOMER_USER':
736 entityTypes.device = types.entityType.device; 748 entityTypes.device = types.entityType.device;
737 entityTypes.asset = types.entityType.asset; 749 entityTypes.asset = types.entityType.asset;
  750 + entityTypes.entityView = types.entityType.entityView;
738 entityTypes.customer = types.entityType.customer; 751 entityTypes.customer = types.entityType.customer;
739 entityTypes.dashboard = types.entityType.dashboard; 752 entityTypes.dashboard = types.entityType.dashboard;
740 if (useAliasEntityTypes) { 753 if (useAliasEntityTypes) {
@@ -346,6 +346,12 @@ export default angular.module('thingsboard.types', []) @@ -346,6 +346,12 @@ export default angular.module('thingsboard.types', [])
346 list: 'entity.list-of-assets', 346 list: 'entity.list-of-assets',
347 nameStartsWith: 'entity.asset-name-starts-with' 347 nameStartsWith: 'entity.asset-name-starts-with'
348 }, 348 },
  349 + "ENTITY_VIEW": {
  350 + type: 'entity.type-entity-view',
  351 + typePlural: 'entity.type-entity-views',
  352 + list: 'entity.list-of-entity-views',
  353 + nameStartsWith: 'entity.entity-view-name-starts-with'
  354 + },
349 "TENANT": { 355 "TENANT": {
350 type: 'entity.type-tenant', 356 type: 'entity.type-tenant',
351 typePlural: 'entity.type-tenants', 357 typePlural: 'entity.type-tenants',
@@ -47,8 +47,8 @@ export default function EntityViewDirective($compile, $templateCache, $filter, t @@ -47,8 +47,8 @@ export default function EntityViewDirective($compile, $templateCache, $filter, t
47 scope.isPublic = false; 47 scope.isPublic = false;
48 scope.assignedCustomer = null; 48 scope.assignedCustomer = null;
49 } 49 }
50 - scope.startTs = $filter('date')(scope.entityView.endTs, 'yyyy-MM-dd HH:mm:ss');  
51 - scope.endTs = $filter('date')(scope.entityView.startTs, 'yyyy-MM-dd HH:mm:ss'); 50 + scope.startTs = new Date(scope.entityView.startTs);
  51 + scope.endTs = new Date(scope.entityView.endTs);
52 } 52 }
53 }); 53 });
54 54
@@ -131,6 +131,12 @@ export default function EntityAutocomplete($compile, $templateCache, $q, $filter @@ -131,6 +131,12 @@ export default function EntityAutocomplete($compile, $templateCache, $q, $filter
131 scope.noEntitiesMatchingText = 'device.no-devices-matching'; 131 scope.noEntitiesMatchingText = 'device.no-devices-matching';
132 scope.entityRequiredText = 'device.device-required'; 132 scope.entityRequiredText = 'device.device-required';
133 break; 133 break;
  134 + case types.entityType.entityView:
  135 + scope.selectEntityText = 'entity-view.select-entity-view';
  136 + scope.entityText = 'entity-view.entity-view';
  137 + scope.noEntitiesMatchingText = 'entity-view.no-entity-views-matching';
  138 + scope.entityRequiredText = 'entity-view.entity-view-required';
  139 + break;
134 case types.entityType.rulechain: 140 case types.entityType.rulechain:
135 scope.selectEntityText = 'rulechain.select-rulechain'; 141 scope.selectEntityText = 'rulechain.select-rulechain';
136 scope.entityText = 'rulechain.rulechain'; 142 scope.entityText = 'rulechain.rulechain';
@@ -708,6 +708,10 @@ @@ -708,6 +708,10 @@
708 "type-assets": "Assets", 708 "type-assets": "Assets",
709 "list-of-assets": "{ count, plural, 1 {One asset} other {List of # assets} }", 709 "list-of-assets": "{ count, plural, 1 {One asset} other {List of # assets} }",
710 "asset-name-starts-with": "Assets whose names start with '{{prefix}}'", 710 "asset-name-starts-with": "Assets whose names start with '{{prefix}}'",
  711 + "type-entity-view": "Entity View",
  712 + "type-entity-views": "Entity Views",
  713 + "list-of-entity-views": "{ count, plural, 1 {One entity view} other {List of # entity views} }",
  714 + "entity-view-name-starts-with": "Entity Views whose names start with '{{prefix}}'",
711 "type-rule": "Rule", 715 "type-rule": "Rule",
712 "type-rules": "Rules", 716 "type-rules": "Rules",
713 "list-of-rules": "{ count, plural, 1 {One rule} other {List of # rules} }", 717 "list-of-rules": "{ count, plural, 1 {One rule} other {List of # rules} }",