Commit 8bb07124 by Torkel Ödegaard

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

parent bce5c447
......@@ -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>
......
......@@ -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',
......
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