Browse Source

Merge branch 'master' of https://github.com/thingsboard/thingsboard

pull/3974/head
lsyer 6 years ago
parent
commit
18a12c142f
  1. 4
      application/src/main/resources/thingsboard.yml
  2. 8
      dao/src/main/java/org/thingsboard/server/dao/event/BaseEventService.java
  3. 2
      rule-engine/rule-engine-components/src/main/java/org/thingsboard/rule/engine/profile/TbDeviceProfileNode.java
  4. 4
      rule-engine/rule-engine-components/src/main/java/org/thingsboard/rule/engine/util/EntitiesFieldsAsyncLoader.java
  5. 20
      ui-ngx/src/app/modules/home/components/widget/lib/flot-widget.ts
  6. 2
      ui-ngx/src/app/modules/home/components/widget/lib/maps/leaflet-map.ts

4
application/src/main/resources/thingsboard.yml

@ -757,6 +757,10 @@ queue:
notifications_topic: "${TB_QUEUE_TRANSPORT_NOTIFICATIONS_TOPIC:tb_transport.notifications}" notifications_topic: "${TB_QUEUE_TRANSPORT_NOTIFICATIONS_TOPIC:tb_transport.notifications}"
poll_interval: "${TB_QUEUE_TRANSPORT_NOTIFICATIONS_POLL_INTERVAL_MS:25}" poll_interval: "${TB_QUEUE_TRANSPORT_NOTIFICATIONS_POLL_INTERVAL_MS:25}"
event:
debug:
max-symbols: "${TB_MAX_DEBUG_EVENT_SYMBOLS:4096}"
service: service:
type: "${TB_SERVICE_TYPE:monolith}" # monolith or tb-core or tb-rule-engine type: "${TB_SERVICE_TYPE:monolith}" # monolith or tb-core or tb-rule-engine
# Unique id for this service (autogenerated if empty) # Unique id for this service (autogenerated if empty)

8
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 lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.thingsboard.server.common.data.Event; import org.thingsboard.server.common.data.Event;
import org.thingsboard.server.common.data.id.EntityId; import org.thingsboard.server.common.data.id.EntityId;
@ -37,7 +38,8 @@ import java.util.Optional;
@Slf4j @Slf4j
public class BaseEventService implements EventService { 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 @Autowired
public EventDao eventDao; public EventDao eventDao;
@ -69,8 +71,8 @@ public class BaseEventService implements EventService {
if (event.getType().startsWith("DEBUG") && event.getBody() != null && event.getBody().has("data")) { if (event.getType().startsWith("DEBUG") && event.getBody() != null && event.getBody().has("data")) {
String dataStr = event.getBody().get("data").asText(); String dataStr = event.getBody().get("data").asText();
int length = dataStr.length(); int length = dataStr.length();
if (length > MAX_DEBUG_EVENT_SYMBOLS) { if (length > maxDebugEventSymbols) {
((ObjectNode) event.getBody()).put("data", dataStr.substring(0, MAX_DEBUG_EVENT_SYMBOLS) + "...[truncated " + (length - MAX_DEBUG_EVENT_SYMBOLS) + " symbols]"); ((ObjectNode) event.getBody()).put("data", dataStr.substring(0, maxDebugEventSymbols) + "...[truncated " + (length - maxDebugEventSymbols) + " symbols]");
log.trace("[{}] Event was truncated: {}", event.getId(), dataStr); log.trace("[{}] Event was truncated: {}", event.getId(), dataStr);
} }
} }

2
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()); DeviceId deviceId = new DeviceId(msg.getOriginator().getId());
if (msg.getType().equals(DataConstants.ENTITY_UPDATED)) { if (msg.getType().equals(DataConstants.ENTITY_UPDATED)) {
invalidateDeviceProfileCache(deviceId, msg.getData()); invalidateDeviceProfileCache(deviceId, msg.getData());
ctx.tellSuccess(msg);
} else if (msg.getType().equals(DataConstants.ENTITY_DELETED)) { } else if (msg.getType().equals(DataConstants.ENTITY_DELETED)) {
removeDeviceState(deviceId); removeDeviceState(deviceId);
ctx.tellSuccess(msg);
} else { } else {
DeviceState deviceState = getOrCreateDeviceState(ctx, deviceId, null); DeviceState deviceState = getOrCreateDeviceState(ctx, deviceId, null);
if (deviceState != null) { if (deviceState != null) {

4
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.CustomerId;
import org.thingsboard.server.common.data.id.DeviceId; import org.thingsboard.server.common.data.id.DeviceId;
import org.thingsboard.server.common.data.id.EntityId; 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.RuleChainId;
import org.thingsboard.server.common.data.id.TenantId; import org.thingsboard.server.common.data.id.TenantId;
import org.thingsboard.server.common.data.id.UserId; import org.thingsboard.server.common.data.id.UserId;
@ -58,6 +59,9 @@ public class EntitiesFieldsAsyncLoader {
case RULE_CHAIN: case RULE_CHAIN:
return getAsync(ctx.getRuleChainService().findRuleChainByIdAsync(ctx.getTenantId(), (RuleChainId) original), return getAsync(ctx.getRuleChainService().findRuleChainByIdAsync(ctx.getTenantId(), (RuleChainId) original),
EntityFieldsData::new); EntityFieldsData::new);
case ENTITY_VIEW:
return getAsync(ctx.getEntityViewService().findEntityViewByIdAsync(ctx.getTenantId(), (EntityViewId) original),
EntityFieldsData::new);
default: default:
return Futures.immediateFailedFuture(new TbNodeException("Unexpected original EntityType " + original)); return Futures.immediateFailedFuture(new TbNodeException("Unexpected original EntityType " + original));
} }

20
ui-ngx/src/app/modules/home/components/widget/lib/flot-widget.ts

@ -388,7 +388,7 @@ export class TbFlot {
item.settings = {}; item.settings = {};
}); });
subscription.datasources.forEach((item) => { subscription.datasources.forEach((item) => {
let datasource: Datasource = { const datasource: Datasource = {
type: item.type, type: item.type,
entityType: item.entityType, entityType: item.entityType,
entityId: item.entityId, entityId: item.entityId,
@ -829,7 +829,7 @@ export class TbFlot {
useDashboardTimewindow: false, useDashboardTimewindow: false,
type: widgetType.latest, type: widgetType.latest,
callbacks: { callbacks: {
onDataUpdated: (subscription) => {this.thresholdsSourcesDataUpdated(subscription.data)} onDataUpdated: (subscription) => this.thresholdsSourcesDataUpdated(subscription.data)
} }
}; };
this.ctx.subscriptionApi.createSubscription(thresholdsSourcesSubscriptionOptions, true).subscribe( this.ctx.subscriptionApi.createSubscription(thresholdsSourcesSubscriptionOptions, true).subscribe(
@ -896,7 +896,7 @@ export class TbFlot {
type: widgetType.latest, type: widgetType.latest,
callbacks: { callbacks: {
onDataUpdated: (subscription) => { onDataUpdated: (subscription) => {
this.labelPatternsParamsDataUpdated(subscription.data) this.labelPatternsParamsDataUpdated(subscription.data);
} }
} }
}; };
@ -918,22 +918,22 @@ export class TbFlot {
} }
private substituteLabelPatterns(series: TbFlotSeries, seriesIndex: number) { 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; return item.datasource.entityId === series.datasource.entityId;
}); });
let label = createLabelFromDatasource(series.datasource, series.dataKey.pattern); let label = createLabelFromDatasource(series.datasource, series.dataKey.pattern);
for (let i = 0; i < seriesLabelPatternsSourcesData.length; i++) { for (let i = 0; i < seriesLabelPatternsSourcesData.length; i++) {
let keyData = seriesLabelPatternsSourcesData[i]; const keyData = seriesLabelPatternsSourcesData[i];
if (keyData && keyData.data && keyData.data[0]) { if (keyData && keyData.data && keyData.data[0]) {
let attrValue = keyData.data[0][1]; const attrValue = keyData.data[0][1];
let attrName = keyData.dataKey.name; const attrName = keyData.dataKey.name;
if (isDefined(attrValue) && (attrValue !== null)) { if (isDefined(attrValue) && (attrValue !== null)) {
label = insertVariable(label, attrName, attrValue); label = insertVariable(label, attrName, attrValue);
} }
} }
} }
if (isDefined(this.subscription.legendData)) { 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; return key.dataIndex === seriesIndex;
}); });
if (targetLegendKeyIndex !== -1) { if (targetLegendKeyIndex !== -1) {
@ -1098,7 +1098,7 @@ export class TbFlot {
flex: '1' flex: '1'
}); });
let columnContent = ''; 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) { if (i >= hoverData.seriesHover.length) {
break; break;
} }
@ -1287,7 +1287,7 @@ export class TbFlot {
let minTimeHistorical: any; let minTimeHistorical: any;
let hoverData: TbFlotSeriesHoverInfo; let hoverData: TbFlotSeriesHoverInfo;
let value: any; let value: any;
let lastValue: any; let lastValue = 0;
let minDistanceHistorical: number; let minDistanceHistorical: number;
const results: TbFlotHoverInfo[] = [{ const results: TbFlotHoverInfo[] = [{
seriesHover: [] seriesHover: []

2
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 marker: Marker = this.markers.get(key);
const location = this.convertPosition(data); const location = this.convertPosition(data);
marker.updateMarkerPosition(location); marker.updateMarkerPosition(location);
marker.setDataSources(data, dataSources);
if (settings.showTooltip) { if (settings.showTooltip) {
marker.updateMarkerTooltip(data); marker.updateMarkerTooltip(data);
} }
marker.setDataSources(data, dataSources);
marker.updateMarkerIcon(settings); marker.updateMarkerIcon(settings);
return marker; return marker;
} }

Loading…
Cancel
Save