From 9ebf769b4d5995e85fb0a73b2985a1d3364ac426 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Torkel=20=C3=96degaard?= Date: Tue, 11 Mar 2014 13:00:28 +0100 Subject: [PATCH] Fixes #191, update graph after adding new function and not changing default value --- package.json | 2 +- src/app/controllers/graphiteTarget.js | 10 +++++++--- src/app/directives/graphiteFuncEditor.js | 7 ++----- src/app/services/graphite/gfunc.js | 4 ---- 4 files changed, 10 insertions(+), 13 deletions(-) diff --git a/package.json b/package.json index bf25a0b5161..333fb02d338 100644 --- a/package.json +++ b/package.json @@ -4,7 +4,7 @@ "company": "Coding Instinct AB" }, "name": "grafana", - "version": "1.5.0", + "version": "1.5.1", "repository": { "type": "git", "url": "http://github.com/torkelo/grafana.git" diff --git a/src/app/controllers/graphiteTarget.js b/src/app/controllers/graphiteTarget.js index 1fa8b98348a..a9617079bd2 100644 --- a/src/app/controllers/graphiteTarget.js +++ b/src/app/controllers/graphiteTarget.js @@ -211,10 +211,14 @@ function (angular, _, config, gfunc, Parser) { return; } + var oldTarget = $scope.target.target; + var target = getSegmentPathUpTo($scope.segments.length); - target = _.reduce($scope.functions, wrapFunction, target); - $scope.target.target = target; - $scope.$parent.get_data(); + $scope.target.target = _.reduce($scope.functions, wrapFunction, target); + + if ($scope.target.target !== oldTarget) { + $scope.$parent.get_data(); + } }; $scope.removeFunction = function(func) { diff --git a/src/app/directives/graphiteFuncEditor.js b/src/app/directives/graphiteFuncEditor.js index 99c3e40b70a..10516f1ca7c 100644 --- a/src/app/directives/graphiteFuncEditor.js +++ b/src/app/directives/graphiteFuncEditor.js @@ -60,11 +60,8 @@ function (angular, _, $) { if ($input.val() !== '') { $link.text($input.val()); - if (func.updateParam($input.val(), paramIndex)) { - $scope.$apply(function() { - $scope.targetChanged(); - }); - } + func.updateParam($input.val(), paramIndex); + $scope.$apply($scope.targetChanged); } $input.hide(); diff --git a/src/app/services/graphite/gfunc.js b/src/app/services/graphite/gfunc.js index 49c9f93d511..7f85197e44d 100644 --- a/src/app/services/graphite/gfunc.js +++ b/src/app/services/graphite/gfunc.js @@ -314,8 +314,6 @@ function (_) { }; FuncInstance.prototype.updateParam = function(strValue, index) { - var oldValue = this.params[index]; - if (this.def.params[index].type === 'int') { this.params[index] = parseInt(strValue, 10); } @@ -324,8 +322,6 @@ function (_) { } this.updateText(); - - return oldValue !== this.params[index]; }; FuncInstance.prototype.updateText = function () {