mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
More work on backend for user favorites
This commit is contained in:
@@ -6,7 +6,6 @@ import (
|
||||
"github.com/torkelo/grafana-pro/pkg/api/dtos"
|
||||
"github.com/torkelo/grafana-pro/pkg/middleware"
|
||||
m "github.com/torkelo/grafana-pro/pkg/models"
|
||||
"github.com/torkelo/grafana-pro/pkg/setting"
|
||||
)
|
||||
|
||||
// Register adds http routes
|
||||
@@ -46,6 +45,8 @@ func Register(r *macaron.Macaron) {
|
||||
r.Put("/", bind(m.UpdateUserCommand{}), UpdateUser)
|
||||
r.Post("/using/:id", SetUsingAccount)
|
||||
r.Get("/accounts", GetUserAccounts)
|
||||
r.Post("/favorites/dashboard/:id", AddAsFavorite)
|
||||
r.Delete("/favorites/dashboard/:id", RemoveAsFavorite)
|
||||
})
|
||||
|
||||
// account
|
||||
@@ -97,51 +98,3 @@ func Register(r *macaron.Macaron) {
|
||||
|
||||
r.NotFound(NotFound)
|
||||
}
|
||||
|
||||
func setIndexViewData(c *middleware.Context) error {
|
||||
settings, err := getFrontendSettings(c)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
currentUser := &dtos.CurrentUser{
|
||||
IsSignedIn: c.IsSignedIn,
|
||||
Login: c.Login,
|
||||
Email: c.Email,
|
||||
Name: c.Name,
|
||||
AccountName: c.AccountName,
|
||||
AccountRole: c.AccountRole,
|
||||
GravatarUrl: dtos.GetGravatarUrl(c.Email),
|
||||
IsGrafanaAdmin: c.IsGrafanaAdmin,
|
||||
}
|
||||
|
||||
c.Data["User"] = currentUser
|
||||
c.Data["Settings"] = settings
|
||||
c.Data["AppUrl"] = setting.AppUrl
|
||||
c.Data["AppSubUrl"] = setting.AppSubUrl
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func Index(c *middleware.Context) {
|
||||
if err := setIndexViewData(c); err != nil {
|
||||
c.Handle(500, "Failed to get settings", err)
|
||||
return
|
||||
}
|
||||
|
||||
c.HTML(200, "index")
|
||||
}
|
||||
|
||||
func NotFound(c *middleware.Context) {
|
||||
if c.IsApiRequest() {
|
||||
c.JsonApiErr(200, "Not found", nil)
|
||||
return
|
||||
}
|
||||
|
||||
if err := setIndexViewData(c); err != nil {
|
||||
c.Handle(500, "Failed to get settings", err)
|
||||
return
|
||||
}
|
||||
|
||||
c.HTML(404, "index")
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user