now revoked or assigned roles arrive to the server, still to be managed

This commit is contained in:
Massimiliano Assante 2021-05-12 19:11:24 +02:00
parent 51620bc664
commit 5cb7bbb3a1
3 changed files with 877 additions and 836 deletions

View File

@ -74,6 +74,7 @@ public class UsersManagementPortletHome extends GenericPortlet {
private static final int DELETE_SITE_TEAMS_TABLE = 0; private static final int DELETE_SITE_TEAMS_TABLE = 0;
private static final int MASS_EDIT_USERS = 0; private static final int MASS_EDIT_USERS = 0;
private static final int ASSIGN_ROLES_TO_USERS = 1; private static final int ASSIGN_ROLES_TO_USERS = 1;
private static final int REMOVE_ROLES_TO_USERS = 3;
private static final int ASSIGN_TEAMS_TO_USERS = 2; private static final int ASSIGN_TEAMS_TO_USERS = 2;
public void init() { public void init() {
@ -557,7 +558,15 @@ public class UsersManagementPortletHome extends GenericPortlet {
HttpServletRequest httpServletRequest = PortalUtil.getHttpServletRequest(request); HttpServletRequest httpServletRequest = PortalUtil.getHttpServletRequest(request);
_log.debug("Editing users for the group: " + groupName); _log.debug("*** \n\n Editing users for the context: " + groupName);
System.out.println("\n\n****");
System.out.println("long[] usersIDs="+usersIDs.toString());
System.out.println("String[] theRoles="+theRoles.toString());
System.out.println("deletePreviousRoles?="+deletePreviousRoles);
System.out.println("selfId="+selfId);
System.out.println("int typeOfChangesUpponUserMode is="+typeOfChangesUpponUserMode);
System.out.println("usersIDs.length="+usersIDs.length);
if(usersIDs.length == 1) {//You can delete previous roles of a single user only. if(usersIDs.length == 1) {//You can delete previous roles of a single user only.
GCubeUser gcu = lum.getUserById(usersIDs[0]); GCubeUser gcu = lum.getUserById(usersIDs[0]);
@ -572,20 +581,12 @@ public class UsersManagementPortletHome extends GenericPortlet {
newRoleIDs[i] = gCubeRoles[i].getRoleId(); newRoleIDs[i] = gCubeRoles[i].getRoleId();
} }
if(deletePreviousRoles && typeOfChangesUpponUserMode == MASS_EDIT_USERS){ if(typeOfChangesUpponUserMode == REMOVE_ROLES_TO_USERS){
_log.debug("MASS_EDIT_USERS"); System.out.println("\n\n\n ****** REMOVE_ROLES_TO_USERS");
try{
lrm.removeAllRolesFromUser(gcu.getUserId(), groupId);
}catch(Exception e){
e.printStackTrace();
}
// List<GCubeTeam> teams = lrm.listTeamsByGroup(groupId); }
// if(teams.size() > 0 ){ else if(typeOfChangesUpponUserMode == ASSIGN_ROLES_TO_USERS){
// lrm.deleteUserTeams(gcu.getUserId(), teams); _log.info("\n\n\n ****** ASSIGN_ROLES_TO_USERS");
// }
} else if(deletePreviousRoles && typeOfChangesUpponUserMode == ASSIGN_ROLES_TO_USERS){
_log.debug("ASSIGN_ROLES_TO_USERS");
try{ try{
lrm.removeAllRolesFromUser(gcu.getUserId(), groupId); lrm.removeAllRolesFromUser(gcu.getUserId(), groupId);
}catch(Exception e){ }catch(Exception e){
@ -706,7 +707,10 @@ public class UsersManagementPortletHome extends GenericPortlet {
} }
_log.debug("User: " + currentUser.getUsername() + " is editing the roles of user: "+ gcu.getUsername() + " for the site: " + groupName + "and deletes all previous site-roles"); _log.debug("User: " + currentUser.getUsername() + " is editing the roles of user: "+ gcu.getUsername() + " for the site: " + groupName + "and deletes all previous site-roles");
}else{
} //END EDIT ROLES
else {
List<GCubeTeam> existingGCubeTeams = lrm.listTeamsByGroup(groupId); List<GCubeTeam> existingGCubeTeams = lrm.listTeamsByGroup(groupId);

View File

@ -191,8 +191,8 @@ function tableEvents() {
// $('#userNamesList').parent().find('div.text-tag').addClass('span4'); // $('#userNamesList').parent().find('div.text-tag').addClass('span4');
$('#userNamesListInAssignRolesModal').parent().find('div.text-button').addClass( $('#userNamesListInAssignRolesModal').parent().find('div.text-button').addClass(
'span12'); 'span12');
$('#userNamesListInAssignRolesModal').parent().find('a.text-remove').html('<i class="fa fa-times"></i>') // $('#userNamesListInAssignRolesModal').parent().find('a.text-remove').html('<i class="fa fa-times"></i>')
.removeClass('text-remove').addClass('tag-remove'); // .removeClass('text-remove').addClass('tag-remove');
}); });
$('#userNamesListInRemoveRolesModal').parent().find('div.text-tags').unbind().bind( $('#userNamesListInRemoveRolesModal').parent().find('div.text-tags').unbind().bind(
@ -205,8 +205,8 @@ function tableEvents() {
// $('#userNamesList').parent().find('div.text-tag').addClass('span4'); // $('#userNamesList').parent().find('div.text-tag').addClass('span4');
$('#userNamesListInRemoveRolesModal').parent().find('div.text-button').addClass( $('#userNamesListInRemoveRolesModal').parent().find('div.text-button').addClass(
'span12'); 'span12');
$('#userNamesListInRemoveRolesModal').parent().find('a.text-remove').html('<i class="fa fa-times"></i>') // $('#userNamesListInRemoveRolesModal').parent().find('a.text-remove').html('<i class="fa fa-times"></i>')
.removeClass('text-remove').addClass('tag-remove'); // .removeClass('text-remove').addClass('tag-remove');
}); });
$('#userNamesList').parent().find('div.text-tags').unbind().bind( $('#userNamesList').parent().find('div.text-tags').unbind().bind(
@ -317,8 +317,8 @@ function tableEvents() {
// $('#roleList').parent().find('div.text-tag').addClass('span5'); // $('#roleList').parent().find('div.text-tag').addClass('span5');
$('#roleListInAssignRolesModal').parent().find('div.text-button').addClass( $('#roleListInAssignRolesModal').parent().find('div.text-button').addClass(
'span12'); 'span12');
$('#roleListInAssignRolesModal').parent().find('a.text-remove').html('<i class="fa fa-times"></i>') // $('#roleListInAssignRolesModal').parent().find('a.text-remove').html('<i class="fa fa-times"></i>')
.removeClass('text-remove').addClass('tag-remove'); // .removeClass('text-remove').addClass('tag-remove');
$('textarea#roleListInAssignRolesModal').parent().find('a.tag-remove').off().on( $('textarea#roleListInAssignRolesModal').parent().find('a.tag-remove').off().on(
'click', function() { 'click', function() {
$(this).closest('.text-tag').remove(); $(this).closest('.text-tag').remove();
@ -1170,6 +1170,44 @@ function tableEvents() {
} }
); );
$('button#saveUsersRolesModalInRemoveRolesModal').off().on(
'click',
function() {
var groupId = theGroupId;
var trueFalse = true;
var mode = acceptMode;
var deleteUsers = false;
var ajaxData = [];
for (var i = 0; i < $($('#userNamesListInRemoveRolesModal').parent().find(
'.text-tag')).length; i++) {
ajaxData.push($(
$('#userNamesListInRemoveRolesModal').parent().find('.text-tag')[i])
.data('userUUID'));
}
var roles = [];
$('#roleListInRemoveRolesModal').parent().find('div.text-tag span.text-label')
.each(function() {
roles.push($(this).text());
});
var teams = [];
var deletePreviousRoles2 = true;//If you remove a role, the roles should be updated even though the checkbox might be unchecked
fetchAllCurrentUsers(mode, deleteUsers, ajaxData, roles, teams, deletePreviousRoles2, [], false, REMOVE_ROLES_TO_USERS);
$('table#CurrentUsersTable tr.selected').removeClass('selected');
$('#assignUsersRolesModal').modal('hide');
$('#removeUsersRolesModal').modal('hide');
// $('div#toolbar').addClass('hiddenToolbar').removeClass('shownToolbar');
$('span#numOfSelLectedRows').text('');
$('#CurrentUsersTable th:first').removeClass('none');
// $('div#toolbar').addClass('hiddenToolbar').removeClass('shownToolbar');
$('div#toolbar').removeClass('openToolbar');
$('div#toolbar').animate({ height: 'hide' });
$('#CurrentUsersTable th:first').removeClass('none');
}
);
$('button#saveUsersTeamsInAssignUsersToGroupsModal').off().on( $('button#saveUsersTeamsInAssignUsersToGroupsModal').off().on(
'click', 'click',
function() { function() {

View File

@ -78,6 +78,7 @@
var MASS_EDIT_USERS = 0; var MASS_EDIT_USERS = 0;
var ASSIGN_ROLES_TO_USERS = 1; var ASSIGN_ROLES_TO_USERS = 1;
var ASSIGN_TEAMS_TO_USERS = 2; var ASSIGN_TEAMS_TO_USERS = 2;
var REMOVE_ROLES_TO_USERS = 3;
var handlersAppliedToToolbarForFirstTime = false; var handlersAppliedToToolbarForFirstTime = false;
</script> </script>
@ -501,10 +502,8 @@
</div> </div>
</div> </div>
<div class="modal-body"> <div class="modal-body">
</div> </div>
<div class="modal-footer"> <div class="modal-footer">
<button id="openEditModal" class="btn btn-link btn-large">Edit</button>
<button id="closeUSerDetailsModal" class="btn btn-link btn-large" data-dismiss="modal" aria-hidden="true">Close</button> <button id="closeUSerDetailsModal" class="btn btn-link btn-large" data-dismiss="modal" aria-hidden="true">Close</button>
</div> </div>
</div> </div>