Commit 316aa05d by Rashid Khan

Fixed timepicker

parent 4774a7a6
...@@ -86,6 +86,7 @@ angular.module('kibana.timepicker', []) ...@@ -86,6 +86,7 @@ angular.module('kibana.timepicker', [])
// In case some other panel broadcasts a time, set us to an absolute range // In case some other panel broadcasts a time, set us to an absolute range
$scope.$on('refresh', function() { $scope.$on('refresh', function() {
/*
if(filterSrv.idsByType('time').length > 0) { if(filterSrv.idsByType('time').length > 0) {
var time = filterSrv.timeRange('min'); var time = filterSrv.timeRange('min');
...@@ -93,6 +94,8 @@ angular.module('kibana.timepicker', []) ...@@ -93,6 +94,8 @@ angular.module('kibana.timepicker', [])
$scope.time.to.diff(moment.utc(time.to),'seconds') !== 0) $scope.time.to.diff(moment.utc(time.to),'seconds') !== 0)
{ {
console.log('time mismatch!')
return;
$scope.set_mode('absolute'); $scope.set_mode('absolute');
// These 3 statements basicly do everything time_apply() does // These 3 statements basicly do everything time_apply() does
...@@ -101,6 +104,7 @@ angular.module('kibana.timepicker', []) ...@@ -101,6 +104,7 @@ angular.module('kibana.timepicker', [])
update_panel(); update_panel();
} }
} }
*/
}); });
}; };
...@@ -176,12 +180,12 @@ angular.module('kibana.timepicker', []) ...@@ -176,12 +180,12 @@ angular.module('kibana.timepicker', [])
// //
$scope.time_calc = function(){ $scope.time_calc = function(){
var from,to; var from,to;
// If time picker is defined (usually is) // If time picker is defined (usually is) TOFIX: Horrible parsing
if(!(_.isUndefined($scope.timepicker))) { if(!(_.isUndefined($scope.timepicker))) {
from = $scope.panel.mode === 'relative' ? moment(kbn.time_ago($scope.panel.timespan)) : from = $scope.panel.mode === 'relative' ? moment(kbn.time_ago($scope.panel.timespan)) :
moment($scope.timepicker.from.date + " " + $scope.timepicker.from.time,'MM/DD/YYYY HH:mm:ss'); moment(moment.utc($scope.timepicker.from.date).format('MM/DD/YYYY') + " " + $scope.timepicker.from.time,'MM/DD/YYYY HH:mm:ss');
to = $scope.panel.mode !== 'absolute' ? moment() : to = $scope.panel.mode !== 'absolute' ? moment() :
moment($scope.timepicker.to.date + " " + $scope.timepicker.to.time,'MM/DD/YYYY HH:mm:ss'); moment(moment.utc($scope.timepicker.to.date).format('MM/DD/YYYY') + " " + $scope.timepicker.to.time,'MM/DD/YYYY HH:mm:ss');
// Otherwise (probably initialization) // Otherwise (probably initialization)
} else { } else {
from = $scope.panel.mode === 'relative' ? moment(kbn.time_ago($scope.panel.timespan)) : from = $scope.panel.mode === 'relative' ? moment(kbn.time_ago($scope.panel.timespan)) :
...@@ -211,11 +215,13 @@ angular.module('kibana.timepicker', []) ...@@ -211,11 +215,13 @@ angular.module('kibana.timepicker', [])
// Remove all other time filters // Remove all other time filters
filterSrv.removeByType('time'); filterSrv.removeByType('time');
$scope.time = $scope.time_calc(); $scope.time = $scope.time_calc();
$scope.time.field = $scope.panel.timefield; $scope.time.field = $scope.panel.timefield;
update_panel();
update_panel();
set_time_filter($scope.time); set_time_filter($scope.time);
dashboard.refresh(); dashboard.refresh();
}; };
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment