Commit e65a6cc0 by Torkel Ödegaard

added an inital admin settings view, very basic right now only displays all…

added an inital admin settings view, very basic right now only displays all config options in grafana.ini
parent 29607d89
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)
......
......@@ -40,11 +40,6 @@ function (angular, _, $, config) {
text: "Admin", href: $scope.getUrl("/admin/users"),
icon: "fa fa-cube",
requireSignedIn: true,
links: [
{ text: 'Settings', href: $scope.getUrl("/admin/settings")},
{ text: 'Users', href: $scope.getUrl("/admin/users"), icon: "fa fa-lock" },
{ text: 'Log', href: "", icon: "fa fa-lock" },
]
});
}
......
define([
'./accountUsersCtrl',
'./datasourcesCtrl',
'./apiKeysCtrl',
'./importCtrl',
'./accountCtrl',
], function () {});
......@@ -6,10 +6,17 @@ function (angular) {
var module = angular.module('grafana.controllers');
module.controller('AdminCtrl', function($scope) {
module.controller('AdminSettingsCtrl', function($scope, backendSrv) {
$scope.init = function() {
$scope.editor = {index: 0};
$scope.accounts = [];
$scope.getUsers();
};
$scope.getUsers = function() {
backendSrv.get('/api/admin/settings').then(function(settings) {
$scope.settings = settings;
});
};
$scope.init();
......
define([
'./adminUsersCtrl',
'./adminEditUserCtrl',
'./adminSettingsCtrl',
], function () {});
<topnav icon="fa fa-cube" title="Admin" subnav="true">
<ul class="nav">
<li class="active"><a href="admin">Settings</a></li>
<li><a href="admin/users">Users</a></li>
</ul>
</topnav>
<div class="gf-box" style="min-height: 500px">
</div>
<topnav icon="fa fa-cube" title="Admin" subnav="true">
<ul class="nav">
<li><a href="admin">Settings</a></li>
<li><a href="admin/settings">Settings</a></li>
<li><a href="admin/users">Users</a></li>
<li ng-class="{active: createMode}"><a href="admin/users/create">Create user</a></li>
<li class="active" ng-show="!createMode"><a href="admin/users/edit/{{user_id}}">Edit user</a></li>
......
<topnav icon="fa fa-cube" title="Admin" subnav="true">
<ul class="nav">
<li class="active"><a href="admin/settings">Settings</a></li>
<li><a href="admin/users">Users</a></li>
<li><a href="admin/users/create">Create user</a></li>
</ul>
</topnav>
<div class="page-container">
<div class="page">
<h2>
System settings
</h2>
<div class="grafana-info-box span8" style="margin: 20px 0 25px 0">
These system settings are defined in grafana.ini or grafana.custom.ini (or overriden in ENV variables).
To change these you currently need to restart grafana.
</div>
<table class="grafana-options-table">
<tr ng-repeat-start="(secName, secValue) in settings">
<td class="admin-settings-section">{{secName}}</td>
<td></td>
</tr>
<tr ng-repeat="(keyName, keyValue) in secValue" ng-repeat-end>
<td style="padding-left: 25px;">{{keyName}}</td>
<td>{{keyValue}}</td>
</tr>
</table>
</div>
</div>
<topnav icon="fa fa-cube" title="Admin" subnav="true">
<ul class="nav">
<li><a href="admin">Settings</a></li>
<li><a href="admin/settings">Settings</a></li>
<li class="active"><a href="admin/users">Users</a></li>
<li><a href="admin/users/create">Create user</a></li>
</ul>
......
......@@ -9,13 +9,7 @@ define([
'./dashboard/all',
'./panel/all',
'./profile/profileCtrl',
'./account/accountUsersCtrl',
'./account/datasourcesCtrl',
'./account/apiKeysCtrl',
'./account/importCtrl',
'./account/accountCtrl',
'./admin/adminUsersCtrl',
'./admin/adminCtrl',
'./admin/adminEditUserCtrl',
'./account/all',
'./admin/all',
'./grafanaDatasource/datasource',
], function () {});
......@@ -54,9 +54,9 @@ define([
templateUrl: 'app/features/profile/partials/profile.html',
controller : 'ProfileCtrl',
})
.when('/admin', {
templateUrl: 'app/features/admin/partials/admin.html',
controller : 'AdminCtrl',
.when('/admin/settings', {
templateUrl: 'app/features/admin/partials/settings.html',
controller : 'AdminSettingsCtrl',
})
.when('/admin/users', {
templateUrl: 'app/features/admin/partials/users.html',
......
.admin-settings-section {
color: @variable;
font-weight: bold;
}
td.admin-settings-key {
padding-left: 20px;
}
......@@ -12,6 +12,7 @@
@import "navbar.less";
@import "gfbox.less";
@import "dashlist.less";
@import "admin.less";
.row-control-inner {
padding:0px;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment