Skip to content

Commit

Permalink
Merge branch 'develop' of bitbucket.org:unicon/comanagework into develop
Browse files Browse the repository at this point in the history
  • Loading branch information
Axel Stohn authored and Axel Stohn committed Mar 13, 2022
2 parents 180a77f + 49096bf commit 8e23cff
Show file tree
Hide file tree
Showing 5 changed files with 169 additions and 47 deletions.
5 changes: 3 additions & 2 deletions Lib/GrouperApiAccess.php
Original file line number Diff line number Diff line change
Expand Up @@ -84,8 +84,9 @@ public function getGrouperMemberOfGroups(array $queryData) {

//Build request logic
$userId = $queryData['userId'];
$connectionUrl = "{$this->config['fullUrl']}/subjects/$userId/groups?";
$connectionUrl .= "wsLiteObjectType=WsRestGetGroupsLiteRequest&actAsSubjectSourceId=ldap&actAsSubjectId=$userId";
$connectionUrl = "{$this->config['fullUrl']}/subjects/$userId/groups";
// $connectionUrl = "{$this->config['fullUrl']}/subjects/$userId/groups?";
// $connectionUrl .= "wsLiteObjectType=WsRestGetGroupsLiteRequest&actAsSubjectSourceId=ldap&actAsSubjectId=$userId";

try {
$results = $this->http->sendRequest('GET', $connectionUrl);
Expand Down
5 changes: 5 additions & 0 deletions Lib/lang.php
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,11 @@
'pl.grouperlite.action.members' => 'Members',
'pl.grouperlite.action.close' => 'Close',
'pl.grouperlite.action.clear' => 'Clear',
'pl.grouperlite.action.add-user' => 'Add',
'pl.grouperlite.action.remove-user' => 'Remove',
'pl.grouperlite.message.user-not-found-error' => 'Error: User not found.',
'pl.grouperlite.message.user-not-added-error' => 'Error: Unable to add user.',
'pl.grouperlite.message.user-not-removed-error' => 'Error: Unable to remove user.',

'pl.grouperlite.form.group.template.label' => 'Select a template',
'pl.grouperlite.form.group.template.empty' => '(choose one)',
Expand Down
9 changes: 5 additions & 4 deletions View/CoGrouperLites/display.ctp
Original file line number Diff line number Diff line change
Expand Up @@ -39,15 +39,15 @@ echo $this->element('GrouperLite.base-styles');

<div class="container-fluid p-0 grouper">
<div class="row no-gutters">
<div class="col-12">
<div class="col-xl-6 col-lg-8 col-xs-12">
<div class="border rounded container ml-0 mr-auto">
<div class="row no-gutters py-2">
<div class="col-xs-12 col-lg-4">
<div class="col-xs-12 col-md-6">
<div class="p-4 h-100 d-flex flex-md-column justify-content-center flex-row align-items-center">
<?php print $this->Html->image('GrouperLite.grouper-logo.png', array('class' => 'logo-fluid')); ?>
</div>
</div>
<div class="col-xs-12 col-md-6 col-lg-4">
<div class="col-xs-12 col-md-6">
<h3 class="text-center mb-2 mt-2 h6"><i class="fa fa-users"></i>&nbsp; <?php echo _txt('pl.grouperlite.dashboard.heading.groups'); ?></h3>
<div class="px-4 d-flex flex-column justify-content-center align-items-center">
<a class="btn btn-primary btn-block text-nowrap" href="<?php print $this->Html->url(
Expand Down Expand Up @@ -87,6 +87,7 @@ echo $this->element('GrouperLite.base-styles');
</a>
</div>
</div>
<?php /*
<div class="col-xs-12 col-md-6 col-lg-4 border-left">
<h3 class="text-center mb-2 mt-2 h6"><i class="fa fa-envelope"></i>&nbsp; <?php echo _txt('pl.grouperlite.dashboard.heading.email-lists'); ?></h3>
<div class="px-4 d-flex flex-column justify-content-center align-items-center">
Expand Down Expand Up @@ -126,7 +127,7 @@ echo $this->element('GrouperLite.base-styles');
</a>
</div>
</div>
</div> */ ?>
</div>
</div>
</div>
Expand Down
2 changes: 2 additions & 0 deletions View/Elements/Components/navigation-groups.ctp
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@
</a>
</div>
<?php } ?>
<?php /*
<div class="align-self-center ml-auto">
<?php
$gotoEmailListsUrl = $this->Html->url(
Expand All @@ -81,4 +82,5 @@
<i class="fa fa-envelope"></i>&nbsp; <?php echo _txt('pl.grouperlite.nav.emaillists'); ?>
</a>
</div>
*/ ?>
</nav>
195 changes: 154 additions & 41 deletions View/Elements/Components/subscriberList.ctp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<div class="modal modal-members modal-primary fade" tabindex="-1" id="subscribers" aria-labelledby="modal-title">
<div class="modal-dialog modal-dialog-scrollable">
<div class="modal-dialog modal-dialog-scrollable modal-lg">
<div class="modal-content">
<div class="modal-header">
<h3 class="modal-title h5" id="modal-title"><?php echo _txt('pl.grouperlite.group.info.members-heading'); ?></h3>
Expand All @@ -16,57 +16,170 @@
<p>There was an error retrieving the subscribers.</p>
</div>
<div class="modal-body subs">
<form class="add-user-form" id="add-user-form">
<div class="d-flex mb-4">
<label class="sr-only" for="addUser"><?php echo _txt('pl.grouperlite.search.tags.text'); ?></label>
<div class="input-group">
<?php echo $this->Form->input("addUser", array('label' => false, 'class' => 'form-control', 'value' => isset($searchcriteria) ? $searchcriteria : '')) ?>
<!--<input type="text" name="search" class="form-control" value="<?php echo isset($searchcriteria) ? $searchcriteria : ''; ?>" /> -->
<div class="input-group-append">
<button class="btn btn-grouper btn-primary px-4" type="submit" value="Submit">
<i class="fa fa-plus"></i>
<span class="ml-2"><?php echo _txt('pl.grouperlite.action.add-user'); ?></span>
</button>
</div>
</div>
</div>
</form>
<table class="table table-striped">
<tbody id="sub-body"></tbody>
</table>
</div>
<div class="modal-footer">
<div class="modal-footer d-flex justify-content-between">
<div>
<p class="alert alert-danger error"></p>
</div>
<button type="button" class="btn btn-grouper btn-link" data-dismiss="modal"><?php echo _txt('pl.grouperlite.action.close'); ?></button>
</div>
</div>
</div>
</div>
<script>
var url = '<?php print $this->Html->url(
array(
'plugin' => "grouper_lite",
'controller' => 'grouper_groups',
'action' => 'groupSubscribers.json'
)
); ?>';
$('.members-btn').click(function(ev) {
var $this = $(this);
var id = $this.data('id');
var modal = $('#subscribers');
modal.addClass('loading');
modal.modal('toggle');
(function($) {
var load, modal;
var loadUrl = '<?php print $this->Html->url(
array(
'plugin' => "grouper_lite",
'controller' => 'grouper_groups',
'action' => 'groupSubscribers.json'
)
); ?>';

$.ajax({
url: url + '?groupname=' + id,
dataType: 'json',
success: function(data) {
$('#sub-body').html(data.reduce(function (table, item) {
var row = [
'<tr>',
'<td>',
item.name,
'</td>',
'<td>',
item.id,
'</td>',
'</tr>'
].join('');
var removeUrl = '<?php print $this->Html->url(
array(
'plugin' => "grouper_lite",
'controller' => 'grouper_groups',
'action' => 'removeSubscriber.json'
)
); ?>';

table += row;
return table;
}, ''))
},
error: function() {
modal.addClass('error');
},
complete: function() {
modal.removeClass('loading');
var removeUrl = '<?php print $this->Html->url(
array(
'plugin' => "grouper_lite",
'controller' => 'grouper_groups',
'action' => 'addSubscriber.json'
)
); ?>';
$('.members-btn').click(function(ev) {
var $this = $(this);
var group = $this.data('id');
modal = $('#subscribers');
modal.modal('toggle');

modal.find('#add-user-form').submit(function(ev) {
ev.preventDefault();
var field = $(ev.target).find('#addUser');
var user = field.val();
onAddUser(user, group, field);
});

load = loadModalData(group);
load();
});

function loadModalData(id) {
return function() {
modal.addClass('loading');
clean();
$.ajax({
method: 'GET',
url: loadUrl + '?groupname=' + id,
dataType: 'json',
success: function(data) {
createModalContent(data);
},
error: function() {
modal.addClass('error');
},
complete: function() {
modal.removeClass('loading');
}
});
}
})
});
}

