diff --git a/src/app/features/account/accountCtrl.js b/src/app/features/account/accountCtrl.js index 918212cc547..07cc75058c4 100644 --- a/src/app/features/account/accountCtrl.js +++ b/src/app/features/account/accountCtrl.js @@ -9,10 +9,20 @@ function (angular) { module.controller('AccountCtrl', function($scope, $http, backendSrv) { $scope.collaborator = {}; + $scope.token = { + role: "ReadWrite" + }; + $scope.roleTypes = [ + "ReadWrite", + "Read" + ]; + $scope.showTokens = false; $scope.init = function() { $scope.getAccount(); $scope.getOtherAccounts(); + $scope.getTokens(); + }; $scope.getAccount = function() { @@ -35,6 +45,25 @@ function (angular) { }).then($scope.getOtherAccounts); }; + $scope.getTokens = function() { + backendSrv.get('/api/tokens').then(function(tokens) { + $scope.tokens = tokens; + }); + } + + $scope.removeToken = function(id) { + backendSrv.delete('/api/tokens/'+id).then($scope.getTokens); + } + + $scope.addToken = function() { + backendSrv.request({ + method: 'PUT', + url: '/api/tokens', + data: $scope.token, + desc: 'Add token' + }).then($scope.getTokens); + } + $scope.update = function() { if (!$scope.accountForm.$valid) { return; } diff --git a/src/app/features/account/partials/account.html b/src/app/features/account/partials/account.html index a69ddb7adb1..734c86bbe8c 100644 --- a/src/app/features/account/partials/account.html +++ b/src/app/features/account/partials/account.html @@ -81,6 +81,45 @@ +