Commit 3d8b2cbbbff85bdfba30745125d68eb21b98560d
Merge branch 'master' of github.com:thingsboard/thingsboard
Showing
6 changed files
with
33 additions
and
3 deletions
... | ... | @@ -210,7 +210,7 @@ public class DefaultEntityQueryRepository implements EntityQueryRepository { |
210 | 210 | entityTableMap.put(EntityType.CUSTOMER, "customer"); |
211 | 211 | entityTableMap.put(EntityType.USER, "tb_user"); |
212 | 212 | entityTableMap.put(EntityType.TENANT, "tenant"); |
213 | - entityTableMap.put(EntityType.API_USAGE_STATE, "(select aus.id, aus.created_time, aus.tenant_id, '' as name, '' as additional_info from api_usage_state as aus)"); | |
213 | + entityTableMap.put(EntityType.API_USAGE_STATE, "api_usage_state"); | |
214 | 214 | } |
215 | 215 | |
216 | 216 | public static EntityType[] RELATION_QUERY_ENTITY_TYPES = new EntityType[]{ | ... | ... |
... | ... | @@ -80,6 +80,7 @@ public class EntityKeyMapping { |
80 | 80 | public static final List<String> labeledEntityFields = Arrays.asList(CREATED_TIME, ENTITY_TYPE, NAME, TYPE, LABEL, ADDITIONAL_INFO); |
81 | 81 | public static final List<String> contactBasedEntityFields = Arrays.asList(CREATED_TIME, ENTITY_TYPE, EMAIL, TITLE, COUNTRY, STATE, CITY, ADDRESS, ADDRESS_2, ZIP, PHONE, ADDITIONAL_INFO); |
82 | 82 | |
83 | + public static final Set<String> apiUsageStateEntityFields = Collections.singleton(CREATED_TIME); | |
83 | 84 | public static final Set<String> commonEntityFieldsSet = new HashSet<>(commonEntityFields); |
84 | 85 | public static final Set<String> relationQueryEntityFieldsSet = new HashSet<>(Arrays.asList(CREATED_TIME, ENTITY_TYPE, NAME, TYPE, LABEL, FIRST_NAME, LAST_NAME, EMAIL, REGION, TITLE, COUNTRY, STATE, CITY, ADDRESS, ADDRESS_2, ZIP, PHONE, ADDITIONAL_INFO)); |
85 | 86 | |
... | ... | @@ -99,6 +100,7 @@ public class EntityKeyMapping { |
99 | 100 | allowedEntityFieldMap.put(EntityType.RULE_NODE, new HashSet<>(commonEntityFields)); |
100 | 101 | allowedEntityFieldMap.put(EntityType.WIDGET_TYPE, new HashSet<>(widgetEntityFields)); |
101 | 102 | allowedEntityFieldMap.put(EntityType.WIDGETS_BUNDLE, new HashSet<>(widgetEntityFields)); |
103 | + allowedEntityFieldMap.put(EntityType.API_USAGE_STATE, apiUsageStateEntityFields); | |
102 | 104 | |
103 | 105 | entityFieldColumnMap.put(CREATED_TIME, ModelConstants.CREATED_TIME_PROPERTY); |
104 | 106 | entityFieldColumnMap.put(ENTITY_TYPE, ModelConstants.ENTITY_TYPE_PROPERTY); | ... | ... |
... | ... | @@ -17,6 +17,7 @@ package org.thingsboard.server.dao.usagerecord; |
17 | 17 | |
18 | 18 | import lombok.extern.slf4j.Slf4j; |
19 | 19 | import org.springframework.stereotype.Service; |
20 | +import org.thingsboard.server.common.data.ApiFeature; | |
20 | 21 | import org.thingsboard.server.common.data.ApiUsageRecordKey; |
21 | 22 | import org.thingsboard.server.common.data.ApiUsageState; |
22 | 23 | import org.thingsboard.server.common.data.ApiUsageStateValue; |
... | ... | @@ -27,6 +28,7 @@ import org.thingsboard.server.common.data.id.ApiUsageStateId; |
27 | 28 | import org.thingsboard.server.common.data.id.TenantId; |
28 | 29 | import org.thingsboard.server.common.data.kv.BasicTsKvEntry; |
29 | 30 | import org.thingsboard.server.common.data.kv.LongDataEntry; |
31 | +import org.thingsboard.server.common.data.kv.StringDataEntry; | |
30 | 32 | import org.thingsboard.server.common.data.kv.TsKvEntry; |
31 | 33 | import org.thingsboard.server.common.data.tenant.profile.TenantProfileConfiguration; |
32 | 34 | import org.thingsboard.server.dao.entity.AbstractEntityService; |
... | ... | @@ -83,7 +85,19 @@ public class ApiUsageStateServiceImpl extends AbstractEntityService implements A |
83 | 85 | Tenant tenant = tenantDao.findById(tenantId, tenantId.getId()); |
84 | 86 | TenantProfile tenantProfile = tenantProfileDao.findById(tenantId, tenant.getTenantProfileId().getId()); |
85 | 87 | TenantProfileConfiguration configuration = tenantProfile.getProfileData().getConfiguration(); |
88 | + List<TsKvEntry> apiUsageStates = new ArrayList<>(); | |
89 | + apiUsageStates.add(new BasicTsKvEntry(saved.getCreatedTime(), | |
90 | + new StringDataEntry(ApiFeature.TRANSPORT.getApiStateKey(), ApiUsageStateValue.ENABLED.name()))); | |
91 | + apiUsageStates.add(new BasicTsKvEntry(saved.getCreatedTime(), | |
92 | + new StringDataEntry(ApiFeature.DB.getApiStateKey(), ApiUsageStateValue.ENABLED.name()))); | |
93 | + apiUsageStates.add(new BasicTsKvEntry(saved.getCreatedTime(), | |
94 | + new StringDataEntry(ApiFeature.RE.getApiStateKey(), ApiUsageStateValue.ENABLED.name()))); | |
95 | + apiUsageStates.add(new BasicTsKvEntry(saved.getCreatedTime(), | |
96 | + new StringDataEntry(ApiFeature.JS.getApiStateKey(), ApiUsageStateValue.ENABLED.name()))); | |
97 | + tsService.save(tenantId, saved.getId(), apiUsageStates, 0L); | |
98 | + | |
86 | 99 | List<TsKvEntry> profileThresholds = new ArrayList<>(); |
100 | + | |
87 | 101 | for (ApiUsageRecordKey key : ApiUsageRecordKey.values()) { |
88 | 102 | profileThresholds.add(new BasicTsKvEntry(saved.getCreatedTime(), new LongDataEntry(key.getApiLimitKey(), configuration.getProfileThreshold(key)))); |
89 | 103 | } | ... | ... |
... | ... | @@ -422,6 +422,12 @@ export class DashboardUtilsService { |
422 | 422 | widgetLayout.row = row; |
423 | 423 | widgetLayout.col = 0; |
424 | 424 | } |
425 | + | |
426 | + widgetLayout.sizeX = Math.floor(widgetLayout.sizeX); | |
427 | + widgetLayout.sizeY = Math.floor(widgetLayout.sizeY); | |
428 | + widgetLayout.row = Math.floor(widgetLayout.row); | |
429 | + widgetLayout.col = Math.floor(widgetLayout.col); | |
430 | + | |
425 | 431 | layout.widgets[widget.id] = widgetLayout; |
426 | 432 | } |
427 | 433 | ... | ... |
... | ... | @@ -47,7 +47,8 @@ export enum EntityType { |
47 | 47 | RULE_NODE = 'RULE_NODE', |
48 | 48 | ENTITY_VIEW = 'ENTITY_VIEW', |
49 | 49 | WIDGETS_BUNDLE = 'WIDGETS_BUNDLE', |
50 | - WIDGET_TYPE = 'WIDGET_TYPE' | |
50 | + WIDGET_TYPE = 'WIDGET_TYPE', | |
51 | + API_USAGE_STATE = 'API_USAGE_STATE' | |
51 | 52 | } |
52 | 53 | |
53 | 54 | export enum AliasEntityType { |
... | ... | @@ -239,6 +240,12 @@ export const entityTypeTranslations = new Map<EntityType | AliasEntityType, Enti |
239 | 240 | } |
240 | 241 | ], |
241 | 242 | [ |
243 | + EntityType.API_USAGE_STATE, | |
244 | + { | |
245 | + type: 'entity.type-api-usage-state' | |
246 | + } | |
247 | + ], | |
248 | + [ | |
242 | 249 | EntityType.WIDGETS_BUNDLE, |
243 | 250 | { |
244 | 251 | details: 'widgets-bundle.widgets-bundle-details', | ... | ... |
... | ... | @@ -1099,7 +1099,8 @@ |
1099 | 1099 | "details": "Entity details", |
1100 | 1100 | "no-entities-prompt": "No entities found", |
1101 | 1101 | "no-data": "No data to display", |
1102 | - "columns-to-display": "Columns to Display" | |
1102 | + "columns-to-display": "Columns to Display", | |
1103 | + "type-api-usage-state": "Api Usage State" | |
1103 | 1104 | }, |
1104 | 1105 | "entity-field": { |
1105 | 1106 | "created-time": "Created time", | ... | ... |