Преглед изворни кода

Fixes #191, update graph after adding new function and not changing default value

Torkel Ödegaard пре 11 година
родитељ
комит
9ebf769b4d

+ 1 - 1
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"

+ 7 - 3
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) {

+ 2 - 5
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();

+ 0 - 4
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 () {