mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
updated
This commit is contained in:
parent
31fe471da5
commit
2380a26987
2
grafana
2
grafana
@ -1 +1 @@
|
||||
Subproject commit 477f66f56bdd7f310d439ac428cb646fbb9b1949
|
||||
Subproject commit c00384ad0644f9db7cdfa426c559d8fc3347a1d2
|
@ -29,8 +29,9 @@ func (self *HttpServer) getDashboard(c *gin.Context) {
|
||||
|
||||
func (self *HttpServer) search(c *gin.Context) {
|
||||
query := c.Params.ByName("q")
|
||||
accountId, err := c.Get("accountId")
|
||||
|
||||
results, err := self.store.Query(query)
|
||||
results, err := self.store.Query(query, accountId.(int))
|
||||
if err != nil {
|
||||
log.Error("Store query error: %v", err)
|
||||
c.JSON(500, newErrorResponse("Failed"))
|
||||
@ -42,12 +43,13 @@ func (self *HttpServer) search(c *gin.Context) {
|
||||
|
||||
func (self *HttpServer) postDashboard(c *gin.Context) {
|
||||
var command saveDashboardCommand
|
||||
accountId, _ := c.Get("accountId")
|
||||
|
||||
if c.EnsureBody(&command) {
|
||||
dashboard := models.NewDashboard("test")
|
||||
dashboard.Data = command.Dashboard
|
||||
dashboard.Title = dashboard.Data["title"].(string)
|
||||
dashboard.AccountId = 1
|
||||
dashboard.AccountId = accountId.(int)
|
||||
dashboard.UpdateSlug()
|
||||
|
||||
if dashboard.Data["id"] != nil {
|
||||
|
@ -51,6 +51,17 @@ func (self *HttpServer) logoutPost(c *gin.Context) {
|
||||
c.JSON(200, gin.H{"status": "logged out"})
|
||||
}
|
||||
|
||||
type GrafanaReqContext struct {
|
||||
}
|
||||
|
||||
type authenticatedAuthRouteFunc func(c *gin.Context, grc GrafanaReqContext)
|
||||
|
||||
func (self *HttpServer) addAuthRoute(route string, handler authenticatedAuthRouteFunc) {
|
||||
self.router.GET(route, self.auth(), func(c *gin.Context) {
|
||||
|
||||
})
|
||||
}
|
||||
|
||||
func (self *HttpServer) auth() gin.HandlerFunc {
|
||||
return func(c *gin.Context) {
|
||||
session, _ := sessionStore.Get(c.Request, "grafana-session")
|
||||
|
@ -44,6 +44,10 @@ func NewRethinkStore(config *RethinkCfg) *rethinkStore {
|
||||
return []interface{}{row.Field("AccountId"), row.Field("Slug")}
|
||||
}).Exec(session)
|
||||
|
||||
r.Db(config.DatabaseName).Table("dashboards").IndexCreateFunc("AccountId", func(row r.Term) interface{} {
|
||||
return []interface{}{row.Field("AccountId")}
|
||||
}).Exec(session)
|
||||
|
||||
r.Db(config.DatabaseName).Table("accounts").IndexCreateFunc("AccountLogin", func(row r.Term) interface{} {
|
||||
return []interface{}{row.Field("Login")}
|
||||
}).Exec(session)
|
||||
@ -88,9 +92,9 @@ func (self *rethinkStore) GetDashboard(slug string, accountId int) (*models.Dash
|
||||
return &dashboard, nil
|
||||
}
|
||||
|
||||
func (self *rethinkStore) Query(query string) ([]*models.SearchResult, error) {
|
||||
func (self *rethinkStore) Query(query string, accountId int) ([]*models.SearchResult, error) {
|
||||
docs, err := r.Table("dashboards").GetAllByIndex("AccountId", []interface{}{accountId}).Filter(r.Row.Field("Title").Match(".*")).Run(self.session)
|
||||
|
||||
docs, err := r.Table("dashboards").Filter(r.Row.Field("Title").Match(".*")).Run(self.session)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
@ -5,9 +5,9 @@ import (
|
||||
)
|
||||
|
||||
type Store interface {
|
||||
GetDashboard(title string, accountId int) (*models.Dashboard, error)
|
||||
GetDashboard(slug string, accountId int) (*models.Dashboard, error)
|
||||
SaveDashboard(dash *models.Dashboard) error
|
||||
Query(query string) ([]*models.SearchResult, error)
|
||||
Query(query string, acccountId int) ([]*models.SearchResult, error)
|
||||
SaveUserAccount(acccount *models.UserAccount) error
|
||||
GetUserAccountLogin(emailOrName string) (*models.UserAccount, error)
|
||||
Close()
|
||||
|
Loading…
Reference in New Issue
Block a user