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
8f067a5e
Commit
8f067a5e
authored
Jan 19, 2016
by
utkarshcmu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added backend functionality for searching snapshots
parent
870775e8
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
63 additions
and
1 deletions
+63
-1
pkg/api/api.go
+8
-1
pkg/api/dashboard_snapshot.go
+22
-0
pkg/api/index.go
+6
-0
pkg/models/dashboard_snapshot.go
+10
-0
pkg/services/sqlstore/dashboard_snapshot.go
+17
-0
No files found.
pkg/api/api.go
View file @
8f067a5e
...
@@ -68,9 +68,11 @@ func Register(r *macaron.Macaron) {
...
@@ -68,9 +68,11 @@ func Register(r *macaron.Macaron) {
r
.
Post
(
"/api/user/password/reset"
,
bind
(
dtos
.
ResetUserPasswordForm
{}),
wrap
(
ResetPassword
))
r
.
Post
(
"/api/user/password/reset"
,
bind
(
dtos
.
ResetUserPasswordForm
{}),
wrap
(
ResetPassword
))
// dashboard snapshots
// dashboard snapshots
r
.
Post
(
"/api/snapshots/"
,
bind
(
m
.
CreateDashboardSnapshotCommand
{}),
CreateDashboardSnapshot
)
r
.
Get
(
"/dashboard/snapshot/*"
,
Index
)
r
.
Get
(
"/dashboard/snapshot/*"
,
Index
)
r
.
Get
(
"/dashboard/snapshots/"
,
reqSignedIn
,
Index
)
// api for dashboard snapshots
r
.
Post
(
"/api/snapshots/"
,
bind
(
m
.
CreateDashboardSnapshotCommand
{}),
CreateDashboardSnapshot
)
r
.
Get
(
"/api/snapshot/shared-options/"
,
GetSharingOptions
)
r
.
Get
(
"/api/snapshot/shared-options/"
,
GetSharingOptions
)
r
.
Get
(
"/api/snapshots/:key"
,
GetDashboardSnapshot
)
r
.
Get
(
"/api/snapshots/:key"
,
GetDashboardSnapshot
)
r
.
Get
(
"/api/snapshots-delete/:key"
,
DeleteDashboardSnapshot
)
r
.
Get
(
"/api/snapshots-delete/:key"
,
DeleteDashboardSnapshot
)
...
@@ -182,6 +184,11 @@ func Register(r *macaron.Macaron) {
...
@@ -182,6 +184,11 @@ func Register(r *macaron.Macaron) {
r
.
Get
(
"/tags"
,
GetDashboardTags
)
r
.
Get
(
"/tags"
,
GetDashboardTags
)
})
})
// dashboard snapshots
r
.
Group
(
"/dashboard/snapshots"
,
func
()
{
r
.
Get
(
"/"
,
wrap
(
SearchDashboardSnapshots
))
})
// Playlist
// Playlist
r
.
Group
(
"/playlists"
,
func
()
{
r
.
Group
(
"/playlists"
,
func
()
{
r
.
Get
(
"/"
,
wrap
(
SearchPlaylists
))
r
.
Get
(
"/"
,
wrap
(
SearchPlaylists
))
...
...
pkg/api/dashboard_snapshot.go
View file @
8f067a5e
...
@@ -98,3 +98,25 @@ func DeleteDashboardSnapshot(c *middleware.Context) {
...
@@ -98,3 +98,25 @@ func DeleteDashboardSnapshot(c *middleware.Context) {
c
.
JSON
(
200
,
util
.
DynMap
{
"message"
:
"Snapshot deleted. It might take an hour before it's cleared from a CDN cache."
})
c
.
JSON
(
200
,
util
.
DynMap
{
"message"
:
"Snapshot deleted. It might take an hour before it's cleared from a CDN cache."
})
}
}
func
SearchDashboardSnapshots
(
c
*
middleware
.
Context
)
Response
{
query
:=
c
.
Query
(
"query"
)
limit
:=
c
.
QueryInt
(
"limit"
)
if
limit
==
0
{
limit
=
1000
}
searchQuery
:=
m
.
GetDashboardSnapshotsQuery
{
Name
:
query
,
Limit
:
limit
,
OrgId
:
c
.
OrgId
,
}
err
:=
bus
.
Dispatch
(
&
searchQuery
)
if
err
!=
nil
{
return
ApiError
(
500
,
"Search failed"
,
err
)
}
return
Json
(
200
,
searchQuery
.
Result
)
}
pkg/api/index.go
View file @
8f067a5e
...
@@ -60,6 +60,12 @@ func setIndexViewData(c *middleware.Context) (*dtos.IndexViewData, error) {
...
@@ -60,6 +60,12 @@ func setIndexViewData(c *middleware.Context) (*dtos.IndexViewData, error) {
Url
:
"/playlists"
,
Url
:
"/playlists"
,
})
})
data
.
MainNavLinks
=
append
(
data
.
MainNavLinks
,
&
dtos
.
NavLink
{
Text
:
"Snapshots"
,
Icon
:
"fa fa-fw fa-camera-retro"
,
Url
:
"/dashboard/snapshots"
,
})
if
c
.
OrgRole
==
m
.
ROLE_ADMIN
{
if
c
.
OrgRole
==
m
.
ROLE_ADMIN
{
data
.
MainNavLinks
=
append
(
data
.
MainNavLinks
,
&
dtos
.
NavLink
{
data
.
MainNavLinks
=
append
(
data
.
MainNavLinks
,
&
dtos
.
NavLink
{
Text
:
"Data Sources"
,
Text
:
"Data Sources"
,
...
...
pkg/models/dashboard_snapshot.go
View file @
8f067a5e
...
@@ -47,3 +47,13 @@ type GetDashboardSnapshotQuery struct {
...
@@ -47,3 +47,13 @@ type GetDashboardSnapshotQuery struct {
Result
*
DashboardSnapshot
Result
*
DashboardSnapshot
}
}
type
DashboardSnapshots
[]
*
DashboardSnapshot
type
GetDashboardSnapshotsQuery
struct
{
Name
string
Limit
int
OrgId
int64
Result
DashboardSnapshots
}
pkg/services/sqlstore/dashboard_snapshot.go
View file @
8f067a5e
...
@@ -12,6 +12,7 @@ func init() {
...
@@ -12,6 +12,7 @@ func init() {
bus
.
AddHandler
(
"sql"
,
CreateDashboardSnapshot
)
bus
.
AddHandler
(
"sql"
,
CreateDashboardSnapshot
)
bus
.
AddHandler
(
"sql"
,
GetDashboardSnapshot
)
bus
.
AddHandler
(
"sql"
,
GetDashboardSnapshot
)
bus
.
AddHandler
(
"sql"
,
DeleteDashboardSnapshot
)
bus
.
AddHandler
(
"sql"
,
DeleteDashboardSnapshot
)
bus
.
AddHandler
(
"sql"
,
SearchDashboardSnapshots
)
}
}
func
CreateDashboardSnapshot
(
cmd
*
m
.
CreateDashboardSnapshotCommand
)
error
{
func
CreateDashboardSnapshot
(
cmd
*
m
.
CreateDashboardSnapshotCommand
)
error
{
...
@@ -63,3 +64,19 @@ func GetDashboardSnapshot(query *m.GetDashboardSnapshotQuery) error {
...
@@ -63,3 +64,19 @@ func GetDashboardSnapshot(query *m.GetDashboardSnapshotQuery) error {
query
.
Result
=
&
snapshot
query
.
Result
=
&
snapshot
return
nil
return
nil
}
}
func
SearchDashboardSnapshots
(
query
*
m
.
GetDashboardSnapshotsQuery
)
error
{
var
snapshots
=
make
(
m
.
DashboardSnapshots
,
0
)
sess
:=
x
.
Limit
(
query
.
Limit
)
if
query
.
Name
!=
""
{
sess
.
Where
(
"name LIKE ?"
,
query
.
Name
)
}
sess
.
Where
(
"org_id = ?"
,
query
.
OrgId
)
err
:=
sess
.
Find
(
&
snapshots
)
query
.
Result
=
snapshots
return
err
}
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