2015-05-13 06:36:13 -05:00
|
|
|
package search
|
|
|
|
|
2017-04-27 05:38:38 -05:00
|
|
|
import "strings"
|
2017-06-16 19:33:53 -05:00
|
|
|
import "github.com/grafana/grafana/pkg/models"
|
2017-04-27 05:38:38 -05:00
|
|
|
|
2015-05-13 06:36:13 -05:00
|
|
|
type HitType string
|
|
|
|
|
|
|
|
const (
|
|
|
|
DashHitDB HitType = "dash-db"
|
|
|
|
DashHitHome HitType = "dash-home"
|
|
|
|
DashHitJson HitType = "dash-json"
|
|
|
|
DashHitScripted HitType = "dash-scripted"
|
2017-03-27 07:36:28 -05:00
|
|
|
DashHitFolder HitType = "dash-folder"
|
2015-05-13 06:36:13 -05:00
|
|
|
)
|
|
|
|
|
|
|
|
type Hit struct {
|
2017-06-23 15:00:26 -05:00
|
|
|
Id int64 `json:"id"`
|
|
|
|
Title string `json:"title"`
|
|
|
|
Uri string `json:"uri"`
|
|
|
|
Type HitType `json:"type"`
|
|
|
|
Tags []string `json:"tags"`
|
|
|
|
IsStarred bool `json:"isStarred"`
|
|
|
|
FolderId int64 `json:"folderId,omitempty"`
|
|
|
|
FolderTitle string `json:"folderTitle,omitempty"`
|
|
|
|
FolderSlug string `json:"folderSlug,omitempty"`
|
2015-05-13 06:36:13 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
type HitList []*Hit
|
|
|
|
|
2017-04-27 05:38:38 -05:00
|
|
|
func (s HitList) Len() int { return len(s) }
|
|
|
|
func (s HitList) Swap(i, j int) { s[i], s[j] = s[j], s[i] }
|
|
|
|
func (s HitList) Less(i, j int) bool {
|
|
|
|
if s[i].Type == "dash-folder" && s[j].Type == "dash-db" {
|
|
|
|
return true
|
|
|
|
}
|
|
|
|
|
|
|
|
if s[i].Type == "dash-db" && s[j].Type == "dash-folder" {
|
|
|
|
return false
|
|
|
|
}
|
|
|
|
|
|
|
|
return strings.ToLower(s[i].Title) < strings.ToLower(s[j].Title)
|
|
|
|
}
|
2015-05-13 06:36:13 -05:00
|
|
|
|
|
|
|
type Query struct {
|
2016-03-05 05:26:21 -06:00
|
|
|
Title string
|
|
|
|
Tags []string
|
|
|
|
OrgId int64
|
2017-06-16 19:33:53 -05:00
|
|
|
SignedInUser *models.SignedInUser
|
2016-03-05 05:26:21 -06:00
|
|
|
Limit int
|
|
|
|
IsStarred bool
|
2017-05-24 11:28:13 -05:00
|
|
|
Type string
|
2017-06-16 19:33:53 -05:00
|
|
|
DashboardIds []int64
|
2017-06-01 16:30:31 -05:00
|
|
|
FolderId int64
|
|
|
|
Mode string
|
2015-05-13 06:36:13 -05:00
|
|
|
|
|
|
|
Result HitList
|
|
|
|
}
|
|
|
|
|
|
|
|
type FindPersistedDashboardsQuery struct {
|
2016-03-05 05:26:21 -06:00
|
|
|
Title string
|
|
|
|
OrgId int64
|
2017-06-16 19:33:53 -05:00
|
|
|
SignedInUser *models.SignedInUser
|
2016-03-05 05:26:21 -06:00
|
|
|
IsStarred bool
|
2017-06-16 19:33:53 -05:00
|
|
|
DashboardIds []int64
|
2017-05-24 11:28:13 -05:00
|
|
|
Type string
|
2017-06-23 15:00:26 -05:00
|
|
|
FolderId int64
|
2017-06-01 16:30:31 -05:00
|
|
|
Mode string
|
2015-05-13 06:36:13 -05:00
|
|
|
|
|
|
|
Result HitList
|
|
|
|
}
|