diff --git a/monitoring/static/monitoring/js/directives.js b/monitoring/static/monitoring/js/directives.js index bc6f2b2a..ea9047ce 100644 --- a/monitoring/static/monitoring/js/directives.js +++ b/monitoring/static/monitoring/js/directives.js @@ -77,7 +77,7 @@ function monAlarmExpressionsDirective(staticPath){ if ($index >= 1 && vm.subExpressions[$index - 1].$valid) { // hide previous expression // if it is valid - vm.subExpressions[$index -1]['preview'] = true; + vm.subExpressions[$index - 1]['preview'] = true; } applyConnectable(); @@ -94,6 +94,11 @@ function monAlarmExpressionsDirective(staticPath){ applyConnectable(); touch(); + if (vm.subExpressions.length === 0) { + vm.expression = ''; + vm.subExpressions.push({}); + } + return true; } @@ -139,13 +144,13 @@ function monAlarmExpressionsDirective(staticPath){ return true; - function subExpressionIt(expr){ + function subExpressionIt(expr) { if (!expr.$valid) { return !(hasInvalid = true); } - angular.forEach(expr.matchBy || [], function it(mb){ - if(matchBy.indexOf(mb) < 0){ + angular.forEach(expr.matchBy || [], function it(mb) { + if(matchBy.indexOf(mb) < 0) { matchBy.push(mb); } }); @@ -242,7 +247,6 @@ function monAlarmSubExpressionDirective(staticPath) { vm.updateExpression = updateExpression; vm.resetExpression = resetExpression; - vm.updateExpression = updateExpression; // init $scope.$on('$destroy', destroyerFactory()); diff --git a/monitoring/static/monitoring/widgets/expression/expression.tpl.html b/monitoring/static/monitoring/widgets/expression/expression.tpl.html index 1669a308..04c05a67 100644 --- a/monitoring/static/monitoring/widgets/expression/expression.tpl.html +++ b/monitoring/static/monitoring/widgets/expression/expression.tpl.html @@ -78,7 +78,7 @@ role="button" title="{$ 'Remove'|translate $}" ng-class="{'btn-block': !expr.preview}" - ng-disabled="vm.subExpressions.length === 1" + ng-disabled="!expr.$valid" ng-click="vm.removeExpression($event, $index)">