diff --git a/pkg/api/dashboard.go b/pkg/api/dashboard.go index 77309a24560..d95f1c71f3e 100644 --- a/pkg/api/dashboard.go +++ b/pkg/api/dashboard.go @@ -4,6 +4,7 @@ import ( "encoding/json" "os" "path" + "strconv" "strings" "github.com/grafana/grafana/pkg/api/dtos" @@ -59,8 +60,7 @@ func GetDashboard(c *middleware.Context) { CanEdit: canEditDashboard(c.OrgRole), Created: dash.Created, Updated: dash.Updated, - CreatedBy: dash.CreatedBy, - UpdatedBy: dash.UpdatedBy, + UpdatedBy: strconv.FormatInt(dash.UpdatedBy, 10), }, } @@ -89,6 +89,7 @@ func DeleteDashboard(c *middleware.Context) { func PostDashboard(c *middleware.Context, cmd m.SaveDashboardCommand) { cmd.OrgId = c.OrgId + cmd.UpdatedBy = c.UserId dash := cmd.GetDashboardModel() if dash.Id == 0 { diff --git a/pkg/models/dashboards.go b/pkg/models/dashboards.go index 9c2350bb7dd..32922213a6a 100644 --- a/pkg/models/dashboards.go +++ b/pkg/models/dashboards.go @@ -33,8 +33,7 @@ type Dashboard struct { Created time.Time Updated time.Time - CreatedBy string - UpdatedBy string + UpdatedBy int64 Title string Data map[string]interface{} @@ -48,8 +47,6 @@ func NewDashboard(title string) *Dashboard { dash.Title = title dash.Created = time.Now() dash.Updated = time.Now() - // TODO:dash.CreatedBy = "Creator" - // TODO:dash.UpdatedBy = "Creator" dash.UpdateSlug() return dash } @@ -81,14 +78,11 @@ func NewDashboardFromJson(data map[string]interface{}) *Dashboard { if dash.Data["version"] != nil { dash.Version = int(dash.Data["version"].(float64)) dash.Updated = time.Now() - // TODO:dash.UpdatedBy = "Updater" } } else { dash.Data["version"] = 0 dash.Created = time.Now() dash.Updated = time.Now() - // TODO:dash.CreatedBy = "Creator" - // TODO:dash.UpdatedBy = "Creator" } return dash @@ -98,6 +92,7 @@ func NewDashboardFromJson(data map[string]interface{}) *Dashboard { func (cmd *SaveDashboardCommand) GetDashboardModel() *Dashboard { dash := NewDashboardFromJson(cmd.Dashboard) dash.OrgId = cmd.OrgId + dash.UpdatedBy = cmd.UpdatedBy dash.UpdateSlug() return dash } @@ -121,6 +116,7 @@ type SaveDashboardCommand struct { Dashboard map[string]interface{} `json:"dashboard" binding:"Required"` Overwrite bool `json:"overwrite"` OrgId int64 `json:"-"` + UpdatedBy int64 `json:"-"` Result *Dashboard } diff --git a/pkg/services/sqlstore/migrations/dashboard_mig.go b/pkg/services/sqlstore/migrations/dashboard_mig.go index 4994cb0a234..b94f1a7d6ac 100644 --- a/pkg/services/sqlstore/migrations/dashboard_mig.go +++ b/pkg/services/sqlstore/migrations/dashboard_mig.go @@ -93,13 +93,8 @@ func addDashboardMigration(mg *Migrator) { Postgres("SELECT 0;"). Mysql("ALTER TABLE dashboard MODIFY data MEDIUMTEXT;")) - // add column to store creator of a dashboard - mg.AddMigration("Add column created_by in dashboard - v2", NewAddColumnMigration(dashboardV2, &Column{ - Name: "created_by", Type: DB_NVarchar, Length: 255, Nullable: false, Default: "Anonymous", - })) - // add column to store updater of a dashboard mg.AddMigration("Add column updated_by in dashboard - v2", NewAddColumnMigration(dashboardV2, &Column{ - Name: "updated_by", Type: DB_NVarchar, Length: 255, Nullable: false, Default: "Anonymous", + Name: "updated_by", Type: DB_Int, Nullable: true, })) } diff --git a/pkg/services/sqlstore/migrations/dashboard_snapshot_mig.go b/pkg/services/sqlstore/migrations/dashboard_snapshot_mig.go index 0173617bf48..b08cc451e55 100644 --- a/pkg/services/sqlstore/migrations/dashboard_snapshot_mig.go +++ b/pkg/services/sqlstore/migrations/dashboard_snapshot_mig.go @@ -54,5 +54,4 @@ func addDashboardSnapshotMigrations(mg *Migrator) { Sqlite("SELECT 0 WHERE 0;"). Postgres("SELECT 0;"). Mysql("ALTER TABLE dashboard_snapshot MODIFY dashboard MEDIUMTEXT;")) - } diff --git a/public/app/features/dashboard/partials/settings.html b/public/app/features/dashboard/partials/settings.html index 36223f152a0..d9a71655667 100644 --- a/public/app/features/dashboard/partials/settings.html +++ b/public/app/features/dashboard/partials/settings.html @@ -117,7 +117,7 @@
-
Info
+
Dashboard info
  • @@ -129,17 +129,6 @@
-
-
    -
  • - Last updated by: -
  • -
  • - {{dashboardMeta.updatedBy}} -
  • -
-
-
  • @@ -151,14 +140,14 @@
-
+
  • - Created by: + Last updated by:
  • - {{dashboardMeta.createdBy}} -
  • + {{dashboardMeta.updatedBy}} +