Skip to content

Commit e0ffcda

Browse files
committed
Added UI , DB settings
1 parent 78fe588 commit e0ffcda

File tree

5 files changed

+70
-5
lines changed

5 files changed

+70
-5
lines changed

pkg/api/dashboard.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,8 @@ func GetDashboard(c *middleware.Context) {
5959
CanEdit: canEditDashboard(c.OrgRole),
6060
Created: dash.Created,
6161
Updated: dash.Updated,
62+
CreatedBy: dash.CreatedBy,
63+
UpdatedBy: dash.UpdatedBy,
6264
},
6365
}
6466

pkg/api/dtos/models.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,8 @@ type DashboardMeta struct {
4141
Expires time.Time `json:"expires"`
4242
Created time.Time `json:"created"`
4343
Updated time.Time `json:"updated"`
44+
CreatedBy string `json:"createdBy"`
45+
UpdatedBy string `json:"updatedBy"`
4446
}
4547

4648
type DashboardFullWithMeta struct {
@@ -61,6 +63,7 @@ type DataSource struct {
6163
BasicAuth bool `json:"basicAuth"`
6264
BasicAuthUser string `json:"basicAuthUser"`
6365
BasicAuthPassword string `json:"basicAuthPassword"`
66+
WithCredentials bool `json:"withCredentials"`
6467
IsDefault bool `json:"isDefault"`
6568
JsonData map[string]interface{} `json:"jsonData"`
6669
}

pkg/models/dashboards.go

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

36+
CreatedBy string
37+
UpdatedBy string
38+
3639
Title string
3740
Data map[string]interface{}
3841
}
@@ -45,6 +48,8 @@ func NewDashboard(title string) *Dashboard {
4548
dash.Title = title
4649
dash.Created = time.Now()
4750
dash.Updated = time.Now()
51+
// TODO:dash.CreatedBy = "Creator"
52+
// TODO:dash.UpdatedBy = "Creator"
4853
dash.UpdateSlug()
4954
return dash
5055
}
@@ -76,11 +81,14 @@ func NewDashboardFromJson(data map[string]interface{}) *Dashboard {
7681
if dash.Data["version"] != nil {
7782
dash.Version = int(dash.Data["version"].(float64))
7883
dash.Updated = time.Now()
84+
// TODO:dash.UpdatedBy = "Updater"
7985
}
8086
} else {
8187
dash.Data["version"] = 0
8288
dash.Created = time.Now()
8389
dash.Updated = time.Now()
90+
// TODO:dash.CreatedBy = "Creator"
91+
// TODO:dash.UpdatedBy = "Creator"
8492
}
8593

8694
return dash

pkg/services/sqlstore/migrations/dashboard_mig.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -94,12 +94,12 @@ func addDashboardMigration(mg *Migrator) {
9494
Mysql("ALTER TABLE dashboard MODIFY data MEDIUMTEXT;"))
9595

9696
// add column to store creator of a dashboard
97-
mg.AddMigration("Add column created_by", NewAddColumnMigration(dashboardV2, &Column{
98-
Name: "created_by", Type: DB_BigInt, Nullable: true,
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",
9999
}))
100100

101101
// add column to store updater of a dashboard
102-
mg.AddMigration("Add column updated_by", NewAddColumnMigration(dashboardV2, &Column{
103-
Name: "updated_by", Type: DB_BigInt, Nullable: true,
102+
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",
104104
}))
105105
}

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

Lines changed: 53 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
</div>
66

77
<div ng-model="editor.index" bs-tabs style="text-transform:capitalize;">
8-
<div ng-repeat="tab in ['General', 'Rows', 'Links', 'Time picker']" data-title="{{tab}}">
8+
<div ng-repeat="tab in ['General', 'Rows', 'Links', 'Time picker', 'Metadata']" data-title="{{tab}}">
99
</div>
1010
</div>
1111

@@ -114,6 +114,58 @@ <h5>Rows settings</h5>
114114
<gf-time-picker-settings dashboard="dashboard"></gf-time-picker-settings>
115115
</div>
116116

117+
<div ng-if="editor.index == 4">
118+
<div class="editor-row">
119+
<div class="tight-form-section">
120+
<h5>Info</h5>
121+
<div class="tight-form">
122+
<ul class="tight-form-list">
123+
<li class="tight-form-item" style="width: 120px">
124+
Last updated at:
125+
</li>
126+
<li class="tight-form-item" style="width: 180px">
127+
{{formatDate(dashboardMeta.updated)}}
128+
</li>
129+
</ul>
130+
<div class="clearfix"></div>
131+
</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>
143+
<div class="tight-form last">
144+
<ul class="tight-form-list">
145+
<li class="tight-form-item" style="width: 120px">
146+
Created at:
147+
</li>
148+
<li class="tight-form-item" style="width: 180px">
149+
{{formatDate(dashboardMeta.created)}}
150+
</li>
151+
</ul>
152+
<div class="clearfix"></div>
153+
</div>
154+
<div class="tight-form last">
155+
<ul class="tight-form-list">
156+
<li class="tight-form-item" style="width: 120px">
157+
Created by:
158+
</li>
159+
<li class="tight-form-item" style="width: 180px">
160+
{{dashboardMeta.createdBy}}
161+
</li>
162+
</ul>
163+
<div class="clearfix"></div>
164+
</div>
165+
</div>
166+
</div>
167+
</div>
168+
117169
</div>
118170

119171
<div class="clearfix"></div>

0 commit comments

Comments
 (0)