Added dashboard support
This commit is contained in:
		
							parent
							
								
									44377d56ca
								
							
						
					
					
						commit
						0123a3520a
					
				@ -24,6 +24,7 @@ import org.thingsboard.server.dao.alarm.AlarmService;
 | 
			
		||||
import org.thingsboard.server.dao.asset.AssetService;
 | 
			
		||||
import org.thingsboard.server.dao.attributes.AttributesService;
 | 
			
		||||
import org.thingsboard.server.dao.customer.CustomerService;
 | 
			
		||||
import org.thingsboard.server.dao.dashboard.DashboardService;
 | 
			
		||||
import org.thingsboard.server.dao.device.DeviceService;
 | 
			
		||||
import org.thingsboard.server.dao.edge.EdgeService;
 | 
			
		||||
import org.thingsboard.server.dao.entityview.EntityViewService;
 | 
			
		||||
@ -65,6 +66,10 @@ public class EdgeContextComponent {
 | 
			
		||||
    @Autowired
 | 
			
		||||
    private AlarmService alarmService;
 | 
			
		||||
 | 
			
		||||
    @Lazy
 | 
			
		||||
    @Autowired
 | 
			
		||||
    private DashboardService dashboardService;
 | 
			
		||||
 | 
			
		||||
    @Lazy
 | 
			
		||||
    @Autowired
 | 
			
		||||
    private ActorService actorService;
 | 
			
		||||
 | 
			
		||||
@ -25,12 +25,14 @@ import com.google.protobuf.ByteString;
 | 
			
		||||
import io.grpc.stub.StreamObserver;
 | 
			
		||||
import lombok.Data;
 | 
			
		||||
import lombok.extern.slf4j.Slf4j;
 | 
			
		||||
import org.thingsboard.server.common.data.Customer;
 | 
			
		||||
import org.thingsboard.server.common.data.Dashboard;
 | 
			
		||||
import org.thingsboard.server.common.data.DataConstants;
 | 
			
		||||
import org.thingsboard.server.common.data.Device;
 | 
			
		||||
import org.thingsboard.server.common.data.EntityType;
 | 
			
		||||
import org.thingsboard.server.common.data.EntityView;
 | 
			
		||||
import org.thingsboard.server.common.data.Event;
 | 
			
		||||
import org.thingsboard.server.common.data.User;
 | 
			
		||||
import org.thingsboard.server.common.data.alarm.Alarm;
 | 
			
		||||
import org.thingsboard.server.common.data.alarm.AlarmSeverity;
 | 
			
		||||
import org.thingsboard.server.common.data.alarm.AlarmStatus;
 | 
			
		||||
@ -67,6 +69,7 @@ import org.thingsboard.server.gen.edge.AssetUpdateMsg;
 | 
			
		||||
import org.thingsboard.server.gen.edge.ConnectRequestMsg;
 | 
			
		||||
import org.thingsboard.server.gen.edge.ConnectResponseCode;
 | 
			
		||||
import org.thingsboard.server.gen.edge.ConnectResponseMsg;
 | 
			
		||||
import org.thingsboard.server.gen.edge.CustomerUpdateMsg;
 | 
			
		||||
import org.thingsboard.server.gen.edge.DashboardUpdateMsg;
 | 
			
		||||
import org.thingsboard.server.gen.edge.DeviceUpdateMsg;
 | 
			
		||||
import org.thingsboard.server.gen.edge.DownlinkMsg;
 | 
			
		||||
@ -85,6 +88,7 @@ import org.thingsboard.server.gen.edge.RuleNodeProto;
 | 
			
		||||
import org.thingsboard.server.gen.edge.UpdateMsgType;
 | 
			
		||||
import org.thingsboard.server.gen.edge.UplinkMsg;
 | 
			
		||||
import org.thingsboard.server.gen.edge.UplinkResponseMsg;
 | 
			
		||||
import org.thingsboard.server.gen.edge.UserUpdateMsg;
 | 
			
		||||
import org.thingsboard.server.service.edge.EdgeContextComponent;
 | 
			
		||||
 | 
			
		||||
import java.io.IOException;
 | 
			
		||||
@ -212,7 +216,7 @@ public final class EdgeGrpcSession implements Cloneable {
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    private void processCustomDownlinkMessage(EdgeQueueEntry entry) throws IOException {
 | 
			
		||||
        log.trace("Executing processCustomDownlinkMessage, entry [{}], msgType [{}]", entry);
 | 
			
		||||
        log.trace("Executing processCustomDownlinkMessage, entry [{}]", entry);
 | 
			
		||||
        TbMsg tbMsg = objectMapper.readValue(entry.getData(), TbMsg.class);
 | 
			
		||||
        String entityName = null;
 | 
			
		||||
        switch (entry.getEntityType()) {
 | 
			
		||||
@ -526,11 +530,25 @@ public final class EdgeGrpcSession implements Cloneable {
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    private DashboardUpdateMsg constructDashboardUpdatedMsg(UpdateMsgType msgType, Dashboard dashboard) {
 | 
			
		||||
        dashboard = ctx.getDashboardService().findDashboardById(edge.getTenantId(), dashboard.getId());
 | 
			
		||||
        DashboardUpdateMsg.Builder builder = DashboardUpdateMsg.newBuilder()
 | 
			
		||||
                .setMsgType(msgType)
 | 
			
		||||
                .setIdMSB(dashboard.getId().getId().getMostSignificantBits())
 | 
			
		||||
                .setIdLSB(dashboard.getId().getId().getLeastSignificantBits())
 | 
			
		||||
                .setName(dashboard.getName());
 | 
			
		||||
                .setTitle(dashboard.getTitle())
 | 
			
		||||
                .setConfiguration(JacksonUtil.toString(dashboard.getConfiguration()));
 | 
			
		||||
        return builder.build();
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    private CustomerUpdateMsg constructCustomerUpdatedMsg(UpdateMsgType msgType, Customer customer) {
 | 
			
		||||
        CustomerUpdateMsg.Builder builder = CustomerUpdateMsg.newBuilder()
 | 
			
		||||
                .setMsgType(msgType);
 | 
			
		||||
        return builder.build();
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    private UserUpdateMsg constructUserUpdatedMsg(UpdateMsgType msgType, User user) {
 | 
			
		||||
        UserUpdateMsg.Builder builder = UserUpdateMsg.newBuilder()
 | 
			
		||||
                .setMsgType(msgType);
 | 
			
		||||
        return builder.build();
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@ -16,5 +16,5 @@
 | 
			
		||||
package org.thingsboard.server.common.data.edge;
 | 
			
		||||
 | 
			
		||||
public enum EdgeQueueEntityType {
 | 
			
		||||
    DASHBOARD, ASSET, DEVICE, ENTITY_VIEW, ALARM, RULE_CHAIN, RULE_CHAIN_METADATA, EDGE
 | 
			
		||||
    DASHBOARD, ASSET, DEVICE, ENTITY_VIEW, ALARM, RULE_CHAIN, RULE_CHAIN_METADATA, EDGE, USER, CUSTOMER
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
@ -52,6 +52,8 @@ message EntityUpdateMsg {
 | 
			
		||||
  AssetUpdateMsg assetUpdateMsg = 5;
 | 
			
		||||
  EntityViewUpdateMsg entityViewUpdateMsg = 6;
 | 
			
		||||
  AlarmUpdateMsg alarmUpdateMsg = 7;
 | 
			
		||||
  UserUpdateMsg userUpdateMsg = 8;
 | 
			
		||||
  CustomerUpdateMsg customerUpdateMsg = 9;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
enum RequestMsgType {
 | 
			
		||||
@ -82,6 +84,7 @@ message EdgeConfiguration {
 | 
			
		||||
  string name = 5;
 | 
			
		||||
  string routingKey = 6;
 | 
			
		||||
  string type = 7;
 | 
			
		||||
  string cloudType = 8;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
enum UpdateMsgType {
 | 
			
		||||
@ -147,7 +150,8 @@ message DashboardUpdateMsg {
 | 
			
		||||
  UpdateMsgType msgType = 1;
 | 
			
		||||
  int64 idMSB = 2;
 | 
			
		||||
  int64 idLSB = 3;
 | 
			
		||||
  string name = 4;
 | 
			
		||||
  string title = 4;
 | 
			
		||||
  string configuration = 5;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
message DeviceUpdateMsg {
 | 
			
		||||
@ -187,6 +191,37 @@ message AlarmUpdateMsg {
 | 
			
		||||
  bool propagate = 13;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
message CustomerUpdateMsg {
 | 
			
		||||
  UpdateMsgType msgType = 1;
 | 
			
		||||
  int64 idMSB = 2;
 | 
			
		||||
  int64 idLSB = 3;
 | 
			
		||||
  string title = 4;
 | 
			
		||||
  string country = 5;
 | 
			
		||||
  string state = 6;
 | 
			
		||||
  string city = 7;
 | 
			
		||||
  string address = 8;
 | 
			
		||||
  string address2 = 9;
 | 
			
		||||
  string zip = 10;
 | 
			
		||||
  string phone = 11;
 | 
			
		||||
  string email = 12;
 | 
			
		||||
  string additionalInfo = 13;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
message UserUpdateMsg {
 | 
			
		||||
  UpdateMsgType msgType = 1;
 | 
			
		||||
  int64 idMSB = 2;
 | 
			
		||||
  int64 idLSB = 3;
 | 
			
		||||
  int64 customerIdMSB = 4;
 | 
			
		||||
  int64 customerIdLSB = 5;
 | 
			
		||||
  string email = 7;
 | 
			
		||||
  string authority = 8;
 | 
			
		||||
  string firstName = 9;
 | 
			
		||||
  string lastName = 10;
 | 
			
		||||
  string additionalInfo = 11;
 | 
			
		||||
  bool enabled = 12;
 | 
			
		||||
  string password = 13;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
enum EntityType {
 | 
			
		||||
    DEVICE = 0;
 | 
			
		||||
    ASSET = 1;
 | 
			
		||||
 | 
			
		||||
@ -29,6 +29,7 @@ import org.springframework.cache.annotation.Cacheable;
 | 
			
		||||
import org.springframework.stereotype.Service;
 | 
			
		||||
import org.springframework.util.StringUtils;
 | 
			
		||||
import org.thingsboard.server.common.data.Customer;
 | 
			
		||||
import org.thingsboard.server.common.data.Dashboard;
 | 
			
		||||
import org.thingsboard.server.common.data.DataConstants;
 | 
			
		||||
import org.thingsboard.server.common.data.Device;
 | 
			
		||||
import org.thingsboard.server.common.data.EntitySubtype;
 | 
			
		||||
@ -549,6 +550,16 @@ public class BaseEdgeService extends AbstractEntityService implements EdgeServic
 | 
			
		||||
                edgeId = new EdgeId(UUID.fromString(tbMsg.getMetaData().getValue("unassignedEdgeId")));
 | 
			
		||||
                pushEventToEdge(tenantId, edgeId, entityType, tbMsg, callback);
 | 
			
		||||
                break;
 | 
			
		||||
            case DataConstants.ENTITY_DELETED:
 | 
			
		||||
            case DataConstants.ENTITY_CREATED:
 | 
			
		||||
            case DataConstants.ENTITY_UPDATED:
 | 
			
		||||
                Dashboard dashboard = mapper.readValue(tbMsg.getData(), Dashboard.class);
 | 
			
		||||
                if (dashboard.getAssignedEdges() != null && !dashboard.getAssignedEdges().isEmpty()) {
 | 
			
		||||
                    for (ShortEdgeInfo assignedEdge : dashboard.getAssignedEdges()) {
 | 
			
		||||
                        pushEventToEdge(tenantId, assignedEdge.getEdgeId(), EdgeQueueEntityType.DASHBOARD, tbMsg, callback);
 | 
			
		||||
                    }
 | 
			
		||||
                }
 | 
			
		||||
                break;
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@ -184,6 +184,8 @@
 | 
			
		||||
        "filter-type-entity-view-type": "Entity View type",
 | 
			
		||||
        "filter-type-entity-view-type-description": "Entity Views of type '{{entityView}}'",
 | 
			
		||||
        "filter-type-entity-view-type-and-name-description": "Entity Views of type '{{entityView}}' and with name starting with '{{prefix}}'",
 | 
			
		||||
        "filter-type-edge-type": "Edge type",
 | 
			
		||||
        "filter-type-edge-type-description": "Edges of type '{{edgeType}}'",
 | 
			
		||||
        "filter-type-relations-query": "Relations query",
 | 
			
		||||
        "filter-type-relations-query-description": "{{entities}} that have {{relationType}} relation {{direction}} {{rootEntity}}",
 | 
			
		||||
        "filter-type-asset-search-query": "Asset search query",
 | 
			
		||||
@ -192,6 +194,8 @@
 | 
			
		||||
        "filter-type-device-search-query-description": "Devices with types {{deviceTypes}} that have {{relationType}} relation {{direction}} {{rootEntity}}",
 | 
			
		||||
        "filter-type-entity-view-search-query": "Entity view search query",
 | 
			
		||||
        "filter-type-entity-view-search-query-description": "Entity views with types {{entityViewTypes}} that have {{relationType}} relation {{direction}} {{rootEntity}}",
 | 
			
		||||
        "filter-type-edge-search-query": "Edge search query",
 | 
			
		||||
        "filter-type-edge-search-query-description": "Edges with types {{edgeTypes}} that have {{relationType}} relation {{direction}} {{rootEntity}}",
 | 
			
		||||
        "entity-filter": "Entity filter",
 | 
			
		||||
        "resolve-multiple": "Resolve as multiple entities",
 | 
			
		||||
        "filter-type": "Filter type",
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user