orgUsersCtrl.js 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. define([
  2. 'angular',
  3. ],
  4. function (angular) {
  5. 'use strict';
  6. var module = angular.module('grafana.controllers');
  7. module.controller('OrgUsersCtrl', function($scope, $http, backendSrv) {
  8. $scope.user = {
  9. loginOrEmail: '',
  10. role: 'Viewer',
  11. };
  12. $scope.users = [];
  13. $scope.pendingInvites = [];
  14. $scope.init = function() {
  15. $scope.get();
  16. $scope.editor = { index: 0 };
  17. };
  18. $scope.get = function() {
  19. backendSrv.get('/api/org/users').then(function(users) {
  20. $scope.users = users;
  21. });
  22. backendSrv.get('/api/org/invites').then(function(pendingInvites) {
  23. $scope.pendingInvites = pendingInvites;
  24. });
  25. };
  26. $scope.updateOrgUser = function(user) {
  27. backendSrv.patch('/api/org/users/' + user.userId, user);
  28. };
  29. $scope.removeUser = function(user) {
  30. backendSrv.delete('/api/org/users/' + user.userId).then($scope.get);
  31. };
  32. $scope.revokeInvite = function(invite, evt) {
  33. evt.stopPropagation();
  34. backendSrv.patch('/api/org/invites/' + invite.code + '/revoke').then($scope.get);
  35. };
  36. $scope.copyInviteToClipboard = function(evt) {
  37. evt.stopPropagation();
  38. };
  39. $scope.openInviteModal = function() {
  40. var modalScope = $scope.$new();
  41. modalScope.invitesSent = function() {
  42. $scope.get();
  43. };
  44. $scope.appEvent('show-modal', {
  45. src: './app/features/org/partials/invite.html',
  46. modalClass: 'modal-no-header invite-modal',
  47. scope: modalScope
  48. });
  49. };
  50. $scope.init();
  51. });
  52. });