Browse Source

Renaming notifications for edge. Minor refactoring

pull/10021/head
Andrii Landiak 3 years ago
parent
commit
d4d019beda
  1. 4
      application/src/main/java/org/thingsboard/server/service/edge/rpc/EdgeGrpcService.java
  2. 52
      application/src/main/java/org/thingsboard/server/service/edge/rpc/EdgeGrpcSession.java
  3. 26
      application/src/main/java/org/thingsboard/server/service/notification/rule/trigger/EdgeCommunicationFailureTriggerProcessor.java
  4. 18
      application/src/main/java/org/thingsboard/server/service/notification/rule/trigger/EdgeConnectionTriggerProcessor.java
  5. 12
      application/src/main/java/org/thingsboard/server/service/sync/ie/exporting/impl/NotificationRuleExportService.java
  6. 12
      application/src/main/java/org/thingsboard/server/service/sync/ie/importing/impl/NotificationRuleImportService.java
  7. 4
      common/data/src/main/java/org/thingsboard/server/common/data/notification/NotificationType.java
  8. 7
      common/data/src/main/java/org/thingsboard/server/common/data/notification/info/EdgeCommunicationFailureNotificationInfo.java
  9. 2
      common/data/src/main/java/org/thingsboard/server/common/data/notification/info/EdgeConnectionNotificationInfo.java
  10. 11
      common/data/src/main/java/org/thingsboard/server/common/data/notification/rule/trigger/EdgeCommunicationFailureTrigger.java
  11. 7
      common/data/src/main/java/org/thingsboard/server/common/data/notification/rule/trigger/EdgeConnectionTrigger.java
  12. 4
      common/data/src/main/java/org/thingsboard/server/common/data/notification/rule/trigger/config/EdgeCommunicationFailureNotificationRuleTriggerConfig.java
  13. 5
      common/data/src/main/java/org/thingsboard/server/common/data/notification/rule/trigger/config/EdgeConnectionNotificationRuleTriggerConfig.java
  14. 4
      common/data/src/main/java/org/thingsboard/server/common/data/notification/rule/trigger/config/NotificationRuleTriggerConfig.java
  15. 4
      common/data/src/main/java/org/thingsboard/server/common/data/notification/rule/trigger/config/NotificationRuleTriggerType.java
  16. 3
      common/data/src/main/java/org/thingsboard/server/common/data/util/TemplateUtils.java
  17. 14
      dao/src/main/java/org/thingsboard/server/dao/notification/DefaultNotificationSettingsService.java
  18. 39
      dao/src/main/java/org/thingsboard/server/dao/notification/DefaultNotifications.java
  19. 18
      ui-ngx/src/app/modules/home/pages/notification/rule/rule-notification-dialog.component.html
  20. 18
      ui-ngx/src/app/modules/home/pages/notification/rule/rule-notification-dialog.component.ts
  21. 8
      ui-ngx/src/app/shared/models/edge.models.ts
  22. 24
      ui-ngx/src/app/shared/models/notification.models.ts
  23. 10
      ui-ngx/src/assets/help/en_US/notification/edge_communication_failure.md
  24. 17
      ui-ngx/src/assets/help/en_US/notification/edge_connection.md
  25. 16
      ui-ngx/src/assets/locale/locale.constant-en_US.json

4
application/src/main/java/org/thingsboard/server/service/edge/rpc/EdgeGrpcService.java

