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
2380a269
Commit
2380a269
authored
Sep 17, 2014
by
Torkel Ödegaard
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
updated
parent
31fe471d
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
24 additions
and
7 deletions
+24
-7
grafana
+1
-1
pkg/api/api_dashboard.go
+4
-2
pkg/api/api_login.go
+11
-0
pkg/stores/rethinkdb.go
+6
-2
pkg/stores/store.go
+2
-2
No files found.
grafana
@
c00384ad
Subproject commit
477f66f56bdd7f310d439ac428cb646fbb9b1949
Subproject commit
c00384ad0644f9db7cdfa426c559d8fc3347a1d2
pkg/api/api_dashboard.go
View file @
2380a269
...
@@ -29,8 +29,9 @@ func (self *HttpServer) getDashboard(c *gin.Context) {
...
@@ -29,8 +29,9 @@ func (self *HttpServer) getDashboard(c *gin.Context) {
func
(
self
*
HttpServer
)
search
(
c
*
gin
.
Context
)
{
func
(
self
*
HttpServer
)
search
(
c
*
gin
.
Context
)
{
query
:=
c
.
Params
.
ByName
(
"q"
)
query
:=
c
.
Params
.
ByName
(
"q"
)
accountId
,
err
:=
c
.
Get
(
"accountId"
)
results
,
err
:=
self
.
store
.
Query
(
query
)
results
,
err
:=
self
.
store
.
Query
(
query
,
accountId
.
(
int
)
)
if
err
!=
nil
{
if
err
!=
nil
{
log
.
Error
(
"Store query error: %v"
,
err
)
log
.
Error
(
"Store query error: %v"
,
err
)
c
.
JSON
(
500
,
newErrorResponse
(
"Failed"
))
c
.
JSON
(
500
,
newErrorResponse
(
"Failed"
))
...
@@ -42,12 +43,13 @@ func (self *HttpServer) search(c *gin.Context) {
...
@@ -42,12 +43,13 @@ func (self *HttpServer) search(c *gin.Context) {
func
(
self
*
HttpServer
)
postDashboard
(
c
*
gin
.
Context
)
{
func
(
self
*
HttpServer
)
postDashboard
(
c
*
gin
.
Context
)
{
var
command
saveDashboardCommand
var
command
saveDashboardCommand
accountId
,
_
:=
c
.
Get
(
"accountId"
)
if
c
.
EnsureBody
(
&
command
)
{
if
c
.
EnsureBody
(
&
command
)
{
dashboard
:=
models
.
NewDashboard
(
"test"
)
dashboard
:=
models
.
NewDashboard
(
"test"
)
dashboard
.
Data
=
command
.
Dashboard
dashboard
.
Data
=
command
.
Dashboard
dashboard
.
Title
=
dashboard
.
Data
[
"title"
]
.
(
string
)
dashboard
.
Title
=
dashboard
.
Data
[
"title"
]
.
(
string
)
dashboard
.
AccountId
=
1
dashboard
.
AccountId
=
accountId
.
(
int
)
dashboard
.
UpdateSlug
()
dashboard
.
UpdateSlug
()
if
dashboard
.
Data
[
"id"
]
!=
nil
{
if
dashboard
.
Data
[
"id"
]
!=
nil
{
...
...
pkg/api/api_login.go
View file @
2380a269
...
@@ -51,6 +51,17 @@ func (self *HttpServer) logoutPost(c *gin.Context) {
...
@@ -51,6 +51,17 @@ func (self *HttpServer) logoutPost(c *gin.Context) {
c
.
JSON
(
200
,
gin
.
H
{
"status"
:
"logged out"
})
c
.
JSON
(
200
,
gin
.
H
{
"status"
:
"logged out"
})
}
}
type
GrafanaReqContext
struct
{
}
type
authenticatedAuthRouteFunc
func
(
c
*
gin
.
Context
,
grc
GrafanaReqContext
)
func
(
self
*
HttpServer
)
addAuthRoute
(
route
string
,
handler
authenticatedAuthRouteFunc
)
{
self
.
router
.
GET
(
route
,
self
.
auth
(),
func
(
c
*
gin
.
Context
)
{
})
}
func
(
self
*
HttpServer
)
auth
()
gin
.
HandlerFunc
{
func
(
self
*
HttpServer
)
auth
()
gin
.
HandlerFunc
{
return
func
(
c
*
gin
.
Context
)
{
return
func
(
c
*
gin
.
Context
)
{
session
,
_
:=
sessionStore
.
Get
(
c
.
Request
,
"grafana-session"
)
session
,
_
:=
sessionStore
.
Get
(
c
.
Request
,
"grafana-session"
)
...
...
pkg/stores/rethinkdb.go
View file @
2380a269
...
@@ -44,6 +44,10 @@ func NewRethinkStore(config *RethinkCfg) *rethinkStore {
...
@@ -44,6 +44,10 @@ func NewRethinkStore(config *RethinkCfg) *rethinkStore {
return
[]
interface
{}{
row
.
Field
(
"AccountId"
),
row
.
Field
(
"Slug"
)}
return
[]
interface
{}{
row
.
Field
(
"AccountId"
),
row
.
Field
(
"Slug"
)}
})
.
Exec
(
session
)
})
.
Exec
(
session
)
r
.
Db
(
config
.
DatabaseName
)
.
Table
(
"dashboards"
)
.
IndexCreateFunc
(
"AccountId"
,
func
(
row
r
.
Term
)
interface
{}
{
return
[]
interface
{}{
row
.
Field
(
"AccountId"
)}
})
.
Exec
(
session
)
r
.
Db
(
config
.
DatabaseName
)
.
Table
(
"accounts"
)
.
IndexCreateFunc
(
"AccountLogin"
,
func
(
row
r
.
Term
)
interface
{}
{
r
.
Db
(
config
.
DatabaseName
)
.
Table
(
"accounts"
)
.
IndexCreateFunc
(
"AccountLogin"
,
func
(
row
r
.
Term
)
interface
{}
{
return
[]
interface
{}{
row
.
Field
(
"Login"
)}
return
[]
interface
{}{
row
.
Field
(
"Login"
)}
})
.
Exec
(
session
)
})
.
Exec
(
session
)
...
@@ -88,9 +92,9 @@ func (self *rethinkStore) GetDashboard(slug string, accountId int) (*models.Dash
...
@@ -88,9 +92,9 @@ func (self *rethinkStore) GetDashboard(slug string, accountId int) (*models.Dash
return
&
dashboard
,
nil
return
&
dashboard
,
nil
}
}
func
(
self
*
rethinkStore
)
Query
(
query
string
)
([]
*
models
.
SearchResult
,
error
)
{
func
(
self
*
rethinkStore
)
Query
(
query
string
,
accountId
int
)
([]
*
models
.
SearchResult
,
error
)
{
docs
,
err
:=
r
.
Table
(
"dashboards"
)
.
GetAllByIndex
(
"AccountId"
,
[]
interface
{}{
accountId
})
.
Filter
(
r
.
Row
.
Field
(
"Title"
)
.
Match
(
".*"
))
.
Run
(
self
.
session
)
docs
,
err
:=
r
.
Table
(
"dashboards"
)
.
Filter
(
r
.
Row
.
Field
(
"Title"
)
.
Match
(
".*"
))
.
Run
(
self
.
session
)
if
err
!=
nil
{
if
err
!=
nil
{
return
nil
,
err
return
nil
,
err
}
}
...
...
pkg/stores/store.go
View file @
2380a269
...
@@ -5,9 +5,9 @@ import (
...
@@ -5,9 +5,9 @@ import (
)
)
type
Store
interface
{
type
Store
interface
{
GetDashboard
(
title
string
,
accountId
int
)
(
*
models
.
Dashboard
,
error
)
GetDashboard
(
slug
string
,
accountId
int
)
(
*
models
.
Dashboard
,
error
)
SaveDashboard
(
dash
*
models
.
Dashboard
)
error
SaveDashboard
(
dash
*
models
.
Dashboard
)
error
Query
(
query
string
)
([]
*
models
.
SearchResult
,
error
)
Query
(
query
string
,
acccountId
int
)
([]
*
models
.
SearchResult
,
error
)
SaveUserAccount
(
acccount
*
models
.
UserAccount
)
error
SaveUserAccount
(
acccount
*
models
.
UserAccount
)
error
GetUserAccountLogin
(
emailOrName
string
)
(
*
models
.
UserAccount
,
error
)
GetUserAccountLogin
(
emailOrName
string
)
(
*
models
.
UserAccount
,
error
)
Close
()
Close
()
...
...
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