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
6a119217
Commit
6a119217
authored
Jan 27, 2016
by
utkarshcmu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Api stores dashboard creator
parent
753fd164
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
23 additions
and
15 deletions
+23
-15
pkg/api/dashboard.go
+23
-15
No files found.
pkg/api/dashboard.go
View file @
6a119217
...
...
@@ -49,18 +49,14 @@ 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 the last creator and 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
{
Dashboard
:
dash
.
Data
,
...
...
@@ -74,12 +70,24 @@ func GetDashboard(c *middleware.Context) {
Created
:
dash
.
Created
,
Updated
:
dash
.
Updated
,
UpdatedBy
:
updater
,
CreatedBy
:
creator
,
},
}
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,10 +112,10 @@ 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
.
UpdatedBy
=
c
.
UserId
}
cmd
.
UserId
=
c
.
UserId
}
dash
:=
cmd
.
GetDashboardModel
()
if
dash
.
Id
==
0
{
...
...
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