mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
added an inital admin settings view, very basic right now only displays all config options in grafana.ini
This commit is contained in:
28
pkg/api/admin_settings.go
Normal file
28
pkg/api/admin_settings.go
Normal file
@@ -0,0 +1,28 @@
|
||||
package api
|
||||
|
||||
import (
|
||||
"strings"
|
||||
|
||||
"github.com/grafana/grafana/pkg/middleware"
|
||||
"github.com/grafana/grafana/pkg/setting"
|
||||
)
|
||||
|
||||
func AdminGetSettings(c *middleware.Context) {
|
||||
settings := make(map[string]interface{})
|
||||
|
||||
for _, section := range setting.Cfg.Sections() {
|
||||
jsonSec := make(map[string]interface{})
|
||||
settings[section.Name()] = jsonSec
|
||||
|
||||
for _, key := range section.Keys() {
|
||||
keyName := key.Name()
|
||||
value := key.Value()
|
||||
if strings.Contains(keyName, "secret") || strings.Contains(keyName, "password") {
|
||||
value = "************"
|
||||
}
|
||||
jsonSec[keyName] = value
|
||||
}
|
||||
}
|
||||
|
||||
c.JSON(200, settings)
|
||||
}
|
||||
@@ -30,6 +30,7 @@ func Register(r *macaron.Macaron) {
|
||||
r.Get("/account/users/", reqSignedIn, Index)
|
||||
r.Get("/account/apikeys/", reqSignedIn, Index)
|
||||
r.Get("/account/import/", reqSignedIn, Index)
|
||||
r.Get("/admin/settings", reqGrafanaAdmin, Index)
|
||||
r.Get("/admin/users", reqGrafanaAdmin, Index)
|
||||
r.Get("/admin/users/create", reqGrafanaAdmin, Index)
|
||||
r.Get("/admin/users/edit/:id", reqGrafanaAdmin, Index)
|
||||
@@ -94,6 +95,7 @@ func Register(r *macaron.Macaron) {
|
||||
|
||||
// admin api
|
||||
r.Group("/api/admin", func() {
|
||||
r.Get("/settings", AdminGetSettings)
|
||||
r.Get("/users", AdminSearchUsers)
|
||||
r.Get("/users/:id", AdminGetUser)
|
||||
r.Post("/users", bind(dtos.AdminCreateUserForm{}), AdminCreateUser)
|
||||
|
||||
Reference in New Issue
Block a user