Commit 9dd6aefc by utkarshcmu

Minor corrections

parent 749fd618
......@@ -160,12 +160,12 @@ func Register(r *macaron.Macaron) {
r.Delete("/:id", wrap(DeleteApiKey))
}, reqOrgAdmin)
// Preferences
r.Group("/preferences", func() {
r.Get("/", wrap(GetPreferences))
r.Put("/", bind(m.SavePreferencesCommand{}), wrap(SavePreferences))
r.Post("/set-home-dash", bind(m.SavePreferencesCommand{}), wrap(SetHomeDashboard))
})
// Preferences
r.Group("/preferences", func() {
r.Get("/", wrap(GetPreferences))
r.Put("/", bind(m.SavePreferencesCommand{}), wrap(SavePreferences))
r.Post("/set-home-dash", bind(m.SavePreferencesCommand{}), wrap(SetHomeDashboard))
})
// Data sources
r.Group("/datasources", func() {
......
......@@ -42,13 +42,13 @@ func GetPreferences(c *middleware.Context) {
// POST /api/preferences/set-home-dash
func SetHomeDashboard(c *middleware.Context, cmd m.SavePreferencesCommand) Response {
cmd.UserId = c.UserId
cmd.OrgId = c.OrgId
cmd.UserId = c.UserId
cmd.OrgId = c.OrgId
if err := bus.Dispatch(&cmd); err != nil {
return ApiError(500, "Failed to set home dashboard", err)
}
if err := bus.Dispatch(&cmd); err != nil {
return ApiError(500, "Failed to set home dashboard", err)
}
return ApiSuccess("Home dashboard set")
return ApiSuccess("Home dashboard set")
}
......@@ -39,7 +39,7 @@ type SavePreferencesCommand struct {
UserId int64
OrgId int64
HomeDashboardId int64 `json:"dashboardId"`
Timezone string `json:"timezone"`
Theme string `json:"theme"`
HomeDashboardId int64 `json:"homeDashboardId"`
Timezone string `json:"timezone"`
Theme string `json:"theme"`
}
package sqlstore
import (
"time"
"github.com/grafana/grafana/pkg/bus"
m "github.com/grafana/grafana/pkg/models"
"time"
)
func init() {
......@@ -42,8 +42,8 @@ func SavePreferences(cmd *m.SavePreferencesCommand) error {
HomeDashboardId: cmd.HomeDashboardId,
Timezone: cmd.Timezone,
Theme: cmd.Theme,
Created: time.Now(),
Updated: time.Now(),
Created: time.Now(),
Updated: time.Now(),
}
_, err = sess.Insert(&prefs)
return err
......@@ -51,8 +51,8 @@ func SavePreferences(cmd *m.SavePreferencesCommand) error {
prefs.HomeDashboardId = cmd.HomeDashboardId
prefs.Timezone = cmd.Timezone
prefs.Theme = cmd.Theme
prefs.Updated = time.Now()
prefs.Version += 1
prefs.Updated = time.Now()
prefs.Version += 1
_, err = sess.Id(prefs.Id).Update(&prefs)
return err
}
......
......@@ -106,7 +106,7 @@ export class DashNavCtrl {
$scope.saveDashboardAsHome = function() {
// TODO: this backend method needs to be implemented
backendSrv.post('/api/preferences/set-home-dash', {
dashboardId: $scope.dashboard.id
homeDashboardId: $scope.dashboard.id
});
};
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment