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
e5811e29
Commit
e5811e29
authored
Dec 19, 2014
by
Torkel Ödegaard
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added username, site and password for influxdb datasources
parent
525b367a
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
25 additions
and
2 deletions
+25
-2
pkg/api/api_config.go
+10
-0
pkg/api/api_datasources.go
+1
-0
pkg/api/dtos/models.go
+1
-0
pkg/models/datasource.go
+3
-0
pkg/stores/sqlstore/sqlstore_datasource.go
+7
-1
pkg/stores/sqlstore/sqlstore_test.go
+3
-1
No files found.
pkg/api/api_config.go
View file @
e5811e29
...
@@ -28,14 +28,24 @@ func renderConfig(data *configJsTmplModel) string {
...
@@ -28,14 +28,24 @@ func renderConfig(data *configJsTmplModel) string {
for
i
,
ds
:=
range
data
.
DataSources
{
for
i
,
ds
:=
range
data
.
DataSources
{
url
:=
ds
.
Url
url
:=
ds
.
Url
if
ds
.
Access
==
m
.
DS_ACCESS_PROXY
{
if
ds
.
Access
==
m
.
DS_ACCESS_PROXY
{
url
=
"/api/datasources/proxy/"
+
strconv
.
FormatInt
(
ds
.
Id
,
10
)
url
=
"/api/datasources/proxy/"
+
strconv
.
FormatInt
(
ds
.
Id
,
10
)
}
}
var
dsMap
=
map
[
string
]
interface
{}{
var
dsMap
=
map
[
string
]
interface
{}{
"type"
:
ds
.
Type
,
"type"
:
ds
.
Type
,
"url"
:
url
,
"url"
:
url
,
}
}
if
ds
.
Type
==
m
.
DS_INFLUXDB
{
if
ds
.
Access
==
m
.
DS_ACCESS_DIRECT
{
dsMap
[
"username"
]
=
ds
.
User
dsMap
[
"password"
]
=
ds
.
Password
dsMap
[
"url"
]
=
url
+
"/db/"
+
ds
.
Database
}
}
// temp hack, first is always default
// temp hack, first is always default
// TODO: implement default ds account setting
// TODO: implement default ds account setting
if
i
==
0
{
if
i
==
0
{
...
...
pkg/api/api_datasources.go
View file @
e5811e29
...
@@ -26,6 +26,7 @@ func GetDataSources(c *middleware.Context) {
...
@@ -26,6 +26,7 @@ func GetDataSources(c *middleware.Context) {
Type
:
ds
.
Type
,
Type
:
ds
.
Type
,
Access
:
ds
.
Access
,
Access
:
ds
.
Access
,
Password
:
ds
.
Password
,
Password
:
ds
.
Password
,
Database
:
ds
.
Database
,
User
:
ds
.
User
,
User
:
ds
.
User
,
BasicAuth
:
ds
.
BasicAuth
,
BasicAuth
:
ds
.
BasicAuth
,
}
}
...
...
pkg/api/dtos/models.go
View file @
e5811e29
...
@@ -47,6 +47,7 @@ type DataSource struct {
...
@@ -47,6 +47,7 @@ type DataSource struct {
Url
string
`json:"url"`
Url
string
`json:"url"`
Password
string
`json:"password"`
Password
string
`json:"password"`
User
string
`json:"user"`
User
string
`json:"user"`
Database
string
`json:"database"`
BasicAuth
bool
`json:"basicAuth"`
BasicAuth
bool
`json:"basicAuth"`
}
}
...
...
pkg/models/datasource.go
View file @
e5811e29
...
@@ -31,6 +31,7 @@ type DataSource struct {
...
@@ -31,6 +31,7 @@ type DataSource struct {
Url
string
Url
string
Password
string
Password
string
User
string
User
string
Database
string
BasicAuth
bool
BasicAuth
bool
Created
time
.
Time
Created
time
.
Time
...
@@ -55,6 +56,7 @@ type AddDataSourceCommand struct {
...
@@ -55,6 +56,7 @@ type AddDataSourceCommand struct {
Access
DsAccess
Access
DsAccess
Url
string
Url
string
Password
string
Password
string
Database
string
User
string
User
string
}
}
...
@@ -67,6 +69,7 @@ type UpdateDataSourceCommand struct {
...
@@ -67,6 +69,7 @@ type UpdateDataSourceCommand struct {
Url
string
Url
string
Password
string
Password
string
User
string
User
string
Database
string
}
}
type
DeleteDataSourceCommand
struct
{
type
DeleteDataSourceCommand
struct
{
...
...
pkg/stores/sqlstore/sqlstore_datasource.go
View file @
e5811e29
...
@@ -28,7 +28,7 @@ func GetDataSourceById(query *m.GetDataSourceByIdQuery) error {
...
@@ -28,7 +28,7 @@ func GetDataSourceById(query *m.GetDataSourceByIdQuery) error {
}
}
func
GetDataSources
(
query
*
m
.
GetDataSourcesQuery
)
error
{
func
GetDataSources
(
query
*
m
.
GetDataSourcesQuery
)
error
{
sess
:=
x
.
Limit
(
100
,
0
)
.
Where
(
"account_id=?"
,
query
.
AccountId
)
sess
:=
x
.
Limit
(
100
,
0
)
.
Where
(
"account_id=?"
,
query
.
AccountId
)
.
Asc
(
"name"
)
query
.
Result
=
make
([]
*
m
.
DataSource
,
0
)
query
.
Result
=
make
([]
*
m
.
DataSource
,
0
)
return
sess
.
Find
(
&
query
.
Result
)
return
sess
.
Find
(
&
query
.
Result
)
...
@@ -53,6 +53,9 @@ func AddDataSource(cmd *m.AddDataSourceCommand) error {
...
@@ -53,6 +53,9 @@ func AddDataSource(cmd *m.AddDataSourceCommand) error {
Type
:
cmd
.
Type
,
Type
:
cmd
.
Type
,
Access
:
cmd
.
Access
,
Access
:
cmd
.
Access
,
Url
:
cmd
.
Url
,
Url
:
cmd
.
Url
,
User
:
cmd
.
User
,
Password
:
cmd
.
Password
,
Database
:
cmd
.
Database
,
Created
:
time
.
Now
(),
Created
:
time
.
Now
(),
Updated
:
time
.
Now
(),
Updated
:
time
.
Now
(),
}
}
...
@@ -75,6 +78,9 @@ func UpdateDataSource(cmd *m.UpdateDataSourceCommand) error {
...
@@ -75,6 +78,9 @@ func UpdateDataSource(cmd *m.UpdateDataSourceCommand) error {
Type
:
cmd
.
Type
,
Type
:
cmd
.
Type
,
Access
:
cmd
.
Access
,
Access
:
cmd
.
Access
,
Url
:
cmd
.
Url
,
Url
:
cmd
.
Url
,
User
:
cmd
.
User
,
Password
:
cmd
.
Password
,
Database
:
cmd
.
Database
,
Updated
:
time
.
Now
(),
Updated
:
time
.
Now
(),
}
}
...
...
pkg/stores/sqlstore/sqlstore_test.go
View file @
e5811e29
...
@@ -34,9 +34,10 @@ func TestDataAccess(t *testing.T) {
...
@@ -34,9 +34,10 @@ func TestDataAccess(t *testing.T) {
err
:=
AddDataSource
(
&
m
.
AddDataSourceCommand
{
err
:=
AddDataSource
(
&
m
.
AddDataSourceCommand
{
AccountId
:
10
,
AccountId
:
10
,
Type
:
m
.
DS_
GRAPHITE
,
Type
:
m
.
DS_
INFLUXDB
,
Access
:
m
.
DS_ACCESS_DIRECT
,
Access
:
m
.
DS_ACCESS_DIRECT
,
Url
:
"http://test"
,
Url
:
"http://test"
,
Database
:
"site"
,
})
})
So
(
err
,
ShouldBeNil
)
So
(
err
,
ShouldBeNil
)
...
@@ -50,6 +51,7 @@ func TestDataAccess(t *testing.T) {
...
@@ -50,6 +51,7 @@ func TestDataAccess(t *testing.T) {
ds
:=
query
.
Result
[
0
]
ds
:=
query
.
Result
[
0
]
So
(
ds
.
AccountId
,
ShouldEqual
,
10
)
So
(
ds
.
AccountId
,
ShouldEqual
,
10
)
So
(
ds
.
Database
,
ShouldEqual
,
"site"
)
})
})
Convey
(
"Given a datasource"
,
func
()
{
Convey
(
"Given a datasource"
,
func
()
{
...
...
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