Sfoglia il codice sorgente

Merge branch 'master' of github.com:grafana/grafana

Torkel Ödegaard 10 anni fa
parent
commit
68a45608e6

+ 2 - 2
pkg/bus/bus.go

@@ -1,7 +1,7 @@
 package bus
 package bus
 
 
 import (
 import (
-	"errors"
+	"fmt"
 	"reflect"
 	"reflect"
 )
 )
 
 
@@ -39,7 +39,7 @@ func (b *InProcBus) Dispatch(msg Msg) error {
 
 
 	var handler = b.handlers[msgName]
 	var handler = b.handlers[msgName]
 	if handler == nil {
 	if handler == nil {
-		return errors.New("handler not found")
+		return fmt.Errorf("handler not found for %s", msgName)
 	}
 	}
 
 
 	var params = make([]reflect.Value, 1)
 	var params = make([]reflect.Value, 1)

+ 5 - 0
public/app/components/kbn.js

@@ -399,6 +399,8 @@ function($, _, moment) {
   kbn.valueFormats.celsius = function(value, decimals) { return kbn.toFixed(value, decimals) + ' °C'; };
   kbn.valueFormats.celsius = function(value, decimals) { return kbn.toFixed(value, decimals) + ' °C'; };
   kbn.valueFormats.farenheit = function(value, decimals) { return kbn.toFixed(value, decimals) + ' °F'; };
   kbn.valueFormats.farenheit = function(value, decimals) { return kbn.toFixed(value, decimals) + ' °F'; };
   kbn.valueFormats.humidity = function(value, decimals) { return kbn.toFixed(value, decimals) + ' %H'; };
   kbn.valueFormats.humidity = function(value, decimals) { return kbn.toFixed(value, decimals) + ' %H'; };
+  kbn.valueFormats.pressurembar = function(value, decimals) { return kbn.toFixed(value, decimals) + ' mbar'; };
+  kbn.valueFormats.pressurehpa = function(value, decimals) { return kbn.toFixed(value, decimals) + ' hPa'; };
   kbn.valueFormats.ppm = function(value, decimals) { return kbn.toFixed(value, decimals) + ' ppm'; };
   kbn.valueFormats.ppm = function(value, decimals) { return kbn.toFixed(value, decimals) + ' ppm'; };
   kbn.valueFormats.velocityms = function(value, decimals) { return kbn.toFixed(value, decimals) + ' m/s'; };
   kbn.valueFormats.velocityms = function(value, decimals) { return kbn.toFixed(value, decimals) + ' m/s'; };
   kbn.valueFormats.velocitykmh = function(value, decimals) { return kbn.toFixed(value, decimals) + ' km/h'; };
   kbn.valueFormats.velocitykmh = function(value, decimals) { return kbn.toFixed(value, decimals) + ' km/h'; };
@@ -541,6 +543,7 @@ function($, _, moment) {
           {text: 'short', value: 'short'},
           {text: 'short', value: 'short'},
           {text: 'percent', value: 'percent'},
           {text: 'percent', value: 'percent'},
           {text: 'ppm', value: 'ppm'},
           {text: 'ppm', value: 'ppm'},
+          {text: 'dB', value: 'dB'},
         ]
         ]
       },
       },
       {
       {
@@ -590,6 +593,8 @@ function($, _, moment) {
           {text: 'Celcius (°C)',         value: 'celsius'  },
           {text: 'Celcius (°C)',         value: 'celsius'  },
           {text: 'Farenheit (°F)',       value: 'farenheit'},
           {text: 'Farenheit (°F)',       value: 'farenheit'},
           {text: 'Humidity (%H)',        value: 'humidity' },
           {text: 'Humidity (%H)',        value: 'humidity' },
+          {text: 'Pressure (mbar)',      value: 'pressurembar' },
+          {text: 'Pressure (hPa)',       value: 'pressurehpa' },
         ]
         ]
       },
       },
       {
       {

+ 1 - 1
public/app/features/templating/templateSrv.js

@@ -27,7 +27,7 @@ function (angular, _) {
       this._texts = {};
       this._texts = {};
 
 
       _.each(this.variables, function(variable) {
       _.each(this.variables, function(variable) {
-        if (!variable.current || !variable.current.value) { return; }
+        if (!variable.current || !variable.current.isNone && !variable.current.value) { return; }
 
 
         this._values[variable.name] = this.renderVariableValue(variable);
         this._values[variable.name] = this.renderVariableValue(variable);
         this._texts[variable.name] = variable.current.text;
         this._texts[variable.name] = variable.current.text;

+ 4 - 0
public/app/features/templating/templateValuesSrv.js

@@ -10,6 +10,7 @@ function (angular, _, kbn) {
 
 
   module.service('templateValuesSrv', function($q, $rootScope, datasourceSrv, $location, templateSrv, timeSrv) {
   module.service('templateValuesSrv', function($q, $rootScope, datasourceSrv, $location, templateSrv, timeSrv) {
     var self = this;
     var self = this;
+    function getNoneOption() { return { text: 'None', value: '', isNone: true }; }
 
 
     $rootScope.onAppEvent('time-range-changed', function()  {
     $rootScope.onAppEvent('time-range-changed', function()  {
       var variable = _.findWhere(self.variables, { type: 'interval' });
       var variable = _.findWhere(self.variables, { type: 'interval' });
@@ -175,6 +176,9 @@ function (angular, _, kbn) {
         if (variable.includeAll) {
         if (variable.includeAll) {
           self.addAllOption(variable);
           self.addAllOption(variable);
         }
         }
+        if (!variable.options.length) {
+          variable.options.push(getNoneOption());
+        }
         return datasource;
         return datasource;
       });
       });
     };
     };

+ 3 - 2
public/test/specs/templateValuesSrv-specs.js

@@ -224,8 +224,9 @@ define([
         scenario.queryResult = [{text: 'apps.backend.backend_01.counters.req'}, {text: 'apps.backend.backend_02.counters.req'}];
         scenario.queryResult = [{text: 'apps.backend.backend_01.counters.req'}, {text: 'apps.backend.backend_02.counters.req'}];
       });
       });
 
 
-      it('should not add non matching items', function() {
-        expect(scenario.variable.options.length).to.be(0);
+      it('should not add non matching items, None option should be added instead', function() {
+        expect(scenario.variable.options.length).to.be(1);
+        expect(scenario.variable.options[0].isNone).to.be(true);
       });
       });
     });
     });