mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
feat(preferences): removed unused api prefernce methods, these need to be abstracted more from an http api perpsective, they are too low level for the http api, #4399
This commit is contained in:
parent
7023dedc05
commit
5e431149cd
@ -162,8 +162,6 @@ func Register(r *macaron.Macaron) {
|
|||||||
|
|
||||||
// Preferences
|
// Preferences
|
||||||
r.Group("/preferences", func() {
|
r.Group("/preferences", func() {
|
||||||
r.Get("/", GetPreferences)
|
|
||||||
r.Put("/", bind(m.SavePreferencesCommand{}), wrap(SavePreferences))
|
|
||||||
r.Post("/set-home-dash", bind(m.SavePreferencesCommand{}), wrap(SetHomeDashboard))
|
r.Post("/set-home-dash", bind(m.SavePreferencesCommand{}), wrap(SetHomeDashboard))
|
||||||
})
|
})
|
||||||
|
|
||||||
|
@ -1,44 +1,11 @@
|
|||||||
package api
|
package api
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/grafana/grafana/pkg/api/dtos"
|
|
||||||
"github.com/grafana/grafana/pkg/bus"
|
"github.com/grafana/grafana/pkg/bus"
|
||||||
"github.com/grafana/grafana/pkg/middleware"
|
"github.com/grafana/grafana/pkg/middleware"
|
||||||
m "github.com/grafana/grafana/pkg/models"
|
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
|
// POST /api/preferences/set-home-dash
|
||||||
func SetHomeDashboard(c *middleware.Context, cmd m.SavePreferencesCommand) Response {
|
func SetHomeDashboard(c *middleware.Context, cmd m.SavePreferencesCommand) Response {
|
||||||
|
|
||||||
@ -50,5 +17,4 @@ func SetHomeDashboard(c *middleware.Context, cmd m.SavePreferencesCommand) Respo
|
|||||||
}
|
}
|
||||||
|
|
||||||
return ApiSuccess("Home dashboard set")
|
return ApiSuccess("Home dashboard set")
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user