Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
N
nexpie-grafana-theme
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Registry
Registry
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Kornkitt Poolsup
nexpie-grafana-theme
Commits
af9b864b
Commit
af9b864b
authored
Dec 20, 2015
by
Carl Bergquist
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #3446 from utkarshcmu/new-columns
Displaying Last UpdatedBy as Metadata
parents
406ee43a
d8b90721
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
42 additions
and
0 deletions
+42
-0
pkg/api/dashboard.go
+21
-0
pkg/api/dtos/models.go
+1
-0
pkg/models/dashboards.go
+4
-0
pkg/services/sqlstore/migrations/dashboard_mig.go
+5
-0
public/app/features/dashboard/partials/settings.html
+11
-0
No files found.
pkg/api/dashboard.go
View file @
af9b864b
...
...
@@ -48,6 +48,20 @@ func GetDashboard(c *middleware.Context) {
}
dash
:=
query
.
Result
// Finding the last updater of the dashboard
updater
:=
"Anonymous"
if
dash
.
UpdatedBy
!=
0
{
userQuery
:=
m
.
GetUserByIdQuery
{
Id
:
dash
.
UpdatedBy
}
userErr
:=
bus
.
Dispatch
(
&
userQuery
)
if
userErr
!=
nil
{
updater
=
"Unknown"
}
else
{
user
:=
userQuery
.
Result
updater
=
user
.
Login
}
}
dto
:=
dtos
.
DashboardFullWithMeta
{
Dashboard
:
dash
.
Data
,
Meta
:
dtos
.
DashboardMeta
{
...
...
@@ -59,6 +73,7 @@ func GetDashboard(c *middleware.Context) {
CanEdit
:
canEditDashboard
(
c
.
OrgRole
),
Created
:
dash
.
Created
,
Updated
:
dash
.
Updated
,
UpdatedBy
:
updater
,
},
}
...
...
@@ -88,6 +103,12 @@ func DeleteDashboard(c *middleware.Context) {
func
PostDashboard
(
c
*
middleware
.
Context
,
cmd
m
.
SaveDashboardCommand
)
{
cmd
.
OrgId
=
c
.
OrgId
if
!
c
.
IsSignedIn
{
cmd
.
UpdatedBy
=
0
}
else
{
cmd
.
UpdatedBy
=
c
.
UserId
}
dash
:=
cmd
.
GetDashboardModel
()
if
dash
.
Id
==
0
{
limitReached
,
err
:=
middleware
.
QuotaReached
(
c
,
"dashboard"
)
...
...
pkg/api/dtos/models.go
View file @
af9b864b
...
...
@@ -41,6 +41,7 @@ type DashboardMeta struct {
Expires
time
.
Time
`json:"expires"`
Created
time
.
Time
`json:"created"`
Updated
time
.
Time
`json:"updated"`
UpdatedBy
string
`json:"updatedBy"`
}
type
DashboardFullWithMeta
struct
{
...
...
pkg/models/dashboards.go
View file @
af9b864b
...
...
@@ -33,6 +33,8 @@ type Dashboard struct {
Created
time
.
Time
Updated
time
.
Time
UpdatedBy
int64
Title
string
Data
map
[
string
]
interface
{}
}
...
...
@@ -90,6 +92,7 @@ func NewDashboardFromJson(data map[string]interface{}) *Dashboard {
func
(
cmd
*
SaveDashboardCommand
)
GetDashboardModel
()
*
Dashboard
{
dash
:=
NewDashboardFromJson
(
cmd
.
Dashboard
)
dash
.
OrgId
=
cmd
.
OrgId
dash
.
UpdatedBy
=
cmd
.
UpdatedBy
dash
.
UpdateSlug
()
return
dash
}
...
...
@@ -113,6 +116,7 @@ type SaveDashboardCommand struct {
Dashboard
map
[
string
]
interface
{}
`json:"dashboard" binding:"Required"`
Overwrite
bool
`json:"overwrite"`
OrgId
int64
`json:"-"`
UpdatedBy
int64
`json:"-"`
Result
*
Dashboard
}
...
...
pkg/services/sqlstore/migrations/dashboard_mig.go
View file @
af9b864b
...
...
@@ -92,4 +92,9 @@ func addDashboardMigration(mg *Migrator) {
Sqlite
(
"SELECT 0 WHERE 0;"
)
.
Postgres
(
"SELECT 0;"
)
.
Mysql
(
"ALTER TABLE dashboard MODIFY data MEDIUMTEXT;"
))
// add column to store updater of a dashboard
mg
.
AddMigration
(
"Add column updated_by in dashboard - v2"
,
NewAddColumnMigration
(
dashboardV2
,
&
Column
{
Name
:
"updated_by"
,
Type
:
DB_Int
,
Nullable
:
true
,
}))
}
public/app/features/dashboard/partials/settings.html
View file @
af9b864b
...
...
@@ -140,6 +140,17 @@
</ul>
<div
class=
"clearfix"
></div>
</div>
<div
class=
"tight-form"
>
<ul
class=
"tight-form-list"
>
<li
class=
"tight-form-item"
style=
"width: 120px"
>
Last updated by:
</li>
<li
class=
"tight-form-item"
style=
"width: 180px"
>
{{dashboardMeta.updatedBy}}
</li>
</ul>
<div
class=
"clearfix"
></div>
</div>
</div>
</div>
</div>
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment