grafana/public/app/features/org/UserInviteCtrl.ts

35 lines
843 B
TypeScript
Raw Normal View History

import coreModule from 'app/core/core_module';
import { BackendSrv } from 'app/core/services/backend_srv';
import { NavModelSrv } from 'app/core/core';
import { ILocationService } from 'angular';
export class UserInviteCtrl {
2017-12-13 06:16:44 -06:00
navModel: any;
invite: any;
inviteForm: any;
/** @ngInject */
constructor(private backendSrv: BackendSrv, navModelSrv: NavModelSrv, private $location: ILocationService) {
2017-12-13 06:16:44 -06:00
this.navModel = navModelSrv.getNav('cfg', 'users', 0);
this.invite = {
name: '',
email: '',
role: 'Editor',
sendEmail: true,
};
2017-12-13 06:16:44 -06:00
}
2017-12-13 06:16:44 -06:00
sendInvite() {
if (!this.inviteForm.$valid) {
return;
}
2017-12-13 06:16:44 -06:00
return this.backendSrv.post('/api/org/invites', this.invite).then(() => {
this.$location.path('org/users/');
});
}
}
coreModule.controller('UserInviteCtrl', UserInviteCtrl);