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
66621d76
Commit
66621d76
authored
Mar 17, 2016
by
utkarshcmu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added getDashboardSlugById api
parent
9dd6aefc
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
39 additions
and
0 deletions
+39
-0
pkg/api/api.go
+1
-0
pkg/api/dashboard.go
+14
-0
pkg/api/dtos/models.go
+4
-0
pkg/models/dashboards.go
+5
-0
pkg/services/sqlstore/dashboard.go
+15
-0
No files found.
pkg/api/api.go
View file @
66621d76
...
...
@@ -200,6 +200,7 @@ func Register(r *macaron.Macaron) {
r
.
Get
(
"/home"
,
GetHomeDashboard
)
r
.
Get
(
"/tags"
,
GetDashboardTags
)
r
.
Post
(
"/import"
,
bind
(
dtos
.
ImportDashboardCommand
{}),
wrap
(
ImportDashboard
))
r
.
Get
(
"/id/:id"
,
GetDashboardSlugById
)
})
// Dashboard snapshots
...
...
pkg/api/dashboard.go
View file @
66621d76
...
...
@@ -204,3 +204,17 @@ func GetDashboardTags(c *middleware.Context) {
c
.
JSON
(
200
,
query
.
Result
)
}
func
GetDashboardSlugById
(
c
*
middleware
.
Context
)
{
dashId
:=
c
.
ParamsInt64
(
":id"
)
query
:=
m
.
GetDashboardSlugByIdQuery
{
Id
:
dashId
}
err
:=
bus
.
Dispatch
(
&
query
)
if
err
!=
nil
{
c
.
JsonApiErr
(
500
,
"Failed to get slug from database"
,
err
)
return
}
slug
:=
dtos
.
DashboardSlug
{
Slug
:
query
.
Result
}
c
.
JSON
(
200
,
&
slug
)
}
pkg/api/dtos/models.go
View file @
66621d76
...
...
@@ -57,6 +57,10 @@ type DashboardFullWithMeta struct {
Dashboard
*
simplejson
.
Json
`json:"dashboard"`
}
type
DashboardSlug
struct
{
Slug
string
`json:"slug"`
}
type
DataSource
struct
{
Id
int64
`json:"id"`
OrgId
int64
`json:"orgId"`
...
...
pkg/models/dashboards.go
View file @
66621d76
...
...
@@ -148,3 +148,8 @@ type GetDashboardsQuery struct {
DashboardIds
[]
int64
Result
*
[]
Dashboard
}
type
GetDashboardSlugByIdQuery
struct
{
Id
int64
Result
string
}
pkg/services/sqlstore/dashboard.go
View file @
66621d76
...
...
@@ -18,6 +18,7 @@ func init() {
bus
.
AddHandler
(
"sql"
,
DeleteDashboard
)
bus
.
AddHandler
(
"sql"
,
SearchDashboards
)
bus
.
AddHandler
(
"sql"
,
GetDashboardTags
)
bus
.
AddHandler
(
"sql"
,
GetDashboardSlugById
)
}
func
SaveDashboard
(
cmd
*
m
.
SaveDashboardCommand
)
error
{
...
...
@@ -255,3 +256,17 @@ func GetDashboards(query *m.GetDashboardsQuery) error {
return
nil
}
func
GetDashboardSlugById
(
query
*
m
.
GetDashboardSlugByIdQuery
)
error
{
dashboard
:=
m
.
Dashboard
{
Id
:
query
.
Id
}
has
,
err
:=
x
.
Get
(
&
dashboard
)
query
.
Result
=
dashboard
.
Slug
if
err
!=
nil
{
return
err
}
else
if
has
==
false
{
return
m
.
ErrDashboardNotFound
}
return
nil
}
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