Browse Source

filterSrv refactoring fixes

Torkel Ödegaard 11 years ago
parent
commit
9f548b9dee
3 changed files with 9 additions and 10 deletions
  1. 2 6
      src/app/controllers/dash.js
  2. 1 1
      src/app/services/dashboard.js
  3. 6 3
      src/app/services/filterSrv.js

+ 2 - 6
src/app/controllers/dash.js

@@ -61,14 +61,10 @@ function (angular, $, config, _) {
       $scope.filter = filterSrv;
       $scope.filter = filterSrv;
       $scope.filter.init(dashboard.current);
       $scope.filter.init(dashboard.current);
 
 
-      $scope.$watch('dashboard.current', function(newValue) {
-        $scope.filter.init(newValue);
+      $rootScope.$on("dashboard-loaded", function(event, dashboard) {
+        $scope.filter.init(dashboard);
       });
       });
 
 
-      $scope.$watch('filter.time', function() {
-        $scope.dashboard.refresh();
-      }, true);
-
       // Clear existing alerts
       // Clear existing alerts
       alertSrv.clearAll();
       alertSrv.clearAll();
 
 

+ 1 - 1
src/app/services/dashboard.js

@@ -167,7 +167,7 @@ function (angular, $, kbn, _, config, moment, Modernizr) {
       // Take out any that we're not allowed to add from the gui.
       // Take out any that we're not allowed to add from the gui.
       self.availablePanels = _.difference(self.availablePanels,config.hidden_panels);
       self.availablePanels = _.difference(self.availablePanels,config.hidden_panels);
 
 
-      $rootScope.$emit('dashboard-loaded');
+      $rootScope.$emit('dashboard-loaded', self.current);
 
 
       $timeout(function() {
       $timeout(function() {
         self.original = angular.copy(self.current);
         self.original = angular.copy(self.current);

+ 6 - 3
src/app/services/filterSrv.js

@@ -55,17 +55,20 @@ define([
 
 
     setTime: function(time) {
     setTime: function(time) {
       _.extend(this.time, time);
       _.extend(this.time, time);
+
       // disable refresh if we have an absolute time
       // disable refresh if we have an absolute time
       if (time.to !== 'now') {
       if (time.to !== 'now') {
         this.old_refresh = this.dashboard.refresh;
         this.old_refresh = this.dashboard.refresh;
         dashboard.set_interval(false);
         dashboard.set_interval(false);
-        return;
       }
       }
-
-      if (this.old_refresh && this.old_refresh !== this.dashboard.refresh) {
+      else if (this.old_refresh && this.old_refresh !== this.dashboard.refresh) {
         dashboard.set_interval(this.old_refresh);
         dashboard.set_interval(this.old_refresh);
         this.old_refresh = null;
         this.old_refresh = null;
       }
       }
+
+      $timeout(function(){
+        dashboard.refresh();
+      },0);
     },
     },
 
 
     timeRange: function(parse) {
     timeRange: function(parse) {