Просмотр исходного кода

Merge branch 'master' of github.com:torkelo/grafana-private into pro

Torkel Ödegaard 11 лет назад
Родитель
Сommit
584f40d0c4

+ 6 - 0
CHANGELOG.md

@@ -1,3 +1,9 @@
+# 2.0.0 (unreleased)
+
+**Enhancements**
+- [Issue #1297](https://github.com/grafana/grafana/issues/1297). Graphite: Added cumulative and minimumBelow graphite functions
+- [Issue #1296](https://github.com/grafana/grafana/issues/1296). InfluxDB: Auto escape column names with special characters. Thanks @steven-aerts
+
 # 1.9.1 (2014-12-29)
 
 **Enhancements**

+ 0 - 4
src/app/components/lodash.extended.js

@@ -14,10 +14,6 @@ function () {
       array.splice(toIndex, 0, array.splice(fromIndex, 1)[0]);
       return array;
     },
-    remove: function (array, index) {
-      array.splice(index, 1);
-      return array;
-    },
     // If variable is value, then return alt. If variable is anything else, return value;
     toggle: function (variable, value, alt) {
       return variable === value ? alt : value;

+ 4 - 1
src/app/features/graphite/datasource.js

@@ -232,7 +232,10 @@ function (angular, _, $, config, kbn, moment) {
       '#A', '#B', '#C', '#D',
       '#E', '#F', '#G', '#H',
       '#I', '#J', '#K', '#L',
-      '#M', '#N', '#O'
+      '#M', '#N', '#O', '#P',
+      '#Q', '#R', '#S', '#T',
+      '#U', '#V', '#W', '#X',
+      '#Y', '#Z'
     ];
 
     GraphiteDatasource.prototype.buildGraphiteParams = function(options) {

+ 14 - 0
src/app/features/graphite/gfunc.js

@@ -223,6 +223,13 @@ function (_, $) {
     defaultParams: ['max']
   });
 
+  addFuncDef({
+    name: "cumulative",
+    category: categories.Special,
+    params: [],
+    defaultParams: []
+  });
+
   addFuncDef({
     name: "groupByNode",
     category: categories.Special,
@@ -467,6 +474,13 @@ function (_, $) {
     defaultParams: [0]
   });
 
+  addFuncDef({
+    name: 'minimumBelow',
+    category: categories.Filter,
+    params: [{ name: "value", type: "int" }],
+    defaultParams: [0]
+  });
+
   addFuncDef({
     name: 'limit',
     category: categories.Filter,

+ 1 - 1
src/app/features/graphite/queryCtrl.js

@@ -9,7 +9,7 @@ function (angular, _, config, gfunc, Parser) {
   'use strict';
 
   var module = angular.module('grafana.controllers');
-  var targetLetters = ['A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O'];
+  var targetLetters = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ';
 
   module.controller('GraphiteQueryCtrl', function($scope, $sce, templateSrv) {
 

+ 11 - 16
src/app/features/influxdb/datasource.js

@@ -74,16 +74,19 @@ function (angular, _, kbn, InfluxSeries, InfluxQueryBuilder) {
     };
 
     InfluxDatasource.prototype.listColumns = function(seriesName) {
-      var interpolated = templateSrv.replace(seriesName);
-      if (interpolated[0] !== '/') {
-        interpolated = '/' + interpolated + '/';
+      seriesName = templateSrv.replace(seriesName);
+
+      if(!seriesName.match('^/.*/') && !seriesName.match(/^merge\(.*\)/)) {
+        seriesName = '"' + seriesName+ '"';
       }
 
-      return this._seriesQuery('select * from ' + interpolated + ' limit 1').then(function(data) {
+      return this._seriesQuery('select * from ' + seriesName + ' limit 1').then(function(data) {
         if (!data) {
           return [];
         }
-        return data[0].columns;
+        return data[0].columns.map(function(item) {
+          return /^\w+$/.test(item) ? item : ('"' + item + '"');
+        });
       });
     };
 
@@ -97,17 +100,9 @@ function (angular, _, kbn, InfluxSeries, InfluxQueryBuilder) {
         if (!data || data.length === 0) {
           return [];
         }
-        // influxdb >= 1.8
-        if (data[0].points.length > 0) {
-          return _.map(data[0].points, function(point) {
-            return point[1];
-          });
-        }
-        else { // influxdb <= 1.7
-          return _.map(data, function(series) {
-            return series.name; // influxdb < 1.7
-          });
-        }
+        return _.map(data[0].points, function(point) {
+          return point[1];
+        });
       });
     };
 

+ 0 - 1
src/app/features/influxdb/queryCtrl.js

@@ -88,7 +88,6 @@ function (angular, _) {
         seriesList = [];
         $scope.datasource.listSeries(query).then(function(series) {
           seriesList = series;
-          console.log(series);
           callback(seriesList);
         });
       }

+ 16 - 17
src/app/services/alertSrv.js

@@ -27,28 +27,27 @@ function (angular, _) {
     this.list = [];
 
     this.set = function(title,text,severity,timeout) {
-      var
-        _a = {
-          title: title || '',
-          text: $sce.trustAsHtml(text || ''),
-          severity: severity || 'info',
-        },
-        _ca = angular.toJson(_a),
-        _clist = _.map(self.list,function(alert) {return angular.toJson(alert);});
-
-      // If we already have this alert, remove it and add a new one
-      // Why do this instead of skipping the add because it resets the timer
-      if(_.contains(_clist,_ca)) {
-        _.remove(self.list,_.indexOf(_clist,_ca));
-      }
+      var newAlert = {
+        title: title || '',
+        text: $sce.trustAsHtml(text || ''),
+        severity: severity || 'info',
+      };
+
+      var newAlertJson = angular.toJson(newAlert);
 
-      self.list.push(_a);
+      // remove same alert if it already exists
+      _.remove(self.list, function(value) {
+        return angular.toJson(value) === newAlertJson;
+      });
+
+      self.list.push(newAlert);
       if (timeout > 0) {
         $timeout(function() {
-          self.list = _.without(self.list,_a);
+          self.list = _.without(self.list,newAlert);
         }, timeout);
       }
-      return(_a);
+
+      return(newAlert);
     };
 
     this.clear = function(alert) {