Fixed small issue in search and showing Home dashboard when filtering by tag

This commit is contained in:
Torkel Ödegaard 2015-02-23 09:54:26 +01:00
parent 6347b9b0d7
commit a146a24c06

View File

@ -14,7 +14,7 @@ function (angular, _, config) {
$scope.giveSearchFocus = 0; $scope.giveSearchFocus = 0;
$scope.selectedIndex = -1; $scope.selectedIndex = -1;
$scope.results = {dashboards: [], tags: [], metrics: []}; $scope.results = {dashboards: [], tags: [], metrics: []};
$scope.query = { query: '' }; $scope.query = { query: '', tag: '', starred: false };
$scope.db = datasourceSrv.getGrafanaDB(); $scope.db = datasourceSrv.getGrafanaDB();
$scope.currentSearchId = 0; $scope.currentSearchId = 0;
@ -72,12 +72,17 @@ function (angular, _, config) {
return dash; return dash;
}); });
if ($scope.query.query === "" && !$scope.query.starred) { if ($scope.queryHasNoFilters()) {
$scope.results.dashboards.unshift({ title: 'Home', url: config.appSubUrl + '/', isHome: true }); $scope.results.dashboards.unshift({ title: 'Home', url: config.appSubUrl + '/', isHome: true });
} }
}); });
}; };
$scope.queryHasNoFilters = function() {
var query = $scope.query;
return query.query === '' && query.starred === false && query.tag === '';
};
$scope.filterByTag = function(tag, evt) { $scope.filterByTag = function(tag, evt) {
$scope.query.tag = tag; $scope.query.tag = tag;
$scope.query.tagcloud = false; $scope.query.tagcloud = false;