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

Commit

Permalink
HAWKULAR-59 - Listing users in organization.
Browse files Browse the repository at this point in the history
  • Loading branch information
jpkrohling committed Sep 30, 2015
1 parent 186a395 commit 359f3f4
Show file tree
Hide file tree
Showing 9 changed files with 213 additions and 17 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<div class="modal-header">
<button type="button" class="close" dismiss="modal" aria-label="Close" ng-click="inviteModal.cancel()">
<span aria-hidden="true">&times;</span>
</button>
<h4 class="modal-title">Invite people</h4>
</div>

<div class="modal-body">
<form role="form" class="form-horizontal">
<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">
</div>
</div>
</form>
</div>

<div class="modal-footer">
<button type="button" class="btn btn-default" dismiss="modal" ng-click="inviteModal.cancel()"
id="inviteToOrganizationFormCancelBtn">
Cancel
</button>
<button type="button" class="btn btn-primary" id="inviteToOrganizationFormBtn" ng-click="inviteModal.invite()">
Invite
</button>
</div>
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
<div class="row">
<div class="col-md-12" ng-controller="HawkularAccounts.OrganizationMembershipController as controller">
<ol class="breadcrumb">
<li><a data-ng-href="/hawkular-ui/organizations">&laquo; All organizations</a></li>
</ol>

<h1 class="text-center">Organization {{controller.organization.name}}</h1>

<div class="pull-right" ng-show="controller.memberships.length && !controller.loading && controller.foundOrganization">
<button class="btn btn-primary" type="button" role="button" ng-click="controller.showInviteModal()">
Invite People
</button>
</div>
<h2>Members</h2>

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

<div ng-show="!controller.loading && controller.foundOrganization">
<div class="row text-center" ng-show="!controller.memberships.length">
<i class="fa fa-users" id="empty-organizations-icon"></i>
<h2>No members for this organization (not even you?). Found organization: {{controller.foundOrganization}}</h2>
<p>
With organizations, multiple users can have access<br/>
to the same resources, with multiple roles.
</p>
<button class="btn btn-primary" type="button" role="button" ng-click="controller.showInviteModal()">
Invite People
</button>
</div>

<div ng-show="controller.memberships.length">
<table class="table table-striped table-bordered">
<thead>
<tr>
<th>Name</th>
<th>Role</th>
</tr>
</thead>
<tbody>
<tr ng-repeat="membership in controller.memberships">
<td>{{membership.member.name}}</td>
<td>{{membership.role.name}}</td>
</tr>
</tbody>
</table>
</div>
</div>

<div class="row text-center" ng-show="!controller.loading && !controller.foundOrganization">
<i class="fa fa-users" id="organization-not-found-icon"></i>
<h2>Organization not found.</h2>
<p>
The requested organization could not be found.
</p>
</div>

</div>
<!-- /col -->
</div>
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,11 @@ <h2>You cannot create an organization.</h2>
</thead>
<tbody>
<tr ng-repeat="organization in organizations">
<td>{{organization.name}}</td>
<td>
<a href="/hawkular-ui/organization/{{organization.id}}/memberships">
{{organization.name}}
</a>
</td>
<td>
<button type="button" class="btn btn-default" aria-label="Remove" ng-click="remove(organization)">
<span class="pficon pficon-delete" aria-hidden="true"></span>
Expand All @@ -57,4 +61,3 @@ <h2>You cannot create an organization.</h2>
<!-- /col -->

</div>
</div>
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ body.inactivity-modal-open #main, body.inactivity-modal-open .navbar, body.inact
filter: blur(5px);
}

#empty-organizations-icon, #empty-organizations-icon-for-organizations {
#empty-organizations-icon, #empty-organizations-icon-for-organizations, #organization-not-found-icon {
color: @gray-light;
font-size: ceil(@font-size-base * 4);
}
12 changes: 12 additions & 0 deletions console/src/main/scripts/plugins/accounts/ts/accountsGlobals.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
/// limitations under the License.
///

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

module HawkularAccounts {
export let pluginName = 'hawkular-accounts';
export let log:Logging.Logger = Logger.get(pluginName);
Expand All @@ -28,4 +30,14 @@ module HawkularAccounts {
createdAt: string;
updatedAt: string;
}

export interface IOrganization extends IPersona{
}

export interface INotificationsService {
info(message: string): void;
success(message: string): void;
warning(message: string): void;
error(message: string): void;
}
}
15 changes: 13 additions & 2 deletions console/src/main/scripts/plugins/accounts/ts/accountsPlugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,19 @@
module HawkularAccounts {
let currentPersona:IPersona = undefined;

_module.config(['$httpProvider', ($httpProvider:ng.IHttpProvider) => {
$httpProvider.interceptors.push(PersonaInterceptorService.Factory);
_module.config(['$httpProvider', 'HawtioNavBuilderProvider', '$routeProvider',
($httpProvider:ng.IHttpProvider, builder:HawtioMainNav.BuilderFactory, $routeProvider) => {

$httpProvider.interceptors.push(PersonaInterceptorService.Factory);

$routeProvider
.when(
'/hawkular-ui/organizations',
{templateUrl: builder.join(HawkularAccounts.templatePath, 'organizations.html')})

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

_module.run(['$rootScope', '$log', '$modal', '$document', 'userDetails',
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
///
/// 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 OrganizationMembershipController {
public static $inject = ['$log', '$routeParams', '$modal', 'HawkularAccount', 'NotificationsService'];

public loading:boolean;
public foundOrganization:boolean;
public memberships:Array<IPersona>;
public organization:IOrganization;

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

$log.debug('Loading memberships for this organization');
this.loading = true;
this.foundOrganization = false;
this.organization = HawkularAccount.Organization.get({id: $routeParams.organizationId},
() => {
this.foundOrganization = true;
this.memberships = HawkularAccount.OrganizationMembership.query({organizationId:$routeParams.organizationId},
() => {
this.loading = false;
$log.debug(`Finished loading members. Size: ${this.memberships.length}`);
},
() => {
NotificationsService.info('List of organizations could NOT be retrieved.');
$log.warn('List of organizations could NOT be retrieved.');
this.loading = false;
}
);
},
() => {
NotificationsService.warning('Organization not found.');
$log.warn(`The requested organization doesn't exist: ${$routeParams.organizationId}`);
this.loading = false;
}
);
}

public showInviteModal():void {
let createFormModal = this.$modal.open({
controller: 'HawkularAccounts.OrganizationInviteModalController as inviteModal',
templateUrl: 'plugins/accounts/html/organization-invite.html'
});

}
}

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

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

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

public invite():void {
this.NotificationsService.warning('Invitation is not implemented yet. Stay tuned.');
this.$modalInstance.close();
}
}

_module.controller('HawkularAccounts.OrganizationMembershipController', OrganizationMembershipController);
_module.controller('HawkularAccounts.OrganizationInviteModalController', OrganizationInviteModalController);
}
11 changes: 0 additions & 11 deletions console/src/main/scripts/plugins/accounts/ts/organizations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,17 +17,6 @@

/// <reference path='accountsPlugin.ts'/>
module HawkularAccounts {
_module.config([
'$routeProvider', 'HawtioNavBuilderProvider',
($routeProvider, builder:HawtioMainNav.BuilderFactory) => {

$routeProvider
.when(
'/hawkular-ui/organizations',
{templateUrl: builder.join(HawkularAccounts.templatePath, 'organizations.html')}
);
}]);

export var OrganizationsController = _module.controller('HawkularAccounts.OrganizationsController', [
'$rootScope', '$scope', '$modal', '$log', '$location', 'HawkularAccount', 'NotificationsService',
($rootScope, $scope, $modal, $log, $location, HawkularAccount, NotificationsService) => {
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-03d94b6f3d75dafdf90d2f78a7dd577882f633b7</version.org.hawkular.accounts>
<version.org.hawkular.accounts>1.0.15.Final-SRC-revision-b74366df3210b32630e24601d7653b7275ca10ee</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 359f3f4

Please sign in to comment.