Skip to content
This repository has been archived by the owner on Nov 9, 2017. It is now read-only.

Commit

Permalink
HAWKULAR-59 - Added feature to invite users to organization.
Browse files Browse the repository at this point in the history
  • Loading branch information
jpkrohling committed Oct 2, 2015
1 parent 4a2557d commit 9bd5c49
Show file tree
Hide file tree
Showing 9 changed files with 142 additions and 8 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
<div class="row">
<div class="col-md-12" ng-controller="HawkularAccounts.InvitationController as controller">
<ol class="breadcrumb">
<li><a data-ng-href="/hawkular-ui/organizations">&laquo; All organizations</a></li>
</ol>

<h1 class="text-center" ng-show="controller.success">Invitation for {{controller.invitation.organization.name}}</h1>
<h1 class="text-center" ng-show="!controller.success">Invitation</h1>

<div class="progress-description" ng-show="controller.loading">
<div class="spinner spinner-xs spinner-inline"></div>
<strong>Loading:</strong> processing invitation
</div>

<div class="row text-center" ng-show="!controller.loading && controller.success">
<i class="fa fa-users" id="accepted-invitation-icon"></i>
<h2>Invitation accepted</h2>
<p>
You can now use Hawkular as {{controller.invitation.organization.name}}. To do that, just select
'{{controller.invitation.organization.name}}' from the account switcher, on the top-right corner of this screen.
</p>
</div>

<div class="row text-center" ng-show="!controller.loading && !controller.success">
<i class="fa fa-users" id="error-accepted-invitation-icon"></i>
<h2>Error</h2>
<p>
Something went wrong while processing your invitation.
</p>
</div>

</div>
<!-- /col -->
</div>
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,12 @@ <h4 class="modal-title">Invite people</h4>
<div class="form-group">
<label for="emails" class="col-md-4 control-label">Invite via email</label>
<div class="col-md-6">
<input type="text" class="form-control" id="emails" placeholder="Emails, separated by comma or space">
<input type="text"
class="form-control"
id="emails"
placeholder="Emails, separated by comma or space"
ng-model="inviteModal.invitation.emails"
/>
</div>
</div>
</form>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ <h4 class="modal-title">Create organization</h4>
<div class="form-group">
<label for="name" class="col-md-4 control-label">Organization name</label>
<div class="col-md-6">
<input type="text" class="form-control" id="name" placeholder="Name" ng-model="organizationNew.name">
<input type="text" class="form-control" id="name" placeholder="Name" ng-model="organizationNew.name"/>
</div>
</div>
</form>
Expand Down
6 changes: 5 additions & 1 deletion console/src/main/scripts/plugins/accounts/less/accounts.less
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,11 @@ body.inactivity-modal-open #main, body.inactivity-modal-open .navbar, body.inact
filter: blur(5px);
}

#empty-organizations-icon, #empty-organizations-icon-for-organizations, #organization-not-found-icon {
#empty-organizations-icon,
#empty-organizations-icon-for-organizations,
#accepted-invitation-icon,
#error-accepted-invitation-icon,
#organization-not-found-icon {
color: @gray-light;
font-size: ceil(@font-size-base * 4);
}
23 changes: 23 additions & 0 deletions console/src/main/scripts/plugins/accounts/ts/accountsGlobals.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,29 @@ module HawkularAccounts {
export interface IOrganization extends IPersona {
}

export interface IDataPayload {
message: string;
}

export interface IErrorPayload {
data: IDataPayload;
}

export interface ISuccessPayload {
data: IDataPayload;
}

export interface IInvitation {
id: string;
token: string;
organization: IOrganization;
}

export interface IInvitationRequest {
emails: string;
$save(success?:(success:ISuccessPayload) => void, failure?:(error:IErrorPayload) => void):void;
}

export interface INotificationsService {
info(message: string): void;
success(message: string): void;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,11 @@ module HawkularAccounts {

.when(
'/hawkular-ui/organization/:organizationId/memberships',
{templateUrl: builder.join(HawkularAccounts.templatePath, 'organization-memberships.html')});
{templateUrl: builder.join(HawkularAccounts.templatePath, 'organization-memberships.html')})

.when(
'/hawkular-ui/invitation/accept/:token',
{templateUrl: builder.join(HawkularAccounts.templatePath, 'organization-accept-invitation.html')});
}]);

