Skip to content

Commit

Permalink
Minor corrections
Browse files Browse the repository at this point in the history
  • Loading branch information
utkarshcmu committed Mar 17, 2016
1 parent 749fd61 commit 9dd6aef
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 21 deletions.
12 changes: 6 additions & 6 deletions pkg/api/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down
12 changes: 6 additions & 6 deletions pkg/api/preferences.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")

}
6 changes: 3 additions & 3 deletions pkg/models/preferences.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"`
}
10 changes: 5 additions & 5 deletions pkg/services/sqlstore/preferences.go
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
package sqlstore

import (
"time"
"github.com/grafana/grafana/pkg/bus"
m "github.com/grafana/grafana/pkg/models"
"time"
)

func init() {
Expand Down Expand Up @@ -42,17 +42,17 @@ 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
} else {
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
}
Expand Down
2 changes: 1 addition & 1 deletion public/app/features/dashboard/dashnav/dashnav.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
});
};

Expand Down

0 comments on commit 9dd6aef

Please sign in to comment.