Search in sources :

Example 6 with User

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();
}
Also used : User(cz.metacentrum.perun.webgui.model.User)

Example 7 with User

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);
}
Also used : JsonCallbackEvents(cz.metacentrum.perun.webgui.json.JsonCallbackEvents) User(cz.metacentrum.perun.webgui.model.User) JSONObject(com.google.gwt.json.client.JSONObject) JavaScriptObject(com.google.gwt.core.client.JavaScriptObject) JsonPostClient(cz.metacentrum.perun.webgui.json.JsonPostClient) PerunError(cz.metacentrum.perun.webgui.model.PerunError)

Example 8 with User

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();
}
Also used : User(cz.metacentrum.perun.webgui.model.User) UserDetailTabItem(cz.metacentrum.perun.webgui.tabs.userstabs.UserDetailTabItem) GetUsers(cz.metacentrum.perun.webgui.json.searcher.GetUsers) PerunSearchParametersWidget(cz.metacentrum.perun.webgui.widgets.PerunSearchParametersWidget)

Example 9 with User

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());
        }
    }
}
Also used : Candidate(cz.metacentrum.perun.webgui.model.Candidate) User(cz.metacentrum.perun.webgui.model.User) RichMember(cz.metacentrum.perun.webgui.model.RichMember)

Example 10 with User

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;
}
Also used : JsonCallbackEvents(cz.metacentrum.perun.webgui.json.JsonCallbackEvents) FieldUpdater(com.google.gwt.cell.client.FieldUpdater) User(cz.metacentrum.perun.webgui.model.User) VoManagersTabItem(cz.metacentrum.perun.webgui.tabs.vostabs.VoManagersTabItem) ClickEvent(com.google.gwt.event.dom.client.ClickEvent) ArrayList(java.util.ArrayList) UserDetailTabItem(cz.metacentrum.perun.webgui.tabs.userstabs.UserDetailTabItem) ClickHandler(com.google.gwt.event.dom.client.ClickHandler) CustomButton(cz.metacentrum.perun.webgui.widgets.CustomButton) RemoveAdmin(cz.metacentrum.perun.webgui.json.authzResolver.RemoveAdmin)

Aggregations

User (cz.metacentrum.perun.webgui.model.User)48 JsonCallbackEvents (cz.metacentrum.perun.webgui.json.JsonCallbackEvents)22 ArrayList (java.util.ArrayList)20 ClickEvent (com.google.gwt.event.dom.client.ClickEvent)19 ClickHandler (com.google.gwt.event.dom.client.ClickHandler)19 JavaScriptObject (com.google.gwt.core.client.JavaScriptObject)18 TabMenu (cz.metacentrum.perun.webgui.widgets.TabMenu)18 CustomButton (cz.metacentrum.perun.webgui.widgets.CustomButton)17 FieldUpdater (com.google.gwt.cell.client.FieldUpdater)15 UserDetailTabItem (cz.metacentrum.perun.webgui.tabs.userstabs.UserDetailTabItem)15 TabItem (cz.metacentrum.perun.webgui.tabs.TabItem)13 ExtendedTextBox (cz.metacentrum.perun.webgui.widgets.ExtendedTextBox)9 FindCompleteRichUsers (cz.metacentrum.perun.webgui.json.usersManager.FindCompleteRichUsers)8 Attribute (cz.metacentrum.perun.webgui.model.Attribute)6 PerunError (cz.metacentrum.perun.webgui.model.PerunError)6 FindUsersByIdsNotInRpc (cz.metacentrum.perun.webgui.json.usersManager.FindUsersByIdsNotInRpc)5 GetSpecificUsersByUser (cz.metacentrum.perun.webgui.json.usersManager.GetSpecificUsersByUser)5 ListHandler (com.google.gwt.user.cellview.client.ColumnSortEvent.ListHandler)4 AddAdmin (cz.metacentrum.perun.webgui.json.authzResolver.AddAdmin)4 RemoveAdmin (cz.metacentrum.perun.webgui.json.authzResolver.RemoveAdmin)4