From ca55d1f31526408ba9255578aa9b12f84984ae23 Mon Sep 17 00:00:00 2001 From: utkarshcmu Date: Tue, 19 Jan 2016 05:05:24 -0800 Subject: [PATCH] Minor bug fixes --- pkg/api/api.go | 16 +++++------ pkg/api/dashboard_snapshot.go | 30 ++++++++++----------- pkg/api/index.go | 10 +++---- pkg/models/dashboard_snapshot.go | 8 +++--- pkg/services/sqlstore/dashboard_snapshot.go | 20 +++++++------- 5 files changed, 42 insertions(+), 42 deletions(-) diff --git a/pkg/api/api.go b/pkg/api/api.go index 034d9adc180..9477288dca6 100644 --- a/pkg/api/api.go +++ b/pkg/api/api.go @@ -68,11 +68,11 @@ func Register(r *macaron.Macaron) { r.Post("/api/user/password/reset", bind(dtos.ResetUserPasswordForm{}), wrap(ResetPassword)) // dashboard snapshots - r.Get("/dashboard/snapshot/*", Index) - r.Get("/dashboard/snapshots/", reqSignedIn, Index) + r.Get("/dashboard/snapshot/*", Index) + r.Get("/dashboard/snapshots/", reqSignedIn, Index) - // api for dashboard snapshots - r.Post("/api/snapshots/", bind(m.CreateDashboardSnapshotCommand{}), CreateDashboardSnapshot) + // api for dashboard snapshots + r.Post("/api/snapshots/", bind(m.CreateDashboardSnapshotCommand{}), CreateDashboardSnapshot) r.Get("/api/snapshot/shared-options/", GetSharingOptions) r.Get("/api/snapshots/:key", GetDashboardSnapshot) r.Get("/api/snapshots-delete/:key", DeleteDashboardSnapshot) @@ -184,10 +184,10 @@ func Register(r *macaron.Macaron) { r.Get("/tags", GetDashboardTags) }) - // Dashboard snapshots - r.Group("/dashboard/snapshots", func() { - r.Get("/", wrap(SearchDashboardSnapshots)) - }) + // Dashboard snapshots + r.Group("/dashboard/snapshots", func() { + r.Get("/", wrap(SearchDashboardSnapshots)) + }) // Playlist r.Group("/playlists", func() { diff --git a/pkg/api/dashboard_snapshot.go b/pkg/api/dashboard_snapshot.go index 8eb9da60231..2d1fbce782c 100644 --- a/pkg/api/dashboard_snapshot.go +++ b/pkg/api/dashboard_snapshot.go @@ -101,23 +101,23 @@ func DeleteDashboardSnapshot(c *middleware.Context) { } func SearchDashboardSnapshots(c *middleware.Context) Response { - query := c.Query("query") - limit := c.QueryInt("limit") + query := c.Query("query") + limit := c.QueryInt("limit") - if limit == 0 { - limit = 1000 - } + if limit == 0 { + limit = 1000 + } - searchQuery := m.GetDashboardSnapshotsQuery{ - Name: query, - Limit: limit, - OrgId: c.OrgId, - } + searchQuery := m.GetDashboardSnapshotsQuery{ + Name: query, + Limit: limit, + OrgId: c.OrgId, + } - err := bus.Dispatch(&searchQuery) - if err != nil { - return ApiError(500, "Search failed", err) - } + err := bus.Dispatch(&searchQuery) + if err != nil { + return ApiError(500, "Search failed", err) + } - return Json(200, searchQuery.Result) + return Json(200, searchQuery.Result) } diff --git a/pkg/api/index.go b/pkg/api/index.go index ca2f9320215..09ef756f95a 100644 --- a/pkg/api/index.go +++ b/pkg/api/index.go @@ -60,11 +60,11 @@ func setIndexViewData(c *middleware.Context) (*dtos.IndexViewData, error) { Url: "/playlists", }) - data.MainNavLinks = append(data.MainNavLinks, &dtos.NavLink{ - Text: "Snapshots", - Icon: "fa fa-fw fa-camera-retro", - Url: "/dashboard/snapshots", - }) + data.MainNavLinks = append(data.MainNavLinks, &dtos.NavLink{ + Text: "Snapshots", + Icon: "fa fa-fw fa-camera-retro", + Url: "/dashboard/snapshots", + }) if c.OrgRole == m.ROLE_ADMIN { data.MainNavLinks = append(data.MainNavLinks, &dtos.NavLink{ diff --git a/pkg/models/dashboard_snapshot.go b/pkg/models/dashboard_snapshot.go index 65163e6b119..8c1a0f47a06 100644 --- a/pkg/models/dashboard_snapshot.go +++ b/pkg/models/dashboard_snapshot.go @@ -52,9 +52,9 @@ type GetDashboardSnapshotQuery struct { type DashboardSnapshots []*DashboardSnapshot type GetDashboardSnapshotsQuery struct { - Name string - Limit int - OrgId int64 + Name string + Limit int + OrgId int64 - Result DashboardSnapshots + Result DashboardSnapshots } diff --git a/pkg/services/sqlstore/dashboard_snapshot.go b/pkg/services/sqlstore/dashboard_snapshot.go index b7ffa0b9912..fc94a91cce5 100644 --- a/pkg/services/sqlstore/dashboard_snapshot.go +++ b/pkg/services/sqlstore/dashboard_snapshot.go @@ -12,7 +12,7 @@ func init() { bus.AddHandler("sql", CreateDashboardSnapshot) bus.AddHandler("sql", GetDashboardSnapshot) bus.AddHandler("sql", DeleteDashboardSnapshot) - bus.AddHandler("sql", SearchDashboardSnapshots) + bus.AddHandler("sql", SearchDashboardSnapshots) } func CreateDashboardSnapshot(cmd *m.CreateDashboardSnapshotCommand) error { @@ -67,16 +67,16 @@ func GetDashboardSnapshot(query *m.GetDashboardSnapshotQuery) error { } func SearchDashboardSnapshots(query *m.GetDashboardSnapshotsQuery) error { - var snapshots = make(m.DashboardSnapshots, 0) + var snapshots = make(m.DashboardSnapshots, 0) - sess := x.Limit(query.Limit) + sess := x.Limit(query.Limit) - if query.Name != "" { - sess.Where("name LIKE ?", query.Name) - } + if query.Name != "" { + sess.Where("name LIKE ?", query.Name) + } - sess.Where("org_id = ?", query.OrgId) - err := sess.Find(&snapshots) - query.Result = snapshots - return err + sess.Where("org_id = ?", query.OrgId) + err := sess.Find(&snapshots) + query.Result = snapshots + return err }