mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
Added createdBy in metadata ui and dashboard table
This commit is contained in:
@@ -42,6 +42,7 @@ type DashboardMeta struct {
|
|||||||
Created time.Time `json:"created"`
|
Created time.Time `json:"created"`
|
||||||
Updated time.Time `json:"updated"`
|
Updated time.Time `json:"updated"`
|
||||||
UpdatedBy string `json:"updatedBy"`
|
UpdatedBy string `json:"updatedBy"`
|
||||||
|
CreatedBy string `json:"createdBy"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type DashboardFullWithMeta struct {
|
type DashboardFullWithMeta struct {
|
||||||
|
|||||||
@@ -34,6 +34,7 @@ type Dashboard struct {
|
|||||||
Updated time.Time
|
Updated time.Time
|
||||||
|
|
||||||
UpdatedBy int64
|
UpdatedBy int64
|
||||||
|
CreatedBy int64
|
||||||
|
|
||||||
Title string
|
Title string
|
||||||
Data map[string]interface{}
|
Data map[string]interface{}
|
||||||
@@ -66,7 +67,7 @@ func (dash *Dashboard) GetTags() []string {
|
|||||||
return b
|
return b
|
||||||
}
|
}
|
||||||
|
|
||||||
func NewDashboardFromJson(data map[string]interface{}) *Dashboard {
|
func NewDashboardFromJson(data map[string]interface {}) *Dashboard {
|
||||||
dash := &Dashboard{}
|
dash := &Dashboard{}
|
||||||
dash.Data = data
|
dash.Data = data
|
||||||
dash.Title = dash.Data["title"].(string)
|
dash.Title = dash.Data["title"].(string)
|
||||||
@@ -91,8 +92,11 @@ func NewDashboardFromJson(data map[string]interface{}) *Dashboard {
|
|||||||
// GetDashboardModel turns the command into the savable model
|
// GetDashboardModel turns the command into the savable model
|
||||||
func (cmd *SaveDashboardCommand) GetDashboardModel() *Dashboard {
|
func (cmd *SaveDashboardCommand) GetDashboardModel() *Dashboard {
|
||||||
dash := NewDashboardFromJson(cmd.Dashboard)
|
dash := NewDashboardFromJson(cmd.Dashboard)
|
||||||
dash.OrgId = cmd.OrgId
|
if dash.Data["version"] == 0 {
|
||||||
dash.UpdatedBy = cmd.UpdatedBy
|
dash.CreatedBy = cmd.UserId
|
||||||
|
}
|
||||||
|
dash.UpdatedBy = cmd.UserId
|
||||||
|
dash.OrgId = cmd.OrgId
|
||||||
dash.UpdateSlug()
|
dash.UpdateSlug()
|
||||||
return dash
|
return dash
|
||||||
}
|
}
|
||||||
@@ -114,9 +118,9 @@ func (dash *Dashboard) UpdateSlug() {
|
|||||||
|
|
||||||
type SaveDashboardCommand struct {
|
type SaveDashboardCommand struct {
|
||||||
Dashboard map[string]interface{} `json:"dashboard" binding:"Required"`
|
Dashboard map[string]interface{} `json:"dashboard" binding:"Required"`
|
||||||
Overwrite bool `json:"overwrite"`
|
UserId int64 `json:"userId"`
|
||||||
OrgId int64 `json:"-"`
|
OrgId int64 `json:"-"`
|
||||||
UpdatedBy int64 `json:"-"`
|
Overwrite bool `json:"overwrite"`
|
||||||
|
|
||||||
Result *Dashboard
|
Result *Dashboard
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -97,4 +97,9 @@ func addDashboardMigration(mg *Migrator) {
|
|||||||
mg.AddMigration("Add column updated_by in dashboard - v2", NewAddColumnMigration(dashboardV2, &Column{
|
mg.AddMigration("Add column updated_by in dashboard - v2", NewAddColumnMigration(dashboardV2, &Column{
|
||||||
Name: "updated_by", Type: DB_Int, Nullable: true,
|
Name: "updated_by", Type: DB_Int, Nullable: true,
|
||||||
}))
|
}))
|
||||||
|
|
||||||
|
// 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_Int, Nullable: true,
|
||||||
|
}))
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -151,6 +151,17 @@
|
|||||||
</ul>
|
</ul>
|
||||||
<div class="clearfix"></div>
|
<div class="clearfix"></div>
|
||||||
</div>
|
</div>
|
||||||
|
<div class="tight-form">
|
||||||
|
<ul class="tight-form-list">
|
||||||
|
<li class="tight-form-item" style="width: 120px">
|
||||||
|
Created by:
|
||||||
|
</li>
|
||||||
|
<li class="tight-form-item" style="width: 180px">
|
||||||
|
{{dashboardMeta.createdBy}}
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
|
<div class="clearfix"></div>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
Reference in New Issue
Block a user