Commit 68b9342d by Daniel Lee

WIP: dashboard search by type (folder or dash)

parent b4576edc
...@@ -14,6 +14,7 @@ func Search(c *middleware.Context) { ...@@ -14,6 +14,7 @@ func Search(c *middleware.Context) {
tags := c.QueryStrings("tag") tags := c.QueryStrings("tag")
starred := c.Query("starred") starred := c.Query("starred")
limit := c.QueryInt("limit") limit := c.QueryInt("limit")
dashboardType := c.Query("type")
if limit == 0 { if limit == 0 {
limit = 1000 limit = 1000
...@@ -35,6 +36,7 @@ func Search(c *middleware.Context) { ...@@ -35,6 +36,7 @@ func Search(c *middleware.Context) {
IsStarred: starred == "true", IsStarred: starred == "true",
OrgId: c.OrgId, OrgId: c.OrgId,
DashboardIds: dbids, DashboardIds: dbids,
Type: dashboardType,
} }
err := bus.Dispatch(&searchQuery) err := bus.Dispatch(&searchQuery)
......
...@@ -45,6 +45,7 @@ func searchHandler(query *Query) error { ...@@ -45,6 +45,7 @@ func searchHandler(query *Query) error {
IsStarred: query.IsStarred, IsStarred: query.IsStarred,
OrgId: query.OrgId, OrgId: query.OrgId,
DashboardIds: query.DashboardIds, DashboardIds: query.DashboardIds,
Type: query.Type,
} }
if err := bus.Dispatch(&dashQuery); err != nil { if err := bus.Dispatch(&dashQuery); err != nil {
......
...@@ -46,6 +46,7 @@ type Query struct { ...@@ -46,6 +46,7 @@ type Query struct {
UserId int64 UserId int64
Limit int Limit int
IsStarred bool IsStarred bool
Type string
DashboardIds []int DashboardIds []int
Result HitList Result HitList
...@@ -57,6 +58,7 @@ type FindPersistedDashboardsQuery struct { ...@@ -57,6 +58,7 @@ type FindPersistedDashboardsQuery struct {
UserId int64 UserId int64
IsStarred bool IsStarred bool
DashboardIds []int DashboardIds []int
Type string
Result HitList Result HitList
} }
...@@ -201,6 +201,14 @@ func findDashboards(query *search.FindPersistedDashboardsQuery) ([]DashboardSear ...@@ -201,6 +201,14 @@ func findDashboards(query *search.FindPersistedDashboardsQuery) ([]DashboardSear
params = append(params, "%"+query.Title+"%") params = append(params, "%"+query.Title+"%")
} }
if len(query.Type) > 0 && query.Type == "dash-folder" {
sql.WriteString(" AND dashboard.is_folder = 1")
}
if len(query.Type) > 0 && query.Type == "dash-db" {
sql.WriteString(" AND dashboard.is_folder = 0")
}
sql.WriteString(fmt.Sprintf(" ORDER BY dashboard.title ASC LIMIT 1000")) sql.WriteString(fmt.Sprintf(" ORDER BY dashboard.title ASC LIMIT 1000"))
var res []DashboardSearchProjection var res []DashboardSearchProjection
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment