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
8c2b6b53
Commit
8c2b6b53
authored
May 25, 2016
by
bergquist
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix(preferences): fixes broken default home dashboard
closes #5167
parent
71d62012
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
7 additions
and
9 deletions
+7
-9
pkg/api/api.go
+1
-1
pkg/api/dashboard.go
+6
-8
No files found.
pkg/api/api.go
View file @
8c2b6b53
...
...
@@ -209,7 +209,7 @@ func Register(r *macaron.Macaron) {
r
.
Combo
(
"/db/:slug"
)
.
Get
(
GetDashboard
)
.
Delete
(
DeleteDashboard
)
r
.
Post
(
"/db"
,
reqEditorRole
,
bind
(
m
.
SaveDashboardCommand
{}),
PostDashboard
)
r
.
Get
(
"/file/:file"
,
GetDashboardFromJsonFile
)
r
.
Get
(
"/home"
,
GetHomeDashboard
)
r
.
Get
(
"/home"
,
wrap
(
GetHomeDashboard
)
)
r
.
Get
(
"/tags"
,
GetDashboardTags
)
r
.
Post
(
"/import"
,
bind
(
dtos
.
ImportDashboardCommand
{}),
wrap
(
ImportDashboard
))
})
...
...
pkg/api/dashboard.go
View file @
8c2b6b53
...
...
@@ -159,10 +159,10 @@ func canEditDashboard(role m.RoleType) bool {
return
role
==
m
.
ROLE_ADMIN
||
role
==
m
.
ROLE_EDITOR
||
role
==
m
.
ROLE_READ_ONLY_EDITOR
}
func
GetHomeDashboard
(
c
*
middleware
.
Context
)
{
func
GetHomeDashboard
(
c
*
middleware
.
Context
)
Response
{
prefsQuery
:=
m
.
GetPreferencesWithDefaultsQuery
{
OrgId
:
c
.
OrgId
,
UserId
:
c
.
UserId
}
if
err
:=
bus
.
Dispatch
(
&
prefsQuery
);
err
!=
nil
{
c
.
JsonApiEr
r
(
500
,
"Failed to get preferences"
,
err
)
return
ApiErro
r
(
500
,
"Failed to get preferences"
,
err
)
}
if
prefsQuery
.
Result
.
HomeDashboardId
!=
0
{
...
...
@@ -170,7 +170,7 @@ func GetHomeDashboard(c *middleware.Context) {
err
:=
bus
.
Dispatch
(
&
slugQuery
)
if
err
==
nil
{
dashRedirect
:=
dtos
.
DashboardRedirect
{
RedirectUri
:
"db/"
+
slugQuery
.
Result
}
c
.
JSON
(
200
,
&
dashRedirect
)
return
Json
(
200
,
&
dashRedirect
)
}
else
{
log
.
Warn
(
"Failed to get slug from database, %s"
,
err
.
Error
())
}
...
...
@@ -179,8 +179,7 @@ func GetHomeDashboard(c *middleware.Context) {
filePath
:=
path
.
Join
(
setting
.
StaticRootPath
,
"dashboards/home.json"
)
file
,
err
:=
os
.
Open
(
filePath
)
if
err
!=
nil
{
c
.
JsonApiErr
(
500
,
"Failed to load home dashboard"
,
err
)
return
return
ApiError
(
500
,
"Failed to load home dashboard"
,
err
)
}
dash
:=
dtos
.
DashboardFullWithMeta
{}
...
...
@@ -188,11 +187,10 @@ func GetHomeDashboard(c *middleware.Context) {
dash
.
Meta
.
CanEdit
=
canEditDashboard
(
c
.
OrgRole
)
jsonParser
:=
json
.
NewDecoder
(
file
)
if
err
:=
jsonParser
.
Decode
(
&
dash
.
Dashboard
);
err
!=
nil
{
c
.
JsonApiErr
(
500
,
"Failed to load home dashboard"
,
err
)
return
return
ApiError
(
500
,
"Failed to load home dashboard"
,
err
)
}
c
.
JSON
(
200
,
&
dash
)
return
Json
(
200
,
&
dash
)
}
func
GetDashboardFromJsonFile
(
c
*
middleware
.
Context
)
{
...
...
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