Skip to content

Commit

Permalink
Merge pull request #347 from barnash/query-params-for-filters
Browse files Browse the repository at this point in the history
Query params for filters
  • Loading branch information
arikfr committed Jan 13, 2015
2 parents ef868db + 02c8163 commit 77d982b
Showing 1 changed file with 11 additions and 10 deletions.
21 changes: 11 additions & 10 deletions rd_ui/app/scripts/controllers/dashboard.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
(function() {
var DashboardCtrl = function($scope, Events, Widget, $routeParams, $http, $timeout, $q, Dashboard) {
var DashboardCtrl = function($scope, Events, Widget, $routeParams, $location, $http, $timeout, $q, Dashboard) {
$scope.refreshEnabled = false;
$scope.refreshRate = 60;

Expand All @@ -15,7 +15,7 @@
return _.map(row, function (widget) {
var w = new Widget(widget);

if (w.visualization && dashboard.dashboard_filters_enabled) {
if (w.visualization) {
promises.push(w.getQuery().getQueryResultPromise());
}

Expand All @@ -32,22 +32,23 @@
// TODO: first object should be a copy, otherwise one of the chart filters behaves different than the others.
filters[filter.name] = filter;
filters[filter.name].originFilters = [];
if (_.has($location.search(), filter.name)) {
filter.current = $location.search()[filter.name];
}

$scope.$watch(function () { return filter.current }, function (value) {
_.each(filter.originFilters, function (originFilter) {
originFilter.current = value;
});
});
};
}

// TODO: merge values.
filters[filter.name].originFilters.push(filter);
});
});

if (dashboard.dashboard_filters_enabled) {
$scope.filters = _.values(filters);
}
$scope.filters = _.values(filters);
});


Expand Down Expand Up @@ -83,8 +84,8 @@
});

}, $scope.refreshRate);
};
}
}
};

$scope.triggerRefresh = function() {
$scope.refreshEnabled = !$scope.refreshEnabled;
Expand Down Expand Up @@ -137,7 +138,7 @@
};

angular.module('redash.controllers')
.controller('DashboardCtrl', ['$scope', 'Events', 'Widget', '$routeParams', '$http', '$timeout', '$q', 'Dashboard', DashboardCtrl])
.controller('DashboardCtrl', ['$scope', 'Events', 'Widget', '$routeParams', '$location', '$http', '$timeout', '$q', 'Dashboard', DashboardCtrl])
.controller('WidgetCtrl', ['$scope', 'Events', 'Query', WidgetCtrl])

})();
})();

0 comments on commit 77d982b

Please sign in to comment.