_module.run(['$rootScope', '$log', '$modal', '$document', 'userDetails',
Expand Down
55 changes: 55 additions & 0 deletions console/src/main/scripts/plugins/accounts/ts/invitation.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
///
/// Copyright 2015 Red Hat, Inc. and/or its affiliates
/// and other contributors as indicated by the @author tags.
///
/// Licensed under the Apache License, Version 2.0 (the "License");
/// you may not use this file except in compliance with the License.
/// You may obtain a copy of the License at
///
/// http://www.apache.org/licenses/LICENSE-2.0
///
/// Unless required by applicable law or agreed to in writing, software
/// distributed under the License is distributed on an "AS IS" BASIS,
/// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
/// See the License for the specific language governing permissions and
/// limitations under the License.
///

/// <reference path='accountsPlugin.ts'/>

module HawkularAccounts {

export class InvitationController {
public static $inject = ['$log', '$routeParams', 'HawkularAccount', 'NotificationsService'];
public invitation:IInvitation;
public loading:boolean;
public success:boolean;

constructor(private $log:ng.ILogService,
private $routeParams:any,
private HawkularAccount:any,
private NotificationsService:INotificationsService) {

this.loading = true;
this.success = false;
HawkularAccount.OrganizationInvitation.update({token: $routeParams.token},
(response:IInvitation) => {
this.invitation = response;
this.$log.debug('Invitation object available:');
this.$log.debug(this.invitation);
this.success = true;
this.loading = false;
},
(error:IErrorPayload) => {
this.success = false;
this.loading = false;
this.NotificationsService.warning(`An error occurred while processing the invitation: ${error.data.message}`);
this.$log.debug(`Error while trying to process the invitation: ${error.data.message}`);
}
);
}
}

_module.controller('HawkularAccounts.InvitationController', InvitationController);
}

Original file line number Diff line number Diff line change
Expand Up @@ -69,21 +69,30 @@ module HawkularAccounts {
}

export class OrganizationInviteModalController {
public static $inject = ['$log', '$modalInstance', 'HawkularAccount', 'NotificationsService'];
public static $inject = ['$log', '$routeParams', '$modalInstance', 'HawkularAccount', 'NotificationsService'];
public invitation:IInvitationRequest;

constructor(private $log:ng.ILogService,
private $routeParams:any,
private $modalInstance:any,
private HawkularAccount:any,
private NotificationsService:INotificationsService) {
this.invitation = new HawkularAccount.OrganizationInvitation({organizationId: $routeParams.organizationId});
}

public cancel():void {
this.$modalInstance.dismiss('cancel');
}

public invite():void {
this.NotificationsService.warning('Invitation is not implemented yet. Stay tuned.');
this.$modalInstance.close();
this.invitation.$save(() => {
this.NotificationsService.info('Your invitation was submitted.');
this.$modalInstance.close('success');
}, (error:IErrorPayload) => {
this.NotificationsService.warning('An error occurred while trying to send the invitations.');
this.$log.debug(`Error while trying to send invitations: ${error.data.message}`);
this.$modalInstance.close('error');
});
}
}

Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@
<version.com.google.guava>16.0.1</version.com.google.guava>
<version.commons.io>2.4</version.commons.io>
<version.gnu.getopt>1.0.13</version.gnu.getopt>
<version.org.hawkular.accounts>1.0.15.Final-SRC-revision-b74366df3210b32630e24601d7653b7275ca10ee</version.org.hawkular.accounts>
<version.org.hawkular.accounts>1.0.16.Final-SRC-revision-e7c1c0c6d5e44796dcae6f68ee8c1a9a48d9be45</version.org.hawkular.accounts>
<version.org.hawkular.agent>0.9.0.Final</version.org.hawkular.agent>
<version.org.hawkular.alerts>0.4.1.Final</version.org.hawkular.alerts>
<version.org.hawkular.bus>0.6.1.Final</version.org.hawkular.bus>
Expand Down

0 comments on commit 9bd5c49

Please sign in to comment.