Skip to content

Commit

Permalink
feat(preferences): removed unused api prefernce methods, these need t…
Browse files Browse the repository at this point in the history
…o be abstracted more from an http api perpsective, they are too low level for the http api, grafana#4399
  • Loading branch information
torkelo committed Mar 20, 2016
1 parent 7023ded commit 5e43114
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 36 deletions.
2 changes: 0 additions & 2 deletions pkg/api/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -162,8 +162,6 @@ func Register(r *macaron.Macaron) {

// Preferences
r.Group("/preferences", func() {
r.Get("/", GetPreferences)
r.Put("/", bind(m.SavePreferencesCommand{}), wrap(SavePreferences))
r.Post("/set-home-dash", bind(m.SavePreferencesCommand{}), wrap(SetHomeDashboard))
})

Expand Down
34 changes: 0 additions & 34 deletions pkg/api/preferences.go
Original file line number Diff line number Diff line change
@@ -1,44 +1,11 @@
package api

import (
"github.com/grafana/grafana/pkg/api/dtos"
"github.com/grafana/grafana/pkg/bus"
"github.com/grafana/grafana/pkg/middleware"
m "github.com/grafana/grafana/pkg/models"
)

// PUT /api/preferences
func SavePreferences(c *middleware.Context, cmd m.SavePreferencesCommand) Response {

cmd.UserId = c.UserId
cmd.OrgId = c.OrgId

if err := bus.Dispatch(&cmd); err != nil {
return ApiError(500, "Failed to save preferences", err)
}

return ApiSuccess("Preferences saved")

}

// GET /api/preferences
func GetPreferences(c *middleware.Context) {

query := m.GetPreferencesQuery{UserId: c.UserId, OrgId: c.OrgId}

if err := bus.Dispatch(&query); err != nil {
c.JsonApiErr(500, "Failed to get preferences", err)
}

dto := dtos.Preferences{
HomeDashboardId: query.Result.HomeDashboardId,
Timezone: query.Result.Timezone,
Theme: query.Result.Theme,
}

c.JSON(200, dto)
}

// POST /api/preferences/set-home-dash
func SetHomeDashboard(c *middleware.Context, cmd m.SavePreferencesCommand) Response {

Expand All @@ -50,5 +17,4 @@ func SetHomeDashboard(c *middleware.Context, cmd m.SavePreferencesCommand) Respo
}

return ApiSuccess("Home dashboard set")

}

0 comments on commit 5e43114

Please sign in to comment.