Forráskód Böngészése

Removed use of absolute urls in dashboard search and dashlist, root_url option is now not required, it is required if you use oauth or proxy grafana under suburl, #1483

Torkel Ödegaard 11 éve
szülő
commit
26eb6e559e

+ 0 - 4
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)

+ 0 - 1
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"`
 }
 

+ 9 - 11
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; }
 
+          $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) {
-            results.dashboards.unshift({ title: 'Home', url: config.appSubUrl + '/', isHome: true });
+            $scope.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;
         });
     };
 

+ 1 - 1
src/app/panels/dashlist/module.html

@@ -1,7 +1,7 @@
 <grafana-panel>
 	<div class="dashlist">
 	<div class="dashlist-item" ng-repeat="dash in dashList">
-		<a class="dashlist-link" href="{{dash.url}}">
+		<a class="dashlist-link" href="dashboard/db/{{dash.slug}}">
 			<span class="dashlist-title">
 				{{dash.title}}
 			</span>