diff --git a/CHANGELOG.md b/CHANGELOG.md
index f8f676f0b5b..04cf919df5c 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,3 +1,9 @@
+# 2.2 (unreleased)
+
+**New Features && Enhancements**
+- [Issue #2457](https://github.com/grafana/grafana/issues/2457). Admin: admin page for all grafana organizations (list / edit view)
+
+
# 2.1.1 (2015-08-11)
**Fixes**
diff --git a/pkg/api/api.go b/pkg/api/api.go
index 7ad4ae73b4c..2d010e2649a 100644
--- a/pkg/api/api.go
+++ b/pkg/api/api.go
@@ -37,6 +37,8 @@ func Register(r *macaron.Macaron) {
r.Get("/admin/users", reqGrafanaAdmin, Index)
r.Get("/admin/users/create", reqGrafanaAdmin, Index)
r.Get("/admin/users/edit/:id", reqGrafanaAdmin, Index)
+ r.Get("/admin/orgs", reqGrafanaAdmin, Index)
+ r.Get("/admin/orgs/edit/:id", reqGrafanaAdmin, Index)
r.Get("/dashboard/*", reqSignedIn, Index)
// sign up
@@ -109,6 +111,7 @@ func Register(r *macaron.Macaron) {
// orgs (admin routes)
r.Group("/orgs/:orgId", func() {
+ r.Get("/", wrap(GetOrgById))
r.Put("/", bind(m.UpdateOrgCommand{}), wrap(UpdateOrg))
r.Get("/users", wrap(GetOrgUsers))
r.Post("/users", bind(m.AddOrgUserCommand{}), wrap(AddOrgUser))
diff --git a/public/app/features/admin/adminEditOrgCtrl.js b/public/app/features/admin/adminEditOrgCtrl.js
new file mode 100644
index 00000000000..ec500704fb3
--- /dev/null
+++ b/public/app/features/admin/adminEditOrgCtrl.js
@@ -0,0 +1,52 @@
+define([
+ 'angular',
+],
+function (angular) {
+ 'use strict';
+
+ var module = angular.module('grafana.controllers');
+
+ module.controller('AdminEditOrgCtrl', function($scope, $routeParams, backendSrv, $location) {
+
+ $scope.init = function() {
+ if ($routeParams.id) {
+ $scope.getOrg($routeParams.id);
+ $scope.getOrgUsers($routeParams.id);
+ }
+ };
+
+ $scope.getOrg = function(id) {
+ backendSrv.get('/api/orgs/' + id).then(function(org) {
+ $scope.org = org;
+ });
+ };
+
+ $scope.getOrgUsers = function(id) {
+ backendSrv.get('/api/orgs/' + id + '/users').then(function(orgUsers) {
+ $scope.orgUsers = orgUsers;
+ });
+ };
+
+ $scope.update = function() {
+ if (!$scope.orgDetailsForm.$valid) { return; }
+
+ backendSrv.put('/api/orgs/' + $scope.org.id, $scope.org).then(function() {
+ $location.path('/admin/orgs');
+ });
+ };
+
+ $scope.updateOrgUser= function(orgUser) {
+ backendSrv.patch('/api/orgs/' + orgUser.orgId + '/users/' + orgUser.userId, orgUser);
+ };
+
+ $scope.removeOrgUser = function(orgUser) {
+ backendSrv.delete('/api/orgs/' + orgUser.orgId + '/users/' + orgUser.userId).then(function() {
+ $scope.getOrgUsers($scope.org.id);
+ });
+ };
+
+ $scope.init();
+
+ });
+
+});
diff --git a/public/app/features/admin/adminListOrgsCtrl.js b/public/app/features/admin/adminListOrgsCtrl.js
new file mode 100644
index 00000000000..380ce41faef
--- /dev/null
+++ b/public/app/features/admin/adminListOrgsCtrl.js
@@ -0,0 +1,38 @@
+define([
+ 'angular',
+],
+function (angular) {
+ 'use strict';
+
+ var module = angular.module('grafana.controllers');
+
+ module.controller('AdminListOrgsCtrl', function($scope, backendSrv) {
+
+ $scope.init = function() {
+ $scope.getOrgs();
+ };
+
+ $scope.getOrgs = function() {
+ backendSrv.get('/api/orgs').then(function(orgs) {
+ $scope.orgs = orgs;
+ });
+ };
+
+ $scope.deleteOrg = function(org) {
+ $scope.appEvent('confirm-modal', {
+ title: 'Do you want to delete organization ' + org.name + '?',
+ icon: 'fa-trash',
+ yesText: 'Delete',
+ onConfirm: function() {
+ backendSrv.delete('/api/orgs/' + org.id).then(function() {
+ $scope.getOrgs();
+ });
+ }
+ });
+ };
+
+ $scope.init();
+
+ });
+
+});
diff --git a/public/app/features/admin/adminUsersCtrl.js b/public/app/features/admin/adminListUsersCtrl.js
similarity index 90%
rename from public/app/features/admin/adminUsersCtrl.js
rename to public/app/features/admin/adminListUsersCtrl.js
index 737812c5474..c89deafaf0f 100644
--- a/public/app/features/admin/adminUsersCtrl.js
+++ b/public/app/features/admin/adminListUsersCtrl.js
@@ -6,7 +6,7 @@ function (angular) {
var module = angular.module('grafana.controllers');
- module.controller('AdminUsersCtrl', function($scope, backendSrv) {
+ module.controller('AdminListUsersCtrl', function($scope, backendSrv) {
$scope.init = function() {
$scope.getUsers();
diff --git a/public/app/features/admin/all.js b/public/app/features/admin/all.js
index 35f1f4f5db9..14bff249b0e 100644
--- a/public/app/features/admin/all.js
+++ b/public/app/features/admin/all.js
@@ -1,5 +1,7 @@
define([
- './adminUsersCtrl',
+ './adminListUsersCtrl',
+ './adminListOrgsCtrl',
+ './adminEditOrgCtrl',
'./adminEditUserCtrl',
'./adminSettingsCtrl',
], function () {});
diff --git a/public/app/features/admin/partials/edit_org.html b/public/app/features/admin/partials/edit_org.html
new file mode 100644
index 00000000000..aef042894ab
--- /dev/null
+++ b/public/app/features/admin/partials/edit_org.html
@@ -0,0 +1,60 @@
+
+
+
+
+
+
+
+ Organization Details
+
+
+
+
+
+ Organization Users
+
+
+
+
+
+
diff --git a/public/app/features/admin/partials/orgs.html b/public/app/features/admin/partials/orgs.html
index 1bb8996a825..fe87073eb6c 100644
--- a/public/app/features/admin/partials/orgs.html
+++ b/public/app/features/admin/partials/orgs.html
@@ -1,6 +1,6 @@
@@ -10,6 +10,26 @@
Organizations
- View not implemented yet...
+
+
diff --git a/public/app/routes/all.js b/public/app/routes/all.js
index 0adca374452..28fa833439a 100644
--- a/public/app/routes/all.js
+++ b/public/app/routes/all.js
@@ -80,7 +80,7 @@ define([
})
.when('/admin/users', {
templateUrl: 'app/features/admin/partials/users.html',
- controller : 'AdminUsersCtrl',
+ controller : 'AdminListUsersCtrl',
})
.when('/admin/users/create', {
templateUrl: 'app/features/admin/partials/new_user.html',
@@ -92,6 +92,11 @@ define([
})
.when('/admin/orgs', {
templateUrl: 'app/features/admin/partials/orgs.html',
+ controller : 'AdminListOrgsCtrl',
+ })
+ .when('/admin/orgs/edit/:id', {
+ templateUrl: 'app/features/admin/partials/edit_org.html',
+ controller : 'AdminEditOrgCtrl',
})
.when('/login', {
templateUrl: 'app/partials/login.html',