fix(gauge): validate min / max range, fixes #4820

This commit is contained in:
Torkel Ödegaard 2016-04-26 13:14:38 +02:00
parent bce5c447b3
commit 8bb07124f7
2 changed files with 14 additions and 2 deletions

View File

@ -179,13 +179,18 @@
Min
</li>
<li>
<input type="text" class="input-small tight-form-input" ng-model="ctrl.panel.gauge.minValue" ng-blur="ctrl.render()" placeholder="0"></input>
<input type="number" class="input-small tight-form-input" ng-model="ctrl.panel.gauge.minValue" ng-blur="ctrl.render()" placeholder="0"></input>
</li>
<li class="tight-form-item last">
Max
</li>
<li>
<input type="text" class="input-small tight-form-input last" ng-model="ctrl.panel.gauge.maxValue" ng-blur="ctrl.render()" placeholder="100"></input>
<input type="number" class="input-small tight-form-input last" ng-model="ctrl.panel.gauge.maxValue" ng-blur="ctrl.render()" placeholder="100"></input>
<span class="alert-state-critical" ng-show="ctrl.invalidGaugeRange">
&nbsp;
<i class="fa fa-warning"></i>
Min value is bigger than max.
</span>
</li>
</ul>
<div class="clearfix"></div>

View File

@ -18,6 +18,7 @@ class SingleStatCtrl extends MetricsPanelCtrl {
data: any;
fontSizes: any[];
unitFormats: any[];
invalidGaugeRange: boolean;
// Set and populate defaults
panelDefaults = {
@ -287,6 +288,12 @@ class SingleStatCtrl extends MetricsPanelCtrl {
}
function addGauge() {
ctrl.invalidGaugeRange = false;
if (panel.gauge.minValue > panel.gauge.maxValue) {
ctrl.invalidGaugeRange = true;
return;
}
var plotCanvas = $('<div></div>');
var plotCss = {
top: '10px',