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 (
|
2017-06-23 16:13:58 -05:00
|
|
|
DashHitDB HitType = "dash-db"
|
|
|
|
DashHitHome HitType = "dash-home"
|
|
|
|
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"`
|
2018-01-31 10:15:00 -06:00
|
|
|
Uid string `json:"uid"`
|
2017-06-23 15:00:26 -05:00
|
|
|
Title string `json:"title"`
|
|
|
|
Uri string `json:"uri"`
|
2018-01-30 08:24:14 -06:00
|
|
|
Url string `json:"url"`
|
2019-02-28 03:35:53 -06:00
|
|
|
Slug string `json:"slug"`
|
2017-06-23 15:00:26 -05:00
|
|
|
Type HitType `json:"type"`
|
|
|
|
Tags []string `json:"tags"`
|
|
|
|
IsStarred bool `json:"isStarred"`
|
|
|
|
FolderId int64 `json:"folderId,omitempty"`
|
2018-02-05 06:23:24 -06:00
|
|
|
FolderUid string `json:"folderUid,omitempty"`
|
2017-06-23 15:00:26 -05:00
|
|
|
FolderTitle string `json:"folderTitle,omitempty"`
|
2018-02-05 06:23:24 -06:00
|
|
|
FolderUrl string `json:"folderUrl,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
|
2019-04-17 06:07:50 -05:00
|
|
|
Limit int64
|
|
|
|
Page int64
|
2016-03-05 05:26:21 -06:00
|
|
|
IsStarred bool
|
2017-05-24 11:28:13 -05:00
|
|
|
Type string
|
2017-06-16 19:33:53 -05:00
|
|
|
DashboardIds []int64
|
2017-11-20 05:47:03 -06:00
|
|
|
FolderIds []int64
|
2018-02-08 10:11:01 -06:00
|
|
|
Permission models.PermissionType
|
2015-05-13 06:36:13 -05:00
|
|
|
|
|
|
|
Result HitList
|
|
|
|
}
|
|
|
|
|
|
|
|
type FindPersistedDashboardsQuery struct {
|
2017-11-20 05:47:03 -06:00
|
|
|
Title string
|
|
|
|
OrgId int64
|
|
|
|
SignedInUser *models.SignedInUser
|
|
|
|
IsStarred bool
|
|
|
|
DashboardIds []int64
|
|
|
|
Type string
|
|
|
|
FolderIds []int64
|
|
|
|
Tags []string
|
2019-04-17 06:07:50 -05:00
|
|
|
Limit int64
|
|
|
|
Page int64
|
2018-02-08 10:11:01 -06:00
|
|
|
Permission models.PermissionType
|
2015-05-13 06:36:13 -05:00
|
|
|
|
|
|
|
Result HitList
|
|
|
|
}
|