UserInviteCtrl.ts 843 B

12345678910111213141516171819202122232425262728293031323334
  1. import coreModule from 'app/core/core_module';
  2. import { BackendSrv } from 'app/core/services/backend_srv';
  3. import { NavModelSrv } from 'app/core/core';
  4. import { ILocationService } from 'angular';
  5. export class UserInviteCtrl {
  6. navModel: any;
  7. invite: any;
  8. inviteForm: any;
  9. /** @ngInject */
  10. constructor(private backendSrv: BackendSrv, navModelSrv: NavModelSrv, private $location: ILocationService) {
  11. this.navModel = navModelSrv.getNav('cfg', 'users', 0);
  12. this.invite = {
  13. name: '',
  14. email: '',
  15. role: 'Editor',
  16. sendEmail: true,
  17. };
  18. }
  19. sendInvite() {
  20. if (!this.inviteForm.$valid) {
  21. return;
  22. }
  23. return this.backendSrv.post('/api/org/invites', this.invite).then(() => {
  24. this.$location.path('org/users/');
  25. });
  26. }
  27. }
  28. coreModule.controller('UserInviteCtrl', UserInviteCtrl);