Explorar el Código

update timepicker on set_time event

Rashid Khan hace 12 años
padre
commit
d62e5c9237
Se han modificado 2 ficheros con 24 adiciones y 12 borrados
  1. 1 1
      panels/histogram/module.js
  2. 23 11
      panels/timepicker/module.js

+ 1 - 1
panels/histogram/module.js

@@ -261,7 +261,7 @@ angular.module('kibana.histogram', [])
         scope.time.from = new Date(ranges.xaxis.from);
         scope.time.to   = new Date(ranges.xaxis.to)
         scope.set_time(scope.time);
-        eventBus.broadcast(scope.$id,scope.panel.group,'time',scope.time)
+        eventBus.broadcast(scope.$id,scope.panel.group,'set_time',scope.time)
       });
     }
   };

+ 23 - 11
panels/timepicker/module.js

@@ -83,6 +83,14 @@ angular.module('kibana.timepicker', [])
     eventBus.register($scope,"get_time", function(event,id) {
       eventBus.broadcast($scope.$id,id,'time',$scope.time)
     });
+
+    // In case some other panel broadcasts a time, set us to an absolute range
+    eventBus.register($scope,"set_time", function(event,time) {
+      $scope.panel.mode = 'absolute';
+      set_timepicker(time.from,time.to)
+      $scope.time_apply()
+    });
+    
     $scope.$on('render', function (){
       $scope.time_apply();
     });
@@ -157,18 +165,8 @@ angular.module('kibana.timepicker', [])
     if (from.getTime() >= to.getTime())
       from = new Date(to.getTime() - 1000)
 
-    // Janky 0s timeout to get around $scope queue processing view issue
     $timeout(function(){
-      $scope.timepicker = {
-        from : {
-          time : from.format("HH:MM:ss"),
-          date : from.format("mm/dd/yyyy")
-        },
-        to : {
-          time : to.format("HH:MM:ss"),
-          date : to.format("mm/dd/yyyy")
-        } 
-      }
+      set_timepicker(from,to)
     });
 
     return {
@@ -202,6 +200,20 @@ angular.module('kibana.timepicker', [])
     };
   };
 
+  function set_timepicker(from,to) {
+    // Janky 0s timeout to get around $scope queue processing view issue
+    $scope.timepicker = {
+      from : {
+        time : from.format("HH:MM:ss"),
+        date : from.format("mm/dd/yyyy")
+      },
+      to : {
+        time : to.format("HH:MM:ss"),
+        date : to.format("mm/dd/yyyy")
+      } 
+    }
+  }
+
   // returns a promise containing an array of all indices matching the index
   // pattern that exist in a given range
   function indices(from,to) {