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:
parent
6c4791b48d
commit
753fd164d7
@ -42,6 +42,7 @@ type DashboardMeta struct {
|
||||
Created time.Time `json:"created"`
|
||||
Updated time.Time `json:"updated"`
|
||||
UpdatedBy string `json:"updatedBy"`
|
||||
CreatedBy string `json:"createdBy"`
|
||||
}
|
||||
|
||||
type DashboardFullWithMeta struct {
|
||||
|
@ -34,6 +34,7 @@ type Dashboard struct {
|
||||
Updated time.Time
|
||||
|
||||
UpdatedBy int64
|
||||
CreatedBy int64
|
||||
|
||||
Title string
|
||||
Data map[string]interface{}
|
||||
@ -66,7 +67,7 @@ func (dash *Dashboard) GetTags() []string {
|
||||
return b
|
||||
}
|
||||
|
||||
func NewDashboardFromJson(data map[string]interface{}) *Dashboard {
|
||||
func NewDashboardFromJson(data map[string]interface {}) *Dashboard {
|
||||
dash := &Dashboard{}
|
||||
dash.Data = data
|
||||
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
|
||||
func (cmd *SaveDashboardCommand) GetDashboardModel() *Dashboard {
|
||||
dash := NewDashboardFromJson(cmd.Dashboard)
|
||||
dash.OrgId = cmd.OrgId
|
||||
dash.UpdatedBy = cmd.UpdatedBy
|
||||
if dash.Data["version"] == 0 {
|
||||
dash.CreatedBy = cmd.UserId
|
||||
}
|
||||
dash.UpdatedBy = cmd.UserId
|
||||
dash.OrgId = cmd.OrgId
|
||||
dash.UpdateSlug()
|
||||
return dash
|
||||
}
|
||||
@ -114,9 +118,9 @@ func (dash *Dashboard) UpdateSlug() {
|
||||
|
||||
type SaveDashboardCommand struct {
|
||||
Dashboard map[string]interface{} `json:"dashboard" binding:"Required"`
|
||||
Overwrite bool `json:"overwrite"`
|
||||
UserId int64 `json:"userId"`
|
||||
OrgId int64 `json:"-"`
|
||||
UpdatedBy int64 `json:"-"`
|
||||
Overwrite bool `json:"overwrite"`
|
||||
|
||||
Result *Dashboard
|
||||
}
|
||||
|
@ -97,4 +97,9 @@ func addDashboardMigration(mg *Migrator) {
|
||||
mg.AddMigration("Add column updated_by in dashboard - v2", NewAddColumnMigration(dashboardV2, &Column{
|
||||
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>
|
||||
<div class="clearfix"></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>
|
||||
|
Loading…
Reference in New Issue
Block a user