diff --git a/src/app/features/account/accountCtrl.js b/src/app/features/account/accountCtrl.js index 06e332e07dd..918212cc547 100644 --- a/src/app/features/account/accountCtrl.js +++ b/src/app/features/account/accountCtrl.js @@ -18,7 +18,6 @@ function (angular) { $scope.getAccount = function() { backendSrv.get('/api/account/').then(function(account) { $scope.account = account; - $scope.collaborators = account.collaborators; }); }; @@ -36,25 +35,10 @@ function (angular) { }).then($scope.getOtherAccounts); }; - $scope.removeCollaborator = function(collaborator) { - backendSrv.request({ - method: 'DELETE', - url: '/api/account/collaborators/' + collaborator.id, - desc: 'Remove collaborator', - }).then($scope.getAccount); - }; + $scope.update = function() { + if (!$scope.accountForm.$valid) { return; } - $scope.addCollaborator = function() { - if (!$scope.addCollaboratorForm.$valid) { - return; - } - - backendSrv.request({ - method: 'PUT', - url: '/api/account/collaborators', - data: $scope.collaborator, - desc: 'Add collaborator' - }).then($scope.getAccount); + backendSrv.post('/api/account/', $scope.account); }; $scope.init(); diff --git a/src/app/features/account/collaboratorsCtrl.js b/src/app/features/account/collaboratorsCtrl.js new file mode 100644 index 00000000000..7bd0feaa5be --- /dev/null +++ b/src/app/features/account/collaboratorsCtrl.js @@ -0,0 +1,48 @@ +define([ + 'angular', +], +function (angular) { + 'use strict'; + + var module = angular.module('grafana.controllers'); + + module.controller('CollaboratorsCtrl', function($scope, $http, backendSrv) { + + $scope.collaborator = {}; + + $scope.init = function() { + $scope.get(); + }; + + $scope.get = function() { + backendSrv.get('/api/account/collaborators').then(function(collaborators) { + $scope.collaborators = collaborators; + console.log(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.addCollaboratorForm.$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/account.html b/src/app/features/account/partials/account.html index ff686736b55..a278505c5c5 100644 --- a/src/app/features/account/partials/account.html +++ b/src/app/features/account/partials/account.html @@ -8,38 +8,54 @@
- Personal information + Account details
-
-
- - -
-
-
-
- - -
-
+
-
-
- - +
+
+
    +
  • + Name +
  • +
  • + +
  • +
+
+
+
+
    +
  • + Email +
  • +
  • + +
  • +
+
+
+
+
    +
  • + Username +
  • +
  • + +
  • +
+
+
-
+
+ +
- - -
@@ -70,43 +86,4 @@
-
- -
-
- - Collaborators -
-
- -
- -
-
-
- - - -
-
-
- -
- - - - - - -
{{collaborator.email}} - {{collaborator.role}} - - - - -
-
- -
-
diff --git a/src/app/features/account/partials/collaborators.html b/src/app/features/account/partials/collaborators.html new file mode 100644 index 00000000000..5f44a2f1b8c --- /dev/null +++ b/src/app/features/account/partials/collaborators.html @@ -0,0 +1,42 @@ +
+ +
+ +
+
+ + Collaborators +
+
+ +
+ +
+
+
+ + + +
+
+
+ +
+ + + + + + +
{{collaborator.email}} + {{collaborator.role}} + + + + +
+
+ +
+
+ diff --git a/src/app/features/all.js b/src/app/features/all.js index 7d6366d51f2..056747fb584 100644 --- a/src/app/features/all.js +++ b/src/app/features/all.js @@ -8,6 +8,7 @@ define([ './elasticsearch/datasource', './dashboard/all', './account/accountCtrl', + './account/collaboratorsCtrl', './account/datasourcesCtrl', './admin/accountsCtrl', './grafanaDatasource/datasource', diff --git a/src/app/partials/sidemenu.html b/src/app/partials/sidemenu.html index eadc69af3a2..3553169c379 100644 --- a/src/app/partials/sidemenu.html +++ b/src/app/partials/sidemenu.html @@ -22,12 +22,15 @@ - Data sources + Data Account + + Collaborators + Admin diff --git a/src/app/routes/backend/all.js b/src/app/routes/backend/all.js index 1156308b3c8..423ab898911 100644 --- a/src/app/routes/backend/all.js +++ b/src/app/routes/backend/all.js @@ -34,6 +34,10 @@ define([ templateUrl: 'app/features/account/partials/datasources.html', controller : 'DataSourcesCtrl', }) + .when('/account/collaborators', { + templateUrl: 'app/features/account/partials/collaborators.html', + controller : 'CollaboratorsCtrl', + }) .when('/account', { templateUrl: 'app/features/account/partials/account.html', controller : 'AccountCtrl',