Commit cc0cc8dd by Carl Bergquist Committed by Torkel Ödegaard

changes to new urlformat for home dashboard (#10738)

parent 0701188e
...@@ -293,10 +293,11 @@ func GetHomeDashboard(c *middleware.Context) Response { ...@@ -293,10 +293,11 @@ func GetHomeDashboard(c *middleware.Context) Response {
} }
if prefsQuery.Result.HomeDashboardId != 0 { if prefsQuery.Result.HomeDashboardId != 0 {
slugQuery := m.GetDashboardSlugByIdQuery{Id: prefsQuery.Result.HomeDashboardId} slugQuery := m.GetDashboardRefByIdQuery{Id: prefsQuery.Result.HomeDashboardId}
err := bus.Dispatch(&slugQuery) err := bus.Dispatch(&slugQuery)
if err == nil { if err == nil {
dashRedirect := dtos.DashboardRedirect{RedirectUri: "db/" + slugQuery.Result} url := m.GetDashboardUrl(slugQuery.Result.Uid, slugQuery.Result.Slug)
dashRedirect := dtos.DashboardRedirect{RedirectUri: url}
return Json(200, &dashRedirect) return Json(200, &dashRedirect)
} else { } else {
log.Warn("Failed to get slug from database, %s", err.Error()) log.Warn("Failed to get slug from database, %s", err.Error())
......
...@@ -293,7 +293,7 @@ type DashboardRef struct { ...@@ -293,7 +293,7 @@ type DashboardRef struct {
Slug string Slug string
} }
type GetDashboardUIDByIdQuery struct { type GetDashboardRefByIdQuery struct {
Id int64 Id int64
Result *DashboardRef Result *DashboardRef
} }
...@@ -90,7 +90,7 @@ func (c *EvalContext) GetDashboardUID() (*m.DashboardRef, error) { ...@@ -90,7 +90,7 @@ func (c *EvalContext) GetDashboardUID() (*m.DashboardRef, error) {
return c.dashboardRef, nil return c.dashboardRef, nil
} }
uidQuery := &m.GetDashboardUIDByIdQuery{Id: c.Rule.DashboardId} uidQuery := &m.GetDashboardRefByIdQuery{Id: c.Rule.DashboardId}
if err := bus.Dispatch(uidQuery); err != nil { if err := bus.Dispatch(uidQuery); err != nil {
return nil, err return nil, err
} }
......
...@@ -569,7 +569,7 @@ func GetDashboardsBySlug(query *m.GetDashboardsBySlugQuery) error { ...@@ -569,7 +569,7 @@ func GetDashboardsBySlug(query *m.GetDashboardsBySlugQuery) error {
return nil return nil
} }
func GetDashboardUIDById(query *m.GetDashboardUIDByIdQuery) error { func GetDashboardUIDById(query *m.GetDashboardRefByIdQuery) error {
var rawSql = `SELECT uid, slug from dashboard WHERE Id=?` var rawSql = `SELECT uid, slug from dashboard WHERE Id=?`
us := &m.DashboardRef{} us := &m.DashboardRef{}
......
...@@ -9,7 +9,7 @@ export class LoadDashboardCtrl { ...@@ -9,7 +9,7 @@ export class LoadDashboardCtrl {
if (!$routeParams.uid && !$routeParams.slug) { if (!$routeParams.uid && !$routeParams.slug) {
backendSrv.get('/api/dashboards/home').then(function(homeDash) { backendSrv.get('/api/dashboards/home').then(function(homeDash) {
if (homeDash.redirectUri) { if (homeDash.redirectUri) {
$location.path('dashboard/' + homeDash.redirectUri); $location.path(homeDash.redirectUri);
} else { } else {
var meta = homeDash.meta; var meta = homeDash.meta;
meta.canSave = meta.canShare = meta.canStar = false; meta.canSave = meta.canShare = meta.canStar = false;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment