use of cz.metacentrum.perun.webgui.json.usersManager.GetSpecificUsersByUser in project perun by CESNET.
the class MemberSponsoredUsersTabItem method draw.
public Widget draw() {
if (member.getUser().isSponsoredUser()) {
this.titleWidget.setText(Utils.getStrippedStringWithEllipsis(member.getUser().getFullNameWithTitles().trim()) + ": sponsors");
} else {
this.titleWidget.setText(Utils.getStrippedStringWithEllipsis(member.getUser().getFullNameWithTitles().trim()) + ": sponsored users");
}
VerticalPanel vp = new VerticalPanel();
vp.setSize("100%", "100%");
// MENU
TabMenu menu = new TabMenu();
vp.add(menu);
vp.setCellHeight(menu, "30px");
menu.addWidget(UiElements.getRefreshButton(this));
if (member.getUser().isSponsoredUser()) {
// request
final GetUsersBySpecificUser request = new GetUsersBySpecificUser(member.getUserId());
request.setCheckable(false);
// table
CellTable<User> table;
if (session.isPerunAdmin()) {
table = request.getTable(new FieldUpdater<User, String>() {
public void update(int i, User user, String s) {
session.getTabManager().addTab(new UserDetailTabItem(user));
}
});
} else {
table = request.getTable();
}
table.addStyleName("perun-table");
table.setWidth("100%");
ScrollPanel sp = new ScrollPanel(table);
sp.addStyleName("perun-tableScrollPanel");
vp.add(sp);
} else {
final GetSpecificUsersByUser request = new GetSpecificUsersByUser(member.getUserId());
request.setCheckable(false);
request.setHideService(true);
// table
CellTable<User> table;
if (session.isPerunAdmin()) {
table = request.getTable(new FieldUpdater<User, String>() {
public void update(int i, User user, String s) {
session.getTabManager().addTab(new UserDetailTabItem(user));
}
});
} else {
table = request.getTable();
}
table.addStyleName("perun-table");
table.setWidth("100%");
ScrollPanel sp = new ScrollPanel(table);
sp.addStyleName("perun-tableScrollPanel");
vp.add(sp);
}
contentWidget.setWidget(vp);
return getWidget();
}
use of cz.metacentrum.perun.webgui.json.usersManager.GetSpecificUsersByUser in project perun by CESNET.
the class SelfSponsoredUsersTabItem method draw.
@Override
public Widget draw() {
VerticalPanel vp = new VerticalPanel();
vp.setSize("100%", "100%");
if (user.isSponsoredUser()) {
// SERVICE TYPE user
this.titleWidget.setText(Utils.getStrippedStringWithEllipsis(user.getFullNameWithTitles().trim()) + ": Sponsors");
// request
final GetUsersBySpecificUser request = new GetUsersBySpecificUser(userId);
// menu
TabMenu menu = new TabMenu();
vp.add(menu);
vp.setCellHeight(menu, "30px");
menu.addWidget(UiElements.getRefreshButton(this));
// table
CellTable<User> table;
if (session.isPerunAdmin()) {
table = request.getTable(new FieldUpdater<User, String>() {
public void update(int i, User user, String s) {
session.getTabManager().addTab(new SelfDetailTabItem(user));
}
});
} else {
table = request.getTable();
}
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);
} else {
// PERSON TYPE user
this.titleWidget.setText(Utils.getStrippedStringWithEllipsis(user.getFullNameWithTitles().trim()) + ": Sponsored users");
// request
final GetSpecificUsersByUser request = new GetSpecificUsersByUser(userId);
request.setHideService(true);
// menu
TabMenu menu = new TabMenu();
vp.add(menu);
vp.setCellHeight(menu, "30px");
menu.addWidget(UiElements.getRefreshButton(this));
// table
CellTable<User> table;
if (session.isPerunAdmin()) {
table = request.getTable(new FieldUpdater<User, String>() {
public void update(int i, User user, String s) {
session.getTabManager().addTab(new SelfDetailTabItem(user));
}
});
} else {
table = request.getTable();
}
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);
}
contentWidget.setWidget(vp);
return getWidget();
}
use of cz.metacentrum.perun.webgui.json.usersManager.GetSpecificUsersByUser in project perun by CESNET.
the class SelfServiceUsersTabItem method draw.
@Override
public Widget draw() {
VerticalPanel vp = new VerticalPanel();
vp.setSize("100%", "100%");
if (user.isServiceUser()) {
// SERVICE TYPE user
this.titleWidget.setText(Utils.getStrippedStringWithEllipsis(user.getFullNameWithTitles().trim()) + ": Associated users");
// request
final GetUsersBySpecificUser request = new GetUsersBySpecificUser(userId);
final JsonCallbackEvents refreshEvents = JsonCallbackEvents.refreshTableEvents(request);
// menu
TabMenu menu = new TabMenu();
vp.add(menu);
vp.setCellHeight(menu, "30px");
menu.addWidget(UiElements.getRefreshButton(this));
// buttons
menu.addWidget(TabMenu.getPredefinedButton(ButtonType.ADD, true, "Add new user to service identity: " + user.getLastName(), new ClickHandler() {
public void onClick(ClickEvent clickEvent) {
session.getTabManager().addTabToCurrentTab(new ConnectServiceIdentityTabItem(user), true);
}
}));
final CustomButton removeUserButton = TabMenu.getPredefinedButton(ButtonType.REMOVE, "Remove user from service identity " + user.getLastName());
menu.addWidget(removeUserButton);
removeUserButton.addClickHandler(new ClickHandler() {
public void onClick(ClickEvent clickEvent) {
final ArrayList<User> list = request.getTableSelectedList();
final ArrayList<User> fullList = request.getList();
if (fullList.size() == list.size()) {
UiElements.generateAlert("Remove warning", "<strong><span class=\"serverResponseLabelError\">If you remove all users from service identity you won't be able to use it in the future.</br></br>Please consider keeping at least one user, e.g. add someone else before you remove yourself.</span></strong><p><strong>Do you wish to continue anyway ?</strong>", new ClickHandler() {
@Override
public void onClick(ClickEvent event) {
UiElements.showDeleteConfirm(list, "Following users will be removed from service identity and they will lose all access to it. Only users associated with service identity can add other users again. If you remove all users connected to the service identity, you won't be able to use it in future!", new ClickHandler() {
@Override
public void onClick(ClickEvent event) {
for (int i = 0; i < list.size(); i++) {
// TODO - SHOULD HAVE ONLY ONE CALLBACK TO CORE
RemoveSpecificUserOwner req;
if (i == list.size() - 1) {
req = new RemoveSpecificUserOwner(JsonCallbackEvents.disableButtonEvents(removeUserButton, refreshEvents));
} else {
req = new RemoveSpecificUserOwner(JsonCallbackEvents.disableButtonEvents(removeUserButton));
}
req.removeServiceUser(list.get(i), user);
// TODO - consider fixing authz in session ?
}
}
});
}
});
} else {
boolean containsMyself = false;
for (User user : list) {
if (user.getId() == session.getUser().getId()) {
containsMyself = true;
}
}
if (containsMyself) {
// if not selected myself, continue same way
UiElements.showDeleteConfirm(list, "<p style=\"color:red;\"><b>You are about to remove yourself from service identity! If you do that, you won't be able to add yourself again. Only users associated with service identity can add other users again.</b></p>" + "<p>Following users will be removed from service identity and they will lose any access to it.</p>", new ClickHandler() {
@Override
public void onClick(ClickEvent event) {
for (int i = 0; i < list.size(); i++) {
// TODO - SHOULD HAVE ONLY ONE CALLBACK TO CORE
RemoveSpecificUserOwner req;
if (i == list.size() - 1) {
req = new RemoveSpecificUserOwner(JsonCallbackEvents.disableButtonEvents(removeUserButton, refreshEvents));
} else {
req = new RemoveSpecificUserOwner(JsonCallbackEvents.disableButtonEvents(removeUserButton));
}
req.removeServiceUser(list.get(i), user);
// TODO - consider fixing authz in session ?
}
}
});
} else {
// if not selected myself, continue same way
UiElements.showDeleteConfirm(list, "Following users will be removed from service identity and they will lose any access to it. Only users associated with service identity can add other users again.", new ClickHandler() {
@Override
public void onClick(ClickEvent event) {
for (int i = 0; i < list.size(); i++) {
// TODO - SHOULD HAVE ONLY ONE CALLBACK TO CORE
RemoveSpecificUserOwner req;
if (i == list.size() - 1) {
req = new RemoveSpecificUserOwner(JsonCallbackEvents.disableButtonEvents(removeUserButton, refreshEvents));
} else {
req = new RemoveSpecificUserOwner(JsonCallbackEvents.disableButtonEvents(removeUserButton));
}
req.removeServiceUser(list.get(i), user);
// TODO - consider fixing authz in session ?
}
}
});
}
}
}
});
menu.addWidget(new Image(SmallIcons.INSTANCE.helpIcon()));
menu.addWidget(new HTML("<strong>Click on yourself to view your profile (switch context).</strong>"));
// table
CellTable<User> table = request.getTable(new FieldUpdater<User, String>() {
public void update(int i, User user, String s) {
if (session.isSelf(user.getId())) {
session.getTabManager().addTab(new SelfDetailTabItem(user));
} else {
UiElements.generateAlert("You are not authorized", "You are not authorized to view personal details of user " + user.getFullNameWithTitles() + ".");
}
}
});
removeUserButton.setEnabled(false);
JsonUtils.addTableManagedButton(request, table, removeUserButton);
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);
} else {
// PERSON TYPE user
this.titleWidget.setText(Utils.getStrippedStringWithEllipsis(user.getFullNameWithTitles().trim()) + ": Service identities");
// request
final GetSpecificUsersByUser request = new GetSpecificUsersByUser(userId);
final JsonCallbackEvents refreshEvents = JsonCallbackEvents.refreshTableEvents(request);
request.setHideSponsored(true);
// menu
TabMenu menu = new TabMenu();
vp.add(menu);
vp.setCellHeight(menu, "30px");
menu.addWidget(UiElements.getRefreshButton(this));
final CustomButton removeUserButton = TabMenu.getPredefinedButton(ButtonType.REMOVE, "Remove service identity from " + user.getFullName());
menu.addWidget(removeUserButton);
removeUserButton.addClickHandler(new ClickHandler() {
@Override
public void onClick(ClickEvent clickEvent) {
final ArrayList<User> list = request.getTableSelectedList();
UiElements.showDeleteConfirm(list, "Following service identities will be removed from you and you will lose any access to them. Only users associated with service identity can add you again.", new ClickHandler() {
@Override
public void onClick(ClickEvent event) {
// TODO - SHOULD HAVE ONLY ONE CALLBACK TO CORE
for (int i = 0; i < list.size(); i++) {
RemoveSpecificUserOwner req;
// if last, refresh
if (i == list.size() - 1) {
req = new RemoveSpecificUserOwner(JsonCallbackEvents.disableButtonEvents(removeUserButton, refreshEvents));
} else {
req = new RemoveSpecificUserOwner(JsonCallbackEvents.disableButtonEvents(removeUserButton));
}
req.removeServiceUser(user, list.get(i));
// TODO - consider fixing authz in session ?
}
}
});
}
});
menu.addWidget(new Image(SmallIcons.INSTANCE.helpIcon()));
menu.addWidget(new HTML("<strong>Click on service identity to view it's profile (switch context).</strong>"));
// table
CellTable<User> table = request.getTable(new FieldUpdater<User, String>() {
public void update(int i, User user, String s) {
session.getTabManager().addTab(new SelfDetailTabItem(user));
}
});
removeUserButton.setEnabled(false);
JsonUtils.addTableManagedButton(request, table, removeUserButton);
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);
}
contentWidget.setWidget(vp);
return getWidget();
}
use of cz.metacentrum.perun.webgui.json.usersManager.GetSpecificUsersByUser in project perun by CESNET.
the class IdentitySelectorTabItem method draw.
public Widget draw() {
final TabItem tab = this;
HorizontalPanel horizontalSplitter = new HorizontalPanel();
horizontalSplitter.setHeight("500px");
horizontalSplitter.setWidth("100%");
// BASE LAYOUT
DecoratorPanel dp = new DecoratorPanel();
FlexTable baseLayout = new FlexTable();
baseLayout.setCellSpacing(10);
dp.add(baseLayout);
baseLayout.setHTML(0, 0, "<p class=\"subsection-heading\">Select base identity</p>");
baseLayout.setHTML(1, 0, "Your base identity you are currently logged in.");
baseLayout.getFlexCellFormatter().setStyleName(1, 0, "inputFormInlineComment");
Anchor userName = new Anchor();
userName.setText(session.getUser().getFullNameWithTitles());
userName.addStyleName("now-managing");
userName.addStyleName("pointer");
userName.setTitle(session.getUser().getFullNameWithTitles());
userName.addClickHandler(new ClickHandler() {
@Override
public void onClick(ClickEvent event) {
session.getTabManager().addTab(new SelfDetailTabItem(session.getUser()));
session.getTabManager().closeTab(tab, false);
}
});
baseLayout.setWidget(2, 0, new Image(LargeIcons.INSTANCE.userGrayIcon()));
baseLayout.setWidget(2, 1, userName);
baseLayout.getFlexCellFormatter().setColSpan(0, 0, 2);
baseLayout.getFlexCellFormatter().setColSpan(1, 0, 2);
// SERVICE IDENTITIES LAYOUT
DecoratorPanel dp2 = new DecoratorPanel();
final FlexTable serviceLayout = new FlexTable();
serviceLayout.setCellSpacing(10);
dp2.add(serviceLayout);
serviceLayout.setHTML(0, 0, "<p class=\"subsection-heading\">Select service identity</p>");
serviceLayout.setHTML(1, 0, "Service identities you have access to.");
serviceLayout.getFlexCellFormatter().setStyleName(1, 0, "inputFormInlineComment");
horizontalSplitter.add(dp);
horizontalSplitter.setCellWidth(dp, "50%");
horizontalSplitter.setCellVerticalAlignment(dp, HasVerticalAlignment.ALIGN_MIDDLE);
horizontalSplitter.setCellHorizontalAlignment(dp, HasHorizontalAlignment.ALIGN_CENTER);
ScrollPanel sp = new ScrollPanel();
final FlexTable innerTable = new FlexTable();
sp.setWidget(innerTable);
sp.setStyleName("scroll-max-height");
serviceLayout.setWidget(2, 0, sp);
if (session.getEditableUsers().size() > 1) {
// user has service identities
GetSpecificUsersByUser call = new GetSpecificUsersByUser(session.getUser().getId(), new JsonCallbackEvents() {
@Override
public void onFinished(JavaScriptObject jso) {
ArrayList<User> list = JsonUtils.jsoAsList(jso);
if (list != null && !list.isEmpty()) {
int row = 0;
for (User u : list) {
if (u.isSponsoredUser())
continue;
final User u2 = u;
innerTable.setWidget(row, 0, new Image(LargeIcons.INSTANCE.userRedIcon()));
Anchor userName = new Anchor();
userName.setText(u2.getFullNameWithTitles());
userName.addStyleName("now-managing");
userName.addStyleName("pointer");
userName.setTitle(u2.getFullNameWithTitles());
userName.addClickHandler(new ClickHandler() {
@Override
public void onClick(ClickEvent event) {
session.getTabManager().addTab(new SelfDetailTabItem(u2));
session.getTabManager().closeTab(tab, false);
}
});
innerTable.setWidget(row, 1, userName);
row++;
}
} else {
innerTable.setHTML(0, 0, "You have no service identities");
}
}
@Override
public void onLoadingStart() {
innerTable.setWidget(0, 0, new AjaxLoaderImage().loadingStart());
}
@Override
public void onError(PerunError error) {
innerTable.setWidget(0, 0, new AjaxLoaderImage().loadingError(error));
}
});
call.retrieveData();
horizontalSplitter.add(dp2);
horizontalSplitter.setCellWidth(dp2, "50%");
horizontalSplitter.setCellHorizontalAlignment(dp2, HasHorizontalAlignment.ALIGN_CENTER);
horizontalSplitter.setCellVerticalAlignment(dp2, HasVerticalAlignment.ALIGN_MIDDLE);
}
this.contentWidget.setWidget(horizontalSplitter);
return getWidget();
}
use of cz.metacentrum.perun.webgui.json.usersManager.GetSpecificUsersByUser in project perun by CESNET.
the class MemberServiceUsersTabItem method draw.
public Widget draw() {
if (member.getUser().isServiceUser()) {
this.titleWidget.setText(Utils.getStrippedStringWithEllipsis(member.getUser().getFullNameWithTitles().trim()) + ": associated users");
} else {
this.titleWidget.setText(Utils.getStrippedStringWithEllipsis(member.getUser().getFullNameWithTitles().trim()) + ": service identities");
}
VerticalPanel vp = new VerticalPanel();
vp.setSize("100%", "100%");
// MENU
TabMenu menu = new TabMenu();
vp.add(menu);
vp.setCellHeight(menu, "30px");
menu.addWidget(UiElements.getRefreshButton(this));
if (member.getUser().isServiceUser()) {
// request
final GetUsersBySpecificUser request = new GetUsersBySpecificUser(member.getUserId());
request.setCheckable(false);
// table
CellTable<User> table;
if (session.isPerunAdmin()) {
table = request.getTable(new FieldUpdater<User, String>() {
public void update(int i, User user, String s) {
session.getTabManager().addTab(new UserDetailTabItem(user));
}
});
} else {
table = request.getTable();
}
table.addStyleName("perun-table");
table.setWidth("100%");
ScrollPanel sp = new ScrollPanel(table);
sp.addStyleName("perun-tableScrollPanel");
vp.add(sp);
} else {
final GetSpecificUsersByUser request = new GetSpecificUsersByUser(member.getUserId());
request.setCheckable(false);
request.setHideSponsored(true);
// table
CellTable<User> table;
if (session.isPerunAdmin()) {
table = request.getTable(new FieldUpdater<User, String>() {
public void update(int i, User user, String s) {
session.getTabManager().addTab(new UserDetailTabItem(user));
}
});
} else {
table = request.getTable();
}
table.addStyleName("perun-table");
table.setWidth("100%");
ScrollPanel sp = new ScrollPanel(table);
sp.addStyleName("perun-tableScrollPanel");
vp.add(sp);
}
contentWidget.setWidget(vp);
return getWidget();
}
Aggregations