Commit 18a12c142f2fe505f6e516063a7d394ad39fccc7

Authored by lsyer
2 parents be1fc2e1 b7655563
... ... @@ -757,6 +757,10 @@ queue:
757 757 notifications_topic: "${TB_QUEUE_TRANSPORT_NOTIFICATIONS_TOPIC:tb_transport.notifications}"
758 758 poll_interval: "${TB_QUEUE_TRANSPORT_NOTIFICATIONS_POLL_INTERVAL_MS:25}"
759 759
  760 +event:
  761 + debug:
  762 + max-symbols: "${TB_MAX_DEBUG_EVENT_SYMBOLS:4096}"
  763 +
760 764 service:
761 765 type: "${TB_SERVICE_TYPE:monolith}" # monolith or tb-core or tb-rule-engine
762 766 # Unique id for this service (autogenerated if empty)
... ...
... ... @@ -20,6 +20,7 @@ import com.google.common.util.concurrent.ListenableFuture;
20 20 import lombok.extern.slf4j.Slf4j;
21 21 import org.apache.commons.lang3.StringUtils;
22 22 import org.springframework.beans.factory.annotation.Autowired;
  23 +import org.springframework.beans.factory.annotation.Value;
23 24 import org.springframework.stereotype.Service;
24 25 import org.thingsboard.server.common.data.Event;
25 26 import org.thingsboard.server.common.data.id.EntityId;
... ... @@ -37,7 +38,8 @@ import java.util.Optional;
37 38 @Slf4j
38 39 public class BaseEventService implements EventService {
39 40
40   - private static final int MAX_DEBUG_EVENT_SYMBOLS = 4 * 1024;
  41 + @Value("${event.debug.max-symbols:4096}")
  42 + private int maxDebugEventSymbols;
41 43
42 44 @Autowired
43 45 public EventDao eventDao;
... ... @@ -69,8 +71,8 @@ public class BaseEventService implements EventService {
69 71 if (event.getType().startsWith("DEBUG") && event.getBody() != null && event.getBody().has("data")) {
70 72 String dataStr = event.getBody().get("data").asText();
71 73 int length = dataStr.length();
72   - if (length > MAX_DEBUG_EVENT_SYMBOLS) {
73   - ((ObjectNode) event.getBody()).put("data", dataStr.substring(0, MAX_DEBUG_EVENT_SYMBOLS) + "...[truncated " + (length - MAX_DEBUG_EVENT_SYMBOLS) + " symbols]");
  74 + if (length > maxDebugEventSymbols) {
  75 + ((ObjectNode) event.getBody()).put("data", dataStr.substring(0, maxDebugEventSymbols) + "...[truncated " + (length - maxDebugEventSymbols) + " symbols]");
74 76 log.trace("[{}] Event was truncated: {}", event.getId(), dataStr);
75 77 }
76 78 }
... ...
... ... @@ -125,8 +125,10 @@ public class TbDeviceProfileNode implements TbNode {
125 125 DeviceId deviceId = new DeviceId(msg.getOriginator().getId());
126 126 if (msg.getType().equals(DataConstants.ENTITY_UPDATED)) {
127 127 invalidateDeviceProfileCache(deviceId, msg.getData());
  128 + ctx.tellSuccess(msg);
128 129 } else if (msg.getType().equals(DataConstants.ENTITY_DELETED)) {
129 130 removeDeviceState(deviceId);
  131 + ctx.tellSuccess(msg);
130 132 } else {
131 133 DeviceState deviceState = getOrCreateDeviceState(ctx, deviceId, null);
132 134 if (deviceState != null) {
... ...
... ... @@ -27,6 +27,7 @@ import org.thingsboard.server.common.data.id.AssetId;
27 27 import org.thingsboard.server.common.data.id.CustomerId;
28 28 import org.thingsboard.server.common.data.id.DeviceId;
29 29 import org.thingsboard.server.common.data.id.EntityId;
  30 +import org.thingsboard.server.common.data.id.EntityViewId;
30 31 import org.thingsboard.server.common.data.id.RuleChainId;
31 32 import org.thingsboard.server.common.data.id.TenantId;
32 33 import org.thingsboard.server.common.data.id.UserId;
... ... @@ -58,6 +59,9 @@ public class EntitiesFieldsAsyncLoader {
58 59 case RULE_CHAIN:
59 60 return getAsync(ctx.getRuleChainService().findRuleChainByIdAsync(ctx.getTenantId(), (RuleChainId) original),
60 61 EntityFieldsData::new);
  62 + case ENTITY_VIEW:
  63 + return getAsync(ctx.getEntityViewService().findEntityViewByIdAsync(ctx.getTenantId(), (EntityViewId) original),
  64 + EntityFieldsData::new);
61 65 default:
62 66 return Futures.immediateFailedFuture(new TbNodeException("Unexpected original EntityType " + original));
63 67 }
... ...
... ... @@ -388,7 +388,7 @@ export class TbFlot {
388 388 item.settings = {};
389 389 });
390 390 subscription.datasources.forEach((item) => {
391   - let datasource: Datasource = {
  391 + const datasource: Datasource = {
392 392 type: item.type,
393 393 entityType: item.entityType,
394 394 entityId: item.entityId,
... ... @@ -829,7 +829,7 @@ export class TbFlot {
829 829 useDashboardTimewindow: false,
830 830 type: widgetType.latest,
831 831 callbacks: {
832   - onDataUpdated: (subscription) => {this.thresholdsSourcesDataUpdated(subscription.data)}
  832 + onDataUpdated: (subscription) => this.thresholdsSourcesDataUpdated(subscription.data)
833 833 }
834 834 };
835 835 this.ctx.subscriptionApi.createSubscription(thresholdsSourcesSubscriptionOptions, true).subscribe(
... ... @@ -896,7 +896,7 @@ export class TbFlot {
896 896 type: widgetType.latest,
897 897 callbacks: {
898 898 onDataUpdated: (subscription) => {
899   - this.labelPatternsParamsDataUpdated(subscription.data)
  899 + this.labelPatternsParamsDataUpdated(subscription.data);
900 900 }
901 901 }
902 902 };
... ... @@ -918,22 +918,22 @@ export class TbFlot {
918 918 }
919 919
920 920 private substituteLabelPatterns(series: TbFlotSeries, seriesIndex: number) {
921   - let seriesLabelPatternsSourcesData = this.labelPatternsSourcesData.filter((item) => {
  921 + const seriesLabelPatternsSourcesData = this.labelPatternsSourcesData.filter((item) => {
922 922 return item.datasource.entityId === series.datasource.entityId;
923 923 });
924 924 let label = createLabelFromDatasource(series.datasource, series.dataKey.pattern);
925 925 for (let i = 0; i < seriesLabelPatternsSourcesData.length; i++) {
926   - let keyData = seriesLabelPatternsSourcesData[i];
  926 + const keyData = seriesLabelPatternsSourcesData[i];
927 927 if (keyData && keyData.data && keyData.data[0]) {
928   - let attrValue = keyData.data[0][1];
929   - let attrName = keyData.dataKey.name;
  928 + const attrValue = keyData.data[0][1];
  929 + const attrName = keyData.dataKey.name;
930 930 if (isDefined(attrValue) && (attrValue !== null)) {
931 931 label = insertVariable(label, attrName, attrValue);
932 932 }
933 933 }
934 934 }
935 935 if (isDefined(this.subscription.legendData)) {
936   - let targetLegendKeyIndex = this.subscription.legendData.keys.findIndex((key) => {
  936 + const targetLegendKeyIndex = this.subscription.legendData.keys.findIndex((key) => {
937 937 return key.dataIndex === seriesIndex;
938 938 });
939 939 if (targetLegendKeyIndex !== -1) {
... ... @@ -1098,7 +1098,7 @@ export class TbFlot {
1098 1098 flex: '1'
1099 1099 });
1100 1100 let columnContent = '';
1101   - for (let i = c*maxRows; i < (c+1)*maxRows; i++) {
  1101 + for (let i = c * maxRows; i < (c + 1) * maxRows; i++) {
1102 1102 if (i >= hoverData.seriesHover.length) {
1103 1103 break;
1104 1104 }
... ... @@ -1287,7 +1287,7 @@ export class TbFlot {
1287 1287 let minTimeHistorical: any;
1288 1288 let hoverData: TbFlotSeriesHoverInfo;
1289 1289 let value: any;
1290   - let lastValue: any;
  1290 + let lastValue = 0;
1291 1291 let minDistanceHistorical: number;
1292 1292 const results: TbFlotHoverInfo[] = [{
1293 1293 seriesHover: []
... ...
... ... @@ -581,10 +581,10 @@ export default abstract class LeafletMap {
581 581 const marker: Marker = this.markers.get(key);
582 582 const location = this.convertPosition(data);
583 583 marker.updateMarkerPosition(location);
  584 + marker.setDataSources(data, dataSources);
584 585 if (settings.showTooltip) {
585 586 marker.updateMarkerTooltip(data);
586 587 }
587   - marker.setDataSources(data, dataSources);
588 588 marker.updateMarkerIcon(settings);
589 589 return marker;
590 590 }
... ...