mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
Minor bug fixes
This commit is contained in:
@@ -68,11 +68,11 @@ func Register(r *macaron.Macaron) {
|
|||||||
r.Post("/api/user/password/reset", bind(dtos.ResetUserPasswordForm{}), wrap(ResetPassword))
|
r.Post("/api/user/password/reset", bind(dtos.ResetUserPasswordForm{}), wrap(ResetPassword))
|
||||||
|
|
||||||
// dashboard snapshots
|
// dashboard snapshots
|
||||||
r.Get("/dashboard/snapshot/*", Index)
|
r.Get("/dashboard/snapshot/*", Index)
|
||||||
r.Get("/dashboard/snapshots/", reqSignedIn, Index)
|
r.Get("/dashboard/snapshots/", reqSignedIn, Index)
|
||||||
|
|
||||||
// api for dashboard snapshots
|
// api for dashboard snapshots
|
||||||
r.Post("/api/snapshots/", bind(m.CreateDashboardSnapshotCommand{}), CreateDashboardSnapshot)
|
r.Post("/api/snapshots/", bind(m.CreateDashboardSnapshotCommand{}), CreateDashboardSnapshot)
|
||||||
r.Get("/api/snapshot/shared-options/", GetSharingOptions)
|
r.Get("/api/snapshot/shared-options/", GetSharingOptions)
|
||||||
r.Get("/api/snapshots/:key", GetDashboardSnapshot)
|
r.Get("/api/snapshots/:key", GetDashboardSnapshot)
|
||||||
r.Get("/api/snapshots-delete/:key", DeleteDashboardSnapshot)
|
r.Get("/api/snapshots-delete/:key", DeleteDashboardSnapshot)
|
||||||
@@ -184,10 +184,10 @@ func Register(r *macaron.Macaron) {
|
|||||||
r.Get("/tags", GetDashboardTags)
|
r.Get("/tags", GetDashboardTags)
|
||||||
})
|
})
|
||||||
|
|
||||||
// Dashboard snapshots
|
// Dashboard snapshots
|
||||||
r.Group("/dashboard/snapshots", func() {
|
r.Group("/dashboard/snapshots", func() {
|
||||||
r.Get("/", wrap(SearchDashboardSnapshots))
|
r.Get("/", wrap(SearchDashboardSnapshots))
|
||||||
})
|
})
|
||||||
|
|
||||||
// Playlist
|
// Playlist
|
||||||
r.Group("/playlists", func() {
|
r.Group("/playlists", func() {
|
||||||
|
@@ -101,23 +101,23 @@ func DeleteDashboardSnapshot(c *middleware.Context) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func SearchDashboardSnapshots(c *middleware.Context) Response {
|
func SearchDashboardSnapshots(c *middleware.Context) Response {
|
||||||
query := c.Query("query")
|
query := c.Query("query")
|
||||||
limit := c.QueryInt("limit")
|
limit := c.QueryInt("limit")
|
||||||
|
|
||||||
if limit == 0 {
|
if limit == 0 {
|
||||||
limit = 1000
|
limit = 1000
|
||||||
}
|
}
|
||||||
|
|
||||||
searchQuery := m.GetDashboardSnapshotsQuery{
|
searchQuery := m.GetDashboardSnapshotsQuery{
|
||||||
Name: query,
|
Name: query,
|
||||||
Limit: limit,
|
Limit: limit,
|
||||||
OrgId: c.OrgId,
|
OrgId: c.OrgId,
|
||||||
}
|
}
|
||||||
|
|
||||||
err := bus.Dispatch(&searchQuery)
|
err := bus.Dispatch(&searchQuery)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return ApiError(500, "Search failed", err)
|
return ApiError(500, "Search failed", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
return Json(200, searchQuery.Result)
|
return Json(200, searchQuery.Result)
|
||||||
}
|
}
|
||||||
|
@@ -60,11 +60,11 @@ func setIndexViewData(c *middleware.Context) (*dtos.IndexViewData, error) {
|
|||||||
Url: "/playlists",
|
Url: "/playlists",
|
||||||
})
|
})
|
||||||
|
|
||||||
data.MainNavLinks = append(data.MainNavLinks, &dtos.NavLink{
|
data.MainNavLinks = append(data.MainNavLinks, &dtos.NavLink{
|
||||||
Text: "Snapshots",
|
Text: "Snapshots",
|
||||||
Icon: "fa fa-fw fa-camera-retro",
|
Icon: "fa fa-fw fa-camera-retro",
|
||||||
Url: "/dashboard/snapshots",
|
Url: "/dashboard/snapshots",
|
||||||
})
|
})
|
||||||
|
|
||||||
if c.OrgRole == m.ROLE_ADMIN {
|
if c.OrgRole == m.ROLE_ADMIN {
|
||||||
data.MainNavLinks = append(data.MainNavLinks, &dtos.NavLink{
|
data.MainNavLinks = append(data.MainNavLinks, &dtos.NavLink{
|
||||||
|
@@ -52,9 +52,9 @@ type GetDashboardSnapshotQuery struct {
|
|||||||
type DashboardSnapshots []*DashboardSnapshot
|
type DashboardSnapshots []*DashboardSnapshot
|
||||||
|
|
||||||
type GetDashboardSnapshotsQuery struct {
|
type GetDashboardSnapshotsQuery struct {
|
||||||
Name string
|
Name string
|
||||||
Limit int
|
Limit int
|
||||||
OrgId int64
|
OrgId int64
|
||||||
|
|
||||||
Result DashboardSnapshots
|
Result DashboardSnapshots
|
||||||
}
|
}
|
||||||
|
@@ -12,7 +12,7 @@ func init() {
|
|||||||
bus.AddHandler("sql", CreateDashboardSnapshot)
|
bus.AddHandler("sql", CreateDashboardSnapshot)
|
||||||
bus.AddHandler("sql", GetDashboardSnapshot)
|
bus.AddHandler("sql", GetDashboardSnapshot)
|
||||||
bus.AddHandler("sql", DeleteDashboardSnapshot)
|
bus.AddHandler("sql", DeleteDashboardSnapshot)
|
||||||
bus.AddHandler("sql", SearchDashboardSnapshots)
|
bus.AddHandler("sql", SearchDashboardSnapshots)
|
||||||
}
|
}
|
||||||
|
|
||||||
func CreateDashboardSnapshot(cmd *m.CreateDashboardSnapshotCommand) error {
|
func CreateDashboardSnapshot(cmd *m.CreateDashboardSnapshotCommand) error {
|
||||||
@@ -67,16 +67,16 @@ func GetDashboardSnapshot(query *m.GetDashboardSnapshotQuery) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func SearchDashboardSnapshots(query *m.GetDashboardSnapshotsQuery) 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 != "" {
|
if query.Name != "" {
|
||||||
sess.Where("name LIKE ?", query.Name)
|
sess.Where("name LIKE ?", query.Name)
|
||||||
}
|
}
|
||||||
|
|
||||||
sess.Where("org_id = ?", query.OrgId)
|
sess.Where("org_id = ?", query.OrgId)
|
||||||
err := sess.Find(&snapshots)
|
err := sess.Find(&snapshots)
|
||||||
query.Result = snapshots
|
query.Result = snapshots
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user