use of io.imunity.furms.api.users.UserService in project furms by unity-idm.
the class SitesAdminsView method init.
private void init(String siteId) {
InviteUserComponent inviteUser = new InviteUserComponent(userService::getAllUsers, () -> siteService.findAllAdministrators(siteId));
MembershipChangerComponent membershipLayout = new MembershipChangerComponent(getTranslation("view.fenix-admin.sites.button.join"), getTranslation("view.fenix-admin.sites.button.demit"), () -> siteService.isCurrentUserAdminOf(siteId));
membershipLayout.addJoinButtonListener(event -> {
siteService.addAdmin(siteId, currentUserId);
gridReload();
inviteUser.reload();
});
membershipLayout.addDemitButtonListener(event -> {
if (siteService.findAllAdministrators(siteId).size() > 1) {
handleExceptions(() -> siteService.removeSiteUser(siteId, currentUserId));
gridReload();
} else {
showErrorNotification(getTranslation("component.administrators.error.validation.remove"));
}
inviteUser.reload();
membershipLayout.loadAppropriateButton();
});
inviteUser.addInviteAction(event -> doInviteAction(siteId, inviteUser, membershipLayout));
UserContextMenuFactory userContextMenuFactory = UserContextMenuFactory.builder().withCurrentUserId(currentUserId).withRemoveUserAction(userId -> siteService.removeSiteUser(siteId, userId)).withPostRemoveUserAction(userId -> {
membershipLayout.loadAppropriateButton();
inviteUser.reload();
}).withRemoveInvitationAction(invitationId -> {
siteService.removeInvitation(siteId, invitationId);
gridReload();
}).withResendInvitationAction(invitationId -> {
siteService.resendInvitation(siteId, invitationId);
gridReload();
}).build();
UserGrid.Builder userGrid = UserGrid.defaultInit(userContextMenuFactory);
grid = UsersGridComponent.defaultInit(() -> siteService.findAllAdministrators(siteId), () -> siteService.findSiteAdminInvitations(siteId), userGrid);
Site site = handleExceptions(() -> siteService.findById(siteId)).flatMap(identity()).orElseThrow(IllegalStateException::new);
ViewHeaderLayout viewHeaderLayout = new ViewHeaderLayout(getTranslation("view.sites.administrators.title", site.getName()), membershipLayout);
getContent().add(viewHeaderLayout, inviteUser, grid);
}
use of io.imunity.furms.api.users.UserService in project furms by unity-idm.
the class CommunityView method loadPage1Content.
private void loadPage1Content(String communityId, String communityName) {
InviteUserComponent inviteUser = new InviteUserComponent(userService::getAllUsers, () -> communityService.findAllAdmins(communityId));
MembershipChangerComponent membershipLayout = new MembershipChangerComponent(getTranslation("view.fenix-admin.community.button.join"), getTranslation("view.fenix-admin.community.button.demit"), () -> communityService.isAdmin(communityId));
UserContextMenuFactory userContextMenuFactory = UserContextMenuFactory.builder().withCurrentUserId(currentUserId).withRemoveUserAction(userId -> communityService.removeAdmin(communityId, userId)).withPostRemoveUserAction(userId -> {
membershipLayout.loadAppropriateButton();
inviteUser.reload();
}).withRemoveInvitationAction(invitationId -> {
communityService.removeInvitation(communityId, invitationId);
gridReload();
}).withResendInvitationAction(invitationId -> {
communityService.resendInvitation(communityId, invitationId);
gridReload();
}).build();
UserGrid.Builder userGrid = UserGrid.defaultInit(userContextMenuFactory);
grid = UsersGridComponent.defaultInit(() -> communityService.findAllAdmins(communityId), () -> communityService.findAllInvitations(communityId), userGrid);
membershipLayout.addJoinButtonListener(event -> {
communityService.addAdmin(communityId, currentUserId);
gridReload();
inviteUser.reload();
});
membershipLayout.addDemitButtonListener(event -> {
if (communityService.findAllAdmins(communityId).size() > 1) {
handleExceptions(() -> communityService.removeAdmin(communityId, currentUserId));
gridReload();
} else {
showErrorNotification(getTranslation("component.administrators.error.validation.remove"));
}
inviteUser.reload();
membershipLayout.loadAppropriateButton();
});
ViewHeaderLayout headerLayout = new ViewHeaderLayout(getTranslation("view.fenix-admin.community.page.header", communityName), membershipLayout);
inviteUser.addInviteAction(event -> doInviteAction(communityId, inviteUser, membershipLayout));
page1.add(headerLayout, inviteUser, grid);
}
Aggregations