mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
Refactor search (#23550)
Co-Authored-By: Arve Knudsen <arve.knudsen@grafana.com> Co-Authored-By: Leonard Gram <leonard.gram@grafana.com>
This commit is contained in:
@@ -1,6 +1,8 @@
|
||||
package api
|
||||
|
||||
import (
|
||||
"github.com/grafana/grafana/pkg/util"
|
||||
"net/http"
|
||||
"strconv"
|
||||
|
||||
"github.com/grafana/grafana/pkg/bus"
|
||||
@@ -16,6 +18,7 @@ func Search(c *models.ReqContext) Response {
|
||||
limit := c.QueryInt64("limit")
|
||||
page := c.QueryInt64("page")
|
||||
dashboardType := c.Query("type")
|
||||
sort := c.Query("sort")
|
||||
permission := models.PERMISSION_VIEW
|
||||
|
||||
if limit > 5000 {
|
||||
@@ -54,6 +57,7 @@ func Search(c *models.ReqContext) Response {
|
||||
Type: dashboardType,
|
||||
FolderIds: folderIDs,
|
||||
Permission: permission,
|
||||
Sort: sort,
|
||||
}
|
||||
|
||||
err := bus.Dispatch(&searchQuery)
|
||||
@@ -64,3 +68,20 @@ func Search(c *models.ReqContext) Response {
|
||||
c.TimeRequest(metrics.MApiDashboardSearch)
|
||||
return JSON(200, searchQuery.Result)
|
||||
}
|
||||
|
||||
func (hs *HTTPServer) ListSortOptions(c *models.ReqContext) Response {
|
||||
opts := hs.SearchService.SortOptions()
|
||||
|
||||
res := []util.DynMap{}
|
||||
for _, o := range opts {
|
||||
res = append(res, util.DynMap{
|
||||
"name": o.Name,
|
||||
"displayName": o.DisplayName,
|
||||
"description": o.Description,
|
||||
})
|
||||
}
|
||||
|
||||
return JSON(http.StatusOK, util.DynMap{
|
||||
"sortOptions": res,
|
||||
})
|
||||
}
|
||||
|
Reference in New Issue
Block a user