feat(invite): small progress

This commit is contained in:
Torkel Ödegaard
2015-07-17 14:42:49 +02:00
parent 0ffcce1b5d
commit 2724cf5db8
7 changed files with 36 additions and 12 deletions

View File

@@ -44,10 +44,15 @@ function (angular) {
};
$scope.openInviteModal = function() {
var modalScope = $scope.$new();
modalScope.invitesSent = function() {
$scope.get();
};
$scope.appEvent('show-modal', {
src: './app/features/org/partials/invite.html',
modalClass: 'modal-no-header invite-modal',
scope: $scope.$new()
scope: modalScope
});
};

View File

@@ -45,15 +45,15 @@
<th>Email</th>
<th>Name</th>
<th>Role</th>
<th>Created on</th>
<th>Invited by</th>
<th>Invited on</th>
<th>By</th>
<th></th>
</tr>
<tr ng-repeat="invite in pendingInvites">
<td>{{invite.email}}</td>
<td>{{invite.name}}</td>
<td>{{invite.role}}</td>
<td>{{invite.createdOn | date:'medium'}}</td>
<td>{{invite.createdOn | date:'shortDate'}}</td>
<td>{{invite.invitedBy}}</td>
<td style="width: 1%">
<a ng-click="removeInvite(invite)" class="btn btn-danger btn-mini">

View File

@@ -7,7 +7,7 @@ function (angular, _) {
var module = angular.module('grafana.controllers');
module.controller('UserInviteCtrl', function($scope, backendSrv) {
module.controller('UserInviteCtrl', function($scope, backendSrv, $q) {
$scope.invites = [
{name: '', email: '', role: 'Editor'},
@@ -27,8 +27,12 @@ function (angular, _) {
$scope.sendInvites = function() {
if (!$scope.inviteForm.$valid) { return; }
_.each($scope.invites, function(invite) {
backendSrv.post('/api/org/invites', invite);
var promises = _.map($scope.invites, function(invite) {
return backendSrv.post('/api/org/invites', invite);
});
$q.all(promises).then(function() {
$scope.invitesSent();
});
$scope.dismiss();