mirror of
https://github.com/grafana/grafana.git
synced 2024-11-26 02:40:26 -06:00
parent
8b8bfa8a17
commit
12570bb959
@ -2,6 +2,7 @@
|
||||
|
||||
### Enhancements
|
||||
* **Login**: Adds option to disable username/password logins, closes [#4674](https://github.com/grafana/grafana/issues/4674)
|
||||
* **SingleStat**: Add seriename as option in singlestat panel, closes [#4740](https://github.com/grafana/grafana/issues/4740)
|
||||
|
||||
|
||||
# 3.1.0 stable (unreleased)
|
||||
|
@ -16,7 +16,10 @@
|
||||
Value
|
||||
</li>
|
||||
<li>
|
||||
<select class="input-small tight-form-input" ng-model="ctrl.panel.valueName" ng-options="f for f in ['min','max','avg', 'current', 'total']" ng-change="ctrl.render()"></select>
|
||||
<select class="input-small tight-form-input"
|
||||
ng-model="ctrl.panel.valueName"
|
||||
ng-options="f for f in ctrl.valueNameOptions"
|
||||
ng-change="ctrl.render()"></select>
|
||||
</li>
|
||||
<li class="tight-form-item">
|
||||
Postfix
|
||||
|
@ -19,6 +19,9 @@ class SingleStatCtrl extends MetricsPanelCtrl {
|
||||
fontSizes: any[];
|
||||
unitFormats: any[];
|
||||
invalidGaugeRange: boolean;
|
||||
panel: any;
|
||||
events: any;
|
||||
valueNameOptions: any[] = ['min','max','avg', 'current', 'total', 'name'];
|
||||
|
||||
// Set and populate defaults
|
||||
panelDefaults = {
|
||||
@ -186,7 +189,11 @@ class SingleStatCtrl extends MetricsPanelCtrl {
|
||||
var lastPoint = _.last(this.series[0].datapoints);
|
||||
var lastValue = _.isArray(lastPoint) ? lastPoint[0] : null;
|
||||
|
||||
if (_.isString(lastValue)) {
|
||||
if (this.panel.valueName === 'name') {
|
||||
data.value = 0;
|
||||
data.valueRounded = 0;
|
||||
data.valueFormated = this.series[0].alias;
|
||||
} else if (_.isString(lastValue)) {
|
||||
data.value = 0;
|
||||
data.valueFormated = lastValue;
|
||||
data.valueRounded = 0;
|
||||
|
@ -51,6 +51,22 @@ describe('SingleStatCtrl', function() {
|
||||
});
|
||||
});
|
||||
|
||||
singleStatScenario('showing serie name instead of value', function(ctx) {
|
||||
ctx.setup(function() {
|
||||
ctx.datapoints = [[10,1], [20,2]];
|
||||
ctx.ctrl.panel.valueName = 'name';
|
||||
});
|
||||
|
||||
it('Should use series avg as default main value', function() {
|
||||
expect(ctx.data.value).to.be(0);
|
||||
expect(ctx.data.valueRounded).to.be(0);
|
||||
});
|
||||
|
||||
it('should set formated falue', function() {
|
||||
expect(ctx.data.valueFormated).to.be('test.cpu1');
|
||||
});
|
||||
});
|
||||
|
||||
singleStatScenario('MainValue should use same number for decimals as displayed when checking thresholds', function(ctx) {
|
||||
ctx.setup(function() {
|
||||
ctx.datapoints = [[99.999,1], [99.99999,2]];
|
||||
|
Loading…
Reference in New Issue
Block a user