Added createdBy in metadata ui and dashboard table

This commit is contained in:
utkarshcmu 2016-01-27 16:33:32 -08:00
parent 6c4791b48d
commit 753fd164d7
4 changed files with 26 additions and 5 deletions

View File

@ -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 {

View File

@ -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
}

View File

@ -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,
}))
}

View File

@ -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>