diff --git a/pkg/api/search.go b/pkg/api/search.go index d0f93851d79..f180482fd0e 100644 --- a/pkg/api/search.go +++ b/pkg/api/search.go @@ -4,7 +4,6 @@ import ( "github.com/grafana/grafana/pkg/bus" "github.com/grafana/grafana/pkg/middleware" m "github.com/grafana/grafana/pkg/models" - "github.com/grafana/grafana/pkg/setting" ) // TODO: this needs to be cached or improved somehow @@ -76,9 +75,6 @@ func Search(c *middleware.Context) { } result.Dashboards = query.Result - for _, dash := range result.Dashboards { - dash.Url = setting.ToAbsUrl("dashboard/db/" + dash.Slug) - } } c.JSON(200, result) diff --git a/pkg/models/search.go b/pkg/models/search.go index 4f5b24ff084..0265d48b32d 100644 --- a/pkg/models/search.go +++ b/pkg/models/search.go @@ -11,7 +11,6 @@ type DashboardSearchHit struct { Title string `json:"title"` Slug string `json:"slug"` Tags []string `json:"tags"` - Url string `json:"url"` IsStarred bool `json:"isStarred"` } diff --git a/src/app/controllers/search.js b/src/app/controllers/search.js index 3819be3a2e7..e724aadcf7f 100644 --- a/src/app/controllers/search.js +++ b/src/app/controllers/search.js @@ -48,7 +48,7 @@ function (angular, _, config) { var selectedDash = $scope.results.dashboards[$scope.selectedIndex]; if (selectedDash) { $location.search({}); - $location.path("/dashboard/db/" + selectedDash.slug); + $location.path(selectedDash.url); } } }; @@ -57,11 +57,6 @@ function (angular, _, config) { $scope.selectedIndex = Math.max(Math.min($scope.selectedIndex + direction, $scope.resultCount - 1), 0); }; - $scope.goToDashboard = function(slug) { - $location.search({}); - $location.path("/dashboard/db/" + slug); - }; - $scope.searchDashboards = function() { $scope.currentSearchId = $scope.currentSearchId + 1; var localSearchId = $scope.currentSearchId; @@ -70,13 +65,16 @@ function (angular, _, config) { .then(function(results) { if (localSearchId < $scope.currentSearchId) { return; } - if ($scope.query.query === "" && !$scope.query.starred) { - results.dashboards.unshift({ title: 'Home', url: config.appSubUrl + '/', isHome: true }); - } - - $scope.results.dashboards = results.dashboards; - $scope.results.tags = results.tags; $scope.resultCount = results.tagsOnly ? results.tags.length : results.dashboards.length; + $scope.results.tags = results.tags; + $scope.results.dashboards = _.map(results.dashboards, function(dash) { + dash.url = 'dashboard/db/' + dash.slug; + return dash; + }); + + if ($scope.query.query === "" && !$scope.query.starred) { + $scope.results.dashboards.unshift({ title: 'Home', url: config.appSubUrl + '/', isHome: true }); + } }); }; diff --git a/src/app/panels/dashlist/module.html b/src/app/panels/dashlist/module.html index c02e993984a..b59822e09a2 100644 --- a/src/app/panels/dashlist/module.html +++ b/src/app/panels/dashlist/module.html @@ -1,7 +1,7 @@