Explorar el Código

Graphs now update/refresh when you edit annotations, Fixes #1430

Torkel Ödegaard hace 11 años
padre
commit
9b9aab27ca

+ 3 - 0
src/app/features/annotations/editorCtrl.js

@@ -58,6 +58,7 @@ function (angular, _, $) {
     $scope.update = function() {
     $scope.update = function() {
       $scope.reset();
       $scope.reset();
       $scope.editor.index = 0;
       $scope.editor.index = 0;
+      $scope.broadcastRefresh();
     };
     };
 
 
     $scope.add = function() {
     $scope.add = function() {
@@ -65,12 +66,14 @@ function (angular, _, $) {
       $scope.reset();
       $scope.reset();
       $scope.editor.index = 0;
       $scope.editor.index = 0;
       $scope.updateSubmenuVisibility();
       $scope.updateSubmenuVisibility();
+      $scope.broadcastRefresh();
     };
     };
 
 
     $scope.removeAnnotation = function(annotation) {
     $scope.removeAnnotation = function(annotation) {
       var index = _.indexOf($scope.annotations, annotation);
       var index = _.indexOf($scope.annotations, annotation);
       $scope.annotations.splice(index, 1);
       $scope.annotations.splice(index, 1);
       $scope.updateSubmenuVisibility();
       $scope.updateSubmenuVisibility();
+      $scope.broadcastRefresh();
     };
     };
 
 
   });
   });

+ 2 - 1
src/app/features/annotations/partials/editor.html

@@ -10,7 +10,8 @@
 			<div ng-repeat="tab in ['Overview', 'Add', 'Edit']" data-title="{{tab}}">
 			<div ng-repeat="tab in ['Overview', 'Add', 'Edit']" data-title="{{tab}}">
 			</div>
 			</div>
 		</div>
 		</div>
-		<button class="gf-box-header-close-btn" ng-click="dismiss();dashboard.refresh();">
+
+		<button class="gf-box-header-close-btn" ng-click="dismiss();">
 			<i class="fa fa-remove"></i>
 			<i class="fa fa-remove"></i>
 		</button>
 		</button>
 	</div>
 	</div>

+ 4 - 0
src/app/features/dashboard/dashboardCtrl.js

@@ -72,6 +72,10 @@ function (angular, $, config) {
       $scope.contextSrv.lightTheme = $scope.dashboard.style === 'light';
       $scope.contextSrv.lightTheme = $scope.dashboard.style === 'light';
     };
     };
 
 
+    $scope.broadcastRefresh = function() {
+      $rootScope.$broadcast('refresh');
+    };
+
     $scope.add_row = function(dash, row) {
     $scope.add_row = function(dash, row) {
       dash.rows.push(row);
       dash.rows.push(row);
     };
     };

+ 1 - 5
src/app/features/dashboard/dashboardSrv.js

@@ -10,7 +10,7 @@ function (angular, $, kbn, _, moment) {
 
 
   var module = angular.module('grafana.services');
   var module = angular.module('grafana.services');
 
 
-  module.factory('dashboardSrv', function($rootScope)  {
+  module.factory('dashboardSrv', function()  {
 
 
     function DashboardModel (data) {
     function DashboardModel (data) {
 
 
@@ -132,10 +132,6 @@ function (angular, $, kbn, _, moment) {
               moment.utc(date).format(format);
               moment.utc(date).format(format);
     };
     };
 
 
-    p.emit_refresh = function() {
-      $rootScope.$broadcast('refresh');
-    };
-
     p._updateSchema = function(old) {
     p._updateSchema = function(old) {
       var i, j, k;
       var i, j, k;
       var oldVersion = this.version;
       var oldVersion = this.version;

+ 2 - 2
src/app/features/dashboard/keybindings.js

@@ -40,7 +40,7 @@ function(angular, $) {
       keyboardManager.bind('ctrl+o', function() {
       keyboardManager.bind('ctrl+o', function() {
         var current = scope.dashboard.sharedCrosshair;
         var current = scope.dashboard.sharedCrosshair;
         scope.dashboard.sharedCrosshair = !current;
         scope.dashboard.sharedCrosshair = !current;
-        scope.dashboard.emit_refresh('refresh');
+        scope.broadcastRefresh();
       }, { inputDisabled: true });
       }, { inputDisabled: true });
 
 
       keyboardManager.bind('ctrl+l', function() {
       keyboardManager.bind('ctrl+l', function() {
@@ -57,7 +57,7 @@ function(angular, $) {
       }, { inputDisabled: true });
       }, { inputDisabled: true });
 
 
       keyboardManager.bind('ctrl+r', function() {
       keyboardManager.bind('ctrl+r', function() {
-        scope.dashboard.emit_refresh();
+        scope.broadcastRefresh();
       }, { inputDisabled: true });
       }, { inputDisabled: true });
 
 
       keyboardManager.bind('ctrl+z', function(evt) {
       keyboardManager.bind('ctrl+z', function(evt) {

+ 1 - 1
src/app/features/dashboard/viewStateSrv.js

@@ -115,7 +115,7 @@ function (angular, _, $) {
 
 
       $timeout(function() {
       $timeout(function() {
         if (self.oldTimeRange !== self.fullscreenPanel.range) {
         if (self.oldTimeRange !== self.fullscreenPanel.range) {
-          self.$scope.dashboard.emit_refresh();
+          self.$scope.broadcastRefresh();
         }
         }
         else {
         else {
           self.fullscreenPanel.$broadcast('render');
           self.fullscreenPanel.$broadcast('render');