mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
fix(single_stat): rounding bug in value => text
This commit is contained in:
parent
ae604b6289
commit
c30c12d369
@ -167,13 +167,13 @@
|
|||||||
<i class="fa fa-remove pointer" ng-click="ctrl.removeValueMap(map)"></i>
|
<i class="fa fa-remove pointer" ng-click="ctrl.removeValueMap(map)"></i>
|
||||||
</li>
|
</li>
|
||||||
<li>
|
<li>
|
||||||
<input type="text" ng-model="ctrl.map.value" placeholder="value" class="input-mini tight-form-input" ng-blur="ctrl.render()">
|
<input type="text" ng-model="map.value" placeholder="value" class="input-mini tight-form-input" ng-blur="ctrl.render()">
|
||||||
</li>
|
</li>
|
||||||
<li class="tight-form-item">
|
<li class="tight-form-item">
|
||||||
<i class="fa fa-arrow-right"></i>
|
<i class="fa fa-arrow-right"></i>
|
||||||
</li>
|
</li>
|
||||||
<li ng-repeat-end>
|
<li ng-repeat-end>
|
||||||
<input type="text" placeholder="text" ng-model="ctrl.map.text" class="input-mini tight-form-input" ng-blur="ctrl.render()">
|
<input type="text" placeholder="text" ng-model="map.text" class="input-mini tight-form-input" ng-blur="ctrl.render()">
|
||||||
</li>
|
</li>
|
||||||
|
|
||||||
<li>
|
<li>
|
||||||
|
@ -213,7 +213,7 @@ class SingleStatCtrl extends MetricsPanelCtrl {
|
|||||||
|
|
||||||
// value/number to text mapping
|
// value/number to text mapping
|
||||||
var value = parseFloat(map.value);
|
var value = parseFloat(map.value);
|
||||||
if (value === data.value) {
|
if (value === data.valueRounded) {
|
||||||
data.valueFormated = map.text;
|
data.valueFormated = map.text;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -69,14 +69,20 @@ describe('SingleStatCtrl', function() {
|
|||||||
|
|
||||||
singleStatScenario('When value to text mapping is specified', function(ctx) {
|
singleStatScenario('When value to text mapping is specified', function(ctx) {
|
||||||
ctx.setup(function() {
|
ctx.setup(function() {
|
||||||
ctx.datapoints = [[10,1]];
|
ctx.datapoints = [[9.9,1]];
|
||||||
ctx.ctrl.panel.valueMaps = [{value: '10', text: 'OK'}];
|
ctx.ctrl.panel.valueMaps = [{value: '10', text: 'OK'}];
|
||||||
});
|
});
|
||||||
|
|
||||||
it('Should replace value with text', function() {
|
it('value should remain', function() {
|
||||||
expect(ctx.data.value).to.be(10);
|
expect(ctx.data.value).to.be(9.9);
|
||||||
expect(ctx.data.valueFormated).to.be('OK');
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('round should be rounded up', function() {
|
||||||
|
expect(ctx.data.valueRounded).to.be(10);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('Should replace value with text', function() {
|
||||||
|
expect(ctx.data.valueFormated).to.be('OK');
|
||||||
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
Loading…
Reference in New Issue
Block a user