Skip to content

Commit af37124

Browse files
committed
Successfully displayed userdId in UI
1 parent 22fd2ae commit af37124

File tree

5 files changed

+12
-32
lines changed

5 files changed

+12
-32
lines changed

pkg/api/dashboard.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import (
44
"encoding/json"
55
"os"
66
"path"
7+
"strconv"
78
"strings"
89

910
"github.com/grafana/grafana/pkg/api/dtos"
@@ -59,8 +60,7 @@ func GetDashboard(c *middleware.Context) {
5960
CanEdit: canEditDashboard(c.OrgRole),
6061
Created: dash.Created,
6162
Updated: dash.Updated,
62-
CreatedBy: dash.CreatedBy,
63-
UpdatedBy: dash.UpdatedBy,
63+
UpdatedBy: strconv.FormatInt(dash.UpdatedBy, 10),
6464
},
6565
}
6666

@@ -89,6 +89,7 @@ func DeleteDashboard(c *middleware.Context) {
8989

9090
func PostDashboard(c *middleware.Context, cmd m.SaveDashboardCommand) {
9191
cmd.OrgId = c.OrgId
92+
cmd.UpdatedBy = c.UserId
9293

9394
dash := cmd.GetDashboardModel()
9495
if dash.Id == 0 {

pkg/models/dashboards.go

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,7 @@ type Dashboard struct {
3333
Created time.Time
3434
Updated time.Time
3535

36-
CreatedBy string
37-
UpdatedBy string
36+
UpdatedBy int64
3837

3938
Title string
4039
Data map[string]interface{}
@@ -48,8 +47,6 @@ func NewDashboard(title string) *Dashboard {
4847
dash.Title = title
4948
dash.Created = time.Now()
5049
dash.Updated = time.Now()
51-
// TODO:dash.CreatedBy = "Creator"
52-
// TODO:dash.UpdatedBy = "Creator"
5350
dash.UpdateSlug()
5451
return dash
5552
}
@@ -81,14 +78,11 @@ func NewDashboardFromJson(data map[string]interface{}) *Dashboard {
8178
if dash.Data["version"] != nil {
8279
dash.Version = int(dash.Data["version"].(float64))
8380
dash.Updated = time.Now()
84-
// TODO:dash.UpdatedBy = "Updater"
8581
}
8682
} else {
8783
dash.Data["version"] = 0
8884
dash.Created = time.Now()
8985
dash.Updated = time.Now()
90-
// TODO:dash.CreatedBy = "Creator"
91-
// TODO:dash.UpdatedBy = "Creator"
9286
}
9387

9488
return dash
@@ -98,6 +92,7 @@ func NewDashboardFromJson(data map[string]interface{}) *Dashboard {
9892
func (cmd *SaveDashboardCommand) GetDashboardModel() *Dashboard {
9993
dash := NewDashboardFromJson(cmd.Dashboard)
10094
dash.OrgId = cmd.OrgId
95+
dash.UpdatedBy = cmd.UpdatedBy
10196
dash.UpdateSlug()
10297
return dash
10398
}
@@ -121,6 +116,7 @@ type SaveDashboardCommand struct {
121116
Dashboard map[string]interface{} `json:"dashboard" binding:"Required"`
122117
Overwrite bool `json:"overwrite"`
123118
OrgId int64 `json:"-"`
119+
UpdatedBy int64 `json:"-"`
124120

125121
Result *Dashboard
126122
}

pkg/services/sqlstore/migrations/dashboard_mig.go

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -93,13 +93,8 @@ func addDashboardMigration(mg *Migrator) {
9393
Postgres("SELECT 0;").
9494
Mysql("ALTER TABLE dashboard MODIFY data MEDIUMTEXT;"))
9595

96-
// add column to store creator of a dashboard
97-
mg.AddMigration("Add column created_by in dashboard - v2", NewAddColumnMigration(dashboardV2, &Column{
98-
Name: "created_by", Type: DB_NVarchar, Length: 255, Nullable: false, Default: "Anonymous",
99-
}))
100-
10196
// add column to store updater of a dashboard
10297
mg.AddMigration("Add column updated_by in dashboard - v2", NewAddColumnMigration(dashboardV2, &Column{
103-
Name: "updated_by", Type: DB_NVarchar, Length: 255, Nullable: false, Default: "Anonymous",
98+
Name: "updated_by", Type: DB_Int, Nullable: true,
10499
}))
105100
}

pkg/services/sqlstore/migrations/dashboard_snapshot_mig.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,5 +54,4 @@ func addDashboardSnapshotMigrations(mg *Migrator) {
5454
Sqlite("SELECT 0 WHERE 0;").
5555
Postgres("SELECT 0;").
5656
Mysql("ALTER TABLE dashboard_snapshot MODIFY dashboard MEDIUMTEXT;"))
57-
5857
}

public/app/features/dashboard/partials/settings.html

Lines changed: 5 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ <h5>Rows settings</h5>
117117
<div ng-if="editor.index == 4">
118118
<div class="editor-row">
119119
<div class="tight-form-section">
120-
<h5>Info</h5>
120+
<h5>Dashboard info</h5>
121121
<div class="tight-form">
122122
<ul class="tight-form-list">
123123
<li class="tight-form-item" style="width: 120px">
@@ -129,17 +129,6 @@ <h5>Info</h5>
129129
</ul>
130130
<div class="clearfix"></div>
131131
</div>
132-
<div class="tight-form">
133-
<ul class="tight-form-list">
134-
<li class="tight-form-item" style="width: 120px">
135-
Last updated by:
136-
</li>
137-
<li class="tight-form-item" style="width: 180px">
138-
{{dashboardMeta.updatedBy}}
139-
</li>
140-
</ul>
141-
<div class="clearfix"></div>
142-
</div>
143132
<div class="tight-form last">
144133
<ul class="tight-form-list">
145134
<li class="tight-form-item" style="width: 120px">
@@ -151,14 +140,14 @@ <h5>Info</h5>
151140
</ul>
152141
<div class="clearfix"></div>
153142
</div>
154-
<div class="tight-form last">
143+
<div class="tight-form">
155144
<ul class="tight-form-list">
156145
<li class="tight-form-item" style="width: 120px">
157-
Created by:
146+
Last updated by:
158147
</li>
159148
<li class="tight-form-item" style="width: 180px">
160-
{{dashboardMeta.createdBy}}
161-
</li>
149+
{{dashboardMeta.updatedBy}}
150+
</li>
162151
</ul>
163152
<div class="clearfix"></div>
164153
</div>

0 commit comments

Comments
 (0)