Worked on dashboard starring and unstarring, renamed favorite model to star

This commit is contained in:
Torkel Ödegaard
2015-02-02 11:32:32 +01:00
parent 706481b1a3
commit ad3d15e28d
12 changed files with 231 additions and 118 deletions
+45
View File
@@ -0,0 +1,45 @@
package api
import (
"github.com/torkelo/grafana-pro/pkg/bus"
"github.com/torkelo/grafana-pro/pkg/middleware"
m "github.com/torkelo/grafana-pro/pkg/models"
)
func StarDashboard(c *middleware.Context) {
var cmd = m.StarDashboardCommand{
UserId: c.UserId,
DashboardId: c.ParamsInt64(":id"),
}
if cmd.DashboardId <= 0 {
c.JsonApiErr(400, "Missing dashboard id", nil)
return
}
if err := bus.Dispatch(&cmd); err != nil {
c.JsonApiErr(500, "Failed to star dashboard", err)
return
}
c.JsonOK("Dashboard starred!")
}
func UnstarDashboard(c *middleware.Context) {
var cmd = m.UnstarDashboardCommand{
UserId: c.UserId,
DashboardId: c.ParamsInt64(":id"),
}
if cmd.DashboardId <= 0 {
c.JsonApiErr(400, "Missing dashboard id", nil)
return
}
if err := bus.Dispatch(&cmd); err != nil {
c.JsonApiErr(500, "Failed to unstar dashboard", err)
return
}
c.JsonOK("Dashboard unstarred")
}