mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
Worked on stars in search results
This commit is contained in:
parent
ad3d15e28d
commit
97758380e0
2
grafana
2
grafana
@ -1 +1 @@
|
||||
Subproject commit 1e3970c6e56af810047ab815acd7fd5e681b5139
|
||||
Subproject commit b67f4dc390b5241339b8f2799110faf3d454e4c5
|
@ -45,6 +45,7 @@ func Register(r *macaron.Macaron) {
|
||||
r.Put("/", bind(m.UpdateUserCommand{}), UpdateUser)
|
||||
r.Post("/using/:id", SetUsingAccount)
|
||||
r.Get("/accounts", GetUserAccounts)
|
||||
r.Get("/stars/", GetUserStars)
|
||||
r.Post("/stars/dashboard/:id", StarDashboard)
|
||||
r.Delete("/stars/dashboard/:id", UnstarDashboard)
|
||||
})
|
||||
|
@ -57,6 +57,10 @@ type MetricQueryResultDataDto struct {
|
||||
DataPoints [][2]float64 `json:"datapoints"`
|
||||
}
|
||||
|
||||
type UserStars struct {
|
||||
DashboardIds map[string]bool `json:"dashboardIds"`
|
||||
}
|
||||
|
||||
func GetGravatarUrl(text string) string {
|
||||
if text == "" {
|
||||
return ""
|
||||
|
@ -1,6 +1,9 @@
|
||||
package api
|
||||
|
||||
import (
|
||||
"strconv"
|
||||
|
||||
"github.com/torkelo/grafana-pro/pkg/api/dtos"
|
||||
"github.com/torkelo/grafana-pro/pkg/bus"
|
||||
"github.com/torkelo/grafana-pro/pkg/middleware"
|
||||
m "github.com/torkelo/grafana-pro/pkg/models"
|
||||
@ -43,3 +46,20 @@ func UnstarDashboard(c *middleware.Context) {
|
||||
|
||||
c.JsonOK("Dashboard unstarred")
|
||||
}
|
||||
|
||||
func GetUserStars(c *middleware.Context) {
|
||||
query := m.GetUserStarsQuery{UserId: c.UserId}
|
||||
|
||||
if err := bus.Dispatch(&query); err != nil {
|
||||
c.JsonApiErr(500, "Failed to get user stars", err)
|
||||
return
|
||||
}
|
||||
|
||||
var result dtos.UserStars
|
||||
result.DashboardIds = make(map[string]bool)
|
||||
for _, star := range query.Result {
|
||||
result.DashboardIds[strconv.FormatInt(star.DashboardId, 10)] = true
|
||||
}
|
||||
|
||||
c.JSON(200, &result)
|
||||
}
|
||||
|
@ -7,6 +7,7 @@ type SearchResult struct {
|
||||
}
|
||||
|
||||
type DashboardSearchHit struct {
|
||||
Id int64 `json:"id"`
|
||||
Title string `json:"title"`
|
||||
Slug string `json:"slug"`
|
||||
Tags []string `json:"tags"`
|
||||
|
@ -105,6 +105,7 @@ func SearchDashboards(query *m.SearchDashboardsQuery) error {
|
||||
hit, exists := hits[item.Id]
|
||||
if !exists {
|
||||
hit = &m.DashboardSearchHit{
|
||||
Id: item.Id,
|
||||
Title: item.Title,
|
||||
Slug: item.Slug,
|
||||
Tags: []string{},
|
||||
|
Loading…
Reference in New Issue
Block a user