TB-73: Make Rule plugin and action optional. Fix rule deletion.
This commit is contained in:
parent
ae4a71346f
commit
d9023482d9
@ -72,16 +72,19 @@ public abstract class RuleManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public Optional<ActorRef> update(ActorContext context, RuleId ruleId, ComponentLifecycleEvent event) {
|
public Optional<ActorRef> update(ActorContext context, RuleId ruleId, ComponentLifecycleEvent event) {
|
||||||
RuleMetaData rule = null;
|
RuleMetaData rule;
|
||||||
if (event != ComponentLifecycleEvent.DELETED) {
|
if (event != ComponentLifecycleEvent.DELETED) {
|
||||||
rule = systemContext.getRuleService().findRuleById(ruleId);
|
rule = systemContext.getRuleService().findRuleById(ruleId);
|
||||||
}
|
} else {
|
||||||
if (rule == null) {
|
|
||||||
rule = ruleMap.keySet().stream()
|
rule = ruleMap.keySet().stream()
|
||||||
.filter(r -> r.getId().equals(ruleId))
|
.filter(r -> r.getId().equals(ruleId))
|
||||||
.peek(r -> r.setState(ComponentLifecycleState.SUSPENDED))
|
.peek(r -> r.setState(ComponentLifecycleState.SUSPENDED))
|
||||||
.findFirst()
|
.findFirst()
|
||||||
.orElse(null);
|
.orElse(null);
|
||||||
|
if (rule != null) {
|
||||||
|
ruleMap.remove(rule);
|
||||||
|
ruleActors.remove(ruleId);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (rule != null) {
|
if (rule != null) {
|
||||||
RuleActorMetaData actorMd = ruleMap.get(rule);
|
RuleActorMetaData actorMd = ruleMap.get(rule);
|
||||||
|
|||||||
@ -176,7 +176,7 @@ actors:
|
|||||||
statistics:
|
statistics:
|
||||||
# Enable/disable actor statistics
|
# Enable/disable actor statistics
|
||||||
enabled: "${ACTORS_STATISTICS_ENABLED:true}"
|
enabled: "${ACTORS_STATISTICS_ENABLED:true}"
|
||||||
persist_frequency: "${ACTORS_STATISTICS_PERSIST_FREQUENCY:60000}"
|
persist_frequency: "${ACTORS_STATISTICS_PERSIST_FREQUENCY:3600000}"
|
||||||
|
|
||||||
# Cache parameters
|
# Cache parameters
|
||||||
cache:
|
cache:
|
||||||
|
|||||||
@ -17,6 +17,7 @@ package org.thingsboard.server.common.data.rule;
|
|||||||
|
|
||||||
import com.fasterxml.jackson.databind.JsonNode;
|
import com.fasterxml.jackson.databind.JsonNode;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
|
import lombok.EqualsAndHashCode;
|
||||||
import org.thingsboard.server.common.data.HasName;
|
import org.thingsboard.server.common.data.HasName;
|
||||||
import org.thingsboard.server.common.data.SearchTextBased;
|
import org.thingsboard.server.common.data.SearchTextBased;
|
||||||
import org.thingsboard.server.common.data.id.RuleId;
|
import org.thingsboard.server.common.data.id.RuleId;
|
||||||
@ -24,6 +25,7 @@ import org.thingsboard.server.common.data.id.TenantId;
|
|||||||
import org.thingsboard.server.common.data.plugin.ComponentLifecycleState;
|
import org.thingsboard.server.common.data.plugin.ComponentLifecycleState;
|
||||||
|
|
||||||
@Data
|
@Data
|
||||||
|
@EqualsAndHashCode(callSuper = true)
|
||||||
public class RuleMetaData extends SearchTextBased<RuleId> implements HasName {
|
public class RuleMetaData extends SearchTextBased<RuleId> implements HasName {
|
||||||
|
|
||||||
private static final long serialVersionUID = -5656679015122935465L;
|
private static final long serialVersionUID = -5656679015122935465L;
|
||||||
|
|||||||
@ -165,11 +165,11 @@
|
|||||||
<fieldset ng-disabled="loading || !isEdit || isReadOnly">
|
<fieldset ng-disabled="loading || !isEdit || isReadOnly">
|
||||||
<md-input-container ng-if="!isEdit || isReadOnly" flex class="md-block">
|
<md-input-container ng-if="!isEdit || isReadOnly" flex class="md-block">
|
||||||
<label translate>plugin.plugin</label>
|
<label translate>plugin.plugin</label>
|
||||||
<input required name="name" ng-model="plugin.name">
|
<input name="name" ng-model="plugin.name">
|
||||||
</md-input-container>
|
</md-input-container>
|
||||||
<tb-plugin-select ng-show="isEdit && !isReadOnly" flex
|
<tb-plugin-select ng-show="isEdit && !isReadOnly" flex
|
||||||
ng-model="plugin"
|
ng-model="plugin"
|
||||||
tb-required="true"
|
tb-required="false"
|
||||||
the-form="theForm"
|
the-form="theForm"
|
||||||
plugins-scope="action">
|
plugins-scope="action">
|
||||||
</tb-plugin-select>
|
</tb-plugin-select>
|
||||||
|
|||||||
@ -85,10 +85,11 @@ export default function RuleDirective($compile, $templateCache, $mdDialog, $docu
|
|||||||
if (scope.rule) {
|
if (scope.rule) {
|
||||||
var valid = scope.rule.filters && scope.rule.filters.length > 0;
|
var valid = scope.rule.filters && scope.rule.filters.length > 0;
|
||||||
scope.theForm.$setValidity('filters', valid);
|
scope.theForm.$setValidity('filters', valid);
|
||||||
valid = angular.isDefined(scope.rule.pluginToken) && scope.rule.pluginToken != null;
|
var processorDefined = angular.isDefined(scope.rule.processor) && scope.rule.processor != null;
|
||||||
scope.theForm.$setValidity('plugin', valid);
|
var pluginDefined = angular.isDefined(scope.rule.pluginToken) && scope.rule.pluginToken != null;
|
||||||
valid = angular.isDefined(scope.rule.action) && scope.rule.action != null;
|
var pluginActionDefined = angular.isDefined(scope.rule.action) && scope.rule.action != null;
|
||||||
scope.theForm.$setValidity('action', valid);
|
valid = processorDefined && !pluginDefined || (pluginDefined && pluginActionDefined);
|
||||||
|
scope.theForm.$setValidity('processorOrPlugin', valid);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -160,6 +161,7 @@ export default function RuleDirective($compile, $templateCache, $mdDialog, $docu
|
|||||||
scope.$watch('rule.processor', function(newVal, prevVal) {
|
scope.$watch('rule.processor', function(newVal, prevVal) {
|
||||||
if (scope.rule && scope.isEdit && !angular.equals(newVal, prevVal)) {
|
if (scope.rule && scope.isEdit && !angular.equals(newVal, prevVal)) {
|
||||||
scope.theForm.$setDirty();
|
scope.theForm.$setDirty();
|
||||||
|
scope.updateValidity();
|
||||||
}
|
}
|
||||||
}, true);
|
}, true);
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user