userInviteCtrl.js 887 B

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. define([
  2. 'angular',
  3. 'lodash',
  4. ],
  5. function (angular, _) {
  6. 'use strict';
  7. var module = angular.module('grafana.controllers');
  8. module.controller('UserInviteCtrl', function($scope, backendSrv, $q) {
  9. $scope.invites = [
  10. {name: '', email: '', role: 'Editor'},
  11. ];
  12. $scope.init = function() {
  13. };
  14. $scope.addInvite = function() {
  15. $scope.invites.push({name: '', email: '', role: 'Editor'});
  16. };
  17. $scope.removeInvite = function(invite) {
  18. $scope.invites = _.without($scope.invites, invite);
  19. };
  20. $scope.sendInvites = function() {
  21. if (!$scope.inviteForm.$valid) { return; }
  22. var promises = _.map($scope.invites, function(invite) {
  23. return backendSrv.post('/api/org/invites', invite);
  24. });
  25. $q.all(promises).then(function() {
  26. $scope.invitesSent();
  27. });
  28. $scope.dismiss();
  29. };
  30. });
  31. });