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
cb42cfc6
Commit
cb42cfc6
authored
Mar 17, 2016
by
utkarshcmu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Removed unwanted api, moved logic into backend
parent
4fbe954a
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
28 additions
and
27 deletions
+28
-27
pkg/api/api.go
+0
-1
pkg/api/dashboard.go
+22
-14
public/app/core/routes/dashboard_loaders.js
+6
-12
No files found.
pkg/api/api.go
View file @
cb42cfc6
...
@@ -200,7 +200,6 @@ func Register(r *macaron.Macaron) {
...
@@ -200,7 +200,6 @@ func Register(r *macaron.Macaron) {
r
.
Get
(
"/home"
,
GetHomeDashboard
)
r
.
Get
(
"/home"
,
GetHomeDashboard
)
r
.
Get
(
"/tags"
,
GetDashboardTags
)
r
.
Get
(
"/tags"
,
GetDashboardTags
)
r
.
Post
(
"/import"
,
bind
(
dtos
.
ImportDashboardCommand
{}),
wrap
(
ImportDashboard
))
r
.
Post
(
"/import"
,
bind
(
dtos
.
ImportDashboardCommand
{}),
wrap
(
ImportDashboard
))
r
.
Get
(
"/id/:id"
,
GetDashboardSlugById
)
})
})
// Dashboard snapshots
// Dashboard snapshots
...
...
pkg/api/dashboard.go
View file @
cb42cfc6
...
@@ -159,6 +159,28 @@ func canEditDashboard(role m.RoleType) bool {
...
@@ -159,6 +159,28 @@ func canEditDashboard(role m.RoleType) bool {
}
}
func
GetHomeDashboard
(
c
*
middleware
.
Context
)
{
func
GetHomeDashboard
(
c
*
middleware
.
Context
)
{
// Checking if there is any preference set for home dashboard
query
:=
m
.
GetPreferencesQuery
{
UserId
:
c
.
UserId
,
OrgId
:
c
.
OrgId
}
if
err
:=
bus
.
Dispatch
(
&
query
);
err
!=
nil
{
c
.
JsonApiErr
(
500
,
"Failed to get preferences"
,
err
)
}
if
query
.
Result
.
HomeDashboardId
!=
0
{
query
:=
m
.
GetDashboardSlugByIdQuery
{
Id
:
query
.
Result
.
HomeDashboardId
}
err
:=
bus
.
Dispatch
(
&
query
)
if
err
!=
nil
{
c
.
JsonApiErr
(
500
,
"Failed to get slug from database"
,
err
)
return
}
slug
:=
dtos
.
DashboardSlug
{
Slug
:
query
.
Result
}
c
.
JSON
(
200
,
&
slug
)
return
}
filePath
:=
path
.
Join
(
setting
.
StaticRootPath
,
"dashboards/home.json"
)
filePath
:=
path
.
Join
(
setting
.
StaticRootPath
,
"dashboards/home.json"
)
file
,
err
:=
os
.
Open
(
filePath
)
file
,
err
:=
os
.
Open
(
filePath
)
if
err
!=
nil
{
if
err
!=
nil
{
...
@@ -204,17 +226,3 @@ func GetDashboardTags(c *middleware.Context) {
...
@@ -204,17 +226,3 @@ func GetDashboardTags(c *middleware.Context) {
c
.
JSON
(
200
,
query
.
Result
)
c
.
JSON
(
200
,
query
.
Result
)
}
}
func
GetDashboardSlugById
(
c
*
middleware
.
Context
)
{
dashId
:=
c
.
ParamsInt64
(
":id"
)
query
:=
m
.
GetDashboardSlugByIdQuery
{
Id
:
dashId
}
err
:=
bus
.
Dispatch
(
&
query
)
if
err
!=
nil
{
c
.
JsonApiErr
(
500
,
"Failed to get slug from database"
,
err
)
return
}
slug
:=
dtos
.
DashboardSlug
{
Slug
:
query
.
Result
}
c
.
JSON
(
200
,
&
slug
)
}
public/app/core/routes/dashboard_loaders.js
View file @
cb42cfc6
...
@@ -7,25 +7,19 @@ function (coreModule) {
...
@@ -7,25 +7,19 @@ function (coreModule) {
coreModule
.
default
.
controller
(
'LoadDashboardCtrl'
,
function
(
$scope
,
$routeParams
,
dashboardLoaderSrv
,
backendSrv
)
{
coreModule
.
default
.
controller
(
'LoadDashboardCtrl'
,
function
(
$scope
,
$routeParams
,
dashboardLoaderSrv
,
backendSrv
)
{
if
(
!
$routeParams
.
slug
)
{
if
(
!
$routeParams
.
slug
)
{
backendSrv
.
get
(
'/api/preferences'
).
then
(
function
(
preferences
)
{
if
(
preferences
!==
null
&&
preferences
.
homeDashboardId
!==
0
)
{
backendSrv
.
get
(
'/api/dashboards/id/'
+
preferences
.
homeDashboardId
).
then
(
function
(
dashSlug
)
{
$routeParams
.
type
=
'db'
;
$routeParams
.
slug
=
dashSlug
.
slug
;
dashboardLoaderSrv
.
loadDashboard
(
$routeParams
.
type
,
$routeParams
.
slug
).
then
(
function
(
result
)
{
$scope
.
initDashboard
(
result
,
$scope
);
});
});
}
else
{
backendSrv
.
get
(
'/api/dashboards/home'
).
then
(
function
(
result
)
{
backendSrv
.
get
(
'/api/dashboards/home'
).
then
(
function
(
result
)
{
if
(
result
.
slug
==
null
)
{
var
meta
=
result
.
meta
;
var
meta
=
result
.
meta
;
meta
.
canSave
=
meta
.
canShare
=
meta
.
canStar
=
false
;
meta
.
canSave
=
meta
.
canShare
=
meta
.
canStar
=
false
;
$scope
.
initDashboard
(
result
,
$scope
);
$scope
.
initDashboard
(
result
,
$scope
);
}
else
{
$routeParams
.
type
=
'db'
;
$routeParams
.
slug
=
result
.
slug
;
dashboardLoaderSrv
.
loadDashboard
(
$routeParams
.
type
,
$routeParams
.
slug
).
then
(
function
(
result
)
{
$scope
.
initDashboard
(
result
,
$scope
);
});
});
}
}
});
});
return
;
return
;
}
}
...
...
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