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
f3132b45
Commit
f3132b45
authored
Dec 28, 2014
by
Torkel Ödegaard
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Trying a different approach to providing frontend settings
parent
a55a606a
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
72 additions
and
3 deletions
+72
-3
grafana
+1
-1
pkg/api/api.go
+8
-1
pkg/api/api_frontendsettings.go
+61
-0
views/index.html
+2
-1
No files found.
grafana
@
cfabccc5
Subproject commit
dede578c7d569f87c35724f74a72216743bf9508
Subproject commit
cfabccc5f29579680dcd186307c431945900c7ce
pkg/api/api.go
View file @
f3132b45
...
...
@@ -54,7 +54,14 @@ func Register(m *macaron.Macaron) {
}
func
Index
(
ctx
*
middleware
.
Context
)
{
ctx
.
Data
[
"User"
]
=
dtos
.
NewCurrentUser
(
ctx
.
UserAccount
)
settings
,
err
:=
getFrontendSettings
(
ctx
.
GetAccountId
())
if
err
!=
nil
{
ctx
.
Handle
(
500
,
"Failed to get settings"
,
err
)
return
}
ctx
.
Data
[
"user"
]
=
dtos
.
NewCurrentUser
(
ctx
.
UserAccount
)
ctx
.
Data
[
"settings"
]
=
settings
ctx
.
HTML
(
200
,
"index"
)
}
...
...
pkg/api/api_frontendsettings.go
0 → 100644
View file @
f3132b45
package
api
import
(
"strconv"
"github.com/torkelo/grafana-pro/pkg/bus"
m
"github.com/torkelo/grafana-pro/pkg/models"
)
func
getFrontendSettings
(
accountId
int64
)
(
map
[
string
]
interface
{},
error
)
{
query
:=
m
.
GetDataSourcesQuery
{
AccountId
:
accountId
}
err
:=
bus
.
Dispatch
(
&
query
)
if
err
!=
nil
{
return
nil
,
err
}
datasources
:=
make
(
map
[
string
]
interface
{})
for
i
,
ds
:=
range
query
.
Result
{
url
:=
ds
.
Url
if
ds
.
Access
==
m
.
DS_ACCESS_PROXY
{
url
=
"/api/datasources/proxy/"
+
strconv
.
FormatInt
(
ds
.
Id
,
10
)
}
var
dsMap
=
map
[
string
]
interface
{}{
"type"
:
ds
.
Type
,
"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
// TODO: implement default ds account setting
if
i
==
0
{
dsMap
[
"default"
]
=
true
}
datasources
[
ds
.
Name
]
=
dsMap
}
// add grafana backend data source
datasources
[
"grafana"
]
=
map
[
string
]
interface
{}{
"type"
:
"grafana"
,
"url"
:
""
,
"grafanaDB"
:
true
,
}
jsonObj
:=
map
[
string
]
interface
{}{
"datasources"
:
datasources
,
}
return
jsonObj
,
nil
}
views/index.html
View file @
f3132b45
...
...
@@ -46,7 +46,8 @@
<script>
window
.
grafanaBootData
=
{
user
:[[.
User
]]
user
:[[.
user
]],
settings
:
[[.
settings
]]
};
</script>
</html>
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