mirror of
https://github.com/grafana/grafana.git
synced 2024-12-30 10:47:30 -06:00
7428668835
* Profile: Fixes profile preferences page being available when anonymous access was enabled * Minor change * Renamed property
36 lines
957 B
Go
36 lines
957 B
Go
package api
|
|
|
|
import (
|
|
"github.com/grafana/grafana/pkg/api/response"
|
|
"github.com/grafana/grafana/pkg/bus"
|
|
"github.com/grafana/grafana/pkg/models"
|
|
)
|
|
|
|
func StarDashboard(c *models.ReqContext) response.Response {
|
|
cmd := models.StarDashboardCommand{UserId: c.UserId, DashboardId: c.ParamsInt64(":id")}
|
|
|
|
if cmd.DashboardId <= 0 {
|
|
return response.Error(400, "Missing dashboard id", nil)
|
|
}
|
|
|
|
if err := bus.Dispatch(&cmd); err != nil {
|
|
return response.Error(500, "Failed to star dashboard", err)
|
|
}
|
|
|
|
return response.Success("Dashboard starred!")
|
|
}
|
|
|
|
func UnstarDashboard(c *models.ReqContext) response.Response {
|
|
cmd := models.UnstarDashboardCommand{UserId: c.UserId, DashboardId: c.ParamsInt64(":id")}
|
|
|
|
if cmd.DashboardId <= 0 {
|
|
return response.Error(400, "Missing dashboard id", nil)
|
|
}
|
|
|
|
if err := bus.Dispatch(&cmd); err != nil {
|
|
return response.Error(500, "Failed to unstar dashboard", err)
|
|
}
|
|
|
|
return response.Success("Dashboard unstarred")
|
|
}
|