diff --git a/src/app/features/account/accountCtrl.js b/src/app/features/account/accountCtrl.js deleted file mode 100644 index 069d0c29096..00000000000 --- a/src/app/features/account/accountCtrl.js +++ /dev/null @@ -1,48 +0,0 @@ -define([ - 'angular', -], -function (angular) { - 'use strict'; - - var module = angular.module('grafana.controllers'); - - module.controller('AccountCtrl', function($scope, $http, backendSrv) { - - $scope.collaborator = {}; - - $scope.init = function() { - $scope.getAccount(); - $scope.getOtherAccounts(); - - }; - - $scope.getAccount = function() { - backendSrv.get('/api/account/').then(function(account) { - $scope.account = account; - }); - }; - - $scope.getOtherAccounts = function() { - backendSrv.get('/api/account/others').then(function(otherAccounts) { - $scope.otherAccounts = otherAccounts; - }); - }; - - $scope.setUsingAccount = function(otherAccount) { - backendSrv.request({ - method: 'POST', - url: '/api/account/using/' + otherAccount.accountId, - desc: 'Change active account', - }).then($scope.getOtherAccounts); - }; - - $scope.update = function() { - if (!$scope.accountForm.$valid) { return; } - - backendSrv.post('/api/account/', $scope.account); - }; - - $scope.init(); - - }); -}); diff --git a/src/app/features/account/accountUsersCtrl.js b/src/app/features/account/accountUsersCtrl.js new file mode 100644 index 00000000000..f167625a26b --- /dev/null +++ b/src/app/features/account/accountUsersCtrl.js @@ -0,0 +1,48 @@ +define([ + 'angular', +], +function (angular) { + 'use strict'; + + var module = angular.module('grafana.controllers'); + + module.controller('AccountUsersCtrl', function($scope, $http, backendSrv) { + + $scope.user = { + loginOrEmail: '', + role: 'Viewer', + }; + + $scope.init = function() { + $scope.get(); + }; + + $scope.get = function() { + backendSrv.get('/api/account/users').then(function(users) { + $scope.users = users; + }); + }; + + $scope.removeUser = function(user) { + backendSrv.request({ + method: 'DELETE', + url: '/api/account/users/' + user.id, + }).then($scope.get); + }; + + $scope.addUser = function() { + if (!$scope.form.$valid) { + return; + } + + backendSrv.request({ + method: 'PUT', + url: '/api/account/users', + data: $scope.user, + }).then($scope.get); + }; + + $scope.init(); + + }); +}); diff --git a/src/app/features/account/collaboratorsCtrl.js b/src/app/features/account/collaboratorsCtrl.js deleted file mode 100644 index 88b9fab7782..00000000000 --- a/src/app/features/account/collaboratorsCtrl.js +++ /dev/null @@ -1,50 +0,0 @@ -define([ - 'angular', -], -function (angular) { - 'use strict'; - - var module = angular.module('grafana.controllers'); - - module.controller('CollaboratorsCtrl', function($scope, $http, backendSrv) { - - $scope.collaborator = { - loginOrEmail: '', - role: 'Viewer', - }; - - $scope.init = function() { - $scope.get(); - }; - - $scope.get = function() { - backendSrv.get('/api/account/collaborators').then(function(collaborators) { - $scope.collaborators = collaborators; - }); - }; - - $scope.removeCollaborator = function(collaborator) { - backendSrv.request({ - method: 'DELETE', - url: '/api/account/collaborators/' + collaborator.id, - desc: 'Remove collaborator', - }).then($scope.get); - }; - - $scope.addCollaborator = function() { - if (!$scope.form.$valid) { - return; - } - - backendSrv.request({ - method: 'PUT', - url: '/api/account/collaborators', - data: $scope.collaborator, - desc: 'Add collaborator' - }).then($scope.get); - }; - - $scope.init(); - - }); -}); diff --git a/src/app/features/account/partials/collaborators.html b/src/app/features/account/partials/users.html similarity index 62% rename from src/app/features/account/partials/collaborators.html rename to src/app/features/account/partials/users.html index 4d3f581c069..87662c13618 100644 --- a/src/app/features/account/partials/collaborators.html +++ b/src/app/features/account/partials/users.html @@ -1,11 +1,11 @@ -
+| {{collaborator.email}} | +|||||
| {{user.email}} | - {{collaborator.role}} + {{user.role}} | - + | diff --git a/src/app/features/admin/accountsCtrl.js b/src/app/features/admin/accountsCtrl.js deleted file mode 100644 index 9be27e719a5..00000000000 --- a/src/app/features/admin/accountsCtrl.js +++ /dev/null @@ -1,26 +0,0 @@ -define([ - 'angular', -], -function (angular) { - 'use strict'; - - var module = angular.module('grafana.controllers'); - - module.controller('AccountsCtrl', function($scope, backendSrv) { - - $scope.init = function() { - $scope.accounts = []; - $scope.getAccounts(); - }; - - $scope.getAccounts = function() { - backendSrv.get('/api/admin/accounts').then(function(accounts) { - console.log(accounts); - $scope.accounts = accounts; - }); - }; - - $scope.init(); - - }); -}); diff --git a/src/app/features/admin/adminUsersCtrl.js b/src/app/features/admin/adminUsersCtrl.js new file mode 100644 index 00000000000..d013465778f --- /dev/null +++ b/src/app/features/admin/adminUsersCtrl.js @@ -0,0 +1,25 @@ +define([ + 'angular', +], +function (angular) { + 'use strict'; + + var module = angular.module('grafana.controllers'); + + module.controller('AdminUsersCtrl', function($scope, backendSrv) { + + $scope.init = function() { + $scope.accounts = []; + $scope.getUsers(); + }; + + $scope.getUsers = function() { + backendSrv.get('/api/admin/users').then(function(users) { + $scope.users = users; + }); + }; + + $scope.init(); + + }); +}); diff --git a/src/app/features/admin/partials/accounts.html b/src/app/features/admin/partials/users.html similarity index 77% rename from src/app/features/admin/partials/accounts.html rename to src/app/features/admin/partials/users.html index d8dffe75044..0a2b48aa435 100644 --- a/src/app/features/admin/partials/accounts.html +++ b/src/app/features/admin/partials/users.html @@ -1,4 +1,4 @@ - +Admin | ||
|---|---|---|---|---|---|
| {{account.id}} | -{{account.login}} | -{{account.email}} | -{{account.name}} | -{{account.isAdmin}} | +|
| {{user.id}} | +{{user.login}} | +{{user.email}} | +{{user.name}} | +{{user.isAdmin}} |
diff --git a/src/app/features/all.js b/src/app/features/all.js
index f3833c65906..54946bb0fc2 100644
--- a/src/app/features/all.js
+++ b/src/app/features/all.js
@@ -7,11 +7,11 @@ define([
'./opentsdb/datasource',
'./elasticsearch/datasource',
'./dashboard/all',
- './account/accountCtrl',
- './account/collaboratorsCtrl',
+ './profile/profileCtrl',
+ './account/accountUsersCtrl',
'./account/datasourcesCtrl',
'./account/apiKeysCtrl',
'./account/importCtrl',
- './admin/accountsCtrl',
+ './admin/adminUsersCtrl',
'./grafanaDatasource/datasource',
], function () {});
diff --git a/src/app/features/account/partials/account.html b/src/app/features/profile/partials/profile.html
similarity index 70%
rename from src/app/features/account/partials/account.html
rename to src/app/features/profile/partials/profile.html
index f68fdaa3ad4..5d256513af0 100644
--- a/src/app/features/account/partials/account.html
+++ b/src/app/features/profile/partials/profile.html
@@ -1,4 +1,4 @@
-
+
@@ -7,13 +7,13 @@
- Account details
+ Your info
- |