use history service in the dashboard app

This commit is contained in:
Joe Fleming 2014-08-05 18:00:01 -07:00
parent 3c62973edb
commit 4d93498e81
2 changed files with 5 additions and 12 deletions

View file

@ -42,10 +42,11 @@ define(function (require) {
}
});
app.directive('dashboardApp', function (Notifier, courier, storage, config, savedVisualizations, appStateFactory, timefilter) {
app.directive('dashboardApp', function (Notifier, courier, History, savedVisualizations, appStateFactory, timefilter) {
return {
controller: function ($scope, $route, $routeParams, $location, configFile) {
$scope.history = storage.get('dashboard:history') || [];
var history = new History('dashboard:history');
$scope.history = history.get();
var notify = new Notifier({
location: 'Dashboard'
@ -98,19 +99,10 @@ define(function (require) {
}
}
function updateQueryHistory() {
if ($state.query.length) {
var history = _.pull($scope.history.slice(0), $state.query);
history.unshift($state.query);
$scope.history = history.slice(0, config.get('history:limit'));
storage.set('dashboard:history', $scope.history);
}
}
$scope.filterResults = function () {
updateQueryOnRootSource();
$state.save();
updateQueryHistory();
$scope.history = history.add($state.query);
courier.fetch();
};

View file

@ -70,6 +70,7 @@
'specs/filters/moment',
'specs/filters/start_from',
'specs/services/storage',
'specs/services/history',
'specs/utils/datemath',
'specs/utils/interval',
'specs/utils/versionmath',