orgApiKeysCtrl.js 1008 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. define([
  2. 'angular',
  3. ],
  4. function (angular) {
  5. 'use strict';
  6. var module = angular.module('grafana.controllers');
  7. module.controller('OrgApiKeysCtrl', function($scope, $http, backendSrv) {
  8. $scope.roleTypes = ['Viewer', 'Editor', 'Admin'];
  9. $scope.token = { role: 'Viewer' };
  10. $scope.init = function() {
  11. $scope.getTokens();
  12. };
  13. $scope.getTokens = function() {
  14. backendSrv.get('/api/auth/keys').then(function(tokens) {
  15. $scope.tokens = tokens;
  16. });
  17. };
  18. $scope.removeToken = function(id) {
  19. backendSrv.delete('/api/auth/keys/'+id).then($scope.getTokens);
  20. };
  21. $scope.addToken = function() {
  22. backendSrv.post('/api/auth/keys', $scope.token).then(function(result) {
  23. var modalScope = $scope.$new(true);
  24. modalScope.key = result.key;
  25. $scope.appEvent('show-modal', {
  26. src: './app/features/org/partials/apikeyModal.html',
  27. scope: modalScope
  28. });
  29. });
  30. };
  31. $scope.init();
  32. });
  33. });