mirror of
https://github.com/grafana/grafana.git
synced 2024-11-26 02:40:26 -06:00
1248728d7f
Breaks some stuff like selected dash in the search result. In dashboard search, if the user is not searching then the result is returned as a tree structure. No ACL's or user group ux yet.
51 lines
1.0 KiB
Go
51 lines
1.0 KiB
Go
package api
|
|
|
|
import (
|
|
"strconv"
|
|
|
|
"github.com/grafana/grafana/pkg/bus"
|
|
"github.com/grafana/grafana/pkg/metrics"
|
|
"github.com/grafana/grafana/pkg/middleware"
|
|
"github.com/grafana/grafana/pkg/services/search"
|
|
)
|
|
|
|
func Search(c *middleware.Context) {
|
|
query := c.Query("query")
|
|
tags := c.QueryStrings("tag")
|
|
starred := c.Query("starred")
|
|
limit := c.QueryInt("limit")
|
|
browseMode := c.Query("browseMode")
|
|
|
|
if limit == 0 {
|
|
limit = 1000
|
|
}
|
|
|
|
dbids := make([]int, 0)
|
|
for _, id := range c.QueryStrings("dashboardIds") {
|
|
dashboardId, err := strconv.Atoi(id)
|
|
if err == nil {
|
|
dbids = append(dbids, dashboardId)
|
|
}
|
|
}
|
|
|
|
searchQuery := search.Query{
|
|
Title: query,
|
|
Tags: tags,
|
|
UserId: c.UserId,
|
|
Limit: limit,
|
|
IsStarred: starred == "true",
|
|
OrgId: c.OrgId,
|
|
DashboardIds: dbids,
|
|
BrowseMode: browseMode == "true",
|
|
}
|
|
|
|
err := bus.Dispatch(&searchQuery)
|
|
if err != nil {
|
|
c.JsonApiErr(500, "Search failed", err)
|
|
return
|
|
}
|
|
|
|
c.TimeRequest(metrics.M_Api_Dashboard_Search)
|
|
c.JSON(200, searchQuery.Result)
|
|
}
|