Skip to content
This repository has been archived by the owner on Apr 22, 2020. It is now read-only.

prevent users from creating checks without entity #646

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,7 @@ angular.module('zmon2App').controller('AlertDefinitionEditCtrl', ['$scope', '$ro
});
});
}else{
$("#alertModal .modal-header .modal-title").html("Unique name required to save");
$("#alertModal .modal-body").html(`An alert with name <b>${alertObj.name}</b> already exists for team <b>${alertObj.team}</b>. Please select a different name to save.`)
$("#alertModal").modal();
}
Expand Down
11 changes: 10 additions & 1 deletion zmon-controller-ui/js/controllers/CheckDefinitionEditCtrl.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,15 @@ angular.module('zmon2App').controller('CheckDefinitionEditCtrl', ['$scope', '$ro
if ($scope.entityFilter.textEntityFilters === '') {
delete $scope.check.entities;
} else {
$scope.check.entities = JSON.parse($scope.entityFilter.textEntityFilters);
var entities = JSON.parse($scope.entityFilter.textEntityFilters);
if(Array.isArray(entities) && entities.length > 0){
$scope.check.entities = entities;
}else{
$("#alertModal .modal-header .modal-title").html("Included Entities Error");
$("#alertModal .modal-body").html(`Please include alteast one entity.`)
$("#alertModal").modal();
return;
}
}


Expand All @@ -70,6 +78,7 @@ angular.module('zmon2App').controller('CheckDefinitionEditCtrl', ['$scope', '$ro
});
});
}else{
$("#alertModal .modal-header .modal-title").html("Unique name required to save");
$("#alertModal .modal-body").html(`A check with name <b>${$scope.check.name}</b> already exists for team <b>${$scope.check.owning_team}</b>. Please select a different name to save.`)
$("#alertModal").modal();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,7 @@ angular.module('zmon2App').controller('DashboardConfigurationCtrl', ['$scope', '
$window.history.back();
});
}else{
$("#alertModal .modal-header .modal-title").html("Unique name required to save");
$("#alertModal .modal-body").html(`A dashboard with name <b>${$scope.dashboard.name}</b> already exists. Please select a different name to save.`)
$("#alertModal").modal();
}
Expand Down
11 changes: 10 additions & 1 deletion zmon-controller-ui/js/controllers/TrialRunCtrl.js
Original file line number Diff line number Diff line change
Expand Up @@ -340,7 +340,15 @@ var TrialRunCtrl = function ($scope, $interval, $timeout, timespanFilter, Commun
if (trc.entityFilter.textEntityFilters === '') {
delete $scope.alert.entities;
} else {
$scope.alert.entities = JSON.parse(trc.entityFilter.textEntityFilters);
var entities = JSON.parse(trc.entityFilter.textEntityFilters);
if(Array.isArray(entities) && entities.length > 0){
$scope.alert.entities = entities;
}else{
$("#alertModal .modal-header .modal-title").html("Included Entities Error");
$("#alertModal .modal-body").html(`Please include alteast one entity.`)
$("#alertModal").modal();
return;
}
}

if (trc.entityExcludeFilter.textEntityFilters === '') {
Expand Down Expand Up @@ -383,6 +391,7 @@ var TrialRunCtrl = function ($scope, $interval, $timeout, timespanFilter, Commun
});
});
}else{
$("#alertModal .modal-header .modal-title").html("Unique name required to save");
$("#alertModal .modal-body").html(`A check with name <b>${obj.name}</b> already exists for team <b>${obj.owning_team}</b>. Please select a different name to save.`)
$("#alertModal").modal();

Expand Down
6 changes: 6 additions & 0 deletions zmon-controller-ui/styles/forms.css
Original file line number Diff line number Diff line change
Expand Up @@ -337,3 +337,9 @@ input.checkbox
{
border: none !important;
}

.info-msg{
font-size: 11px;
margin: 3px;
font-style: italic;
}
3 changes: 2 additions & 1 deletion zmon-controller-ui/views/checkDefinitionEditForm.html
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,9 @@ <h1 ng-switch-when="clone">Clone Check Definition</h1>

<div class="form-group" ng-class="{'has-error': cdForm.submitted && cdForm.entities.$error['valid-json'] || cdForm.entities.$error.required }">
<label for="inp-entities" class="col-sm-2 control-label">
<a href="https://docs.zmon.io/en/latest/user/check-definitions.html#entity-filter" rel="help" target="docs">Included Entities</a>
<a href="https://docs.zmon.io/en/latest/user/check-definitions.html#entity-filter" rel="help" target="docs">Included Entities *</a>
<div id="entity-filter-buttons">
<div class="info-msg">(Add atleast one entity) </div>
<button type="button" class="btn btn-primary fa fa-keyboard-o" ng-model="entityFilterInputMethod" uib-btn-radio="'text'" title="Plain text input"></button>
<button type="button" class="btn btn-primary fa fa-check-square-o" ng-model="entityFilterInputMethod" uib-btn-radio="'form'" title="Form input"></button>
</div>
Expand Down
5 changes: 3 additions & 2 deletions zmon-controller-ui/views/trialRun.html
Original file line number Diff line number Diff line change
Expand Up @@ -115,10 +115,11 @@ <h1 class="no-margin">

<div class="form-group" ng-class="{'has-error': trForm.submitted && trForm.entities.$error['valid-json'] || trForm.entities.$error.required }">
<label for="inp-entities" class="col-sm-2 control-label">
<a href="https://docs.zmon.io/en/latest/user/alert-definitions.html#entity-exclude-filter" rel="help" target="docs">Included Entities</a>
<a href="https://docs.zmon.io/en/latest/user/alert-definitions.html#entity-exclude-filter" rel="help" target="docs">Included Entities *</a>
<div id="entity-filter-buttons">
<div class="info-msg">(Add atleast one entity) </div>
<button type="button" class="btn btn-primary fa fa-keyboard-o" ng-model="TrialRunCtrl.entityFilterInputMethod" uib-btn-radio="'text'" title="Plain text input"></button>
<button type="button" class="btn btn-primary fa fa-check-square-o" ng-model="TrialRunCtrl.entityFilterInputMethod" uib-btn-radio="'form'" title="Form input"></button>
<button type="button" class="btn btn-primary fa fa-check-square-o" ng-model="TrialRunCtrl.entityFilterInputMethod" uib-btn-radio="'form'" title="Form input"></button>
</div>
</label>
<div class="col-sm-10" ng-class="{'has-error': trForm.submitted && trForm.entities.$error['non-empty-json']}">
Expand Down