Commit 5c9ef9d9 by Torkel Ödegaard

Added form validation and css class for invalid timespans, #1494

parent ad13fd05
define(['angular'],
function (angular) {
define([
'angular',
'kbn'
],
function (angular, kbn) {
'use strict';
angular
......@@ -34,5 +37,18 @@ function (angular) {
});
}
};
})
.directive('validTimeSpan', function() {
return {
require: 'ngModel',
link: function(scope, elm, attrs, ctrl) {
ctrl.$validators.integer = function(modelValue, viewValue) {
if (ctrl.$isEmpty(modelValue)) {
return true;
}
return kbn.isValidTimeSpan(viewValue);
};
}
};
});
});
......@@ -12,8 +12,8 @@
Last
</li>
<li>
<input type="text" class="input-small tight-form-input" placeholder="1h"
empty-to-null ng-model="panel.timeFrom"
<input type="text" class="input-small tight-form-input last" placeholder="1h"
empty-to-null ng-model="panel.timeFrom" valid-time-span
ng-change="get_data()" ng-model-onblur>
</li>
</ul>
......@@ -31,8 +31,8 @@
Amount
</li>
<li>
<input type="text" class="input-small tight-form-input" placeholder="1h"
empty-to-null ng-model="panel.timeShift"
<input type="text" class="input-small tight-form-input last" placeholder="1h"
empty-to-null ng-model="panel.timeShift" valid-time-span
ng-change="get_data()" ng-model-onblur>
</li>
</ul>
......
......@@ -18,7 +18,10 @@
</li>
<li>
<input type="text" class="input-mini tight-form-input last"
ng-model="panel.nowDelay" placeholder="0m" bs-tooltip="'Enter 1m to ignore the last minute (because it can contain incomplete metrics)'" data-placement="right">
ng-model="panel.nowDelay" placeholder="0m"
valid-time-span
bs-tooltip="'Enter 1m to ignore the last minute (because it can contain incomplete metrics)'"
data-placement="right">
</li>
</ul>
<div class="clearfix"></div>
......
......@@ -13,6 +13,7 @@
@import "gfbox.less";
@import "dashlist.less";
@import "admin.less";
@import "validation.less";
.row-control-inner {
padding:0px;
......
input[type=text].ng-invalid {
box-shadow: inset 0 0px 7px @red;
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment