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

This commit is contained in:
Torkel Ödegaard 2015-02-18 09:20:39 +01:00
parent ad13fd0542
commit 5c9ef9d9da
5 changed files with 30 additions and 7 deletions

View File

@ -1,5 +1,8 @@
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);
};
}
};
});
});

View File

@ -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>

View File

@ -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>

View File

@ -13,6 +13,7 @@
@import "gfbox.less";
@import "dashlist.less";
@import "admin.less";
@import "validation.less";
.row-control-inner {
padding:0px;

View File

@ -0,0 +1,3 @@
input[type=text].ng-invalid {
box-shadow: inset 0 0px 7px @red;
}