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
22c001c8
Commit
22c001c8
authored
Jan 08, 2016
by
bergquist
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix(playlist): implement api according to new standard
parent
d15b0bf4
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
24 additions
and
30 deletions
+24
-30
pkg/api/api.go
+6
-6
pkg/api/playlist.go
+18
-24
No files found.
pkg/api/api.go
View file @
22c001c8
...
...
@@ -174,12 +174,12 @@ func Register(r *macaron.Macaron) {
// Playlist
r
.
Group
(
"/playlists"
,
func
()
{
r
.
Get
(
"/"
,
SearchPlaylists
)
r
.
Get
(
"/:id"
,
ValidateOrgPlaylist
,
GetPlaylist
)
r
.
Get
(
"/:id/dashboards"
,
ValidateOrgPlaylist
,
GetPlaylistDashboards
)
r
.
Delete
(
"/:id"
,
reqEditorRole
,
ValidateOrgPlaylist
,
DeletePlaylist
)
r
.
Put
(
"/:id"
,
reqEditorRole
,
bind
(
m
.
UpdatePlaylistQuery
{}),
ValidateOrgPlaylist
,
UpdatePlaylist
)
r
.
Post
(
"/"
,
reqEditorRole
,
bind
(
m
.
CreatePlaylistQuery
{}),
CreatePlaylist
)
r
.
Get
(
"/"
,
wrap
(
SearchPlaylists
)
)
r
.
Get
(
"/:id"
,
ValidateOrgPlaylist
,
wrap
(
GetPlaylist
)
)
r
.
Get
(
"/:id/dashboards"
,
ValidateOrgPlaylist
,
wrap
(
GetPlaylistDashboards
)
)
r
.
Delete
(
"/:id"
,
reqEditorRole
,
ValidateOrgPlaylist
,
wrap
(
DeletePlaylist
)
)
r
.
Put
(
"/:id"
,
reqEditorRole
,
bind
(
m
.
UpdatePlaylistQuery
{}),
ValidateOrgPlaylist
,
wrap
(
UpdatePlaylist
)
)
r
.
Post
(
"/"
,
reqEditorRole
,
bind
(
m
.
CreatePlaylistQuery
{}),
wrap
(
CreatePlaylist
)
)
})
// Search
...
...
pkg/api/playlist.go
View file @
22c001c8
...
...
@@ -22,7 +22,7 @@ func ValidateOrgPlaylist(c *middleware.Context) {
}
}
func
SearchPlaylists
(
c
*
middleware
.
Context
)
{
func
SearchPlaylists
(
c
*
middleware
.
Context
)
Response
{
query
:=
c
.
Query
(
"query"
)
limit
:=
c
.
QueryInt
(
"limit"
)
...
...
@@ -38,66 +38,60 @@ func SearchPlaylists(c *middleware.Context) {
err
:=
bus
.
Dispatch
(
&
searchQuery
)
if
err
!=
nil
{
c
.
JsonApiErr
(
500
,
"Search failed"
,
err
)
return
return
ApiError
(
500
,
"Search failed"
,
err
)
}
c
.
JSON
(
200
,
searchQuery
.
Result
)
return
Json
(
200
,
searchQuery
.
Result
)
}
func
GetPlaylist
(
c
*
middleware
.
Context
)
{
func
GetPlaylist
(
c
*
middleware
.
Context
)
Response
{
id
:=
c
.
ParamsInt64
(
":id"
)
cmd
:=
m
.
GetPlaylistByIdQuery
{
Id
:
id
}
if
err
:=
bus
.
Dispatch
(
&
cmd
);
err
!=
nil
{
c
.
JsonApiErr
(
500
,
"Playlist not found"
,
err
)
return
return
ApiError
(
500
,
"Playlist not found"
,
err
)
}
c
.
JSON
(
200
,
cmd
.
Result
)
return
Json
(
200
,
cmd
.
Result
)
}
func
GetPlaylistDashboards
(
c
*
middleware
.
Context
)
{
func
GetPlaylistDashboards
(
c
*
middleware
.
Context
)
Response
{
id
:=
c
.
ParamsInt64
(
":id"
)
query
:=
m
.
GetPlaylistDashboardsQuery
{
Id
:
id
}
if
err
:=
bus
.
Dispatch
(
&
query
);
err
!=
nil
{
c
.
JsonApiErr
(
500
,
"Playlist not found"
,
err
)
return
return
ApiError
(
500
,
"Playlist not found"
,
err
)
}
c
.
JSON
(
200
,
query
.
Result
)
return
Json
(
200
,
query
.
Result
)
}
func
DeletePlaylist
(
c
*
middleware
.
Context
)
{
func
DeletePlaylist
(
c
*
middleware
.
Context
)
Response
{
id
:=
c
.
ParamsInt64
(
":id"
)
cmd
:=
m
.
DeletePlaylistQuery
{
Id
:
id
}
if
err
:=
bus
.
Dispatch
(
&
cmd
);
err
!=
nil
{
c
.
JsonApiErr
(
500
,
"Failed to delete playlist"
,
err
)
return
return
ApiError
(
500
,
"Failed to delete playlist"
,
err
)
}
c
.
JSON
(
200
,
""
)
return
Json
(
200
,
""
)
}
func
CreatePlaylist
(
c
*
middleware
.
Context
,
query
m
.
CreatePlaylistQuery
)
{
func
CreatePlaylist
(
c
*
middleware
.
Context
,
query
m
.
CreatePlaylistQuery
)
Response
{
query
.
OrgId
=
c
.
OrgId
err
:=
bus
.
Dispatch
(
&
query
)
if
err
!=
nil
{
c
.
JsonApiErr
(
500
,
"Failed to create playlist"
,
err
)
return
return
ApiError
(
500
,
"Failed to create playlist"
,
err
)
}
c
.
JSON
(
200
,
query
.
Result
)
return
Json
(
200
,
query
.
Result
)
}
func
UpdatePlaylist
(
c
*
middleware
.
Context
,
query
m
.
UpdatePlaylistQuery
)
{
func
UpdatePlaylist
(
c
*
middleware
.
Context
,
query
m
.
UpdatePlaylistQuery
)
Response
{
err
:=
bus
.
Dispatch
(
&
query
)
if
err
!=
nil
{
c
.
JsonApiErr
(
500
,
"Failed to save playlist"
,
err
)
return
return
ApiError
(
500
,
"Failed to save playlist"
,
err
)
}
c
.
JSON
(
200
,
query
.
Result
)
return
Json
(
200
,
query
.
Result
)
}
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