use of cz.metacentrum.perun.webgui.tabs.groupstabs.GroupDetailTabItem in project perun by CESNET.
the class ResourceAssignedGroupsTabItem method draw.
public Widget draw() {
titleWidget.setText(Utils.getStrippedStringWithEllipsis(resource.getName()) + ": manage assigned groups");
VerticalPanel vp = new VerticalPanel();
vp.setSize("100%", "100%");
TabMenu menu = new TabMenu();
menu.addWidget(UiElements.getRefreshButton(this));
final GetAssignedGroups resourceGroups = new GetAssignedGroups(resourceId);
final JsonCallbackEvents localEvents = JsonCallbackEvents.refreshTableEvents(resourceGroups);
CustomButton assignGroupButton = TabMenu.getPredefinedButton(ButtonType.ADD, true, ButtonTranslation.INSTANCE.assignGroupToResource(), new ClickHandler() {
public void onClick(ClickEvent event) {
session.getTabManager().addTabToCurrentTab(new AssignGroupTabItem(resource), true);
}
});
final CustomButton removeGroupButton = TabMenu.getPredefinedButton(ButtonType.REMOVE, ButtonTranslation.INSTANCE.removeGroupFromResource());
removeGroupButton.addClickHandler(new ClickHandler() {
@Override
public void onClick(ClickEvent event) {
final ArrayList<Group> groupsForRemoving = resourceGroups.getTableSelectedList();
String text = "Following groups will be removed from resource.";
UiElements.showDeleteConfirm(groupsForRemoving, text, new ClickHandler() {
@Override
public void onClick(ClickEvent clickEvent) {
RemoveGroupsFromResource request = new RemoveGroupsFromResource(JsonCallbackEvents.disableButtonEvents(removeGroupButton, localEvents));
request.removeGroupsFromResource(groupsForRemoving, resource);
}
});
}
});
if (!session.isVoAdmin(resource.getVoId())) {
resourceGroups.setCheckable(false);
assignGroupButton.setEnabled(false);
}
menu.addWidget(assignGroupButton);
menu.addWidget(removeGroupButton);
menu.addFilterWidget(new ExtendedSuggestBox(resourceGroups.getOracle()), new PerunSearchEvent() {
@Override
public void searchFor(String text) {
resourceGroups.filterTable(text);
}
}, ButtonTranslation.INSTANCE.filterGroup());
// display menu to vo admin only
if (session.isVoAdmin(resource.getVoId())) {
resourceGroups.setCheckable(true);
vp.add(menu);
vp.setCellHeight(menu, "30px");
} else {
resourceGroups.setCheckable(false);
}
// table with field updater which leads to group detail
CellTable<Group> table = resourceGroups.getTable(new FieldUpdater<Group, String>() {
public void update(int index, Group object, String value) {
session.getTabManager().addTab(new GroupDetailTabItem(object));
}
});
removeGroupButton.setEnabled(false);
if (session.isVoAdmin(resource.getVoId()))
JsonUtils.addTableManagedButton(resourceGroups, table, removeGroupButton);
table.addStyleName("perun-table");
table.setWidth("100%");
ScrollPanel sp = new ScrollPanel(table);
sp.addStyleName("perun-tableScrollPanel");
vp.add(sp);
session.getUiElements().resizePerunTable(sp, 350, this);
this.contentWidget.setWidget(vp);
return getWidget();
}
use of cz.metacentrum.perun.webgui.tabs.groupstabs.GroupDetailTabItem in project perun by CESNET.
the class CreateFacilityTabItem method fillContentGroups.
private Widget fillContentGroups(final GetAdminGroups jsonCallback, TabMenu menu) {
jsonCallback.clearTableSelectedSet();
// get the table
CellTable<Group> table = jsonCallback.getTable(new FieldUpdater<Group, String>() {
@Override
public void update(int i, Group grp, String s) {
session.getTabManager().addTab(new GroupDetailTabItem(grp));
}
});
menu.addWidget(0, TabMenu.getPredefinedButton(ButtonType.ADD, true, ButtonTranslation.INSTANCE.addManagerGroupToFacility(), new ClickHandler() {
public void onClick(ClickEvent event) {
session.getTabManager().addTabToCurrentTab(new AddFacilityManagerGroupTabItem(facility, JsonCallbackEvents.refreshTableEvents(jsonCallback)), true);
}
}));
final CustomButton removeButton = TabMenu.getPredefinedButton(ButtonType.REMOVE, ButtonTranslation.INSTANCE.removeManagerGroupFromFacility());
menu.addWidget(1, removeButton);
removeButton.addClickHandler(new ClickHandler() {
public void onClick(ClickEvent event) {
final ArrayList<Group> list = jsonCallback.getTableSelectedList();
String text = "Members of following groups won't be facility managers anymore and won't be able to manage this facility in Perun.";
UiElements.showDeleteConfirm(list, text, new ClickHandler() {
@Override
public void onClick(ClickEvent clickEvent) {
// TODO - SHOULD HAVE ONLY ONE CALLBACK TO CORE !!
for (int i = 0; i < list.size(); i++) {
if (i == list.size() - 1) {
RemoveAdmin request = new RemoveAdmin(PerunEntity.FACILITY, JsonCallbackEvents.disableButtonEvents(removeButton, JsonCallbackEvents.refreshTableEvents(jsonCallback)));
request.removeFacilityAdminGroup(facility, list.get(i));
} else {
RemoveAdmin request = new RemoveAdmin(PerunEntity.FACILITY, JsonCallbackEvents.disableButtonEvents(removeButton));
request.removeFacilityAdminGroup(facility, list.get(i));
}
}
}
});
}
});
removeButton.setEnabled(false);
JsonUtils.addTableManagedButton(jsonCallback, table, removeButton);
table.addStyleName("perun-table");
return table;
}
use of cz.metacentrum.perun.webgui.tabs.groupstabs.GroupDetailTabItem in project perun by CESNET.
the class FacilityManagersTabItem method fillContentGroups.
private Widget fillContentGroups(final GetAdminGroups jsonCallback, TabMenu menu) {
jsonCallback.clearTableSelectedSet();
// get the table
CellTable<Group> table = jsonCallback.getTable(new FieldUpdater<Group, String>() {
@Override
public void update(int i, Group grp, String s) {
session.getTabManager().addTab(new GroupDetailTabItem(grp));
}
});
menu.addWidget(0, UiElements.getRefreshButton(this));
menu.addWidget(1, TabMenu.getPredefinedButton(ButtonType.ADD, true, ButtonTranslation.INSTANCE.addManagerGroupToFacility(), new ClickHandler() {
public void onClick(ClickEvent event) {
session.getTabManager().addTabToCurrentTab(new AddFacilityManagerGroupTabItem(facility, JsonCallbackEvents.refreshTableEvents(jsonCallback)), true);
}
}));
final CustomButton removeButton = TabMenu.getPredefinedButton(ButtonType.REMOVE, ButtonTranslation.INSTANCE.removeManagerGroupFromFacility());
menu.addWidget(2, removeButton);
removeButton.addClickHandler(new ClickHandler() {
public void onClick(ClickEvent event) {
final ArrayList<Group> list = jsonCallback.getTableSelectedList();
String text = "Members of following groups won't be facility managers anymore and won't be able to manage this facility in Perun.";
UiElements.showDeleteConfirm(list, text, new ClickHandler() {
@Override
public void onClick(ClickEvent clickEvent) {
// TODO - SHOULD HAVE ONLY ONE CALLBACK TO CORE !!
for (int i = 0; i < list.size(); i++) {
if (i == list.size() - 1) {
RemoveAdmin request = new RemoveAdmin(PerunEntity.FACILITY, JsonCallbackEvents.disableButtonEvents(removeButton, JsonCallbackEvents.refreshTableEvents(jsonCallback)));
request.removeFacilityAdminGroup(facility, list.get(i));
} else {
RemoveAdmin request = new RemoveAdmin(PerunEntity.FACILITY, JsonCallbackEvents.disableButtonEvents(removeButton));
request.removeFacilityAdminGroup(facility, list.get(i));
}
}
}
});
}
});
removeButton.setEnabled(false);
JsonUtils.addTableManagedButton(jsonCallback, table, removeButton);
table.addStyleName("perun-table");
return table;
}
use of cz.metacentrum.perun.webgui.tabs.groupstabs.GroupDetailTabItem in project perun by CESNET.
the class FacilityAllowedGroupsTabItem method draw.
public Widget draw() {
// set title
titleWidget.setText(Utils.getStrippedStringWithEllipsis(facility.getName()) + ": Allowed Groups");
final ListBoxWithObjects<VirtualOrganization> vosListbox = new ListBoxWithObjects<VirtualOrganization>();
final ListBoxWithObjects<Service> servicesListbox = new ListBoxWithObjects<Service>();
final GetAllowedGroups jsonCallback = new GetAllowedGroups(facilityId);
jsonCallback.setCheckable(false);
// content
VerticalPanel vp = new VerticalPanel();
vp.setSize("100%", "100%");
TabMenu menu = new TabMenu();
vp.add(menu);
vp.setCellHeight(menu, "30px");
menu.addWidget(UiElements.getRefreshButton(this));
menu.addWidget(new HTML("<strong>Filter by VO:</strong>"));
menu.addWidget(vosListbox);
menu.addWidget(new HTML("<strong>Filter by service:</strong>"));
menu.addWidget(servicesListbox);
// get the table
final GetAllowedVos vosCall = new GetAllowedVos(facilityId, new JsonCallbackEvents() {
public void onFinished(JavaScriptObject jso) {
vosListbox.clear();
vosListbox.removeAllOption();
vosListbox.addAllItems(new TableSorter<VirtualOrganization>().sortByName(JsonUtils.<VirtualOrganization>jsoAsList(jso)));
vosListbox.addAllOption();
if (lastSelectedVoId == 0) {
vosListbox.setSelectedIndex(0);
} else {
for (VirtualOrganization vo : vosListbox.getAllObjects()) {
if (vo.getId() == lastSelectedVoId) {
vosListbox.setSelected(vo, true);
break;
}
}
}
jsonCallback.setVos(vosListbox.getAllObjects());
vosCallDone = true;
}
public void onLoadingStart() {
vosListbox.removeAllOption();
vosListbox.clear();
vosListbox.addItem("Loading...");
vosCallDone = false;
}
public void onError(PerunError error) {
vosListbox.clear();
vosListbox.removeAllOption();
vosListbox.addItem("Error while loading");
vosCallDone = false;
}
});
vosCall.retrieveData();
GetFacilityAssignedServices servCall = new GetFacilityAssignedServices(facilityId, new JsonCallbackEvents() {
public void onFinished(JavaScriptObject jso) {
servicesListbox.clear();
servicesListbox.removeAllOption();
servicesListbox.addAllItems(new TableSorter<Service>().sortByName(JsonUtils.<Service>jsoAsList(jso)));
servicesListbox.addAllOption();
if (servicesListbox.isEmpty()) {
servicesListbox.addItem("No service available on facility");
}
if (lastSelectedServiceId == 0) {
// choose all
servicesListbox.setSelectedIndex(0);
} else {
for (Service s : servicesListbox.getAllObjects()) {
if (s.getId() == lastSelectedServiceId) {
servicesListbox.setSelected(s, true);
break;
}
}
}
callDone = true;
}
public void onLoadingStart() {
servicesListbox.removeAllOption();
servicesListbox.clear();
servicesListbox.addItem("Loading...");
callDone = false;
}
public void onError(PerunError error) {
servicesListbox.clear();
servicesListbox.removeAllOption();
servicesListbox.addItem("Error while loading");
callDone = false;
}
});
servCall.retrieveData();
Scheduler.get().scheduleFixedPeriod(new Scheduler.RepeatingCommand() {
@Override
public boolean execute() {
if (vosCallDone && callDone) {
jsonCallback.setVoId(lastSelectedVoId);
jsonCallback.setServiceId(lastSelectedServiceId);
jsonCallback.retrieveData();
return false;
} else {
return true;
}
}
}, 200);
vosListbox.addChangeHandler(new ChangeHandler() {
@Override
public void onChange(ChangeEvent changeEvent) {
if (vosListbox.getSelectedIndex() > 0) {
jsonCallback.setVoId(vosListbox.getSelectedObject().getId());
lastSelectedVoId = vosListbox.getSelectedObject().getId();
} else {
jsonCallback.setVoId(0);
lastSelectedVoId = 0;
}
jsonCallback.retrieveData();
}
});
servicesListbox.addChangeHandler(new ChangeHandler() {
@Override
public void onChange(ChangeEvent changeEvent) {
if (servicesListbox.getSelectedIndex() > 0) {
jsonCallback.setServiceId(servicesListbox.getSelectedObject().getId());
lastSelectedServiceId = servicesListbox.getSelectedObject().getId();
} else {
jsonCallback.setServiceId(0);
lastSelectedServiceId = 0;
}
jsonCallback.retrieveData();
}
});
CellTable<Group> table = jsonCallback.getEmptyTable(new FieldUpdater<Group, String>() {
@Override
public void update(int i, Group group, String s) {
if (session.isVoAdmin(group.getVoId()) || session.isGroupAdmin(group.getId())) {
session.getTabManager().addTab(new GroupDetailTabItem(group));
} else {
// show alert
UiElements.generateInfo("You are not VO / Group manager of this group", "You MUST be VO manager or Group manager of group: <strong>" + SafeHtmlUtils.fromString(group.getName()).asString() + "</strong> to view it's details.");
}
}
});
table.addStyleName("perun-table");
ScrollPanel sp = new ScrollPanel(table);
sp.addStyleName("perun-tableScrollPanel");
vp.add(sp);
session.getUiElements().resizePerunTable(sp, 350, this);
this.contentWidget.setWidget(vp);
return getWidget();
}
use of cz.metacentrum.perun.webgui.tabs.groupstabs.GroupDetailTabItem in project perun by CESNET.
the class VoGroupsTabItem method draw.
public Widget draw() {
this.titleWidget.setText(Utils.getStrippedStringWithEllipsis(vo.getName()) + ": " + "groups");
// MAIN PANEL
VerticalPanel firstTabPanel = new VerticalPanel();
firstTabPanel.setSize("100%", "100%");
// HORIZONTAL MENU
TabMenu menu = new TabMenu();
// VO Groups request
ArrayList<String> attrNames = new ArrayList<>();
attrNames.add("urn:perun:group:attribute-def:def:synchronizationEnabled");
attrNames.add("urn:perun:group:attribute-def:def:synchronizationInterval");
attrNames.add("urn:perun:group:attribute-def:def:lastSynchronizationState");
attrNames.add("urn:perun:group:attribute-def:def:lastSuccessSynchronizationTimestamp");
attrNames.add("urn:perun:group:attribute-def:def:lastSynchronizationTimestamp");
attrNames.add("urn:perun:group:attribute-def:def:authoritativeGroup");
attrNames.add("urn:perun:group:attribute-def:def:groupSynchronizationTimes");
attrNames.add("urn:perun:group:attribute-def:def:startOfLastSuccessfulSynchronization");
attrNames.add("urn:perun:group:attribute-def:def:startOfLastSynchronization");
final GetAllRichGroups groups = new GetAllRichGroups(voId, attrNames);
final JsonCallbackEvents events = JsonCallbackEvents.refreshTableEvents(groups);
if (!session.isVoAdmin(voId))
groups.setCheckable(false);
// refresh
menu.addWidget(UiElements.getRefreshButton(this));
// add new group button
CustomButton createButton = TabMenu.getPredefinedButton(ButtonType.CREATE, true, ButtonTranslation.INSTANCE.createGroup(), new ClickHandler() {
public void onClick(ClickEvent event) {
session.getTabManager().addTabToCurrentTab(new CreateGroupTabItem(vo));
}
});
if (!session.isVoAdmin(voId))
createButton.setEnabled(false);
menu.addWidget(createButton);
// delete selected groups button
final CustomButton removeButton = TabMenu.getPredefinedButton(ButtonType.DELETE, ButtonTranslation.INSTANCE.deleteGroup());
removeButton.addClickHandler(new ClickHandler() {
public void onClick(ClickEvent event) {
final ArrayList<RichGroup> groupsToDelete = groups.getTableSelectedList();
String text = "Following groups (including all sub-groups) will be deleted.";
UiElements.showDeleteConfirm(groupsToDelete, text, new ClickHandler() {
@Override
public void onClick(ClickEvent clickEvent) {
DeleteGroups request = new DeleteGroups(JsonCallbackEvents.disableButtonEvents(removeButton, events));
request.deleteGroups(groupsToDelete);
}
});
}
});
menu.addWidget(removeButton);
CustomButton moveButton = TabMenu.getPredefinedButton(ButtonType.MOVE, true, ButtonTranslation.INSTANCE.moveGroup(), new ClickHandler() {
public void onClick(ClickEvent event) {
final ArrayList<RichGroup> groupsToMove = groups.getTableSelectedList();
session.getTabManager().addTabToCurrentTab(new MoveGroupsTabItem(vo, groupsToMove));
}
});
if (session.isPerunAdmin()) {
// FIXME - temporary for perun admin
if (!session.isVoAdmin(voId))
moveButton.setEnabled(false);
menu.addWidget(moveButton);
}
// filter box
menu.addFilterWidget(new ExtendedSuggestBox(groups.getOracle()), new PerunSearchEvent() {
public void searchFor(String text) {
groups.filterTable(text);
}
}, ButtonTranslation.INSTANCE.filterGroup());
// add a table with a onclick
CellTable<RichGroup> table = groups.getTable(new FieldUpdater<RichGroup, String>() {
public void update(int index, RichGroup group, String value) {
session.getTabManager().addTab(new GroupDetailTabItem(group.getId()));
}
});
// add a class to the table and wrap it into scroll panel
table.addStyleName("perun-table");
ScrollPanel sp = new ScrollPanel(table);
sp.addStyleName("perun-tableScrollPanel");
// add menu and the table to the main panel
firstTabPanel.add(menu);
firstTabPanel.setCellHeight(menu, "30px");
firstTabPanel.add(sp);
removeButton.setEnabled(false);
if (session.isVoAdmin(voId))
JsonUtils.addTableManagedButton(groups, table, removeButton);
// fixme - temporary only for perun admin
if (session.isPerunAdmin()) {
JsonUtils.addTableManagedButton(groups, table, moveButton);
moveButton.setEnabled(false);
}
session.getUiElements().resizePerunTable(sp, 350, this);
this.contentWidget.setWidget(firstTabPanel);
return getWidget();
}
Aggregations