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
db27bbb1
Commit
db27bbb1
authored
Feb 05, 2016
by
Torkel Ödegaard
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #3918 from utkarshcmu/metadata
Added metadata fields under Settings tab
parents
1bce8f66
59a384b4
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
66 additions
and
24 deletions
+66
-24
docs/sources/reference/http_api.md
+1
-1
pkg/api/dashboard.go
+22
-13
pkg/api/dtos/models.go
+2
-0
pkg/models/dashboards.go
+7
-3
pkg/services/sqlstore/migrations/dashboard_mig.go
+5
-0
public/app/features/dashboard/partials/settings.html
+29
-7
No files found.
docs/sources/reference/http_api.md
View file @
db27bbb1
...
...
@@ -75,7 +75,7 @@ Creates a new dashboard or updates an existing dashboard.
JSON Body schema:
-
**dashboard**
– The complete dashboard model, id = null to create a new dashboard
-
**dashboard**
– The complete dashboard model, id = null to create a new dashboard
.
-
**overwrite**
– Set to true if you want to overwrite existing dashboard with newer version or with same dashboard title.
**Example Response**
:
...
...
pkg/api/dashboard.go
View file @
db27bbb1
...
...
@@ -49,17 +49,13 @@ 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
}
// Finding creator and last updater of the dashboard
updater
,
creator
:=
"Anonymous"
,
"Anonymous"
if
dash
.
UpdatedBy
>
0
{
updater
=
getUserLogin
(
dash
.
UpdatedBy
)
}
if
dash
.
CreatedBy
>
0
{
creator
=
getUserLogin
(
dash
.
CreatedBy
)
}
dto
:=
dtos
.
DashboardFullWithMeta
{
...
...
@@ -74,12 +70,25 @@ func GetDashboard(c *middleware.Context) {
Created
:
dash
.
Created
,
Updated
:
dash
.
Updated
,
UpdatedBy
:
updater
,
CreatedBy
:
creator
,
Version
:
dash
.
Version
,
},
}
c
.
JSON
(
200
,
dto
)
}
func
getUserLogin
(
userId
int64
)
string
{
query
:=
m
.
GetUserByIdQuery
{
Id
:
userId
}
err
:=
bus
.
Dispatch
(
&
query
)
if
err
!=
nil
{
return
"Anonymous"
}
else
{
user
:=
query
.
Result
return
user
.
Login
}
}
func
DeleteDashboard
(
c
*
middleware
.
Context
)
{
slug
:=
c
.
Params
(
":slug"
)
...
...
@@ -104,9 +113,9 @@ func PostDashboard(c *middleware.Context, cmd m.SaveDashboardCommand) {
cmd
.
OrgId
=
c
.
OrgId
if
!
c
.
IsSignedIn
{
cmd
.
U
pdatedBy
=
0
cmd
.
U
serId
=
-
1
}
else
{
cmd
.
U
pdatedBy
=
c
.
UserId
cmd
.
U
serId
=
c
.
UserId
}
dash
:=
cmd
.
GetDashboardModel
()
...
...
pkg/api/dtos/models.go
View file @
db27bbb1
...
...
@@ -42,6 +42,8 @@ type DashboardMeta struct {
Created
time
.
Time
`json:"created"`
Updated
time
.
Time
`json:"updated"`
UpdatedBy
string
`json:"updatedBy"`
CreatedBy
string
`json:"createdBy"`
Version
int
`json:"version"`
}
type
DashboardFullWithMeta
struct
{
...
...
pkg/models/dashboards.go
View file @
db27bbb1
...
...
@@ -34,6 +34,7 @@ type Dashboard struct {
Updated
time
.
Time
UpdatedBy
int64
CreatedBy
int64
Title
string
Data
map
[
string
]
interface
{}
...
...
@@ -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
)
if
dash
.
Data
[
"version"
]
==
0
{
dash
.
CreatedBy
=
cmd
.
UserId
}
dash
.
UpdatedBy
=
cmd
.
UserId
dash
.
OrgId
=
cmd
.
OrgId
dash
.
UpdatedBy
=
cmd
.
UpdatedBy
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
}
...
...
pkg/services/sqlstore/migrations/dashboard_mig.go
View file @
db27bbb1
...
...
@@ -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
,
}))
}
public/app/features/dashboard/partials/settings.html
View file @
db27bbb1
...
...
@@ -115,9 +115,9 @@
</div>
<div
ng-if=
"editor.index == 4"
>
<div
class=
"
editor-
row"
>
<
div
class=
"tight-form-section"
>
<h5>
Dashboard info
</h5
>
<div
class=
"row"
>
<
h5>
Dashboard info
</h5
>
<div
class=
"pull-left tight-form"
>
<div
class=
"tight-form"
>
<ul
class=
"tight-form-list"
>
<li
class=
"tight-form-item"
style=
"width: 120px"
>
...
...
@@ -132,21 +132,43 @@
<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
class=
"tight-form"
>
<ul
class=
"tight-form-list"
>
<li
class=
"tight-form-item"
style=
"width: 120px"
>
Created at:
</li>
<li
class=
"tight-form-item"
style=
"width: 180px"
>
{{formatDate(dashboardMeta.created)}}
</li>
</li>
</ul>
<div
class=
"clearfix"
></div>
</div>
<div
class=
"tight-form
last
"
>
<div
class=
"tight-form"
>
<ul
class=
"tight-form-list"
>
<li
class=
"tight-form-item"
style=
"width: 120px"
>
Last upd
ated by:
Cre
ated by:
</li>
<li
class=
"tight-form-item"
style=
"width: 180px"
>
{{dashboardMeta.updatedBy}}
{{dashboardMeta.createdBy}}
</li>
</ul>
<div
class=
"clearfix"
></div>
</div>
<div
class=
"tight-form"
>
<ul
class=
"tight-form-list"
>
<li
class=
"tight-form-item"
style=
"width: 120px"
>
Current version:
</li>
<li
class=
"tight-form-item"
style=
"width: 180px"
>
{{dashboardMeta.version}}
</li>
</ul>
<div
class=
"clearfix"
></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