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
73ee8a59
Commit
73ee8a59
authored
May 04, 2015
by
Torkel Ödegaard
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
HTTP API: fix for POST /api/dashboards/db returned 200 ok when dashboard was not found, Fixes #1929
parent
697529d0
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
28 additions
and
3 deletions
+28
-3
pkg/api/dashboard.go
+4
-0
pkg/models/dashboards.go
+1
-1
pkg/services/sqlstore/dashboard.go
+8
-2
pkg/services/sqlstore/dashboard_test.go
+15
-0
No files found.
pkg/api/dashboard.go
View file @
73ee8a59
...
...
@@ -87,6 +87,10 @@ func PostDashboard(c *middleware.Context, cmd m.SaveDashboardCommand) {
c
.
JSON
(
412
,
util
.
DynMap
{
"status"
:
"version-mismatch"
,
"message"
:
err
.
Error
()})
return
}
if
err
==
m
.
ErrDashboardNotFound
{
c
.
JSON
(
404
,
util
.
DynMap
{
"status"
:
"not-found"
,
"message"
:
err
.
Error
()})
return
}
c
.
JsonApiErr
(
500
,
"Failed to save dashboard"
,
err
)
return
}
...
...
pkg/models/dashboards.go
View file @
73ee8a59
...
...
@@ -10,7 +10,7 @@ import (
// Typed errors
var
(
ErrDashboardNotFound
=
errors
.
New
(
"
Account
not found"
)
ErrDashboardNotFound
=
errors
.
New
(
"
Dashboard
not found"
)
ErrDashboardWithSameNameExists
=
errors
.
New
(
"A dashboard with the same name already exists"
)
ErrDashboardVersionMismatch
=
errors
.
New
(
"The dashboard has been changed by someone else"
)
)
...
...
pkg/services/sqlstore/dashboard.go
View file @
73ee8a59
...
...
@@ -48,13 +48,19 @@ func SaveDashboard(cmd *m.SaveDashboardCommand) error {
}
}
affectedRows
:=
int64
(
0
)
if
dash
.
Id
==
0
{
metrics
.
M_Models_Dashboard_Insert
.
Inc
(
1
)
_
,
err
=
sess
.
Insert
(
dash
)
affectedRows
,
err
=
sess
.
Insert
(
dash
)
}
else
{
dash
.
Version
+=
1
dash
.
Data
[
"version"
]
=
dash
.
Version
_
,
err
=
sess
.
Id
(
dash
.
Id
)
.
Update
(
dash
)
affectedRows
,
err
=
sess
.
Id
(
dash
.
Id
)
.
Update
(
dash
)
}
if
affectedRows
==
0
{
return
m
.
ErrDashboardNotFound
}
// delete existing tabs
...
...
pkg/services/sqlstore/dashboard_test.go
View file @
73ee8a59
...
...
@@ -51,6 +51,21 @@ func TestDashboardDataAccess(t *testing.T) {
So
(
query
.
Result
.
Slug
,
ShouldEqual
,
"test-dash-23"
)
})
Convey
(
"Should return error if no dashboard is updated"
,
func
()
{
cmd
:=
m
.
SaveDashboardCommand
{
OrgId
:
1
,
Overwrite
:
true
,
Dashboard
:
map
[
string
]
interface
{}{
"id"
:
float64
(
123412321
),
"title"
:
"Expect error"
,
"tags"
:
[]
interface
{}{},
},
}
err
:=
SaveDashboard
(
&
cmd
)
So
(
err
,
ShouldNotBeNil
)
})
Convey
(
"Should be able to search for dashboard"
,
func
()
{
query
:=
m
.
SearchDashboardsQuery
{
Title
:
"test"
,
...
...
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