Showing
6 changed files
with
77 additions
and
4 deletions
... | ... | @@ -24,6 +24,7 @@ import org.thingsboard.server.dao.alarm.AlarmService; |
24 | 24 | import org.thingsboard.server.dao.asset.AssetService; |
25 | 25 | import org.thingsboard.server.dao.attributes.AttributesService; |
26 | 26 | import org.thingsboard.server.dao.customer.CustomerService; |
27 | +import org.thingsboard.server.dao.dashboard.DashboardService; | |
27 | 28 | import org.thingsboard.server.dao.device.DeviceService; |
28 | 29 | import org.thingsboard.server.dao.edge.EdgeService; |
29 | 30 | import org.thingsboard.server.dao.entityview.EntityViewService; |
... | ... | @@ -67,5 +68,9 @@ public class EdgeContextComponent { |
67 | 68 | |
68 | 69 | @Lazy |
69 | 70 | @Autowired |
71 | + private DashboardService dashboardService; | |
72 | + | |
73 | + @Lazy | |
74 | + @Autowired | |
70 | 75 | private ActorService actorService; |
71 | 76 | } | ... | ... |
... | ... | @@ -25,12 +25,14 @@ import com.google.protobuf.ByteString; |
25 | 25 | import io.grpc.stub.StreamObserver; |
26 | 26 | import lombok.Data; |
27 | 27 | import lombok.extern.slf4j.Slf4j; |
28 | +import org.thingsboard.server.common.data.Customer; | |
28 | 29 | import org.thingsboard.server.common.data.Dashboard; |
29 | 30 | import org.thingsboard.server.common.data.DataConstants; |
30 | 31 | import org.thingsboard.server.common.data.Device; |
31 | 32 | import org.thingsboard.server.common.data.EntityType; |
32 | 33 | import org.thingsboard.server.common.data.EntityView; |
33 | 34 | import org.thingsboard.server.common.data.Event; |
35 | +import org.thingsboard.server.common.data.User; | |
34 | 36 | import org.thingsboard.server.common.data.alarm.Alarm; |
35 | 37 | import org.thingsboard.server.common.data.alarm.AlarmSeverity; |
36 | 38 | import org.thingsboard.server.common.data.alarm.AlarmStatus; |
... | ... | @@ -67,6 +69,7 @@ import org.thingsboard.server.gen.edge.AssetUpdateMsg; |
67 | 69 | import org.thingsboard.server.gen.edge.ConnectRequestMsg; |
68 | 70 | import org.thingsboard.server.gen.edge.ConnectResponseCode; |
69 | 71 | import org.thingsboard.server.gen.edge.ConnectResponseMsg; |
72 | +import org.thingsboard.server.gen.edge.CustomerUpdateMsg; | |
70 | 73 | import org.thingsboard.server.gen.edge.DashboardUpdateMsg; |
71 | 74 | import org.thingsboard.server.gen.edge.DeviceUpdateMsg; |
72 | 75 | import org.thingsboard.server.gen.edge.DownlinkMsg; |
... | ... | @@ -85,6 +88,7 @@ import org.thingsboard.server.gen.edge.RuleNodeProto; |
85 | 88 | import org.thingsboard.server.gen.edge.UpdateMsgType; |
86 | 89 | import org.thingsboard.server.gen.edge.UplinkMsg; |
87 | 90 | import org.thingsboard.server.gen.edge.UplinkResponseMsg; |
91 | +import org.thingsboard.server.gen.edge.UserUpdateMsg; | |
88 | 92 | import org.thingsboard.server.service.edge.EdgeContextComponent; |
89 | 93 | |
90 | 94 | import java.io.IOException; |
... | ... | @@ -212,7 +216,7 @@ public final class EdgeGrpcSession implements Cloneable { |
212 | 216 | } |
213 | 217 | |
214 | 218 | private void processCustomDownlinkMessage(EdgeQueueEntry entry) throws IOException { |
215 | - log.trace("Executing processCustomDownlinkMessage, entry [{}], msgType [{}]", entry); | |
219 | + log.trace("Executing processCustomDownlinkMessage, entry [{}]", entry); | |
216 | 220 | TbMsg tbMsg = objectMapper.readValue(entry.getData(), TbMsg.class); |
217 | 221 | String entityName = null; |
218 | 222 | switch (entry.getEntityType()) { |
... | ... | @@ -526,11 +530,25 @@ public final class EdgeGrpcSession implements Cloneable { |
526 | 530 | } |
527 | 531 | |
528 | 532 | private DashboardUpdateMsg constructDashboardUpdatedMsg(UpdateMsgType msgType, Dashboard dashboard) { |
533 | + dashboard = ctx.getDashboardService().findDashboardById(edge.getTenantId(), dashboard.getId()); | |
529 | 534 | DashboardUpdateMsg.Builder builder = DashboardUpdateMsg.newBuilder() |
530 | 535 | .setMsgType(msgType) |
531 | 536 | .setIdMSB(dashboard.getId().getId().getMostSignificantBits()) |
532 | 537 | .setIdLSB(dashboard.getId().getId().getLeastSignificantBits()) |
533 | - .setName(dashboard.getName()); | |
538 | + .setTitle(dashboard.getTitle()) | |
539 | + .setConfiguration(JacksonUtil.toString(dashboard.getConfiguration())); | |
540 | + return builder.build(); | |
541 | + } | |
542 | + | |
543 | + private CustomerUpdateMsg constructCustomerUpdatedMsg(UpdateMsgType msgType, Customer customer) { | |
544 | + CustomerUpdateMsg.Builder builder = CustomerUpdateMsg.newBuilder() | |
545 | + .setMsgType(msgType); | |
546 | + return builder.build(); | |
547 | + } | |
548 | + | |
549 | + private UserUpdateMsg constructUserUpdatedMsg(UpdateMsgType msgType, User user) { | |
550 | + UserUpdateMsg.Builder builder = UserUpdateMsg.newBuilder() | |
551 | + .setMsgType(msgType); | |
534 | 552 | return builder.build(); |
535 | 553 | } |
536 | 554 | ... | ... |
... | ... | @@ -16,5 +16,5 @@ |
16 | 16 | package org.thingsboard.server.common.data.edge; |
17 | 17 | |
18 | 18 | public enum EdgeQueueEntityType { |
19 | - DASHBOARD, ASSET, DEVICE, ENTITY_VIEW, ALARM, RULE_CHAIN, RULE_CHAIN_METADATA, EDGE | |
19 | + DASHBOARD, ASSET, DEVICE, ENTITY_VIEW, ALARM, RULE_CHAIN, RULE_CHAIN_METADATA, EDGE, USER, CUSTOMER | |
20 | 20 | } | ... | ... |
... | ... | @@ -52,6 +52,8 @@ message EntityUpdateMsg { |
52 | 52 | AssetUpdateMsg assetUpdateMsg = 5; |
53 | 53 | EntityViewUpdateMsg entityViewUpdateMsg = 6; |
54 | 54 | AlarmUpdateMsg alarmUpdateMsg = 7; |
55 | + UserUpdateMsg userUpdateMsg = 8; | |
56 | + CustomerUpdateMsg customerUpdateMsg = 9; | |
55 | 57 | } |
56 | 58 | |
57 | 59 | enum RequestMsgType { |
... | ... | @@ -82,6 +84,7 @@ message EdgeConfiguration { |
82 | 84 | string name = 5; |
83 | 85 | string routingKey = 6; |
84 | 86 | string type = 7; |
87 | + string cloudType = 8; | |
85 | 88 | } |
86 | 89 | |
87 | 90 | enum UpdateMsgType { |
... | ... | @@ -147,7 +150,8 @@ message DashboardUpdateMsg { |
147 | 150 | UpdateMsgType msgType = 1; |
148 | 151 | int64 idMSB = 2; |
149 | 152 | int64 idLSB = 3; |
150 | - string name = 4; | |
153 | + string title = 4; | |
154 | + string configuration = 5; | |
151 | 155 | } |
152 | 156 | |
153 | 157 | message DeviceUpdateMsg { |
... | ... | @@ -187,6 +191,37 @@ message AlarmUpdateMsg { |
187 | 191 | bool propagate = 13; |
188 | 192 | } |
189 | 193 | |
194 | +message CustomerUpdateMsg { | |
195 | + UpdateMsgType msgType = 1; | |
196 | + int64 idMSB = 2; | |
197 | + int64 idLSB = 3; | |
198 | + string title = 4; | |
199 | + string country = 5; | |
200 | + string state = 6; | |
201 | + string city = 7; | |
202 | + string address = 8; | |
203 | + string address2 = 9; | |
204 | + string zip = 10; | |
205 | + string phone = 11; | |
206 | + string email = 12; | |
207 | + string additionalInfo = 13; | |
208 | +} | |
209 | + | |
210 | +message UserUpdateMsg { | |
211 | + UpdateMsgType msgType = 1; | |
212 | + int64 idMSB = 2; | |
213 | + int64 idLSB = 3; | |
214 | + int64 customerIdMSB = 4; | |
215 | + int64 customerIdLSB = 5; | |
216 | + string email = 7; | |
217 | + string authority = 8; | |
218 | + string firstName = 9; | |
219 | + string lastName = 10; | |
220 | + string additionalInfo = 11; | |
221 | + bool enabled = 12; | |
222 | + string password = 13; | |
223 | +} | |
224 | + | |
190 | 225 | enum EntityType { |
191 | 226 | DEVICE = 0; |
192 | 227 | ASSET = 1; | ... | ... |
... | ... | @@ -29,6 +29,7 @@ import org.springframework.cache.annotation.Cacheable; |
29 | 29 | import org.springframework.stereotype.Service; |
30 | 30 | import org.springframework.util.StringUtils; |
31 | 31 | import org.thingsboard.server.common.data.Customer; |
32 | +import org.thingsboard.server.common.data.Dashboard; | |
32 | 33 | import org.thingsboard.server.common.data.DataConstants; |
33 | 34 | import org.thingsboard.server.common.data.Device; |
34 | 35 | import org.thingsboard.server.common.data.EntitySubtype; |
... | ... | @@ -549,6 +550,16 @@ public class BaseEdgeService extends AbstractEntityService implements EdgeServic |
549 | 550 | edgeId = new EdgeId(UUID.fromString(tbMsg.getMetaData().getValue("unassignedEdgeId"))); |
550 | 551 | pushEventToEdge(tenantId, edgeId, entityType, tbMsg, callback); |
551 | 552 | break; |
553 | + case DataConstants.ENTITY_DELETED: | |
554 | + case DataConstants.ENTITY_CREATED: | |
555 | + case DataConstants.ENTITY_UPDATED: | |
556 | + Dashboard dashboard = mapper.readValue(tbMsg.getData(), Dashboard.class); | |
557 | + if (dashboard.getAssignedEdges() != null && !dashboard.getAssignedEdges().isEmpty()) { | |
558 | + for (ShortEdgeInfo assignedEdge : dashboard.getAssignedEdges()) { | |
559 | + pushEventToEdge(tenantId, assignedEdge.getEdgeId(), EdgeQueueEntityType.DASHBOARD, tbMsg, callback); | |
560 | + } | |
561 | + } | |
562 | + break; | |
552 | 563 | } |
553 | 564 | } |
554 | 565 | ... | ... |
... | ... | @@ -184,6 +184,8 @@ |
184 | 184 | "filter-type-entity-view-type": "Entity View type", |
185 | 185 | "filter-type-entity-view-type-description": "Entity Views of type '{{entityView}}'", |
186 | 186 | "filter-type-entity-view-type-and-name-description": "Entity Views of type '{{entityView}}' and with name starting with '{{prefix}}'", |
187 | + "filter-type-edge-type": "Edge type", | |
188 | + "filter-type-edge-type-description": "Edges of type '{{edgeType}}'", | |
187 | 189 | "filter-type-relations-query": "Relations query", |
188 | 190 | "filter-type-relations-query-description": "{{entities}} that have {{relationType}} relation {{direction}} {{rootEntity}}", |
189 | 191 | "filter-type-asset-search-query": "Asset search query", |
... | ... | @@ -192,6 +194,8 @@ |
192 | 194 | "filter-type-device-search-query-description": "Devices with types {{deviceTypes}} that have {{relationType}} relation {{direction}} {{rootEntity}}", |
193 | 195 | "filter-type-entity-view-search-query": "Entity view search query", |
194 | 196 | "filter-type-entity-view-search-query-description": "Entity views with types {{entityViewTypes}} that have {{relationType}} relation {{direction}} {{rootEntity}}", |
197 | + "filter-type-edge-search-query": "Edge search query", | |
198 | + "filter-type-edge-search-query-description": "Edges with types {{edgeTypes}} that have {{relationType}} relation {{direction}} {{rootEntity}}", | |
195 | 199 | "entity-filter": "Entity filter", |
196 | 200 | "resolve-multiple": "Resolve as multiple entities", |
197 | 201 | "filter-type": "Filter type", | ... | ... |