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
369597f7
Commit
369597f7
authored
Jan 30, 2018
by
Marcus Efraimsson
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
dashboards: return url in response to save dashboard. #7883
parent
6ab52688
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
30 additions
and
22 deletions
+30
-22
pkg/api/dashboard.go
+15
-1
pkg/api/dashboard_test.go
+15
-21
No files found.
pkg/api/dashboard.go
View file @
369597f7
...
...
@@ -238,8 +238,22 @@ func PostDashboard(c *middleware.Context, cmd m.SaveDashboardCommand) Response {
return
ApiError
(
500
,
"Invalid alert data. Cannot save dashboard"
,
err
)
}
var
url
string
if
dash
.
IsFolder
{
url
=
m
.
GetFolderUrl
(
dashboard
.
Uid
,
dashboard
.
Slug
)
}
else
{
url
=
m
.
GetDashboardUrl
(
dashboard
.
Uid
,
dashboard
.
Slug
)
}
c
.
TimeRequest
(
metrics
.
M_Api_Dashboard_Save
)
return
Json
(
200
,
util
.
DynMap
{
"status"
:
"success"
,
"slug"
:
dashboard
.
Slug
,
"version"
:
dashboard
.
Version
,
"id"
:
dashboard
.
Id
,
"uid"
:
dashboard
.
Uid
})
return
Json
(
200
,
util
.
DynMap
{
"status"
:
"success"
,
"slug"
:
dashboard
.
Slug
,
"version"
:
dashboard
.
Version
,
"id"
:
dashboard
.
Id
,
"uid"
:
dashboard
.
Uid
,
"url"
:
url
,
})
}
func
GetHomeDashboard
(
c
*
middleware
.
Context
)
Response
{
...
...
pkg/api/dashboard_test.go
View file @
369597f7
...
...
@@ -180,13 +180,7 @@ func TestDashboardApiEndpoint(t *testing.T) {
})
postDashboardScenario
(
"When calling POST on"
,
"/api/dashboards"
,
"/api/dashboards"
,
role
,
cmd
,
func
(
sc
*
scenarioContext
)
{
CallPostDashboard
(
sc
)
So
(
sc
.
resp
.
Code
,
ShouldEqual
,
200
)
result
:=
sc
.
ToJson
()
So
(
result
.
Get
(
"status"
)
.
MustString
(),
ShouldEqual
,
"success"
)
So
(
result
.
Get
(
"id"
)
.
MustInt64
(),
ShouldBeGreaterThan
,
0
)
So
(
result
.
Get
(
"uid"
)
.
MustString
(),
ShouldNotBeNil
)
So
(
result
.
Get
(
"slug"
)
.
MustString
(),
ShouldNotBeNil
)
CallPostDashboardShouldReturnSuccess
(
sc
)
})
Convey
(
"When saving a dashboard folder in another folder"
,
func
()
{
...
...
@@ -423,13 +417,7 @@ func TestDashboardApiEndpoint(t *testing.T) {
})
postDashboardScenario
(
"When calling POST on"
,
"/api/dashboards"
,
"/api/dashboards"
,
role
,
cmd
,
func
(
sc
*
scenarioContext
)
{
CallPostDashboard
(
sc
)
So
(
sc
.
resp
.
Code
,
ShouldEqual
,
200
)
result
:=
sc
.
ToJson
()
So
(
result
.
Get
(
"status"
)
.
MustString
(),
ShouldEqual
,
"success"
)
So
(
result
.
Get
(
"id"
)
.
MustInt64
(),
ShouldBeGreaterThan
,
0
)
So
(
result
.
Get
(
"uid"
)
.
MustString
(),
ShouldNotBeNil
)
So
(
result
.
Get
(
"slug"
)
.
MustString
(),
ShouldNotBeNil
)
CallPostDashboardShouldReturnSuccess
(
sc
)
})
})
...
...
@@ -544,13 +532,7 @@ func TestDashboardApiEndpoint(t *testing.T) {
})
postDashboardScenario
(
"When calling POST on"
,
"/api/dashboards"
,
"/api/dashboards"
,
role
,
cmd
,
func
(
sc
*
scenarioContext
)
{
CallPostDashboard
(
sc
)
So
(
sc
.
resp
.
Code
,
ShouldEqual
,
200
)
result
:=
sc
.
ToJson
()
So
(
result
.
Get
(
"status"
)
.
MustString
(),
ShouldEqual
,
"success"
)
So
(
result
.
Get
(
"id"
)
.
MustInt64
(),
ShouldBeGreaterThan
,
0
)
So
(
result
.
Get
(
"uid"
)
.
MustString
(),
ShouldNotBeNil
)
So
(
result
.
Get
(
"slug"
)
.
MustString
(),
ShouldNotBeNil
)
CallPostDashboardShouldReturnSuccess
(
sc
)
})
})
...
...
@@ -678,6 +660,18 @@ func CallPostDashboard(sc *scenarioContext) {
sc
.
fakeReqWithParams
(
"POST"
,
sc
.
url
,
map
[
string
]
string
{})
.
exec
()
}
func
CallPostDashboardShouldReturnSuccess
(
sc
*
scenarioContext
)
{
CallPostDashboard
(
sc
)
So
(
sc
.
resp
.
Code
,
ShouldEqual
,
200
)
result
:=
sc
.
ToJson
()
So
(
result
.
Get
(
"status"
)
.
MustString
(),
ShouldEqual
,
"success"
)
So
(
result
.
Get
(
"id"
)
.
MustInt64
(),
ShouldBeGreaterThan
,
0
)
So
(
result
.
Get
(
"uid"
)
.
MustString
(),
ShouldNotBeNil
)
So
(
result
.
Get
(
"slug"
)
.
MustString
(),
ShouldNotBeNil
)
So
(
result
.
Get
(
"url"
)
.
MustString
(),
ShouldNotBeNil
)
}
func
postDashboardScenario
(
desc
string
,
url
string
,
routePattern
string
,
role
m
.
RoleType
,
cmd
m
.
SaveDashboardCommand
,
fn
scenarioFunc
)
{
Convey
(
desc
+
" "
+
url
,
func
()
{
defer
bus
.
ClearBusHandlers
()
...
...
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