Merge remote-tracking branch 'upstream/master'

This commit is contained in:
Rashid Khan 2014-05-22 10:02:56 -07:00
commit 7c4fb49e9e

View file

@ -59,7 +59,7 @@ define(function (require) {
// the actual courier.SearchSource // the actual courier.SearchSource
var searchSource = savedSearch.searchSource; var searchSource = savedSearch.searchSource;
/* Manage state & url state */ // Manage state & url state
var initialQuery = searchSource.get('query'); var initialQuery = searchSource.get('query');
var stateDefaults = { var stateDefaults = {
@ -98,9 +98,6 @@ define(function (require) {
// So we can watch it. // So we can watch it.
$scope.time = timefilter.time; $scope.time = timefilter.time;
// TODO: Switch this to watching time.string when we implement it
$scope.$watchCollection('time', _.bindKey($scope, 'fetch'));
// stores the complete list of fields // stores the complete list of fields
$scope.fields = null; $scope.fields = null;
@ -118,6 +115,12 @@ define(function (require) {
if (_.difference(changed, ignoreStateChanges).length) $scope.fetch(); if (_.difference(changed, ignoreStateChanges).length) $scope.fetch();
}); });
// TODO: Switch this to watching time.string when we implement it
$scope.$watchCollection('time', function (newTime, oldTime) {
// don't fetch unless there was a previous value and the values are not loosly equal
if (!_.isUndefined(oldTime) && !angular.equals(newTime, oldTime)) $scope.fetch();
});
$scope.$watch('state.sort', function (sort) { $scope.$watch('state.sort', function (sort) {
if (!sort) return; if (!sort) return;
@ -174,12 +177,12 @@ define(function (require) {
}; };
$scope.fetch = function () { $scope.fetch = function () {
if ($scope.opts.timefield) timefilter.enabled(true);
updateDataSource();
$state.commit();
setupVisualization().then(function () { setupVisualization().then(function () {
if ($scope.opts.timefield) timefilter.enabled(true);
updateDataSource();
$state.commit();
courier.fetch(); courier.fetch();
}, notify.error); }, notify.error);
}; };
@ -343,8 +346,8 @@ define(function (require) {
return; return;
} }
// since we fetch all fields, adding/removing fields does not require another fetch // if this commit results in something besides the columns changing, a fetch will be executed.
// $scope.fetch(); $state.commit();
} }
// TODO: Move to utility class // TODO: Move to utility class