function createModalContent(data) {
$('#sub-body').html(data.reduce(function(table, item) {
var row = [
'<tr>',
'<td>',
item.name,
'</td>',
'<td>',
item.id,
'</td>',
'<td>',
'<button data-user="' + item.id + '" class="btn btn-grouper btn-block btn-primary btn-sm m-1 text-nowrap member-del-btn">',
'<?php echo _txt('pl.grouperlite.action.remove-user'); ?>',
'</button>',
'</td>',
'</tr>'
].join('');

table += row;
return table;
}, ''));

$('.member-del-btn').on('click', onRemoveUser);
}

function clean() {
$('#subscribers .error').hide();
$('#add-user-form #addUser').val('');
$('.member-del-btn').off('click', onRemoveUser);
}

function onRemoveUser(ev) {
var user = $(ev.target).data('user');
$.ajax({
method: 'DELETE',
url: removeUrl + '?userId=' + user,
dataType: 'json',
success: function(data) {
load();
},
error: function() {
$(ev.target).attr('disabled', 'disabled');
var err = $('#subscribers .error');
err.text('<?php echo _txt('pl.grouperlite.message.user-not-removed-error'); ?>').show();
},
complete: function() {

}
});
}

function onAddUser(user, group, field) {
$.ajax({
method: 'POST',
url: removeUrl + '?group=' + group + '&userId=' + user,
dataType: 'json',
success: function(data) {
load();
},
error: function(ev) {
var msg = ev.status === 404 ?
'<?php echo _txt('pl.grouperlite.message.user-not-found-error'); ?>' :
'<?php echo _txt('pl.grouperlite.message.user-not-added-error'); ?>';

var err = $('#subscribers .error');
err.text(msg).show();
},
complete: function() {

}
});
}

})(jQuery);
</script>

0 comments on commit 8e23cff

Please sign in to comment.