diff --git a/application/src/main/resources/thingsboard.yml b/application/src/main/resources/thingsboard.yml index 0ffde924a5..0cc7c08669 100644 --- a/application/src/main/resources/thingsboard.yml +++ b/application/src/main/resources/thingsboard.yml @@ -757,6 +757,10 @@ queue: notifications_topic: "${TB_QUEUE_TRANSPORT_NOTIFICATIONS_TOPIC:tb_transport.notifications}" poll_interval: "${TB_QUEUE_TRANSPORT_NOTIFICATIONS_POLL_INTERVAL_MS:25}" +event: + debug: + max-symbols: "${TB_MAX_DEBUG_EVENT_SYMBOLS:4096}" + service: type: "${TB_SERVICE_TYPE:monolith}" # monolith or tb-core or tb-rule-engine # Unique id for this service (autogenerated if empty) diff --git a/dao/src/main/java/org/thingsboard/server/dao/event/BaseEventService.java b/dao/src/main/java/org/thingsboard/server/dao/event/BaseEventService.java index 53c2b09d0e..4cc853b2b9 100644 --- a/dao/src/main/java/org/thingsboard/server/dao/event/BaseEventService.java +++ b/dao/src/main/java/org/thingsboard/server/dao/event/BaseEventService.java @@ -20,6 +20,7 @@ import com.google.common.util.concurrent.ListenableFuture; import lombok.extern.slf4j.Slf4j; import org.apache.commons.lang3.StringUtils; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Value; import org.springframework.stereotype.Service; import org.thingsboard.server.common.data.Event; import org.thingsboard.server.common.data.id.EntityId; @@ -37,7 +38,8 @@ import java.util.Optional; @Slf4j public class BaseEventService implements EventService { - private static final int MAX_DEBUG_EVENT_SYMBOLS = 4 * 1024; + @Value("${event.debug.max-symbols:4096}") + private int maxDebugEventSymbols; @Autowired public EventDao eventDao; @@ -69,8 +71,8 @@ public class BaseEventService implements EventService { if (event.getType().startsWith("DEBUG") && event.getBody() != null && event.getBody().has("data")) { String dataStr = event.getBody().get("data").asText(); int length = dataStr.length(); - if (length > MAX_DEBUG_EVENT_SYMBOLS) { - ((ObjectNode) event.getBody()).put("data", dataStr.substring(0, MAX_DEBUG_EVENT_SYMBOLS) + "...[truncated " + (length - MAX_DEBUG_EVENT_SYMBOLS) + " symbols]"); + if (length > maxDebugEventSymbols) { + ((ObjectNode) event.getBody()).put("data", dataStr.substring(0, maxDebugEventSymbols) + "...[truncated " + (length - maxDebugEventSymbols) + " symbols]"); log.trace("[{}] Event was truncated: {}", event.getId(), dataStr); } } diff --git a/rule-engine/rule-engine-components/src/main/java/org/thingsboard/rule/engine/profile/TbDeviceProfileNode.java b/rule-engine/rule-engine-components/src/main/java/org/thingsboard/rule/engine/profile/TbDeviceProfileNode.java index e8b700a0a3..3faac79420 100644 --- a/rule-engine/rule-engine-components/src/main/java/org/thingsboard/rule/engine/profile/TbDeviceProfileNode.java +++ b/rule-engine/rule-engine-components/src/main/java/org/thingsboard/rule/engine/profile/TbDeviceProfileNode.java @@ -125,8 +125,10 @@ public class TbDeviceProfileNode implements TbNode { DeviceId deviceId = new DeviceId(msg.getOriginator().getId()); if (msg.getType().equals(DataConstants.ENTITY_UPDATED)) { invalidateDeviceProfileCache(deviceId, msg.getData()); + ctx.tellSuccess(msg); } else if (msg.getType().equals(DataConstants.ENTITY_DELETED)) { removeDeviceState(deviceId); + ctx.tellSuccess(msg); } else { DeviceState deviceState = getOrCreateDeviceState(ctx, deviceId, null); if (deviceState != null) { diff --git a/rule-engine/rule-engine-components/src/main/java/org/thingsboard/rule/engine/util/EntitiesFieldsAsyncLoader.java b/rule-engine/rule-engine-components/src/main/java/org/thingsboard/rule/engine/util/EntitiesFieldsAsyncLoader.java index e41fe472d2..fbf7271f53 100644 --- a/rule-engine/rule-engine-components/src/main/java/org/thingsboard/rule/engine/util/EntitiesFieldsAsyncLoader.java +++ b/rule-engine/rule-engine-components/src/main/java/org/thingsboard/rule/engine/util/EntitiesFieldsAsyncLoader.java @@ -27,6 +27,7 @@ import org.thingsboard.server.common.data.id.AssetId; import org.thingsboard.server.common.data.id.CustomerId; import org.thingsboard.server.common.data.id.DeviceId; import org.thingsboard.server.common.data.id.EntityId; +import org.thingsboard.server.common.data.id.EntityViewId; import org.thingsboard.server.common.data.id.RuleChainId; import org.thingsboard.server.common.data.id.TenantId; import org.thingsboard.server.common.data.id.UserId; @@ -58,6 +59,9 @@ public class EntitiesFieldsAsyncLoader { case RULE_CHAIN: return getAsync(ctx.getRuleChainService().findRuleChainByIdAsync(ctx.getTenantId(), (RuleChainId) original), EntityFieldsData::new); + case ENTITY_VIEW: + return getAsync(ctx.getEntityViewService().findEntityViewByIdAsync(ctx.getTenantId(), (EntityViewId) original), + EntityFieldsData::new); default: return Futures.immediateFailedFuture(new TbNodeException("Unexpected original EntityType " + original)); } diff --git a/ui-ngx/src/app/modules/home/components/widget/lib/flot-widget.ts b/ui-ngx/src/app/modules/home/components/widget/lib/flot-widget.ts index 2e45f7b725..390ac26d5c 100644 --- a/ui-ngx/src/app/modules/home/components/widget/lib/flot-widget.ts +++ b/ui-ngx/src/app/modules/home/components/widget/lib/flot-widget.ts @@ -388,7 +388,7 @@ export class TbFlot { item.settings = {}; }); subscription.datasources.forEach((item) => { - let datasource: Datasource = { + const datasource: Datasource = { type: item.type, entityType: item.entityType, entityId: item.entityId, @@ -829,7 +829,7 @@ export class TbFlot { useDashboardTimewindow: false, type: widgetType.latest, callbacks: { - onDataUpdated: (subscription) => {this.thresholdsSourcesDataUpdated(subscription.data)} + onDataUpdated: (subscription) => this.thresholdsSourcesDataUpdated(subscription.data) } }; this.ctx.subscriptionApi.createSubscription(thresholdsSourcesSubscriptionOptions, true).subscribe( @@ -896,7 +896,7 @@ export class TbFlot { type: widgetType.latest, callbacks: { onDataUpdated: (subscription) => { - this.labelPatternsParamsDataUpdated(subscription.data) + this.labelPatternsParamsDataUpdated(subscription.data); } } }; @@ -918,22 +918,22 @@ export class TbFlot { } private substituteLabelPatterns(series: TbFlotSeries, seriesIndex: number) { - let seriesLabelPatternsSourcesData = this.labelPatternsSourcesData.filter((item) => { + const seriesLabelPatternsSourcesData = this.labelPatternsSourcesData.filter((item) => { return item.datasource.entityId === series.datasource.entityId; }); let label = createLabelFromDatasource(series.datasource, series.dataKey.pattern); for (let i = 0; i < seriesLabelPatternsSourcesData.length; i++) { - let keyData = seriesLabelPatternsSourcesData[i]; + const keyData = seriesLabelPatternsSourcesData[i]; if (keyData && keyData.data && keyData.data[0]) { - let attrValue = keyData.data[0][1]; - let attrName = keyData.dataKey.name; + const attrValue = keyData.data[0][1]; + const attrName = keyData.dataKey.name; if (isDefined(attrValue) && (attrValue !== null)) { label = insertVariable(label, attrName, attrValue); } } } if (isDefined(this.subscription.legendData)) { - let targetLegendKeyIndex = this.subscription.legendData.keys.findIndex((key) => { + const targetLegendKeyIndex = this.subscription.legendData.keys.findIndex((key) => { return key.dataIndex === seriesIndex; }); if (targetLegendKeyIndex !== -1) { @@ -1098,7 +1098,7 @@ export class TbFlot { flex: '1' }); let columnContent = ''; - for (let i = c*maxRows; i < (c+1)*maxRows; i++) { + for (let i = c * maxRows; i < (c + 1) * maxRows; i++) { if (i >= hoverData.seriesHover.length) { break; } @@ -1287,7 +1287,7 @@ export class TbFlot { let minTimeHistorical: any; let hoverData: TbFlotSeriesHoverInfo; let value: any; - let lastValue: any; + let lastValue = 0; let minDistanceHistorical: number; const results: TbFlotHoverInfo[] = [{ seriesHover: [] diff --git a/ui-ngx/src/app/modules/home/components/widget/lib/maps/leaflet-map.ts b/ui-ngx/src/app/modules/home/components/widget/lib/maps/leaflet-map.ts index 1f462a5386..be3551b51f 100644 --- a/ui-ngx/src/app/modules/home/components/widget/lib/maps/leaflet-map.ts +++ b/ui-ngx/src/app/modules/home/components/widget/lib/maps/leaflet-map.ts @@ -581,10 +581,10 @@ export default abstract class LeafletMap { const marker: Marker = this.markers.get(key); const location = this.convertPosition(data); marker.updateMarkerPosition(location); + marker.setDataSources(data, dataSources); if (settings.showTooltip) { marker.updateMarkerTooltip(data); } - marker.setDataSources(data, dataSources); marker.updateMarkerIcon(settings); return marker; }