use of cz.metacentrum.perun.webgui.tabs.userstabs.InviteUserTabItem in project perun by CESNET.
the class VoOverviewTabItem method draw.
public Widget draw() {
// main panel
ScrollPanel scroll = new ScrollPanel();
final VerticalPanel vp2 = new VerticalPanel();
vp2.setStyleName("perun-table");
scroll.setWidget(vp2);
scroll.setStyleName("perun-tableScrollPanel");
vp2.setSpacing(5);
// tools panel
final DisclosurePanel tools = new DisclosurePanel();
tools.setWidth("100%");
tools.setOpen(true);
FlexTable toolsHeader = new FlexTable();
toolsHeader.setWidget(0, 0, new Image(LargeIcons.INSTANCE.settingToolsIcon()));
toolsHeader.setWidget(0, 1, new HTML("<h3>Quick tools</h3>"));
toolsHeader.setTitle("Click to show/hide VO quick tools");
tools.setHeader(toolsHeader);
// tools panel content
FlexTable toolsLayout = new FlexTable();
toolsLayout.setSize("100%", "100%");
toolsLayout.setCellSpacing(5);
tools.setContent(toolsLayout);
toolsLayout.getFlexCellFormatter().setWidth(0, 0, "220px");
toolsLayout.getFlexCellFormatter().setAlignment(0, 0, HasHorizontalAlignment.ALIGN_LEFT, HasVerticalAlignment.ALIGN_MIDDLE);
toolsLayout.getFlexCellFormatter().setAlignment(0, 1, HasHorizontalAlignment.ALIGN_LEFT, HasVerticalAlignment.ALIGN_MIDDLE);
toolsLayout.getFlexCellFormatter().setAlignment(1, 0, HasHorizontalAlignment.ALIGN_LEFT, HasVerticalAlignment.ALIGN_MIDDLE);
toolsLayout.getFlexCellFormatter().setAlignment(1, 1, HasHorizontalAlignment.ALIGN_LEFT, HasVerticalAlignment.ALIGN_MIDDLE);
toolsLayout.getFlexCellFormatter().setAlignment(2, 0, HasHorizontalAlignment.ALIGN_LEFT, HasVerticalAlignment.ALIGN_MIDDLE);
toolsLayout.getFlexCellFormatter().setAlignment(2, 1, HasHorizontalAlignment.ALIGN_LEFT, HasVerticalAlignment.ALIGN_MIDDLE);
toolsLayout.getFlexCellFormatter().setAlignment(3, 0, HasHorizontalAlignment.ALIGN_LEFT, HasVerticalAlignment.ALIGN_MIDDLE);
toolsLayout.getFlexCellFormatter().setAlignment(3, 1, HasHorizontalAlignment.ALIGN_LEFT, HasVerticalAlignment.ALIGN_MIDDLE);
toolsLayout.getFlexCellFormatter().setAlignment(4, 0, HasHorizontalAlignment.ALIGN_LEFT, HasVerticalAlignment.ALIGN_MIDDLE);
toolsLayout.getFlexCellFormatter().setAlignment(4, 1, HasHorizontalAlignment.ALIGN_LEFT, HasVerticalAlignment.ALIGN_MIDDLE);
toolsLayout.getFlexCellFormatter().setAlignment(5, 0, HasHorizontalAlignment.ALIGN_LEFT, HasVerticalAlignment.ALIGN_MIDDLE);
toolsLayout.getFlexCellFormatter().setAlignment(5, 1, HasHorizontalAlignment.ALIGN_LEFT, HasVerticalAlignment.ALIGN_MIDDLE);
toolsLayout.getFlexCellFormatter().setAlignment(6, 0, HasHorizontalAlignment.ALIGN_LEFT, HasVerticalAlignment.ALIGN_MIDDLE);
toolsLayout.getFlexCellFormatter().setAlignment(6, 1, HasHorizontalAlignment.ALIGN_LEFT, HasVerticalAlignment.ALIGN_MIDDLE);
CustomButton addMember = new CustomButton(ButtonTranslation.INSTANCE.addMemberButton() + "…", ButtonTranslation.INSTANCE.addMemberToVo(), SmallIcons.INSTANCE.addIcon(), new ClickHandler() {
@Override
public void onClick(ClickEvent clickEvent) {
session.getTabManager().addTabToCurrentTab(new AddMemberToVoTabItem(vo), true);
}
});
CustomButton addServiceMember = new CustomButton(ButtonTranslation.INSTANCE.createServiceMemberButton() + "…", ButtonTranslation.INSTANCE.createServiceMember(), SmallIcons.INSTANCE.addIcon(), new ClickHandler() {
@Override
public void onClick(ClickEvent clickEvent) {
session.getTabManager().addTabToCurrentTab(new CreateServiceMemberInVoTabItem(vo));
}
});
CustomButton inviteUser = new CustomButton("Invite member…", "Invite person to become member of your Virtual organization.", SmallIcons.INSTANCE.emailAddIcon(), new ClickHandler() {
@Override
public void onClick(ClickEvent clickEvent) {
session.getTabManager().addTabToCurrentTab(new InviteUserTabItem(vo, null));
}
});
CustomButton addManager = new CustomButton(ButtonTranslation.INSTANCE.addManagerButton() + "…", ButtonTranslation.INSTANCE.addManagerToVo(), SmallIcons.INSTANCE.addIcon(), new ClickHandler() {
@Override
public void onClick(ClickEvent clickEvent) {
session.getTabManager().addTabToCurrentTab(new AddVoManagerTabItem(vo), true);
}
});
CustomButton createGroup = new CustomButton(ButtonTranslation.INSTANCE.createGroupButton() + "…", ButtonTranslation.INSTANCE.createGroup(), SmallIcons.INSTANCE.addIcon(), new ClickHandler() {
@Override
public void onClick(ClickEvent clickEvent) {
session.getTabManager().addTabToCurrentTab(new CreateGroupTabItem(vo));
}
});
CustomButton addToResource = new CustomButton(ButtonTranslation.INSTANCE.addMemberToResourceButton() + "…", ButtonTranslation.INSTANCE.addMemberToResource(), SmallIcons.INSTANCE.addIcon(), new ClickHandler() {
@Override
public void onClick(ClickEvent clickEvent) {
session.getTabManager().addTabToCurrentTab(new AddMemberToResourceTabItem(vo), true);
}
});
toolsLayout.setWidget(0, 0, addMember);
toolsLayout.setWidget(1, 0, addServiceMember);
toolsLayout.setWidget(2, 0, inviteUser);
toolsLayout.setWidget(3, 0, addManager);
toolsLayout.setWidget(4, 0, createGroup);
toolsLayout.setWidget(5, 0, addToResource);
if (!session.isVoAdmin(voId))
addMember.setEnabled(false);
if (!session.isVoAdmin(voId))
addServiceMember.setEnabled(false);
if (!session.isVoAdmin(voId))
inviteUser.setEnabled(false);
if (!session.isVoAdmin(voId))
addManager.setEnabled(false);
if (!session.isVoAdmin(voId))
createGroup.setEnabled(false);
if (!session.isVoAdmin(voId))
addToResource.setEnabled(false);
toolsLayout.setHTML(0, 1, "Add new member into your VO. Candidates can be searched for in VO's external sources or among user already existing in Perun.");
toolsLayout.setHTML(1, 1, "Create new member which represent service account (account usually used by more users with separate login and password).");
toolsLayout.setHTML(2, 1, "Invite person to become member of your Virtual organization.");
toolsLayout.setHTML(3, 1, "Add new manager which can manage your VO in Perun.");
toolsLayout.setHTML(4, 1, "Create new group in your VO.");
toolsLayout.setHTML(5, 1, "Add selected member to specific resource (grant some type of access to Facility resources).");
vp2.add(tools);
// statistics - json
// call the request for number of members
final GetMembersCount countMembers = new GetMembersCount(vo.getId(), null);
final GetMembersCount countValidMembers = new GetMembersCount(vo.getId(), PerunStatus.VALID);
final GetMembersCount countInvalidMembers = new GetMembersCount(vo.getId(), PerunStatus.INVALID);
final GetMembersCount countSuspendedMembers = new GetMembersCount(vo.getId(), PerunStatus.SUSPENDED);
final GetMembersCount countExpiredMembers = new GetMembersCount(vo.getId(), PerunStatus.EXPIRED);
final GetMembersCount countDisabledMembers = new GetMembersCount(vo.getId(), PerunStatus.DISABLED);
// call the request for number of resources
final GetResourcesCount countResources = new GetResourcesCount(vo.getId());
// call the request for number of groups
final GetGroupsCount countGroups = new GetGroupsCount(vo.getId());
// statistics
final DisclosurePanel statistics = new DisclosurePanel();
statistics.setWidth("100%");
//statistics.setOpen(true);
FlexTable statHeader = new FlexTable();
statHeader.setWidget(0, 0, new Image(LargeIcons.INSTANCE.statisticsIcon()));
statHeader.setWidget(0, 1, new HTML("<h3>Statistics</h3>"));
statHeader.setTitle("Click to show/hide VO statistics");
statistics.setHeader(statHeader);
final FlexTable vosTable = new FlexTable();
vosTable.addStyleName("statisticsTable");
statHeader.addClickHandler(new ClickHandler() {
public void onClick(ClickEvent event) {
if (statistics.getContent() == null) {
countMembers.retrieveData();
countValidMembers.retrieveData();
countInvalidMembers.retrieveData();
countSuspendedMembers.retrieveData();
countExpiredMembers.retrieveData();
countDisabledMembers.retrieveData();
countResources.retrieveData();
countGroups.retrieveData();
statistics.setContent(vosTable);
}
}
});
vosTable.setWidget(0, 0, new HTML("<strong>" + "Members" + "</strong>"));
vosTable.setWidget(0, 1, countMembers.getMembersCountLabel());
vosTable.setWidget(1, 0, new HTML(" - valid"));
vosTable.setWidget(1, 1, countValidMembers.getMembersCountLabel());
vosTable.setWidget(2, 0, new HTML(" - invalid"));
vosTable.setWidget(2, 1, countInvalidMembers.getMembersCountLabel());
vosTable.setWidget(3, 0, new HTML(" - suspended"));
vosTable.setWidget(3, 1, countSuspendedMembers.getMembersCountLabel());
vosTable.setWidget(4, 0, new HTML(" - expired"));
vosTable.setWidget(4, 1, countExpiredMembers.getMembersCountLabel());
vosTable.setWidget(5, 0, new HTML(" - disabled"));
vosTable.setWidget(5, 1, countDisabledMembers.getMembersCountLabel());
vosTable.setWidget(6, 0, new HTML("<strong>" + "Resources" + "</strong>"));
vosTable.setWidget(6, 1, countResources.getResourcesCountLabel());
vosTable.setWidget(7, 0, new HTML("<strong>" + "Groups" + "</strong>"));
vosTable.setWidget(7, 1, countGroups.getGroupsCountLabel());
vp2.add(statistics);
session.getUiElements().resizeSmallTabPanel(scroll, 350, this);
contentWidget.setWidget(scroll);
return getWidget();
}
use of cz.metacentrum.perun.webgui.tabs.userstabs.InviteUserTabItem in project perun by CESNET.
the class GroupMembersTabItem method draw.
public Widget draw() {
// SET TAB NAME
titleWidget.setText(Utils.getStrippedStringWithEllipsis(group.getName()) + ": members");
// MAIN PANEL
final VerticalPanel firstTabPanel = new VerticalPanel();
firstTabPanel.setSize("100%", "100%");
// MENU
final TabMenu tabMenu = new TabMenu();
firstTabPanel.add(tabMenu);
firstTabPanel.setCellHeight(tabMenu, "30px");
// DISABLED CHECKBOX
final CheckBox disabled = new CheckBox(WidgetTranslation.INSTANCE.showDisabledMembers());
disabled.setTitle(WidgetTranslation.INSTANCE.showDisabledMembersTitle());
disabled.setValue(wasDisabled);
// CALLBACKS
final GetCompleteRichMembers members = new GetCompleteRichMembers(PerunEntity.GROUP, groupId, null);
final FindCompleteRichMembers findMembers = new FindCompleteRichMembers(PerunEntity.GROUP, groupId, "", null);
members.excludeDisabled(!wasDisabled);
members.setIndirectCheckable(false);
findMembers.setIndirectCheckable(false);
final CustomButton searchButton = TabMenu.getPredefinedButton(ButtonType.SEARCH, ButtonTranslation.INSTANCE.searchMemberInGroup());
final CustomButton listAllButton = TabMenu.getPredefinedButton(ButtonType.LIST_ALL_MEMBERS, ButtonTranslation.INSTANCE.listAllMembersInGroup());
if ((!session.isVoAdmin(group.getVoId()) && !session.isGroupAdmin(groupId)) || group.isCoreGroup()) {
findMembers.setCheckable(false);
}
table = findMembers.getEmptyTable(new FieldUpdater<RichMember, RichMember>() {
// when user click on a row -> open new tab
public void update(int index, RichMember object, RichMember value) {
session.getTabManager().addTab(new MemberDetailTabItem(object.getId(), groupId));
}
});
tableWidget = table.getEmptyTableWidget();
// refresh
tabMenu.addWidget(UiElements.getRefreshButton(this));
// ADD
CustomButton addButton = TabMenu.getPredefinedButton(ButtonType.ADD, true, ButtonTranslation.INSTANCE.addMemberToGroup(), new ClickHandler() {
public void onClick(ClickEvent event) {
session.getTabManager().addTabToCurrentTab(new AddMemberToGroupTabItem(groupId), true);
}
});
if (!session.isGroupAdmin(groupId) && !session.isVoAdmin(group.getVoId()))
addButton.setEnabled(false);
CustomButton inviteButton = new CustomButton("Invite member…", SmallIcons.INSTANCE.emailAddIcon(), new ClickHandler() {
@Override
public void onClick(ClickEvent event) {
session.getTabManager().addTabToCurrentTab(new InviteUserTabItem(group.getVoId(), group));
}
});
if (!session.isGroupAdmin(groupId) && !session.isVoAdmin(group.getVoId()))
inviteButton.setEnabled(false);
// REMOVE
final CustomButton removeButton = TabMenu.getPredefinedButton(ButtonType.REMOVE, ButtonTranslation.INSTANCE.removeMemberFromGroup());
if (!session.isGroupAdmin(groupId) && !session.isVoAdmin(group.getVoId()))
removeButton.setEnabled(false);
if (!group.isCoreGroup()) {
tabMenu.addWidget(addButton);
tabMenu.addWidget(inviteButton);
tabMenu.addWidget(removeButton);
}
// refreshMembers
final JsonCallbackEvents refreshEvent = new JsonCallbackEvents() {
@Override
public void onFinished(JavaScriptObject jso) {
if (search) {
findMembers.searchFor(searchString);
} else {
findMembers.clearTable();
members.retrieveData();
}
}
};
// add click handler for remove button
removeButton.addClickHandler(new ClickHandler() {
@Override
public void onClick(ClickEvent event) {
// state specific events
final ArrayList<RichMember> membersForRemoving = findMembers.getTableSelectedList();
String text = "Following members will be removed from group. They will lose access to resources provided by this group.";
UiElements.showDeleteConfirm(membersForRemoving, text, new ClickHandler() {
@Override
public void onClick(ClickEvent clickEvent) {
// TODO - SHOULD HAVE ONLY ONE CALLBACK TO CORE !!
for (int i = 0; i < membersForRemoving.size(); i++) {
RemoveMember request;
if (i == membersForRemoving.size() - 1) {
request = new RemoveMember(JsonCallbackEvents.disableButtonEvents(removeButton, refreshEvent));
} else {
request = new RemoveMember(JsonCallbackEvents.disableButtonEvents(removeButton));
}
request.removeMemberFromGroup(group, membersForRemoving.get(i));
}
}
});
}
});
final ExtendedTextBox searchBox = tabMenu.addSearchWidget(new PerunSearchEvent() {
public void searchFor(String text) {
table.setEmptyTableWidget(tableWidget);
searchString = text;
search = true;
findMembers.searchFor(text);
}
}, searchButton);
searchBox.getTextBox().setText(searchString);
// checkbox click handler
disabled.addValueChangeHandler(new ValueChangeHandler<Boolean>() {
@Override
public void onValueChange(ValueChangeEvent<Boolean> event) {
wasDisabled = disabled.getValue();
if (search) {
// case when update but not triggered by button
searchString = searchBox.getTextBox().getText();
members.excludeDisabled(!disabled.getValue());
} else {
members.excludeDisabled(!disabled.getValue());
members.retrieveData();
}
}
});
findMembers.setEvents(JsonCallbackEvents.mergeEvents(JsonCallbackEvents.disableButtonEvents(searchButton, JsonCallbackEvents.disableCheckboxEvents(disabled)), new JsonCallbackEvents() {
@Override
public void onFinished(JavaScriptObject jso) {
searchBox.getTextBox().setEnabled(true);
listAllButton.setEnabled(true);
}
@Override
public void onError(PerunError error) {
searchBox.getTextBox().setEnabled(true);
listAllButton.setEnabled(true);
}
@Override
public void onLoadingStart() {
searchBox.getTextBox().setEnabled(false);
listAllButton.setEnabled(false);
disabled.setVisible(false);
}
}));
members.setEvents(JsonCallbackEvents.mergeEvents(JsonCallbackEvents.disableButtonEvents(listAllButton, JsonCallbackEvents.disableCheckboxEvents(disabled)), new JsonCallbackEvents() {
@Override
public void onFinished(JavaScriptObject jso) {
// pass data to table handling callback
findMembers.onFinished(jso);
((AjaxLoaderImage) table.getEmptyTableWidget()).setEmptyResultMessage("Group has no members.");
searchBox.getTextBox().setEnabled(true);
searchButton.setEnabled(true);
}
@Override
public void onError(PerunError error) {
// pass data to table handling callback
findMembers.onError(error);
searchBox.getTextBox().setEnabled(true);
searchButton.setEnabled(true);
}
@Override
public void onLoadingStart() {
table.setEmptyTableWidget(tableWidget);
searchBox.getTextBox().setEnabled(false);
searchButton.setEnabled(false);
disabled.setVisible(true);
// to show progress when reloading
((AjaxLoaderImage) table.getEmptyTableWidget()).loadingStart();
}
}));
// LIST ALL BUTTON
listAllButton.addClickHandler(new ClickHandler() {
public void onClick(ClickEvent event) {
table.setEmptyTableWidget(tableWidget);
search = false;
searchString = "";
searchBox.getTextBox().setText("");
findMembers.clearTable();
members.retrieveData();
}
});
tabMenu.addWidget(listAllButton);
tabMenu.addWidget(disabled);
/* WHEN TAB RELOADS, CHECK THE STATE */
if (search) {
findMembers.searchFor(searchString);
} else {
GetGroupMembersCount count = new GetGroupMembersCount(groupId, new JsonCallbackEvents() {
@Override
public void onFinished(JavaScriptObject jso) {
int membersCount = ((BasicOverlayType) jso.cast()).getInt();
if (membersCount > 1000) {
FlexTable panel = new FlexTable();
panel.setSize("100%", "150px");
HTML label = new HTML();
label.setHTML("<h2>Group has " + membersCount + " members. We suggest you to use search instead.</h2><h2>You can search member by name, login, email or click List all to see all members.</h2>");
panel.setWidget(0, 0, label);
panel.getFlexCellFormatter().setHorizontalAlignment(0, 0, HasHorizontalAlignment.ALIGN_CENTER);
table.setEmptyTableWidget(panel);
} else {
// load all members
members.excludeDisabled(!disabled.getValue());
members.retrieveData();
}
onceAsked = true;
}
@Override
public void onError(PerunError error) {
// load all members
members.excludeDisabled(!disabled.getValue());
members.retrieveData();
}
@Override
public void onLoadingStart() {
}
});
if (!onceAsked) {
count.retrieveData();
} else {
// load all members
members.excludeDisabled(!disabled.getValue());
members.retrieveData();
}
}
ScrollPanel tableWrapper = new ScrollPanel();
table.addStyleName("perun-table");
tableWrapper.setWidget(table);
tableWrapper.addStyleName("perun-tableScrollPanel");
session.getUiElements().resizePerunTable(tableWrapper, 350, this);
// add menu and the table to the main panel
firstTabPanel.add(tableWrapper);
removeButton.setEnabled(false);
JsonUtils.addTableManagedButton(findMembers, table, removeButton);
this.contentWidget.setWidget(firstTabPanel);
return getWidget();
}
Aggregations