@ -38,7 +38,7 @@ import org.thingsboard.server.common.data.kv.BasicTsKvEntry;
import org.thingsboard.server.common.data.kv.BooleanDataEntry;
import org.thingsboard.server.common.data.kv.LongDataEntry;
import org.thingsboard.server.common.data.msg.TbMsgType;
import org.thingsboard.server.common.data.notification.rule.trigger.EdgeConnectivityTrigger;
import org.thingsboard.server.common.data.notification.rule.trigger.EdgeConnectionTrigger;
import org.thingsboard.server.common.msg.TbMsg;
import org.thingsboard.server.common.msg.TbMsgDataType;
import org.thingsboard.server.common.msg.TbMsgMetaData;
@ -467,7 +467,7 @@ public class EdgeGrpcService extends EdgeRpcServiceGrpc.EdgeRpcServiceImplBase i
edgeState.put(DefaultDeviceStateService.ACTIVITY_STATE, false);
edgeState.put(DefaultDeviceStateService.LAST_DISCONNECT_TIME, ts);
}
ctx.getNotificationRuleProcessor().process(EdgeConnectivityTrigger.builder()
ctx.getNotificationRuleProcessor().process(EdgeConnectionTrigger.builder()
.tenantId(tenantId)
.customerId(edge.getCustomerId())
.edgeId(edgeId)

52
application/src/main/java/org/thingsboard/server/service/edge/rpc/EdgeGrpcSession.java

@ -35,7 +35,7 @@ import org.thingsboard.server.common.data.kv.AttributeKvEntry;
import org.thingsboard.server.common.data.kv.BaseAttributeKvEntry;
import org.thingsboard.server.common.data.kv.LongDataEntry;
import org.thingsboard.server.common.data.kv.StringDataEntry;
import org.thingsboard.server.common.data.notification.rule.trigger.EdgeFailureTrigger;
import org.thingsboard.server.common.data.notification.rule.trigger.EdgeCommunicationFailureTrigger;
import org.thingsboard.server.common.data.page.PageData;
import org.thingsboard.server.common.data.page.PageLink;
import org.thingsboard.server.common.data.page.SortOrder;
@ -466,22 +466,24 @@ public final class EdgeGrpcSession implements Closeable {
if (isConnected() && sessionState.getPendingMsgsMap().values().size() > 0) {
List<DownlinkMsg> copy = new ArrayList<>(sessionState.getPendingMsgsMap().values());
if (attempt > 1) {
String errorMsg = String.format("Failed to deliver the batch: {%s}", copy);
String error = "Failed to deliver the batch";
String failureMsg = String.format("{%s}: {%s}", error, copy);
if (attempt == 2) {
// Send a failure notification only on the second attempt.
// This ensures that failure alerts are sent just once to avoid redundant notifications.
ctx.getNotificationRuleProcessor().process(EdgeFailureTrigger.builder().tenantId(tenantId)
.edgeId(edge.getId()).customerId(edge.getCustomerId()).edgeName(edge.getName()).errorMsg(errorMsg).build());
ctx.getNotificationRuleProcessor().process(EdgeCommunicationFailureTrigger.builder().tenantId(tenantId)
.edgeId(edge.getId()).customerId(edge.getCustomerId()).edgeName(edge.getName()).failureMsg(failureMsg).error(error).build());
}
log.warn("[{}][{}] {}, attempt: {}", this.tenantId, this.sessionId, errorMsg, attempt);
log.warn("[{}][{}] {}, attempt: {}", this.tenantId, this.sessionId, failureMsg, attempt);
}
log.trace("[{}][{}][{}] downlink msg(s) are going to be send.", this.tenantId, this.sessionId, copy.size());
for (DownlinkMsg downlinkMsg : copy) {
if (this.clientMaxInboundMessageSize != 0 && downlinkMsg.getSerializedSize() > this.clientMaxInboundMessageSize) {
log.error("[{}][{}][{}] Downlink msg size [{}] exceeds client max inbound message size [{}]. Skipping this message. " +
"Please increase value of CLOUD_RPC_MAX_INBOUND_MESSAGE_SIZE env variable on the edge and restart it." +
"Message {}", this.tenantId, edge.getId(), this.sessionId, downlinkMsg.getSerializedSize(),
this.clientMaxInboundMessageSize, downlinkMsg);
String message = String.format("Downlink msg size [{%s}] exceeds client max inbound message size [{%s}]. " +
"Please increase value of CLOUD_RPC_MAX_INBOUND_MESSAGE_SIZE env variable on the edge and restart it.", downlinkMsg.getSerializedSize(), this.clientMaxInboundMessageSize);
log.error("[{}][{}][{}] {} Message {}", this.tenantId, edge.getId(), this.sessionId, message, downlinkMsg);
ctx.getNotificationRuleProcessor().process(EdgeCommunicationFailureTrigger.builder().tenantId(tenantId)
.edgeId(edge.getId()).customerId(edge.getCustomerId()).edgeName(edge.getName()).failureMsg(message).error(message).build());
sessionState.getPendingMsgsMap().remove(downlinkMsg.getDownlinkMsgId());
} else {
sendDownlinkMsg(ResponseMsg.newBuilder()
@ -492,11 +494,12 @@ public final class EdgeGrpcSession implements Closeable {
if (attempt < MAX_DOWNLINK_ATTEMPTS) {
scheduleDownlinkMsgsPackSend(attempt + 1);
} else {
String errorMsg = String.format("Failed to deliver messages: %s", copy);
String failureMsg = String.format("Failed to deliver messages: %s", copy);
log.warn("[{}][{}] Failed to deliver the batch after {} attempts. Next messages are going to be discarded {}",
this.tenantId, this.sessionId, MAX_DOWNLINK_ATTEMPTS, copy);
ctx.getNotificationRuleProcessor().process(EdgeFailureTrigger.builder().tenantId(tenantId).edgeId(edge.getId())
.customerId(edge.getCustomerId()).edgeName(edge.getName()).errorMsg(errorMsg).build());
ctx.getNotificationRuleProcessor().process(EdgeCommunicationFailureTrigger.builder().tenantId(tenantId).edgeId(edge.getId())
.customerId(edge.getCustomerId()).edgeName(edge.getName()).failureMsg(failureMsg)
.error("Failed to deliver messages after " + MAX_DOWNLINK_ATTEMPTS + " attempts").build());
stopCurrentSendDownlinkMsgsTask(false);
}
} else {
@ -790,10 +793,10 @@ public final class EdgeGrpcSession implements Closeable {
}
}
} catch (Exception e) {
String errorMsg = String.format("Can't process uplink msg [%s] from edge", uplinkMsg);
String failureMsg = String.format("Can't process uplink msg [%s] from edge", uplinkMsg);
log.error("[{}][{}] Can't process uplink msg [{}]", this.tenantId, this.sessionId, uplinkMsg, e);
ctx.getNotificationRuleProcessor().process(EdgeFailureTrigger.builder().tenantId(tenantId).edgeId(edge.getId())
.customerId(edge.getCustomerId()).edgeName(edge.getName()).errorMsg(errorMsg).build());
ctx.getNotificationRuleProcessor().process(EdgeCommunicationFailureTrigger.builder().tenantId(tenantId).edgeId(edge.getId())
.customerId(edge.getCustomerId()).edgeName(edge.getName()).failureMsg(failureMsg).error(e.getMessage()).build());
return Futures.immediateFailedFuture(e);
}
return Futures.allAsList(result);
@ -817,21 +820,22 @@ public final class EdgeGrpcSession implements Closeable {
.setMaxInboundMessageSize(maxInboundMessageSize)
.build();
}
String errorMsg = String.format("Failed to validate the edge! Provided request secret: %s", request.getEdgeSecret());
ctx.getNotificationRuleProcessor().process(EdgeFailureTrigger.builder().tenantId(tenantId).edgeId(edge.getId())
.customerId(edge.getCustomerId()).edgeName(edge.getName()).errorMsg(errorMsg).build());
String error = "Failed to validate the edge!";
String failureMsg = String.format("{%s} Provided request secret: %s", error, request.getEdgeSecret());
ctx.getNotificationRuleProcessor().process(EdgeCommunicationFailureTrigger.builder().tenantId(tenantId).edgeId(edge.getId())
.customerId(edge.getCustomerId()).edgeName(edge.getName()).failureMsg(failureMsg).error(error).build());
return ConnectResponseMsg.newBuilder()
.setResponseCode(ConnectResponseCode.BAD_CREDENTIALS)
.setErrorMsg(errorMsg)
.setErrorMsg(failureMsg)
.setConfiguration(EdgeConfiguration.getDefaultInstance()).build();
} catch (Exception e) {
String errorMsg = "Failed to process edge connection!";
ctx.getNotificationRuleProcessor().process(EdgeFailureTrigger.builder().tenantId(tenantId).edgeId(edge.getId())
.customerId(edge.getCustomerId()).edgeName(edge.getName()).errorMsg(errorMsg).build());
log.error(errorMsg, e);
String failureMsg = "Failed to process edge connection!";
ctx.getNotificationRuleProcessor().process(EdgeCommunicationFailureTrigger.builder().tenantId(tenantId).edgeId(edge.getId())
.customerId(edge.getCustomerId()).edgeName(edge.getName()).failureMsg(failureMsg).error(e.getMessage()).build());
log.error(failureMsg, e);
return ConnectResponseMsg.newBuilder()
.setResponseCode(ConnectResponseCode.SERVER_UNAVAILABLE)
.setErrorMsg(errorMsg)
.setErrorMsg(failureMsg)
.setConfiguration(EdgeConfiguration.getDefaultInstance()).build();
}
}

26
application/src/main/java/org/thingsboard/server/service/notification/rule/trigger/EdgeFailureTriggerProcessor.java → application/src/main/java/org/thingsboard/server/service/notification/rule/trigger/EdgeCommunicationFailureTriggerProcessor.java

@ -18,18 +18,18 @@ package org.thingsboard.server.service.notification.rule.trigger;
import lombok.RequiredArgsConstructor;
import org.apache.commons.collections.CollectionUtils;
import org.springframework.stereotype.Service;
import org.thingsboard.server.common.data.notification.info.EdgeFailureNotificationInfo;
import org.thingsboard.server.common.data.notification.info.EdgeCommunicationFailureNotificationInfo;
import org.thingsboard.server.common.data.notification.info.RuleOriginatedNotificationInfo;
import org.thingsboard.server.common.data.notification.rule.trigger.EdgeFailureTrigger;
import org.thingsboard.server.common.data.notification.rule.trigger.config.EdgeFailureNotificationRuleTriggerConfig;
import org.thingsboard.server.common.data.notification.rule.trigger.EdgeCommunicationFailureTrigger;
import org.thingsboard.server.common.data.notification.rule.trigger.config.EdgeCommunicationFailureNotificationRuleTriggerConfig;
import org.thingsboard.server.common.data.notification.rule.trigger.config.NotificationRuleTriggerType;
@Service
@RequiredArgsConstructor
public class EdgeFailureTriggerProcessor implements NotificationRuleTriggerProcessor<EdgeFailureTrigger, EdgeFailureNotificationRuleTriggerConfig> {
public class EdgeCommunicationFailureTriggerProcessor implements NotificationRuleTriggerProcessor<EdgeCommunicationFailureTrigger, EdgeCommunicationFailureNotificationRuleTriggerConfig> {
@Override
public boolean matchesFilter(EdgeFailureTrigger trigger, EdgeFailureNotificationRuleTriggerConfig triggerConfig) {
public boolean matchesFilter(EdgeCommunicationFailureTrigger trigger, EdgeCommunicationFailureNotificationRuleTriggerConfig triggerConfig) {
if (CollectionUtils.isNotEmpty(triggerConfig.getEdges())) {
return !triggerConfig.getEdges().contains(trigger.getEdgeId().getId());
}
@ -37,18 +37,26 @@ public class EdgeFailureTriggerProcessor implements NotificationRuleTriggerProce
}
@Override
public RuleOriginatedNotificationInfo constructNotificationInfo(EdgeFailureTrigger trigger) {
return EdgeFailureNotificationInfo.builder()
public RuleOriginatedNotificationInfo constructNotificationInfo(EdgeCommunicationFailureTrigger trigger) {
return EdgeCommunicationFailureNotificationInfo.builder()
.tenantId(trigger.getTenantId())
.edgeId(trigger.getEdgeId())
.customerId(trigger.getCustomerId())
.edgeName(trigger.getEdgeName())
.errorMsg(trigger.getErrorMsg())
.failureMsg(truncateFailureMsg(trigger.getFailureMsg()))
.build();
}
@Override
public NotificationRuleTriggerType getTriggerType() {
return NotificationRuleTriggerType.EDGE_FAILURE;
return NotificationRuleTriggerType.EDGE_COMMUNICATION_FAILURE;
}
private String truncateFailureMsg(String input) {
int maxLength = 800;
if (input != null && input.length() > maxLength) {
return input.substring(0, maxLength);
}
return input;
}
}

18
application/src/main/java/org/thingsboard/server/service/notification/rule/trigger/EdgeConnectivityTriggerProcessor.java → application/src/main/java/org/thingsboard/server/service/notification/rule/trigger/EdgeConnectionTriggerProcessor.java

@ -18,19 +18,19 @@ package org.thingsboard.server.service.notification.rule.trigger;
import lombok.RequiredArgsConstructor;
import org.apache.commons.collections.CollectionUtils;
import org.springframework.stereotype.Service;
import org.thingsboard.server.common.data.notification.info.EdgeConnectivityNotificationInfo;
import org.thingsboard.server.common.data.notification.info.EdgeConnectionNotificationInfo;
import org.thingsboard.server.common.data.notification.info.RuleOriginatedNotificationInfo;
import org.thingsboard.server.common.data.notification.rule.trigger.EdgeConnectivityTrigger;
import org.thingsboard.server.common.data.notification.rule.trigger.config.EdgeConnectivityNotificationRuleTriggerConfig;
import org.thingsboard.server.common.data.notification.rule.trigger.config.EdgeConnectivityNotificationRuleTriggerConfig.EdgeConnectivityEvent;
import org.thingsboard.server.common.data.notification.rule.trigger.EdgeConnectionTrigger;
import org.thingsboard.server.common.data.notification.rule.trigger.config.EdgeConnectionNotificationRuleTriggerConfig;
import org.thingsboard.server.common.data.notification.rule.trigger.config.EdgeConnectionNotificationRuleTriggerConfig.EdgeConnectivityEvent;
import org.thingsboard.server.common.data.notification.rule.trigger.config.NotificationRuleTriggerType;
@Service
@RequiredArgsConstructor
public class EdgeConnectivityTriggerProcessor implements NotificationRuleTriggerProcessor<EdgeConnectivityTrigger, EdgeConnectivityNotificationRuleTriggerConfig> {
public class EdgeConnectionTriggerProcessor implements NotificationRuleTriggerProcessor<EdgeConnectionTrigger, EdgeConnectionNotificationRuleTriggerConfig> {
@Override
public boolean matchesFilter(EdgeConnectivityTrigger trigger, EdgeConnectivityNotificationRuleTriggerConfig triggerConfig) {
public boolean matchesFilter(EdgeConnectionTrigger trigger, EdgeConnectionNotificationRuleTriggerConfig triggerConfig) {
EdgeConnectivityEvent event = trigger.isConnected() ? EdgeConnectivityEvent.CONNECTED : EdgeConnectivityEvent.DISCONNECTED;
if (CollectionUtils.isEmpty(triggerConfig.getNotifyOn()) || !triggerConfig.getNotifyOn().contains(event)) {
return false;
@ -42,8 +42,8 @@ public class EdgeConnectivityTriggerProcessor implements NotificationRuleTrigger
}
@Override
public RuleOriginatedNotificationInfo constructNotificationInfo(EdgeConnectivityTrigger trigger) {
return EdgeConnectivityNotificationInfo.builder()
public RuleOriginatedNotificationInfo constructNotificationInfo(EdgeConnectionTrigger trigger) {
return EdgeConnectionNotificationInfo.builder()
.eventType(trigger.isConnected() ? "connected" : "disconnected")
.tenantId(trigger.getTenantId())
.customerId(trigger.getCustomerId())
@ -54,7 +54,7 @@ public class EdgeConnectivityTriggerProcessor implements NotificationRuleTrigger
@Override
public NotificationRuleTriggerType getTriggerType() {
return NotificationRuleTriggerType.EDGE_CONNECTIVITY;
return NotificationRuleTriggerType.EDGE_CONNECTION;
}
}

12
application/src/main/java/org/thingsboard/server/service/sync/ie/exporting/impl/NotificationRuleExportService.java

@ -29,8 +29,8 @@ import org.thingsboard.server.common.data.notification.rule.EscalatedNotificatio
import org.thingsboard.server.common.data.notification.rule.NotificationRule;
import org.thingsboard.server.common.data.notification.rule.NotificationRuleRecipientsConfig;
import org.thingsboard.server.common.data.notification.rule.trigger.config.DeviceActivityNotificationRuleTriggerConfig;
import org.thingsboard.server.common.data.notification.rule.trigger.config.EdgeConnectivityNotificationRuleTriggerConfig;
import org.thingsboard.server.common.data.notification.rule.trigger.config.EdgeFailureNotificationRuleTriggerConfig;
import org.thingsboard.server.common.data.notification.rule.trigger.config.EdgeConnectionNotificationRuleTriggerConfig;
import org.thingsboard.server.common.data.notification.rule.trigger.config.EdgeCommunicationFailureNotificationRuleTriggerConfig;
import org.thingsboard.server.common.data.notification.rule.trigger.config.NotificationRuleTriggerConfig;
import org.thingsboard.server.common.data.notification.rule.trigger.config.RuleEngineComponentLifecycleEventNotificationRuleTriggerConfig;
import org.thingsboard.server.common.data.sync.ie.EntityExportData;
@ -75,13 +75,13 @@ public class NotificationRuleExportService<I extends EntityId, E extends Exporta
}
break;
}
case EDGE_CONNECTIVITY: {
EdgeConnectivityNotificationRuleTriggerConfig triggerConfig = (EdgeConnectivityNotificationRuleTriggerConfig) ruleTriggerConfig;
case EDGE_CONNECTION: {
EdgeConnectionNotificationRuleTriggerConfig triggerConfig = (EdgeConnectionNotificationRuleTriggerConfig) ruleTriggerConfig;
triggerConfig.setEdges(null);
break;
}
case EDGE_FAILURE: {
EdgeFailureNotificationRuleTriggerConfig triggerConfig = (EdgeFailureNotificationRuleTriggerConfig) ruleTriggerConfig;
case EDGE_COMMUNICATION_FAILURE: {
EdgeCommunicationFailureNotificationRuleTriggerConfig triggerConfig = (EdgeCommunicationFailureNotificationRuleTriggerConfig) ruleTriggerConfig;
triggerConfig.setEdges(null);
break;
}

12
application/src/main/java/org/thingsboard/server/service/sync/ie/importing/impl/NotificationRuleImportService.java

@ -33,8 +33,8 @@ import org.thingsboard.server.common.data.notification.rule.EscalatedNotificatio
import org.thingsboard.server.common.data.notification.rule.NotificationRule;
import org.thingsboard.server.common.data.notification.rule.NotificationRuleRecipientsConfig;
import org.thingsboard.server.common.data.notification.rule.trigger.config.DeviceActivityNotificationRuleTriggerConfig;
import org.thingsboard.server.common.data.notification.rule.trigger.config.EdgeConnectivityNotificationRuleTriggerConfig;
import org.thingsboard.server.common.data.notification.rule.trigger.config.EdgeFailureNotificationRuleTriggerConfig;
import org.thingsboard.server.common.data.notification.rule.trigger.config.EdgeConnectionNotificationRuleTriggerConfig;
import org.thingsboard.server.common.data.notification.rule.trigger.config.EdgeCommunicationFailureNotificationRuleTriggerConfig;
import org.thingsboard.server.common.data.notification.rule.trigger.config.NotificationRuleTriggerConfig;
import org.thingsboard.server.common.data.notification.rule.trigger.config.NotificationRuleTriggerType;
import org.thingsboard.server.common.data.notification.rule.trigger.config.RuleEngineComponentLifecycleEventNotificationRuleTriggerConfig;
@ -98,13 +98,13 @@ public class NotificationRuleImportService extends BaseEntityImportService<Notif
}
break;
}
case EDGE_CONNECTIVITY: {
EdgeConnectivityNotificationRuleTriggerConfig triggerConfig = (EdgeConnectivityNotificationRuleTriggerConfig) ruleTriggerConfig;
case EDGE_CONNECTION: {
EdgeConnectionNotificationRuleTriggerConfig triggerConfig = (EdgeConnectionNotificationRuleTriggerConfig) ruleTriggerConfig;
triggerConfig.setEdges(null);
break;
}
case EDGE_FAILURE: {
EdgeFailureNotificationRuleTriggerConfig triggerConfig = (EdgeFailureNotificationRuleTriggerConfig) ruleTriggerConfig;
case EDGE_COMMUNICATION_FAILURE: {
EdgeCommunicationFailureNotificationRuleTriggerConfig triggerConfig = (EdgeCommunicationFailureNotificationRuleTriggerConfig) ruleTriggerConfig;
triggerConfig.setEdges(null);
break;
}

4
common/data/src/main/java/org/thingsboard/server/common/data/notification/NotificationType.java

@ -29,6 +29,6 @@ public enum NotificationType {
API_USAGE_LIMIT,
RULE_NODE,
RATE_LIMITS,
EDGE_CONNECTIVITY,
EDGE_FAILURE
EDGE_CONNECTION,
EDGE_COMMUNICATION_FAILURE
}

7
common/data/src/main/java/org/thingsboard/server/common/data/notification/info/EdgeFailureNotificationInfo.java → common/data/src/main/java/org/thingsboard/server/common/data/notification/info/EdgeCommunicationFailureNotificationInfo.java

@ -19,7 +19,6 @@ import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.thingsboard.server.common.data.EntityType;
import org.thingsboard.server.common.data.id.CustomerId;
import org.thingsboard.server.common.data.id.EdgeId;
import org.thingsboard.server.common.data.id.EntityId;
@ -33,13 +32,13 @@ import static org.thingsboard.server.common.data.util.CollectionsUtil.mapOf;
@NoArgsConstructor
@AllArgsConstructor
@Builder
public class EdgeFailureNotificationInfo implements RuleOriginatedNotificationInfo {
public class EdgeCommunicationFailureNotificationInfo implements RuleOriginatedNotificationInfo {
private TenantId tenantId;
private CustomerId customerId;
private EdgeId edgeId;
private String edgeName;
private String errorMsg;
private String failureMsg;
@Override
public Map<String, String> getTemplateData() {
@ -47,7 +46,7 @@ public class EdgeFailureNotificationInfo implements RuleOriginatedNotificationIn
"tenantId", tenantId.toString(),
"edgeId", edgeId.toString(),
"edgeName", edgeName,
"errorMsg", errorMsg
"failureMsg", failureMsg
);
}

2
common/data/src/main/java/org/thingsboard/server/common/data/notification/info/EdgeConnectivityNotificationInfo.java → common/data/src/main/java/org/thingsboard/server/common/data/notification/info/EdgeConnectionNotificationInfo.java

@ -32,7 +32,7 @@ import static org.thingsboard.server.common.data.util.CollectionsUtil.mapOf;
@NoArgsConstructor
@AllArgsConstructor
@Builder
public class EdgeConnectivityNotificationInfo implements RuleOriginatedNotificationInfo {
public class EdgeConnectionNotificationInfo implements RuleOriginatedNotificationInfo {
private String eventType;
private TenantId tenantId;

11
common/data/src/main/java/org/thingsboard/server/common/data/notification/rule/trigger/EdgeFailureTrigger.java → common/data/src/main/java/org/thingsboard/server/common/data/notification/rule/trigger/EdgeCommunicationFailureTrigger.java

@ -27,13 +27,14 @@ import java.util.concurrent.TimeUnit;
@Data
@Builder
public class EdgeFailureTrigger implements NotificationRuleTrigger {
public class EdgeCommunicationFailureTrigger implements NotificationRuleTrigger {
private final TenantId tenantId;
private final CustomerId customerId;
private final EdgeId edgeId;
private final String edgeName;
private final String errorMsg;
private final String failureMsg;
private final String error;
@Override
public boolean deduplicate() {
@ -42,17 +43,17 @@ public class EdgeFailureTrigger implements NotificationRuleTrigger {
@Override
public String getDeduplicationKey() {
return String.join(":", NotificationRuleTrigger.super.getDeduplicationKey(), edgeName, errorMsg);
return String.join(":", NotificationRuleTrigger.super.getDeduplicationKey(), edgeId.toString(), error);
}
@Override
public long getDefaultDeduplicationDuration() {
return TimeUnit.HOURS.toMillis(2);
return TimeUnit.MINUTES.toMillis(30);
}
@Override
public NotificationRuleTriggerType getType() {
return NotificationRuleTriggerType.EDGE_FAILURE;
return NotificationRuleTriggerType.EDGE_COMMUNICATION_FAILURE;
}
@Override

7
common/data/src/main/java/org/thingsboard/server/common/data/notification/rule/trigger/EdgeConnectivityTrigger.java → common/data/src/main/java/org/thingsboard/server/common/data/notification/rule/trigger/EdgeConnectionTrigger.java

@ -23,12 +23,11 @@ import org.thingsboard.server.common.data.id.EntityId;
import org.thingsboard.server.common.data.id.TenantId;
import org.thingsboard.server.common.data.notification.rule.trigger.config.NotificationRuleTriggerType;
import java.util.UUID;
import java.util.concurrent.TimeUnit;
@Data
@Builder
public class EdgeConnectivityTrigger implements NotificationRuleTrigger {
public class EdgeConnectionTrigger implements NotificationRuleTrigger {
private final TenantId tenantId;
private final CustomerId customerId;
@ -48,12 +47,12 @@ public class EdgeConnectivityTrigger implements NotificationRuleTrigger {
@Override
public long getDefaultDeduplicationDuration() {
return TimeUnit.HOURS.toMillis(3);
return TimeUnit.MINUTES.toMillis(30);
}
@Override
public NotificationRuleTriggerType getType() {
return NotificationRuleTriggerType.EDGE_CONNECTIVITY;
return NotificationRuleTriggerType.EDGE_CONNECTION;
}
@Override

4
common/data/src/main/java/org/thingsboard/server/common/data/notification/rule/trigger/config/EdgeFailureNotificationRuleTriggerConfig.java → common/data/src/main/java/org/thingsboard/server/common/data/notification/rule/trigger/config/EdgeCommunicationFailureNotificationRuleTriggerConfig.java

@ -27,13 +27,13 @@ import java.util.UUID;
@NoArgsConstructor
@AllArgsConstructor
@Builder
public class EdgeFailureNotificationRuleTriggerConfig implements NotificationRuleTriggerConfig {
public class EdgeCommunicationFailureNotificationRuleTriggerConfig implements NotificationRuleTriggerConfig {
private Set<UUID> edges; // if empty - all edges
@Override
public NotificationRuleTriggerType getTriggerType() {
return NotificationRuleTriggerType.EDGE_FAILURE;
return NotificationRuleTriggerType.EDGE_COMMUNICATION_FAILURE;
}
}

5
common/data/src/main/java/org/thingsboard/server/common/data/notification/rule/trigger/config/EdgeConnectivityNotificationRuleTriggerConfig.java → common/data/src/main/java/org/thingsboard/server/common/data/notification/rule/trigger/config/EdgeConnectionNotificationRuleTriggerConfig.java

@ -20,7 +20,6 @@ import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import javax.validation.constraints.NotEmpty;
import java.util.Set;
import java.util.UUID;
@ -28,14 +27,14 @@ import java.util.UUID;
@NoArgsConstructor
@AllArgsConstructor
@Builder
public class EdgeConnectivityNotificationRuleTriggerConfig implements NotificationRuleTriggerConfig {
public class EdgeConnectionNotificationRuleTriggerConfig implements NotificationRuleTriggerConfig {
private Set<UUID> edges; // if empty - all edges
private Set<EdgeConnectivityEvent> notifyOn;
@Override
public NotificationRuleTriggerType getTriggerType() {
return NotificationRuleTriggerType.EDGE_CONNECTIVITY;
return NotificationRuleTriggerType.EDGE_CONNECTION;
}
public enum EdgeConnectivityEvent {

4
common/data/src/main/java/org/thingsboard/server/common/data/notification/rule/trigger/config/NotificationRuleTriggerConfig.java

@ -36,8 +36,8 @@ import java.io.Serializable;
@Type(value = EntitiesLimitNotificationRuleTriggerConfig.class, name = "ENTITIES_LIMIT"),
@Type(value = ApiUsageLimitNotificationRuleTriggerConfig.class, name = "API_USAGE_LIMIT"),
@Type(value = RateLimitsNotificationRuleTriggerConfig.class, name = "RATE_LIMITS"),
@Type(value = EdgeConnectivityNotificationRuleTriggerConfig.class, name = "EDGE_CONNECTIVITY"),
@Type(value = EdgeFailureNotificationRuleTriggerConfig.class, name = "EDGE_FAILURE"),
@Type(value = EdgeConnectionNotificationRuleTriggerConfig.class, name = "EDGE_CONNECTION"),
@Type(value = EdgeCommunicationFailureNotificationRuleTriggerConfig.class, name = "EDGE_COMMUNICATION_FAILURE"),
})
public interface NotificationRuleTriggerConfig extends Serializable {

4
common/data/src/main/java/org/thingsboard/server/common/data/notification/rule/trigger/config/NotificationRuleTriggerType.java

@ -26,8 +26,8 @@ public enum NotificationRuleTriggerType {
ALARM_ASSIGNMENT,
DEVICE_ACTIVITY,
RULE_ENGINE_COMPONENT_LIFECYCLE_EVENT,
EDGE_CONNECTIVITY,
EDGE_FAILURE,
EDGE_CONNECTION,
EDGE_COMMUNICATION_FAILURE,
NEW_PLATFORM_VERSION(false),
ENTITIES_LIMIT(false),
API_USAGE_LIMIT(false),

3
common/data/src/main/java/org/thingsboard/server/common/data/util/TemplateUtils.java

@ -19,6 +19,7 @@ import org.apache.commons.lang3.StringUtils;
import java.util.Map;
import java.util.function.UnaryOperator;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import static com.google.common.base.Strings.nullToEmpty;
@ -49,7 +50,7 @@ public class TemplateUtils {
value = FUNCTIONS.get(function).apply(value);
}
}
return value;
return Matcher.quoteReplacement(value);
});
}

14
dao/src/main/java/org/thingsboard/server/dao/notification/DefaultNotificationSettingsService.java

@ -189,8 +189,8 @@ public class DefaultNotificationSettingsService implements NotificationSettingsS
defaultNotifications.create(tenantId, DefaultNotifications.alarmComment, tenantAdmins.getId());
defaultNotifications.create(tenantId, DefaultNotifications.alarmAssignment, affectedUser.getId());
defaultNotifications.create(tenantId, DefaultNotifications.ruleEngineComponentLifecycleFailure, tenantAdmins.getId());
defaultNotifications.create(tenantId, DefaultNotifications.edgeConnectivity, tenantAdmins.getId());
defaultNotifications.create(tenantId, DefaultNotifications.edgeFailure, tenantAdmins.getId());
defaultNotifications.create(tenantId, DefaultNotifications.edgeConnection, tenantAdmins.getId());
defaultNotifications.create(tenantId, DefaultNotifications.edgeCommunicationFailures, tenantAdmins.getId());
}
@Override
@ -210,7 +210,7 @@ public class DefaultNotificationSettingsService implements NotificationSettingsS
defaultNotifications.create(tenantId, DefaultNotifications.exceededPerEntityRateLimits, affectedTenantAdmins.getId());
defaultNotifications.create(tenantId, DefaultNotifications.exceededRateLimitsForSysadmin, sysAdmins.getId());
} else {
List<NotificationType> requiredNotificationTypes = List.of(NotificationType.EDGE_CONNECTIVITY, NotificationType.EDGE_FAILURE);
List<NotificationType> requiredNotificationTypes = List.of(NotificationType.EDGE_CONNECTION, NotificationType.EDGE_COMMUNICATION_FAILURE);
List<NotificationType> existingNotificationTypes = notificationTemplateService.findNotificationTemplatesByTenantIdAndNotificationTypes(
tenantId, requiredNotificationTypes, new PageLink(1))
.getData()
@ -227,11 +227,11 @@ public class DefaultNotificationSettingsService implements NotificationSettingsS
for (NotificationType type : requiredNotificationTypes) {
if (!existingNotificationTypes.contains(type)) {
switch (type) {
case EDGE_CONNECTIVITY:
defaultNotifications.create(tenantId, DefaultNotifications.edgeConnectivity, tenantAdmins.getId());
case EDGE_CONNECTION:
defaultNotifications.create(tenantId, DefaultNotifications.edgeConnection, tenantAdmins.getId());
break;
case EDGE_FAILURE:
defaultNotifications.create(tenantId, DefaultNotifications.edgeFailure, tenantAdmins.getId());
case EDGE_COMMUNICATION_FAILURE:
defaultNotifications.create(tenantId, DefaultNotifications.edgeCommunicationFailures, tenantAdmins.getId());
break;
}
}

39
dao/src/main/java/org/thingsboard/server/dao/notification/DefaultNotifications.java

@ -40,9 +40,9 @@ import org.thingsboard.server.common.data.notification.rule.trigger.config.Alarm
import org.thingsboard.server.common.data.notification.rule.trigger.config.ApiUsageLimitNotificationRuleTriggerConfig;
import org.thingsboard.server.common.data.notification.rule.trigger.config.DeviceActivityNotificationRuleTriggerConfig;
import org.thingsboard.server.common.data.notification.rule.trigger.config.DeviceActivityNotificationRuleTriggerConfig.DeviceEvent;
import org.thingsboard.server.common.data.notification.rule.trigger.config.EdgeConnectivityNotificationRuleTriggerConfig;
import org.thingsboard.server.common.data.notification.rule.trigger.config.EdgeConnectivityNotificationRuleTriggerConfig.EdgeConnectivityEvent;
import org.thingsboard.server.common.data.notification.rule.trigger.config.EdgeFailureNotificationRuleTriggerConfig;
import org.thingsboard.server.common.data.notification.rule.trigger.config.EdgeConnectionNotificationRuleTriggerConfig;
import org.thingsboard.server.common.data.notification.rule.trigger.config.EdgeConnectionNotificationRuleTriggerConfig.EdgeConnectivityEvent;
import org.thingsboard.server.common.data.notification.rule.trigger.config.EdgeCommunicationFailureNotificationRuleTriggerConfig;
import org.thingsboard.server.common.data.notification.rule.trigger.config.EntitiesLimitNotificationRuleTriggerConfig;
import org.thingsboard.server.common.data.notification.rule.trigger.config.EntityActionNotificationRuleTriggerConfig;
import org.thingsboard.server.common.data.notification.rule.trigger.config.NewPlatformVersionNotificationRuleTriggerConfig;
@ -328,34 +328,33 @@ public class DefaultNotifications {
.description("Send notification to tenant admins when any Rule chain or Rule node failed to start, update or stop")
.build())
.build();
public static final DefaultNotification edgeConnectivity = DefaultNotification.builder()
.name("Edge connectivity notification")
.type(NotificationType.EDGE_CONNECTIVITY)
.subject("Edge '${edgeName}' is ${eventType}")
public static final DefaultNotification edgeConnection = DefaultNotification.builder()
.name("Edge connection notification")
.type(NotificationType.EDGE_CONNECTION)
.subject("Edge connection status change")
.text("Edge '${edgeName}' is now ${eventType}")
.icon("info").color(null)
.button("Go to Edge").link("/edgeManagement/instances/${edgeId}")
.rule(DefaultRule.builder()
.name("Edge connectivity")
.enabled(false)
.triggerConfig(EdgeConnectivityNotificationRuleTriggerConfig.builder()
.name("Edge connection status change")
.triggerConfig(EdgeConnectionNotificationRuleTriggerConfig.builder()
.edges(null)
.notifyOn(Set.of(EdgeConnectivityEvent.CONNECTED, EdgeConnectivityEvent.DISCONNECTED))
.build())
.description("Send notification to tenant admins when Edge changes its connectivity state")
.description("Send notification to tenant admins when the connection status between TB and Edge changes")
.build())
.build();
public static final DefaultNotification edgeFailure = DefaultNotification.builder()
.name("Edge error notification")
.type(NotificationType.EDGE_FAILURE)
.subject("Edge '${edgeName}' received error")
.text("Error message: '${errorMsg}'")
.icon("error").color(null)
public static final DefaultNotification edgeCommunicationFailures = DefaultNotification.builder()
.name("Edge communication failure notification")
.type(NotificationType.EDGE_COMMUNICATION_FAILURE)
.subject("Edge '${edgeName}' communication failure occured")
.text("Failure message: '${failureMsg}'")
.icon("error").color(RED_COLOR)
.button("Go to Edge").link("/edgeManagement/instances/${edgeId}")
.rule(DefaultRule.builder()
.name("Edge error")
.triggerConfig(EdgeFailureNotificationRuleTriggerConfig.builder().edges(null).build())
.description("Send notification to tenant admins or to assigned customers to Edge when error occurs")
.name("Edge communication failure")
.triggerConfig(EdgeCommunicationFailureNotificationRuleTriggerConfig.builder().edges(null).build())
.description("Send notification to tenant admins when communication failures occur")
.build())
.build();

18
ui-ngx/src/app/modules/home/pages/notification/rule/rule-notification-dialog.component.html

@ -408,10 +408,10 @@
</form>
</mat-step>
<mat-step [stepControl]="edgeConnectivityTemplateForm"
*ngIf="ruleNotificationForm.get('triggerType').value === triggerType.EDGE_CONNECTIVITY">
<mat-step [stepControl]="edgeConnectionTemplateForm"
*ngIf="ruleNotificationForm.get('triggerType').value === triggerType.EDGE_CONNECTION">
<ng-template matStepLabel>{{ 'notification.edge-trigger-settings' | translate }}</ng-template>
<form [formGroup]="edgeConnectivityTemplateForm">
<form [formGroup]="edgeConnectionTemplateForm">
<section formGroupName="triggerConfig">
<fieldset class="fields-group tb-margin-before-field">
<legend translate>notification.filter</legend>
@ -426,9 +426,9 @@
<mat-form-field fxFlex class="mat-block" floatLabel="always">
<mat-label translate>notification.notify-on</mat-label>
<mat-select formControlName="notifyOn" multiple
placeholder="{{ !edgeConnectivityTemplateForm.get('triggerConfig.notifyOn').value?.length ? ('event.all-events' | translate) : '' }}">
<mat-option *ngFor="let edgeEvent of edgeConnectivityEvents" [value]="edgeEvent">
{{ edgeConnectivityEventTranslationMap.get(edgeEvent) | translate }}
placeholder="{{ !edgeConnectionTemplateForm.get('triggerConfig.notifyOn').value?.length ? ('event.all-events' | translate) : '' }}">
<mat-option *ngFor="let edgeEvent of edgeConnectionEvents" [value]="edgeEvent">
{{ edgeConnectionEventTranslationMap.get(edgeEvent) | translate }}
</mat-option>
</mat-select>
</mat-form-field>
@ -445,10 +445,10 @@
</form>
</mat-step>
<mat-step [stepControl]="edgeFailureTemplateForm"
*ngIf="ruleNotificationForm.get('triggerType').value === triggerType.EDGE_FAILURE">
<mat-step [stepControl]="edgeCommunicationFailureTemplateForm"
*ngIf="ruleNotificationForm.get('triggerType').value === triggerType.EDGE_COMMUNICATION_FAILURE">
<ng-template matStepLabel>{{ 'notification.edge-trigger-settings' | translate }}</ng-template>
<form [formGroup]="edgeFailureTemplateForm">
<form [formGroup]="edgeCommunicationFailureTemplateForm">
<section formGroupName="triggerConfig">
<fieldset class="fields-group tb-margin-before-field">
<legend translate>notification.filter</legend>

18
ui-ngx/src/app/modules/home/pages/notification/rule/rule-notification-dialog.component.ts

@ -68,7 +68,7 @@ import {
} from '@shared/models/api-usage.models';
import { LimitedApi, LimitedApiTranslationMap } from '@shared/models/limited-api.models';
import { StringItemsOption } from '@shared/components/string-items-list.component';
import { EdgeConnectivityEvent, EdgeConnectivityEventTranslationMap } from '@shared/models/edge.models';
import { EdgeConnectionEvent, EdgeConnectionEventTranslationMap } from '@shared/models/edge.models';
export interface RuleNotificationDialogData {
rule?: NotificationRule;
@ -99,8 +99,8 @@ export class RuleNotificationDialogComponent extends
apiUsageLimitTemplateForm: FormGroup;
newPlatformVersionTemplateForm: FormGroup;
rateLimitsTemplateForm: FormGroup;
edgeFailureTemplateForm: FormGroup;
edgeConnectivityTemplateForm: FormGroup;
edgeCommunicationFailureTemplateForm: FormGroup;
edgeConnectionTemplateForm: FormGroup;
triggerType = TriggerType;
triggerTypes: TriggerType[];
@ -135,8 +135,8 @@ export class RuleNotificationDialogComponent extends
apiFeatures: ApiFeature[] = Object.values(ApiFeature);
apiFeatureTranslationMap = ApiFeatureTranslationMap;
edgeConnectivityEvents: EdgeConnectivityEvent[] = Object.values(EdgeConnectivityEvent);
edgeConnectivityEventTranslationMap = EdgeConnectivityEventTranslationMap;
edgeConnectionEvents: EdgeConnectionEvent[] = Object.values(EdgeConnectionEvent);
edgeConnectionEventTranslationMap = EdgeConnectionEventTranslationMap;
limitedApis: StringItemsOption[];
@ -227,14 +227,14 @@ export class RuleNotificationDialogComponent extends
}
});
this.edgeConnectivityTemplateForm = this.fb.group({
this.edgeConnectionTemplateForm = this.fb.group({
triggerConfig: this.fb.group({
edges: [null],
notifyOn: [null]
})
});
this.edgeFailureTemplateForm = this.fb.group({
this.edgeCommunicationFailureTemplateForm = this.fb.group({
triggerConfig: this.fb.group({
edges: [null]
})
@ -348,8 +348,8 @@ export class RuleNotificationDialogComponent extends
[TriggerType.API_USAGE_LIMIT, this.apiUsageLimitTemplateForm],
[TriggerType.NEW_PLATFORM_VERSION, this.newPlatformVersionTemplateForm],
[TriggerType.RATE_LIMITS, this.rateLimitsTemplateForm],
[TriggerType.EDGE_FAILURE, this.edgeFailureTemplateForm],
[TriggerType.EDGE_CONNECTIVITY, this.edgeConnectivityTemplateForm]
[TriggerType.EDGE_COMMUNICATION_FAILURE, this.edgeCommunicationFailureTemplateForm],
[TriggerType.EDGE_CONNECTION, this.edgeConnectionTemplateForm]
]);
if (data.isAdd || data.isCopy) {

8
ui-ngx/src/app/shared/models/edge.models.ts

@ -191,14 +191,14 @@ export enum EdgeInstructionsMethod {
export const edgeVersionAttributeKey = 'edgeVersion';
export enum EdgeConnectivityEvent {
export enum EdgeConnectionEvent {
CONNECTED= 'CONNECTED',
DISCONNECTED = 'DISCONNECTED'
}
export const EdgeConnectivityEventTranslationMap = new Map<EdgeConnectivityEvent, string>(
export const EdgeConnectionEventTranslationMap = new Map<EdgeConnectionEvent, string>(
[
[EdgeConnectivityEvent.CONNECTED, 'edge-event.connected'],
[EdgeConnectivityEvent.DISCONNECTED, 'edge-event.disconnected']
[EdgeConnectionEvent.CONNECTED, 'edge.connected'],
[EdgeConnectionEvent.DISCONNECTED, 'edge.disconnected']
]
);

24
ui-ngx/src/app/shared/models/notification.models.ts

@ -475,8 +475,8 @@ export enum NotificationType {
NEW_PLATFORM_VERSION = 'NEW_PLATFORM_VERSION',
RULE_NODE = 'RULE_NODE',
RATE_LIMITS = 'RATE_LIMITS',
EDGE_CONNECTIVITY = 'EDGE_CONNECTIVITY',
EDGE_FAILURE = 'EDGE_FAILURE'
EDGE_CONNECTION = 'EDGE_CONNECTION',
EDGE_COMMUNICATION_FAILURE = 'EDGE_COMMUNICATION_FAILURE'
}
export const NotificationTypeIcons = new Map<NotificationType, string | null>([
@ -588,16 +588,16 @@ export const NotificationTemplateTypeTranslateMap = new Map<NotificationType, No
helpId: 'notification/rate_limits'
}
],
[NotificationType.EDGE_CONNECTIVITY,
[NotificationType.EDGE_CONNECTION,
{
name: 'notification.template-type.edge-connectivity',
helpId: 'notification/edge_connectivity'
name: 'notification.template-type.edge-connection',
helpId: 'notification/edge_connection'
}
],
[NotificationType.EDGE_FAILURE,
[NotificationType.EDGE_COMMUNICATION_FAILURE,
{
name: 'notification.template-type.edge-failure',
helpId: 'notification/edge_failure'
name: 'notification.template-type.edge-communication-failure',
helpId: 'notification/edge_communication_failure'
}
]
]);
@ -613,8 +613,8 @@ export enum TriggerType {
API_USAGE_LIMIT = 'API_USAGE_LIMIT',
NEW_PLATFORM_VERSION = 'NEW_PLATFORM_VERSION',
RATE_LIMITS = 'RATE_LIMITS',
EDGE_CONNECTIVITY = 'EDGE_CONNECTIVITY',
EDGE_FAILURE = 'EDGE_FAILURE'
EDGE_CONNECTION = 'EDGE_CONNECTION',
EDGE_COMMUNICATION_FAILURE = 'EDGE_COMMUNICATION_FAILURE'
}
export const TriggerTypeTranslationMap = new Map<TriggerType, string>([
@ -628,8 +628,8 @@ export const TriggerTypeTranslationMap = new Map<TriggerType, string>([
[TriggerType.API_USAGE_LIMIT, 'notification.trigger.api-usage-limit'],
[TriggerType.NEW_PLATFORM_VERSION, 'notification.trigger.new-platform-version'],
[TriggerType.RATE_LIMITS, 'notification.trigger.rate-limits'],
[TriggerType.EDGE_CONNECTIVITY, 'notification.trigger.edge-connectivity'],
[TriggerType.EDGE_FAILURE, 'notification.trigger.edge-failure']
[TriggerType.EDGE_CONNECTION, 'notification.trigger.edge-connection'],
[TriggerType.EDGE_COMMUNICATION_FAILURE, 'notification.trigger.edge-communication-failure']
]);
export interface NotificationUserSettings {

10
ui-ngx/src/assets/help/en_US/notification/edge_failure.md → ui-ngx/src/assets/help/en_US/notification/edge_communication_failure.md

@ -11,7 +11,7 @@ Available template parameters:
* `edgeId` - the edge id as uuid string;
* `edgeName` - the name of the edge;
* `errorMsg` - the string representation of the error, occurred on the Edge;
* `failureMsg` - the string representation of the failure, occurred on the Edge;
Parameter names must be wrapped using `${...}`. For example: `${edgeName}`.
You may also modify the value of the parameter with one of the suffixes:
@ -28,14 +28,14 @@ Let's assume the notification about the failing of processing connection to Edge
The following template:
```text
Edge '${edgeName}' received error
Edge '${edgeName}' communication failure occurred
{:copy-code}
```
will be transformed to:
```text
Edge 'DatacenterEdge' received error
Edge 'DatacenterEdge' communication failure occurred
```
<br/>
@ -43,14 +43,14 @@ Edge 'DatacenterEdge' received error
The following template:
```text
Error message: '${errorMsg}'
Failure message: '${failureMsg}'
{:copy-code}
```
will be transformed to:
```text
Error message: 'Failed to process edge connection!'
Failure message: 'Failed to process edge connection!'
```
<br>

17
ui-ngx/src/assets/help/en_US/notification/edge_connectivity.md → ui-ngx/src/assets/help/en_US/notification/edge_connection.md

@ -28,30 +28,17 @@ Let's assume the notification about the connecting Edge into the ThingsBoard.
The following template:
```text
Edge '${edgeName}' is ${eventType}
Edge '${edgeName}' is now ${eventType}
{:copy-code}
```
will be transformed to:
```text
Edge 'DatacenterEdge' is connected
Edge 'DatacenterEdge' is now connected
```
<br/>
The following template:
```text
"Edge '${edgeName}' is now ${eventType}"
{:copy-code}
```
will be transformed to:
```text
Edge 'DatacenterEdge' is now connected
```
<br>
<br>

16
ui-ngx/src/assets/locale/locale.constant-en_US.json

@ -2030,7 +2030,9 @@
"missing-related-rule-chains-title": "Edge has missing related rule chain(s)",
"missing-related-rule-chains-text": "Assigned to edge rule chain(s) use rule nodes that forward message(s) to rule chain(s) that are not assigned to this edge. <br><br> List of missing rule chain(s): <br> {{missingRuleChains}}",
"upgrade-instructions": "Upgrade Instructions",
"widget-datasource-error": "This widget supports only EDGE entity datasource"
"widget-datasource-error": "This widget supports only EDGE entity datasource",
"connected": "Connected",
"disconnected": "Disconnected"
},
"edge-event": {
"type-dashboard": "Dashboard",
@ -2073,9 +2075,7 @@
"action-type-assigned-to-edge": "Assigned to Edge",
"action-type-unassigned-from-edge": "Unassigned from Edge",
"action-type-credentials-request": "Credentials Request",
"action-type-entity-merge-request": "Entity Merge Request",
"connected": "Connected",
"disconnected": "Disconnected"
"action-type-entity-merge-request": "Entity Merge Request"
},
"error": {
"unable-to-connect": "Unable to connect to the server! Please check your internet connection.",
@ -3430,8 +3430,8 @@
"rule-node": "Rule node",
"new-platform-version": "New platform version",
"rate-limits": "Exceeded rate limits",
"edge-failure": "Edge error",
"edge-connectivity": "Edge connectivity"
"edge-communication-failure": "Edge communication failure",
"edge-connection": "Edge connection"
},
"templates": "Templates",
"notification-templates": "Notifications / Templates",
@ -3452,8 +3452,8 @@
"rule-engine-lifecycle-event": "Rule engine lifecycle event",
"new-platform-version": "New platform version",
"rate-limits": "Exceeded rate limits",
"edge-connectivity": "Edge connectivity",
"edge-failure": "Edge failure",
"edge-connection": "Edge connection",
"edge-communication-failure": "Edge communication failure",
"trigger": "Trigger",
"trigger-required": "Trigger is required"
},

Loading…
Cancel
Save