From 30bf838065928872adbecc979eb67265b8560253 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Torkel=20=C3=96degaard?= Date: Mon, 14 Apr 2014 08:17:42 +0200 Subject: [PATCH] added smartSummarize graphite function definition --- src/app/services/graphite/gfunc.js | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/src/app/services/graphite/gfunc.js b/src/app/services/graphite/gfunc.js index 3f1bad4e679..d21624fd1cc 100644 --- a/src/app/services/graphite/gfunc.js +++ b/src/app/services/graphite/gfunc.js @@ -140,7 +140,7 @@ function (_) { ], defaultParams: ['max'] }); - + addFuncDef({ name: "groupByNode", category: categories.Special, @@ -285,6 +285,13 @@ function (_) { defaultParams: ['1h', 'sum'] }); + addFuncDef({ + name: 'smartSummarize', + category: categories.Transform, + params: [ { name: "interval", type: "string" }, { name: "func", type: "select", options: ['sum', 'avg', 'min', 'max', 'last'] }], + defaultParams: ['1h', 'sum'] + }); + addFuncDef({ name: 'absolute', category: categories.Transform, @@ -490,25 +497,25 @@ function (_) { return this.def.params[index + 1] && this.def.params[index + 1].optional; }; - FuncInstance.prototype.updateParam = function(strValue, index) { + FuncInstance.prototype.updateParam = function(strValue, index) { // handle optional parameters // if string contains ',' and next param is optional, split and update both - if (this._hasMultipleParamsInString(strValue, index)) { + if (this._hasMultipleParamsInString(strValue, index)) { _.each(strValue.split(','), function(partVal, idx) { this.updateParam(partVal.trim(), idx); - }, this); + }, this); return; } - if (strValue === '' && this.def.params[index].optional) { - this.params.splice(index, 1); + if (strValue === '' && this.def.params[index].optional) { + this.params.splice(index, 1); } else if (this.def.params[index].type === 'int') { this.params[index] = parseFloat(strValue, 10); } else { this.params[index] = strValue; - } + } this.updateText(); };