Commit 5c9ef9d9 by Torkel Ödegaard

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

parent ad13fd05
define(['angular'], define([
function (angular) { 'angular',
'kbn'
],
function (angular, kbn) {
'use strict'; 'use strict';
angular angular
...@@ -34,5 +37,18 @@ function (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 @@ ...@@ -12,8 +12,8 @@
Last Last
</li> </li>
<li> <li>
<input type="text" class="input-small tight-form-input" placeholder="1h" <input type="text" class="input-small tight-form-input last" placeholder="1h"
empty-to-null ng-model="panel.timeFrom" empty-to-null ng-model="panel.timeFrom" valid-time-span
ng-change="get_data()" ng-model-onblur> ng-change="get_data()" ng-model-onblur>
</li> </li>
</ul> </ul>
...@@ -31,8 +31,8 @@ ...@@ -31,8 +31,8 @@
Amount Amount
</li> </li>
<li> <li>
<input type="text" class="input-small tight-form-input" placeholder="1h" <input type="text" class="input-small tight-form-input last" placeholder="1h"
empty-to-null ng-model="panel.timeShift" empty-to-null ng-model="panel.timeShift" valid-time-span
ng-change="get_data()" ng-model-onblur> ng-change="get_data()" ng-model-onblur>
</li> </li>
</ul> </ul>
......
...@@ -18,7 +18,10 @@ ...@@ -18,7 +18,10 @@
</li> </li>
<li> <li>
<input type="text" class="input-mini tight-form-input last" <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> </li>
</ul> </ul>
<div class="clearfix"></div> <div class="clearfix"></div>
......
...@@ -13,6 +13,7 @@ ...@@ -13,6 +13,7 @@
@import "gfbox.less"; @import "gfbox.less";
@import "dashlist.less"; @import "dashlist.less";
@import "admin.less"; @import "admin.less";
@import "validation.less";
.row-control-inner { .row-control-inner {
padding:0px; 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