use of cz.metacentrum.perun.webgui.model.User in project perun by CESNET.
the class GetUsers method onFinished.
/**
* Called, when operation finishes successfully.
*/
public void onFinished(JavaScriptObject jso) {
ArrayList<User> list = JsonUtils.jsoAsList(jso);
for (User u : list) {
if (hideService && u.isServiceUser()) {
// if service hidden, skip service users
} else if (hidePerson && !u.isServiceUser() && !u.isSponsoredUser()) {
// if person hidden, skip person
} else if (hideSponsored && !u.isSponsoredUser()) {
// if sponsored hidden, skip person
} else {
addToTable(u);
}
}
sortTable();
session.getUiElements().setLogText("Users loaded: " + list.size());
events.onFinished(jso);
loaderImage.loadingFinished();
}
use of cz.metacentrum.perun.webgui.model.User in project perun by CESNET.
the class UpdateNameTitles method updateUserTitles.
/**
* Updates user details
* @param user User with updated details
*/
public void updateUserTitles(User user) {
if (user == null) {
UiElements.generateAlert("Parameter error", "User to update can't be null");
return;
}
// OBJECT
JSONObject oldUser = new JSONObject(user);
// RECONSTRUCT OBJECT
JSONObject newUser = new JSONObject();
newUser.put("id", oldUser.get("id"));
newUser.put("firstName", oldUser.get("firstName"));
newUser.put("middleName", oldUser.get("middleName"));
newUser.put("lastName", oldUser.get("lastName"));
newUser.put("titleBefore", oldUser.get("titleBefore"));
newUser.put("titleAfter", oldUser.get("titleAfter"));
newUser.put("serviceUser", oldUser.get("serviceUser"));
// whole JSON query
JSONObject jsonQuery = new JSONObject();
jsonQuery.put("user", newUser);
// new events
JsonCallbackEvents newEvents = new JsonCallbackEvents() {
public void onError(PerunError error) {
session.getUiElements().setLogErrorText("Updating user failed.");
events.onError(error);
}
;
public void onFinished(JavaScriptObject jso) {
User u = jso.cast();
session.getUiElements().setLogSuccessText("User " + u.getFullNameWithTitles() + " successfully updated!");
events.onFinished(jso);
}
;
public void onLoadingStart() {
events.onLoadingStart();
}
;
};
// sending data
JsonPostClient jspc = new JsonPostClient(newEvents);
jspc.sendData(JSON_URL, jsonQuery);
}
use of cz.metacentrum.perun.webgui.model.User in project perun by CESNET.
the class SearcherTabItem method draw.
public Widget draw() {
// request
final GetUsers request = new GetUsers();
// MAIN TAB PANEL
VerticalPanel firstTabPanel = new VerticalPanel();
firstTabPanel.setSize("100%", "100%");
PerunSearchParametersWidget params = new PerunSearchParametersWidget(PerunEntity.USER, new PerunSearchParametersWidget.SearchEvent() {
public void search(Map<String, String> map) {
request.clearParameters();
for (Map.Entry<String, String> entry : map.entrySet()) {
request.addSearchParameter(entry.getKey(), entry.getValue());
}
request.search();
}
});
firstTabPanel.add(params);
// get the table
final CellTable<User> table = request.getEmptyTable(new FieldUpdater<User, String>() {
public void update(int index, User object, String value) {
// opens the tab
session.getTabManager().addTab(new UserDetailTabItem(object));
}
});
// 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");
firstTabPanel.add(sp);
session.getUiElements().resizePerunTable(sp, 350, this);
this.contentWidget.setWidget(firstTabPanel);
return getWidget();
}
use of cz.metacentrum.perun.webgui.model.User in project perun by CESNET.
the class AddMemberToGroupTabItem method rebuildAlreadyAddedWidget.
/**
* Rebuild already added widget based on already added members
*/
private void rebuildAlreadyAddedWidget() {
alreadyAdded.setStyleName("alreadyAdded");
alreadyAdded.setVisible(!alreadyAddedList.isEmpty());
alreadyAdded.setWidget(new HTML("<strong>Already added: </strong>"));
for (int i = 0; i < alreadyAddedList.size(); i++) {
if (alreadyAddedList.get(i).getObjectType().equals("Candidate")) {
Candidate c = alreadyAddedList.get(i).cast();
alreadyAdded.getWidget().getElement().setInnerHTML(alreadyAdded.getWidget().getElement().getInnerHTML() + ((i != 0) ? ", " : "") + c.getFullName());
} else if (alreadyAddedList.get(i).getObjectType().equals("User") || alreadyAddedList.get(i).getObjectType().equals("RichUser")) {
User u = alreadyAddedList.get(i).cast();
alreadyAdded.getWidget().getElement().setInnerHTML(alreadyAdded.getWidget().getElement().getInnerHTML() + ((i != 0) ? ", " : "") + u.getFullName());
} else {
RichMember m = alreadyAddedList.get(i).cast();
alreadyAdded.getWidget().getElement().setInnerHTML(alreadyAdded.getWidget().getElement().getInnerHTML() + ((i != 0) ? ", " : "") + m.getUser().getFullName());
}
}
}
use of cz.metacentrum.perun.webgui.model.User in project perun by CESNET.
the class GroupManagersTabItem method fillContentUsers.
private Widget fillContentUsers(final GetRichAdminsWithAttributes admins, TabMenu menu) {
admins.clearTableSelectedSet();
boolean isMembersGroup = group.isCoreGroup();
menu.addWidget(0, UiElements.getRefreshButton(this));
// Events for reloading when finished
final JsonCallbackEvents events = JsonCallbackEvents.refreshTableEvents(admins);
final CustomButton removeButton = TabMenu.getPredefinedButton(ButtonType.REMOVE, ButtonTranslation.INSTANCE.removeManagerFromGroup());
if (!isMembersGroup) {
CustomButton addButton = TabMenu.getPredefinedButton(ButtonType.ADD, true, ButtonTranslation.INSTANCE.addManagerToGroup(), new ClickHandler() {
public void onClick(ClickEvent event) {
session.getTabManager().addTabToCurrentTab(new AddGroupManagerTabItem(group), true);
}
});
if (!session.isVoAdmin(group.getVoId()) && !session.isGroupAdmin(group.getId()))
addButton.setEnabled(false);
menu.addWidget(1, addButton);
removeButton.addClickHandler(new ClickHandler() {
public void onClick(ClickEvent event) {
final ArrayList<User> itemsToRemove = admins.getTableSelectedList();
String text = "Following users won't be group managers anymore.";
UiElements.showDeleteConfirm(itemsToRemove, text, new ClickHandler() {
@Override
public void onClick(ClickEvent clickEvent) {
// TODO - SHOULD HAVE ONLY ONE CALLBACK TO CORE !!
for (int i = 0; i < itemsToRemove.size(); i++) {
RemoveAdmin request;
if (i == itemsToRemove.size() - 1) {
request = new RemoveAdmin(PerunEntity.GROUP, JsonCallbackEvents.disableButtonEvents(removeButton, events));
} else {
request = new RemoveAdmin(PerunEntity.GROUP, JsonCallbackEvents.disableButtonEvents(removeButton));
}
request.removeGroupAdmin(group, itemsToRemove.get(i));
}
}
});
}
});
menu.addWidget(2, removeButton);
} else {
// is core group
menu.addWidget(1, new Image(SmallIcons.INSTANCE.helpIcon()));
Anchor a = new Anchor("<strong>To edit VO managers use VO manager section in menu.</strong>", true);
a.addClickHandler(new ClickHandler() {
@Override
public void onClick(ClickEvent event) {
session.getTabManager().addTab(new VoManagersTabItem(group.getVoId()));
}
});
menu.addWidget(2, a);
}
// get the table
CellTable<User> table;
if (session.isPerunAdmin()) {
table = admins.getTable(new FieldUpdater<User, String>() {
public void update(int i, User user, String s) {
session.getTabManager().addTab(new UserDetailTabItem(user));
}
});
} else {
table = admins.getTable();
}
removeButton.setEnabled(false);
if (session.isVoAdmin(group.getVoId()) || session.isGroupAdmin(group.getId())) {
JsonUtils.addTableManagedButton(admins, table, removeButton);
}
table.setStyleName("perun-table");
return table;
}
Aggregations