diff --git a/CHANGELOG.md b/CHANGELOG.md index cbf3cb542cc..caec17d0116 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,7 @@ **Fixes** - [Issue #1199](https://github.com/grafana/grafana/issues/1199). Graph: fix for series tooltip when one series is hidden/disabled +- [Issue #1207](https://github.com/grafana/grafana/issues/1207). Graphite: movingAverage / movingMedian parameter type impovement, now handles int and interval parameter # 1.9.0 (2014-12-02) diff --git a/src/app/services/graphite/gfunc.js b/src/app/services/graphite/gfunc.js index da1c8830569..6d1990d651e 100644 --- a/src/app/services/graphite/gfunc.js +++ b/src/app/services/graphite/gfunc.js @@ -1,7 +1,8 @@ define([ - 'lodash' + 'lodash', + 'jquery' ], -function (_) { +function (_, $) { 'use strict'; var index = []; @@ -501,15 +502,15 @@ function (_) { addFuncDef({ name: 'movingAverage', category: categories.Filter, - params: [{ name: "window size", type: "int" }], + params: [{ name: "windowSize", type: "int_or_interval", options: ['5', '7', '10', '5min', '10min', '30min', '1hour'] }], defaultParams: [10] }); addFuncDef({ name: 'movingMedian', category: categories.Filter, - params: [{ name: "windowSize", type: "select", options: ['1min', '5min', '15min', '30min', '1hour'] }], - defaultParams: ['1min'] + params: [{ name: "windowSize", type: "int_or_interval", options: ['5', '7', '10', '5min', '10min', '30min', '1hour'] }], + defaultParams: ['5'] }); addFuncDef({ @@ -595,6 +596,9 @@ function (_) { if (paramType === 'int' || paramType === 'value_or_series' || paramType === 'boolean') { return value; } + else if (paramType === 'int_or_interval' && $.isNumeric(value)) { + return value; + } return "'" + value + "'"; diff --git a/src/test/specs/gfunc-specs.js b/src/test/specs/gfunc-specs.js index f0650c16077..fdfb1051217 100644 --- a/src/test/specs/gfunc-specs.js +++ b/src/test/specs/gfunc-specs.js @@ -46,6 +46,18 @@ define([ expect(func.render('hello')).to.equal("scaleToSeconds(hello, 1)"); }); + it('should handle int or interval params with number', function() { + var func = gfunc.createFuncInstance('movingMedian'); + func.params[0] = '5'; + expect(func.render('hello')).to.equal("movingMedian(hello, 5)"); + }); + + it('should handle int or interval params with interval string', function() { + var func = gfunc.createFuncInstance('movingMedian'); + func.params[0] = '5min'; + expect(func.render('hello')).to.equal("movingMedian(hello, '5min')"); + }); + it('should handle metric param and int param and string param', function() { var func = gfunc.createFuncInstance('groupByNode'); func.params[0] = 5;