mirror of https://github.com/grafana/grafana.git
fix(gauge): validate min / max range, fixes #4820
This commit is contained in:
parent
bce5c447b3
commit
8bb07124f7
|
|
@ -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">
|
||||
|
||||
<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',
|
||||
|
|
|
|||
Loading…
Reference in New Issue