Search in sources :

Example 1 with GetListOfAttributes

use of cz.metacentrum.perun.webgui.json.attributesManager.GetListOfAttributes in project perun by CESNET.

the class EditMailFooterTabItem method draw.

public Widget draw() {
    final FlexTable content = new FlexTable();
    content.setStyleName("inputFormFlexTable");
    content.setWidth("360px");
    final TextArea footer = new TextArea();
    footer.setSize("340px", "200px");
    content.setHTML(0, 0, "Footer text:");
    content.getFlexCellFormatter().setStyleName(0, 0, "itemName");
    content.setWidget(1, 0, footer);
    content.setHTML(2, 0, "This text will be added as footer for all email notifications (replacing {mailFooter} tag in mail definition).");
    content.getFlexCellFormatter().setStyleName(2, 0, "inputFormInlineComment");
    final Map<String, Integer> ids = new HashMap<String, Integer>();
    if (group == null) {
        ids.put("vo", voId);
    } else {
        ids.put("group", groupId);
    }
    final ArrayList<Attribute> list = new ArrayList<Attribute>();
    final GetListOfAttributes call = new GetListOfAttributes(new JsonCallbackEvents() {

        @Override
        public void onFinished(JavaScriptObject jso) {
            list.addAll(JsonUtils.<Attribute>jsoAsList(jso));
            // only if attribute exists
            if (list != null && !list.isEmpty()) {
                for (Attribute a : list) {
                    if (a.getFriendlyName().equalsIgnoreCase("mailFooter")) {
                        // if value not null - enter
                        if (!a.getValue().equalsIgnoreCase("null")) {
                            footer.setText(a.getValue());
                        }
                    }
                }
            }
        }
    });
    ArrayList<String> l = new ArrayList<String>();
    if (group == null) {
        l.add("urn:perun:vo:attribute-def:def:mailFooter");
    } else {
        l.add("urn:perun:group:attribute-def:def:mailFooter");
    }
    call.getListOfAttributes(ids, l);
    final TabItem tab = this;
    VerticalPanel vp = new VerticalPanel();
    TabMenu menu = new TabMenu();
    final CustomButton save = TabMenu.getPredefinedButton(ButtonType.SAVE, ButtonTranslation.INSTANCE.saveMailFooter());
    save.addClickHandler(new ClickHandler() {

        @Override
        public void onClick(ClickEvent clickEvent) {
            // will be set
            ArrayList<Attribute> toSend = new ArrayList<Attribute>();
            // will be removed
            ArrayList<Attribute> toRemove = new ArrayList<Attribute>();
            for (Attribute a : list) {
                String oldValue = a.getValue();
                String newValue = "";
                if (a.getFriendlyName().equalsIgnoreCase("mailFooter")) {
                    newValue = footer.getText();
                } else {
                    // other than mailFooter attributes must be skipped
                    continue;
                }
                if (oldValue.equalsIgnoreCase(newValue) || (oldValue.equalsIgnoreCase("null") && newValue.equalsIgnoreCase(""))) {
                    // skip this cycle
                    continue;
                } else {
                    if (newValue.equalsIgnoreCase("")) {
                        // value was cleared
                        toRemove.add(a);
                    } else {
                        // set value
                        a.setValue(newValue);
                        // value was changed / added
                        toSend.add(a);
                    }
                }
            }
            // requests
            SetAttributes request = new SetAttributes(JsonCallbackEvents.closeTabDisableButtonEvents(save, tab));
            RemoveAttributes removeRequest = new RemoveAttributes(JsonCallbackEvents.closeTabDisableButtonEvents(save, tab));
            // send if not empty
            if (!toRemove.isEmpty()) {
                removeRequest.removeAttributes(ids, toRemove);
            }
            if (!toSend.isEmpty()) {
                request.setAttributes(ids, toSend);
            }
        }
    });
    menu.addWidget(save);
    menu.addWidget(TabMenu.getPredefinedButton(ButtonType.CANCEL, "", new ClickHandler() {

        @Override
        public void onClick(ClickEvent clickEvent) {
            session.getTabManager().closeTab(tab, false);
        }
    }));
    vp.add(content);
    vp.add(menu);
    vp.setCellHeight(menu, "30px");
    vp.setCellHorizontalAlignment(menu, HasHorizontalAlignment.ALIGN_RIGHT);
    this.contentWidget.setWidget(vp);
    return getWidget();
}
Also used : JsonCallbackEvents(cz.metacentrum.perun.webgui.json.JsonCallbackEvents) HashMap(java.util.HashMap) Attribute(cz.metacentrum.perun.webgui.model.Attribute) GetListOfAttributes(cz.metacentrum.perun.webgui.json.attributesManager.GetListOfAttributes) ClickEvent(com.google.gwt.event.dom.client.ClickEvent) ArrayList(java.util.ArrayList) SetAttributes(cz.metacentrum.perun.webgui.json.attributesManager.SetAttributes) TabMenu(cz.metacentrum.perun.webgui.widgets.TabMenu) TabItem(cz.metacentrum.perun.webgui.tabs.TabItem) ClickHandler(com.google.gwt.event.dom.client.ClickHandler) JavaScriptObject(com.google.gwt.core.client.JavaScriptObject) CustomButton(cz.metacentrum.perun.webgui.widgets.CustomButton) RemoveAttributes(cz.metacentrum.perun.webgui.json.attributesManager.RemoveAttributes)

Example 2 with GetListOfAttributes

use of cz.metacentrum.perun.webgui.json.attributesManager.GetListOfAttributes in project perun by CESNET.

the class SelfAuthenticationsTabItem method draw.

public Widget draw() {
    this.titleWidget.setText(Utils.getStrippedStringWithEllipsis(user.getFullNameWithTitles().trim()) + ": Authentication");
    final String notSet = "<i>N/A</i>";
    // content
    ScrollPanel vp = new ScrollPanel();
    vp.setSize("100%", "100%");
    final VerticalPanel innerVp = new VerticalPanel();
    innerVp.setSize("100%", "100%");
    final TabMenu menu = new TabMenu();
    innerVp.add(menu);
    innerVp.setCellHeight(menu, "30px");
    menu.addWidget(UiElements.getRefreshButton(this));
    final FlexTable layout = new FlexTable();
    layout.setSize("100%", "100%");
    vp.add(innerVp);
    innerVp.add(layout);
    layout.setStyleName("perun-table");
    vp.setStyleName("perun-tableScrollPanel");
    session.getUiElements().resizeSmallTabPanel(vp, 350, this);
    FlexTable loginsHeader = new FlexTable();
    loginsHeader.setWidget(0, 0, new Image(LargeIcons.INSTANCE.keyIcon()));
    loginsHeader.setHTML(0, 1, "<p>Logins");
    loginsHeader.getFlexCellFormatter().setStyleName(0, 1, "subsection-heading");
    layout.setWidget(0, 0, loginsHeader);
    FlexTable certHeader = new FlexTable();
    certHeader.setWidget(0, 0, new Image(LargeIcons.INSTANCE.sslCertificatesIcon()));
    certHeader.setHTML(0, 1, "<p>Certificates");
    certHeader.getFlexCellFormatter().setStyleName(0, 1, "subsection-heading");
    layout.setWidget(3, 0, certHeader);
    layout.setHTML(4, 0, "To <strong>add certificate</strong> please visit <a href=\"" + Utils.getIdentityConsolidatorLink(false) + "\" target=\"_blank\">identity consolidator &gt;&gt;</a> and select \"Using personal certificate\" option.<br />&nbsp;");
    FlexTable sshHeader = new FlexTable();
    sshHeader.setWidget(0, 0, new Image(LargeIcons.INSTANCE.serverKeyIcon()));
    sshHeader.setHTML(0, 1, "<p>Kerberos & SSH keys");
    sshHeader.getFlexCellFormatter().setStyleName(0, 1, "subsection-heading");
    layout.setWidget(6, 0, sshHeader);
    // login table
    final FlexTable loginsTable = new FlexTable();
    loginsTable.setStyleName("inputFormFlexTableDark");
    final GetLogins logins = new GetLogins(userId, new JsonCallbackEvents() {

        @Override
        public void onFinished(JavaScriptObject jso) {
            final ArrayList<Attribute> list = JsonUtils.jsoAsList(jso);
            layout.setWidget(1, 0, loginsTable);
            int row = 0;
            if (user.isServiceUser() || user.isSponsoredUser()) {
                CustomButton addLogin = TabMenu.getPredefinedButton(ButtonType.ADD, "Add new login (only for supported namespaces)");
                addLogin.addClickHandler(new ClickHandler() {

                    @Override
                    public void onClick(ClickEvent event) {
                        session.getTabManager().addTabToCurrentTab(new AddLoginTabItem(user, list));
                    }
                });
                loginsTable.setWidget(row, 0, addLogin);
                row++;
            }
            if (list != null && !list.isEmpty()) {
                for (final Attribute a : list) {
                    loginsTable.setHTML(row, 0, "Login in " + a.getFriendlyNameParameter().toUpperCase() + ":");
                    loginsTable.getFlexCellFormatter().setWidth(row, 0, "150px");
                    loginsTable.getFlexCellFormatter().addStyleName(row, 0, "itemName");
                    loginsTable.setHTML(row, 1, a.getValue());
                    loginsTable.getFlexCellFormatter().setWidth(row, 1, "150px");
                    // change password if possible
                    if (Utils.getSupportedPasswordNamespaces().contains(a.getFriendlyNameParameter())) {
                        FlexTable fw = new FlexTable();
                        fw.addStyleName("padding-vertical");
                        CustomButton cb = new CustomButton("Change password…", SmallIcons.INSTANCE.keyIcon(), new ClickHandler() {

                            public void onClick(ClickEvent event) {
                                session.getTabManager().addTabToCurrentTab(new SelfPasswordTabItem(user, a.getFriendlyNameParameter(), a.getValue(), SelfPasswordTabItem.Actions.CHANGE));
                            }
                        });
                        CustomButton cb2 = new CustomButton("Reset password…", SmallIcons.INSTANCE.keyIcon(), new ClickHandler() {

                            public void onClick(ClickEvent event) {
                                // OPEN PASSWORD RESET APPLICATION ON SAME SERVER
                                Window.open("" + Utils.getPasswordResetLink(a.getFriendlyNameParameter()), "_blank", "");
                            }
                        });
                        fw.setWidget(0, 0, cb);
                        if (!user.isServiceUser()) {
                            fw.setWidget(0, 1, cb2);
                        } else {
                            cb.setText("Reset password…");
                        }
                        loginsTable.setWidget(row, 2, fw);
                    }
                    row++;
                }
            } else {
                loginsTable.setHTML(row, 0, "You don't have any login in supported namespaces.");
                loginsTable.getFlexCellFormatter().setStyleName(0, 0, "inputFormInlineComment");
            }
        }

        @Override
        public void onLoadingStart() {
            layout.setWidget(1, 0, new AjaxLoaderImage().loadingStart());
        }

        @Override
        public void onError(PerunError error) {
            layout.setHTML(1, 0, "Error while loading logins.");
            layout.getFlexCellFormatter().setStyleName(1, 0, "serverResponseLabelError");
        }
    });
    logins.retrieveData();
    // certificates table
    final FlexTable certTable = new FlexTable();
    certTable.addStyleName("inputFormFlexTableDark");
    certTable.setHTML(0, 0, "Certificates: ");
    certTable.getFlexCellFormatter().addStyleName(0, 0, "itemName");
    certTable.getFlexCellFormatter().setWidth(0, 0, "150px");
    layout.setWidget(5, 0, certTable);
    final GetUserExtSources ueses = new GetUserExtSources(userId);
    ueses.setEvents(new JsonCallbackEvents() {

        @Override
        public void onFinished(JavaScriptObject jso) {
            ArrayList<UserExtSource> list = JsonUtils.jsoAsList(jso);
            if (list != null && !list.isEmpty()) {
                boolean found = false;
                FlexTable tab = new FlexTable();
                // rowcounter
                int i = 0;
                for (final UserExtSource a : list) {
                    if (a.getExtSource().getType().equals("cz.metacentrum.perun.core.impl.ExtSourceX509")) {
                        found = true;
                        tab.setHTML(i++, 0, "<strong>" + a.getLogin() + "</strong>");
                        tab.setHTML(i++, 0, "Issuer: " + a.getExtSource().getName());
                        if (!a.isPersistent()) {
                            CustomButton removeButton = new CustomButton("Remove", SmallIcons.INSTANCE.deleteIcon(), new ClickHandler() {

                                @Override
                                public void onClick(ClickEvent event) {
                                    RemoveUserExtSource remove = new RemoveUserExtSource(new JsonCallbackEvents() {

                                        @Override
                                        public void onFinished(JavaScriptObject jso) {
                                            // reload whole tab
                                            ueses.retrieveData();
                                        }
                                    });
                                    remove.removeUserExtSource(userId, a.getId());
                                }
                            });
                            // add button to table
                            tab.getFlexCellFormatter().setRowSpan(i - 2, 1, 2);
                            tab.setWidget(i - 2, 1, removeButton);
                        }
                    }
                }
                if (found) {
                    certTable.setWidget(0, 1, tab);
                } else {
                    certTable.setHTML(0, 1, notSet);
                }
            } else {
                certTable.setHTML(0, 1, notSet);
            }
        }

        @Override
        public void onError(PerunError error) {
            certTable.setHTML(0, 1, "Error while loading certificates. Refresh page to retry.");
            certTable.getFlexCellFormatter().setStyleName(0, 1, "serverResponseLabelError");
        }

        @Override
        public void onLoadingStart() {
            certTable.setWidget(0, 1, new Image(AjaxLoaderImage.SMALL_IMAGE_URL));
        }
    });
    ueses.retrieveData();
    // Kerberos and SSH table
    Map<String, Integer> ids = new HashMap<>();
    ids.put("user", userId);
    final PerunAttributeTableWidget table = new PerunAttributeTableWidget(ids);
    table.setDark(true);
    table.setDescriptionShown(true);
    final GetListOfAttributes attrs2 = new GetListOfAttributes(new JsonCallbackEvents() {

        @Override
        public void onFinished(JavaScriptObject jso) {
            table.add(JsonUtils.<Attribute>jsoAsList(jso));
            layout.setWidget(7, 0, table);
        }

        @Override
        public void onError(PerunError error) {
            layout.setHTML(7, 0, "Error while loading Kerberos and SSH settings. Refresh page to retry.");
            layout.getFlexCellFormatter().setStyleName(7, 0, "serverResponseLabelError");
        }

        @Override
        public void onLoadingStart() {
            layout.setWidget(7, 0, new AjaxLoaderImage().loadingStart());
        }
    });
    ArrayList<String> list2 = new ArrayList<String>();
    list2.add("urn:perun:user:attribute-def:def:kerberosAdminPrincipal");
    list2.add("urn:perun:user:attribute-def:def:sshPublicAdminKey");
    list2.add("urn:perun:user:attribute-def:def:sshPublicKey");
    attrs2.getListOfAttributes(ids, list2);
    this.contentWidget.setWidget(vp);
    return getWidget();
}
Also used : JsonCallbackEvents(cz.metacentrum.perun.webgui.json.JsonCallbackEvents) AjaxLoaderImage(cz.metacentrum.perun.webgui.widgets.AjaxLoaderImage) Attribute(cz.metacentrum.perun.webgui.model.Attribute) HashMap(java.util.HashMap) ClickEvent(com.google.gwt.event.dom.client.ClickEvent) ArrayList(java.util.ArrayList) PerunAttributeTableWidget(cz.metacentrum.perun.webgui.widgets.PerunAttributeTableWidget) AjaxLoaderImage(cz.metacentrum.perun.webgui.widgets.AjaxLoaderImage) RemoveUserExtSource(cz.metacentrum.perun.webgui.json.usersManager.RemoveUserExtSource) CustomButton(cz.metacentrum.perun.webgui.widgets.CustomButton) GetLogins(cz.metacentrum.perun.webgui.json.attributesManager.GetLogins) GetListOfAttributes(cz.metacentrum.perun.webgui.json.attributesManager.GetListOfAttributes) TabMenu(cz.metacentrum.perun.webgui.widgets.TabMenu) ClickHandler(com.google.gwt.event.dom.client.ClickHandler) JavaScriptObject(com.google.gwt.core.client.JavaScriptObject) UserExtSource(cz.metacentrum.perun.webgui.model.UserExtSource) RemoveUserExtSource(cz.metacentrum.perun.webgui.json.usersManager.RemoveUserExtSource) GetUserExtSources(cz.metacentrum.perun.webgui.json.usersManager.GetUserExtSources) PerunError(cz.metacentrum.perun.webgui.model.PerunError)

Example 3 with GetListOfAttributes

use of cz.metacentrum.perun.webgui.json.attributesManager.GetListOfAttributes in project perun by CESNET.

the class UserDetailTabItem method loadCertificatesLoginsPasswords.

private Widget loadCertificatesLoginsPasswords() {
    // set content
    final VerticalPanel attributesTable = new VerticalPanel();
    final TabMenu menu = new TabMenu();
    attributesTable.add(menu);
    attributesTable.setWidth("100%");
    final ScrollPanel sp = new ScrollPanel();
    sp.setStyleName("perun-tableScrollPanel");
    session.getUiElements().resizeSmallTabPanel(sp, 350, this);
    sp.setWidth("100%");
    //attributesTable.setStyleName("userDetailTable");
    // clear logins when page refreshed
    userLoginAttrs.clear();
    // ids used for attribute handling
    Map<String, Integer> ids = new HashMap<String, Integer>();
    ids.put("user", userId);
    // attribute table
    final PerunAttributeTableWidget table = new PerunAttributeTableWidget(ids);
    table.setDescriptionShown(true);
    table.setDisplaySaveButton(false);
    // load data
    GetListOfAttributes attributes = new GetListOfAttributes(new JsonCallbackEvents() {

        public void onFinished(JavaScriptObject jso) {
            userLoginAttrs.addAll(JsonUtils.<Attribute>jsoAsList(jso));
            userLoginAttrs = new TableSorter<Attribute>().sortByAttrNameTranslation(userLoginAttrs);
            for (Attribute a : userLoginAttrs) {
                if (a.getFriendlyName().equalsIgnoreCase("userCertificates")) {
                    table.add(a);
                } else if (a.getFriendlyName().equalsIgnoreCase("sshPublicKey")) {
                    table.add(a);
                } else if (a.getFriendlyName().equalsIgnoreCase("kerberosAdminPrincipal")) {
                    table.add(a);
                } else if (a.getFriendlyName().equalsIgnoreCase("sshPublicAdminKey")) {
                    table.add(a);
                }
            }
            // build attr table
            table.build();
            menu.addWidget(table.getSaveButton());
            // content
            VerticalPanel vpContent = new VerticalPanel();
            vpContent.add(table.asWidget());
            FlexTable innerTable = new FlexTable();
            innerTable.setCellPadding(5);
            vpContent.add(innerTable);
            // set content to page
            sp.add(vpContent);
            attributesTable.add(sp);
            int rowCount = 0;
            for (final Attribute a : userLoginAttrs) {
                if (a.getBaseFriendlyName().equalsIgnoreCase("login-namespace")) {
                    if (a.getValueAsObject() != null) {
                        // name
                        innerTable.setHTML(rowCount, 0, "<strong>" + a.getDisplayName() + "</strong>");
                        // value
                        innerTable.setHTML(rowCount, 1, a.getValue());
                        // change password
                        if (Utils.getSupportedPasswordNamespaces().contains(a.getFriendlyNameParameter())) {
                            CustomButton cb = new CustomButton("Change password…", SmallIcons.INSTANCE.keyIcon(), new ClickHandler() {

                                public void onClick(ClickEvent event) {
                                    session.getTabManager().addTabToCurrentTab(new SelfPasswordTabItem(user, a.getFriendlyNameParameter(), a.getValue(), SelfPasswordTabItem.Actions.CHANGE));
                                }
                            });
                            innerTable.setWidget(rowCount, 2, cb);
                        }
                        rowCount++;
                    }
                }
            }
        }
    });
    HashSet<String> set = new HashSet<String>();
    set.add("urn:perun:user:attribute-def:def:userCertificates");
    set.add("urn:perun:user:attribute-def:def:kerberosAdminPrincipal");
    set.add("urn:perun:user:attribute-def:def:sshPublicKey");
    set.add("urn:perun:user:attribute-def:def:sshPublicAdminKey");
    set.add("urn:perun:user:attribute-def:def:login-namespace:mu");
    set.add("urn:perun:user:attribute-def:def:login-namespace:einfra");
    set.add("urn:perun:user:attribute-def:def:login-namespace:sitola");
    set.add("urn:perun:user:attribute-def:def:login-namespace:egi-ui");
    set.add("urn:perun:user:attribute-def:def:login-namespace:cesnet");
    set.add("urn:perun:user:attribute-def:def:login-namespace:meta");
    set.add("urn:perun:user:attribute-def:def:login-namespace:einfra-services");
    set.add("urn:perun:user:attribute-def:def:login-namespace:shongo");
    // TODO - FIXME - must be dynamic !!
    for (String namespace : Utils.getSupportedPasswordNamespaces()) {
        set.add("urn:perun:user:attribute-def:def:login-namespace:" + namespace);
    }
    // TODO - remove SHONGO
    ArrayList<String> list = JsonUtils.setToList(set);
    attributes.getListOfAttributes(ids, list);
    return attributesTable;
}
Also used : JsonCallbackEvents(cz.metacentrum.perun.webgui.json.JsonCallbackEvents) HashMap(java.util.HashMap) GetListOfAttributes(cz.metacentrum.perun.webgui.json.attributesManager.GetListOfAttributes) ClickEvent(com.google.gwt.event.dom.client.ClickEvent) ClickHandler(com.google.gwt.event.dom.client.ClickHandler) JavaScriptObject(com.google.gwt.core.client.JavaScriptObject) CustomButton(cz.metacentrum.perun.webgui.widgets.CustomButton) HashSet(java.util.HashSet)

Example 4 with GetListOfAttributes

use of cz.metacentrum.perun.webgui.json.attributesManager.GetListOfAttributes in project perun by CESNET.

the class SelfVosTabItem method displayVoSubtab.

/**
	 * Internal method which renders subtab for each (selected) VO
	 *
	 * @param vo VO to render preferences for
	 * @return subtab widget
	 */
private Widget displayVoSubtab(final VirtualOrganization vo) {
    // do the layout
    HorizontalPanel horizontalSplitter = new HorizontalPanel();
    horizontalSplitter.setSize("100%", "100%");
    final VerticalPanel leftPanel = new VerticalPanel();
    final VerticalPanel rightPanel = new VerticalPanel();
    horizontalSplitter.add(leftPanel);
    horizontalSplitter.add(rightPanel);
    horizontalSplitter.setCellWidth(leftPanel, "50%");
    horizontalSplitter.setCellWidth(rightPanel, "50%");
    // VO overview
    FlexTable voHeader = new FlexTable();
    voHeader.setWidget(0, 0, new Image(LargeIcons.INSTANCE.buildingIcon()));
    voHeader.setHTML(0, 1, "<p class=\"subsection-heading\">" + vo.getName() + "</p>");
    final FlexTable voOverview = new FlexTable();
    voOverview.setStyleName("inputFormFlexTableDark");
    leftPanel.add(voHeader);
    leftPanel.add(voOverview);
    GetAttributes voAttrsCall = new GetAttributes(new JsonCallbackEvents() {

        @Override
        public void onFinished(JavaScriptObject jso) {
            ArrayList<Attribute> attrs = JsonUtils.jsoAsList(jso);
            int i = 0;
            for (Attribute a : attrs) {
                if (a.getFriendlyName().equalsIgnoreCase("userManualsLink")) {
                    voOverview.setHTML(i, 0, "User's manuals:");
                    Anchor link = new Anchor(a.getValue(), a.getValue());
                    link.getElement().setPropertyString("target", "_blank");
                    voOverview.setWidget(i, 1, link);
                    i++;
                } else if (a.getFriendlyName().equalsIgnoreCase("dashboardLink")) {
                    voOverview.setHTML(i, 0, "Dashboard:");
                    Anchor link = new Anchor(a.getValue(), a.getValue());
                    link.getElement().setPropertyString("target", "_blank");
                    voOverview.setWidget(i, 1, link);
                    i++;
                } else if (a.getFriendlyName().equalsIgnoreCase("contactEmail")) {
                    voOverview.setHTML(i, 0, "VO contact:");
                    voOverview.setHTML(i, 1, a.getValue());
                    i++;
                }
            }
            // no rows in selected result
            if (i < 1) {
                voOverview.setHTML(i, 0, "VO doesn't provide any details or contacts about itself.");
                voOverview.getFlexCellFormatter().setStyleName(i, 0, "inputFormInlineComment");
            } else {
                for (int n = 0; n < voOverview.getRowCount(); n++) {
                    voOverview.getFlexCellFormatter().setStyleName(n, 0, "itemName");
                    voOverview.getFlexCellFormatter().setWidth(n, 0, "200px");
                }
            }
        }

        @Override
        public void onError(PerunError error) {
            voOverview.setHTML(0, 0, "Error while loading");
        }

        @Override
        public void onLoadingStart() {
            voOverview.setWidget(0, 0, new AjaxLoaderImage());
        }
    });
    voAttrsCall.getVoAttributes(vo.getId());
    voAttrsCall.retrieveData();
    // CONTACT INFO
    FlexTable contactHeader = new FlexTable();
    contactHeader.setWidget(0, 0, new Image(LargeIcons.INSTANCE.vcardIcon()));
    contactHeader.setHTML(0, 1, "<p class=\"subsection-heading\">Contact</p>");
    final PerunAttributeTableWidget contactTable = new PerunAttributeTableWidget();
    contactTable.setDark(true);
    contactTable.setDisplaySaveButton(false);
    leftPanel.add(contactHeader);
    final GetListOfAttributes attributes = new GetListOfAttributes(new JsonCallbackEvents() {

        @Override
        public void onFinished(JavaScriptObject jso) {
            contactTable.add(new TableSorter<Attribute>().sortByAttrNameTranslation(JsonUtils.<Attribute>jsoAsList(jso)));
            leftPanel.add(contactTable.getSaveButton());
            leftPanel.setCellHeight(contactTable.getSaveButton(), "50px");
            leftPanel.add(contactTable);
        }
    });
    final ArrayList<String> list = new ArrayList<String>();
    list.add("urn:perun:member:attribute-def:def:organization");
    list.add("urn:perun:member:attribute-def:def:workplace");
    list.add("urn:perun:member:attribute-def:opt:researchGroup");
    list.add("urn:perun:member:attribute-def:def:mail");
    list.add("urn:perun:member:attribute-def:def:phone");
    list.add("urn:perun:member:attribute-def:def:address");
    GetMemberByUser mem = new GetMemberByUser(vo.getId(), userId, new JsonCallbackEvents() {

        @Override
        public void onFinished(JavaScriptObject jso) {
            Member m = jso.cast();
            HashMap<String, Integer> ids = new HashMap<String, Integer>();
            ids.put("member", m.getId());
            contactTable.setIds(ids);
            attributes.getListOfAttributes(ids, list);
        }
    });
    mem.retrieveData();
    // MEMBERSHIP STATE
    FlexTable membershipHeader = new FlexTable();
    membershipHeader.setWidget(0, 0, new Image(LargeIcons.INSTANCE.userGreenIcon()));
    membershipHeader.setHTML(0, 1, "<p class=\"subsection-heading\">Membership</p>");
    // Membership table
    final FlexTable memberLayout = new FlexTable();
    memberLayout.setStyleName("inputFormFlexTableDark");
    rightPanel.add(membershipHeader);
    rightPanel.add(memberLayout);
    GetMemberByUser call = new GetMemberByUser(vo.getId(), userId, new JsonCallbackEvents() {

        @Override
        public void onFinished(JavaScriptObject jso) {
            final Member m = jso.cast();
            memberLayout.setHTML(0, 0, "Status:");
            memberLayout.setHTML(1, 0, "Expiration:");
            memberLayout.getFlexCellFormatter().setStyleName(0, 0, "itemName");
            memberLayout.getFlexCellFormatter().setStyleName(1, 0, "itemName");
            // fill inner layout
            PerunStatusWidget<Member> statusWidget;
            if (session.isVoAdmin(vo.getId())) {
                JsonCallbackEvents event = new JsonCallbackEvents() {

                    @Override
                    public void onFinished(JavaScriptObject jso) {
                        // REFRESH PARENT TAB
                        draw();
                    }
                };
                statusWidget = new PerunStatusWidget<Member>(m, user.getFullName(), event);
            } else {
                statusWidget = new PerunStatusWidget<Member>(m, user.getFullName(), null);
            }
            memberLayout.setWidget(0, 1, statusWidget);
            HashMap<String, Integer> ids = new HashMap<String, Integer>();
            ids.put("member", m.getId());
            GetListOfAttributes attrCall = new GetListOfAttributes(new JsonCallbackEvents() {

                @Override
                public void onFinished(JavaScriptObject jso) {
                    ArrayList<Attribute> la = JsonUtils.jsoAsList(jso);
                    if (la != null && !la.isEmpty()) {
                        for (Attribute a : la) {
                            if ("urn:perun:member:attribute-def:def:membershipExpiration".equals(a.getName())) {
                                RichMember rm = m.cast();
                                // store value into richmember
                                rm.setAttribute(a);
                                memberLayout.setWidget(1, 1, new MembershipExpirationWidget(rm));
                            }
                        }
                    }
                }
            });
            ArrayList<String> ls = new ArrayList<String>();
            ls.add("urn:perun:member:attribute-def:def:membershipExpiration");
            attrCall.getListOfAttributes(ids, ls);
        }

        @Override
        public void onLoadingStart() {
            memberLayout.setWidget(0, 0, new AjaxLoaderImage());
        }

        @Override
        public void onError(PerunError error) {
            memberLayout.setWidget(0, 0, new AjaxLoaderImage().loadingError(error));
        }
    });
    call.retrieveData();
    // RESOURCES SETTINGS
    FlexTable resourcesSettingsHeader = new FlexTable();
    resourcesSettingsHeader.setWidget(0, 0, new Image(LargeIcons.INSTANCE.settingToolsIcon()));
    resourcesSettingsHeader.setHTML(0, 1, "<p class=\"subsection-heading\">Resources settings</p>");
    FlexTable resourcesSettingsTable = new FlexTable();
    resourcesSettingsTable.setStyleName("inputFormFlexTable");
    Anchor a = new Anchor();
    a.setText("Go to Resources settings page >>");
    a.setStyleName("pointer");
    a.addClickHandler(new ClickHandler() {

        @Override
        public void onClick(ClickEvent event) {
            if (tabPanel != null) {
                // resource settings tab is next to this one
                SelfResourcesSettingsTabItem tab = ((SelfResourcesSettingsTabItem) tabPanel.getTabItem(tabPanel.getSelectedIndex() + 1));
                tab.setVo(vo);
                tab.draw();
                tabPanel.selectTab(tabPanel.getSelectedIndex() + 1);
            } else {
                session.getTabManager().addTab(new SelfResourcesSettingsTabItem(user, vo), true);
            }
        }
    });
    resourcesSettingsTable.setHTML(0, 0, "Manage VO resources specific settings like: shell, data/files quotas, mailing list exclusions");
    resourcesSettingsTable.getFlexCellFormatter().setStyleName(0, 0, "inputFormInlineComment");
    resourcesSettingsTable.setWidget(1, 0, a);
    rightPanel.add(resourcesSettingsHeader);
    rightPanel.add(resourcesSettingsTable);
    // GROUPS
    FlexTable groupsHeader = new FlexTable();
    groupsHeader.setWidget(0, 0, new Image(LargeIcons.INSTANCE.groupIcon()));
    groupsHeader.setHTML(0, 1, "<p class=\"subsection-heading\">Groups</p>");
    final FlexTable groupsTable = new FlexTable();
    groupsTable.setStyleName("inputFormFlexTable");
    rightPanel.add(groupsHeader);
    rightPanel.add(groupsTable);
    GetMemberByUser memCall = new GetMemberByUser(vo.getId(), userId, new JsonCallbackEvents() {

        @Override
        public void onFinished(JavaScriptObject jso) {
            Member m = jso.cast();
            GetMemberGroups groupsCall = new GetMemberGroups(m.getId(), new JsonCallbackEvents() {

                @Override
                public void onError(PerunError error) {
                    groupsTable.setWidget(0, 0, new AjaxLoaderImage().loadingError(error));
                }

                @Override
                public void onFinished(JavaScriptObject jso) {
                    ArrayList<Group> list = JsonUtils.jsoAsList(jso);
                    if (list.isEmpty() || list == null) {
                        groupsTable.setHTML(0, 0, "You aren't member of any group in this VO.");
                        return;
                    }
                    groupsTable.addStyleName("userDetailTable");
                    groupsTable.setHTML(0, 0, "<strong>Name</strong>");
                    groupsTable.setHTML(0, 1, "<strong>Description</strong>");
                    for (int i = 0; i < list.size(); i++) {
                        groupsTable.setHTML(i + 1, 0, list.get(i).getName());
                        groupsTable.setHTML(i + 1, 1, list.get(i).getDescription());
                    }
                }
            });
            groupsCall.retrieveData();
        }

        @Override
        public void onError(PerunError error) {
            groupsTable.setWidget(0, 0, new AjaxLoaderImage().loadingError(error));
        }

        @Override
        public void onLoadingStart() {
            groupsTable.setWidget(0, 0, new AjaxLoaderImage().loadingStart());
        }
    });
    memCall.retrieveData();
    return horizontalSplitter;
}
Also used : JsonCallbackEvents(cz.metacentrum.perun.webgui.json.JsonCallbackEvents) HashMap(java.util.HashMap) ClickEvent(com.google.gwt.event.dom.client.ClickEvent) ArrayList(java.util.ArrayList) GetVosWhereUserIsMember(cz.metacentrum.perun.webgui.json.usersManager.GetVosWhereUserIsMember) GetAttributes(cz.metacentrum.perun.webgui.json.attributesManager.GetAttributes) GetListOfAttributes(cz.metacentrum.perun.webgui.json.attributesManager.GetListOfAttributes) ClickHandler(com.google.gwt.event.dom.client.ClickHandler) JavaScriptObject(com.google.gwt.core.client.JavaScriptObject) GetMemberByUser(cz.metacentrum.perun.webgui.json.membersManager.GetMemberByUser) GetMemberGroups(cz.metacentrum.perun.webgui.json.groupsManager.GetMemberGroups)

Example 5 with GetListOfAttributes

use of cz.metacentrum.perun.webgui.json.attributesManager.GetListOfAttributes in project perun by CESNET.

the class SelfPersonalTabItem method draw.

public Widget draw() {
    // content
    final ScrollPanel sp = new ScrollPanel();
    sp.setSize("100%", "100%");
    sp.setStyleName("perun-tableScrollPanel");
    session.getUiElements().resizeSmallTabPanel(sp, 350, this);
    HorizontalPanel horizontalSplitter = new HorizontalPanel();
    horizontalSplitter.setStyleName("perun-table");
    horizontalSplitter.setSize("100%", "100%");
    final VerticalPanel leftPanel = new VerticalPanel();
    final VerticalPanel rightPanel = new VerticalPanel();
    horizontalSplitter.add(leftPanel);
    horizontalSplitter.add(rightPanel);
    horizontalSplitter.setCellWidth(leftPanel, "50%");
    horizontalSplitter.setCellWidth(rightPanel, "50%");
    final VerticalPanel innerVp = new VerticalPanel();
    innerVp.setSize("100%", "100%");
    final TabMenu menu = new TabMenu();
    innerVp.add(menu);
    innerVp.setCellHeight(menu, "30px");
    menu.addWidget(UiElements.getRefreshButton(this));
    innerVp.add(horizontalSplitter);
    sp.setWidget(innerVp);
    FlexTable quickHeader = new FlexTable();
    quickHeader.setWidget(0, 0, new Image(LargeIcons.INSTANCE.directionIcon()));
    quickHeader.setHTML(0, 1, "<p class=\"subsection-heading\">Quick links</p>");
    FlexTable prefHeader = new FlexTable();
    prefHeader.setWidget(0, 0, new Image(LargeIcons.INSTANCE.settingToolsIcon()));
    prefHeader.setHTML(0, 1, "<p class=\"subsection-heading\">Global settings</p>");
    leftPanel.add(quickHeader);
    rightPanel.add(prefHeader);
    // widgets
    final ExtendedTextBox preferredEmail = new ExtendedTextBox();
    preferredEmail.getTextBox().setWidth("300px");
    preferredEmail.setWidth("300px");
    final ListBox preferredLanguage = new ListBox();
    preferredLanguage.addItem("Not selected", "");
    if (!Utils.getNativeLanguage().isEmpty()) {
        preferredLanguage.addItem(Utils.getNativeLanguage().get(2), Utils.getNativeLanguage().get(0));
    }
    preferredLanguage.addItem("English", "en");
    final ListBox timezone = new ListBox();
    timezone.addItem("Not set", "null");
    for (String zone : Utils.getTimezones()) {
        timezone.addItem(zone, zone);
    }
    final PreferredShellsWidget preferredShellsWidget = new PreferredShellsWidget();
    final PreferredUnixGroupNameWidget preferredUnixGroupNameWidget = new PreferredUnixGroupNameWidget();
    // content
    final FlexTable settingsTable = new FlexTable();
    settingsTable.setStyleName("inputFormFlexTableDark");
    settingsTable.setHTML(1, 0, "Preferred&nbsp;mail:");
    settingsTable.setWidget(1, 1, preferredEmail);
    settingsTable.getFlexCellFormatter().setRowSpan(1, 0, 2);
    settingsTable.setHTML(2, 0, "");
    settingsTable.setHTML(3, 0, "Preferred&nbsp;language:");
    settingsTable.setWidget(3, 1, preferredLanguage);
    settingsTable.setHTML(4, 0, "Timezone:");
    settingsTable.setWidget(4, 1, timezone);
    settingsTable.setHTML(5, 0, "Preferred shells:");
    settingsTable.setWidget(5, 1, preferredShellsWidget);
    settingsTable.getFlexCellFormatter().setRowSpan(5, 0, 2);
    settingsTable.setHTML(6, 0, "List of preferred shells ordered from the most preferred to least is used to determine your shell on provided resources. If none of preferred shells is available on resource (or no preferred shell is set), resource's default is used.");
    settingsTable.getFlexCellFormatter().setStyleName(6, 0, "inputFormInlineComment");
    settingsTable.setHTML(7, 0, "Preferred primary unix groups names:");
    for (int i = 1; i < settingsTable.getRowCount(); i++) {
        if (i == 2 || i == 6)
            continue;
        settingsTable.getFlexCellFormatter().addStyleName(i, 0, "itemName");
    }
    // SET SAVE CLICK HANDLER
    final CustomButton save = TabMenu.getPredefinedButton(ButtonType.SAVE, "Save changes in preferences");
    //TabMenu menu = new TabMenu();
    //menu.addWidget(save);
    settingsTable.setWidget(0, 0, save);
    final GetListOfAttributes attrsCall = new GetListOfAttributes();
    // list of wanted attributes
    final ArrayList<String> list = new ArrayList<String>();
    list.add("urn:perun:user:attribute-def:def:preferredLanguage");
    list.add("urn:perun:user:attribute-def:def:preferredMail");
    list.add("urn:perun:user:attribute-def:def:timezone");
    list.add("urn:perun:user:attribute-def:def:preferredShells");
    for (String s : Utils.getNamespacesForPreferredGroupNames()) {
        list.add("urn:perun:user:attribute-def:def:preferredUnixGroupName-namespace:" + s);
    }
    final Map<String, Integer> ids = new HashMap<String, Integer>();
    ids.put("user", userId);
    save.addClickHandler(new ClickHandler() {

        public void onClick(ClickEvent event) {
            // will be set
            ArrayList<Attribute> toSend = new ArrayList<Attribute>();
            for (final Attribute a : userAttrs) {
                String oldValue = a.getValue();
                String newValue = "";
                if (a.getFriendlyName().equalsIgnoreCase("preferredLanguage")) {
                    newValue = preferredLanguage.getValue(preferredLanguage.getSelectedIndex());
                } else if (a.getFriendlyName().equalsIgnoreCase("timezone")) {
                    newValue = timezone.getValue(timezone.getSelectedIndex());
                } else if (a.getFriendlyName().equalsIgnoreCase("preferredMail")) {
                    newValue = preferredEmail.getTextBox().getValue().trim();
                } else if (a.getFriendlyName().equalsIgnoreCase("preferredShells")) {
                    String s = preferredShellsWidget.getAttribute().getValue();
                    newValue = (!s.equalsIgnoreCase("null")) ? s : "";
                } else if (a.getBaseFriendlyName().equals("preferredUnixGroupName-namespace")) {
                    String s = preferredUnixGroupNameWidget.getAttribute(a.getName()).getValue();
                    newValue = (!s.equalsIgnoreCase("null")) ? s : "";
                } else {
                    // other than contact attributes must be skipped
                    continue;
                }
                if (oldValue.equals(newValue) || (oldValue.equalsIgnoreCase("null") && ("").equals(newValue))) {
                    // skip this cycle
                    continue;
                } else {
                    if (("").equals(newValue) || ("null").equals(newValue)) {
                        Attribute newA = JsonUtils.clone(a).cast();
                        // set value
                        newA.setValueAsJso(null);
                        // value was cleared
                        toSend.add(newA);
                    // preferred email can't be ever removed from here
                    } else {
                        if (a.getFriendlyName().equalsIgnoreCase("preferredMail")) {
                            RequestPreferredEmailChange call = new RequestPreferredEmailChange(JsonCallbackEvents.disableButtonEvents(save));
                            call.requestChange(user, newValue);
                        } else {
                            Attribute newA = JsonUtils.clone(a).cast();
                            // set value
                            newA.setValue(newValue);
                            // value was changed / added
                            toSend.add(newA);
                        }
                    }
                }
            }
            // ids
            Map<String, Integer> localIds = new HashMap<String, Integer>();
            localIds.put("user", userId);
            // requests
            SetAttributes request = new SetAttributes(JsonCallbackEvents.disableButtonEvents(save, new JsonCallbackEvents() {

                @Override
                public void onFinished(JavaScriptObject jso) {
                    attrsCall.getListOfAttributes(ids, list);
                }
            }));
            // send if not empty
            if (!toSend.isEmpty()) {
                request.setAttributes(localIds, toSend);
            }
        }
    });
    // GET USER ATTRIBUTES BY NAME
    attrsCall.setEvents(new JsonCallbackEvents() {

        @Override
        public void onFinished(JavaScriptObject jso) {
            userAttrs = JsonUtils.jsoAsList(jso);
            settingsTable.setWidget(1, 1, preferredEmail);
            settingsTable.setWidget(3, 1, preferredLanguage);
            settingsTable.setWidget(4, 1, timezone);
            settingsTable.setWidget(5, 1, preferredShellsWidget);
            settingsTable.setWidget(7, 1, preferredUnixGroupNameWidget);
            // clear on re-init
            preferredUnixGroupNameWidget.clear();
            for (final Attribute a : userAttrs) {
                if (a.getValue() == null || a.getValue().equalsIgnoreCase("null")) {
                    if (a.getFriendlyName().equalsIgnoreCase("preferredShells")) {
                        // don't skip this null attribute
                        preferredShellsWidget.setAttribute(a);
                    }
                    if (a.getBaseFriendlyName().equalsIgnoreCase("preferredUnixGroupName-namespace")) {
                        // don't skip this null attribute
                        preferredUnixGroupNameWidget.setAttribute((Attribute) JsonUtils.clone(a).cast());
                    }
                    // skip null attributes
                    continue;
                }
                if (a.getBaseFriendlyName().equalsIgnoreCase("preferredUnixGroupName-namespace")) {
                    // don't skip this null attribute
                    preferredUnixGroupNameWidget.setAttribute((Attribute) JsonUtils.clone(a).cast());
                } else if (a.getFriendlyName().equalsIgnoreCase("preferredLanguage")) {
                    if (!Utils.getNativeLanguage().isEmpty() && a.getValue().equals(Utils.getNativeLanguage().get(0))) {
                        preferredLanguage.setSelectedIndex(1);
                    } else if (a.getValue().equals("en")) {
                        preferredLanguage.setSelectedIndex(2);
                    }
                } else if (a.getFriendlyName().equalsIgnoreCase("preferredMail")) {
                    preferredEmail.getTextBox().setText(a.getValue());
                    // display notice if there is any valid pending change request
                    GetPendingPreferredEmailChanges get = new GetPendingPreferredEmailChanges(user.getId(), new JsonCallbackEvents() {

                        @Override
                        public void onFinished(JavaScriptObject jso) {
                            // process returned value
                            if (jso != null) {
                                BasicOverlayType basic = jso.cast();
                                emails = basic.getListOfStrings();
                                if (!emails.isEmpty()) {
                                    for (String s : emails) {
                                        if (!s.equals(preferredEmail.getTextBox().getText().trim())) {
                                            resultText += s + ", ";
                                        }
                                    }
                                    if (resultText.length() >= 2)
                                        resultText = resultText.substring(0, resultText.length() - 2);
                                    settingsTable.setHTML(2, 0, "You have pending change request. Please check inbox of: " + resultText + " for validation email.");
                                    settingsTable.getFlexCellFormatter().setStyleName(2, 0, "inputFormInlineComment serverResponseLabelError");
                                }
                            }
                            // set validator with respect to returned values
                            preferredEmail.setValidator(new ExtendedTextBox.TextBoxValidator() {

                                @Override
                                public boolean validateTextBox() {
                                    if (preferredEmail.getTextBox().getText().trim().isEmpty()) {
                                        preferredEmail.setError("Preferred email address can't be empty.");
                                        return false;
                                    } else if (!JsonUtils.isValidEmail(preferredEmail.getTextBox().getText().trim())) {
                                        preferredEmail.setError("Not valid email address format.");
                                        return false;
                                    }
                                    // update notice under textbox on any cut/past/type action
                                    if (!preferredEmail.getTextBox().getText().trim().equals(a.getValue())) {
                                        settingsTable.setHTML(2, 0, "No changes are saved, until new address is validated. After change please check your inbox for validation mail." + ((!resultText.isEmpty()) ? "<p><span class=\"serverResponseLabelError\">You have pending change request. Please check inbox of: " + resultText + " for validation email.</span>" : ""));
                                        settingsTable.getFlexCellFormatter().setStyleName(2, 0, "inputFormInlineComment");
                                    } else {
                                        settingsTable.setHTML(2, 0, (!resultText.isEmpty()) ? "You have pending change request. Please check inbox of: " + resultText + " for validation email." : "");
                                        settingsTable.getFlexCellFormatter().setStyleName(2, 0, "inputFormInlineComment serverResponseLabelError");
                                    }
                                    preferredEmail.setOk();
                                    return true;
                                }
                            });
                        }

                        @Override
                        public void onError(PerunError error) {
                            //save.setEnabled(true);
                            // add basic validator even if there is any error
                            preferredEmail.setValidator(new ExtendedTextBox.TextBoxValidator() {

                                @Override
                                public boolean validateTextBox() {
                                    if (preferredEmail.getTextBox().getText().trim().isEmpty()) {
                                        preferredEmail.setError("Preferred email address can't be empty.");
                                        return false;
                                    } else if (!JsonUtils.isValidEmail(preferredEmail.getTextBox().getText().trim())) {
                                        preferredEmail.setError("Not valid email address format.");
                                        return false;
                                    } else {
                                        preferredEmail.setOk();
                                        return true;
                                    }
                                }
                            });
                        }

                        @Override
                        public void onLoadingStart() {
                        //save.setEnabled(false);
                        }
                    });
                    get.retrieveData();
                } else if (a.getFriendlyName().equalsIgnoreCase("timezone")) {
                    for (int i = 0; i < timezone.getItemCount(); i++) {
                        if (timezone.getValue(i).equals(a.getValue())) {
                            timezone.setSelectedIndex(i);
                        }
                    }
                } else if (a.getFriendlyName().equalsIgnoreCase("preferredShells")) {
                    // set attribute and display value
                    preferredShellsWidget.setAttribute(a);
                }
            }
        }

        @Override
        public void onLoadingStart() {
            settingsTable.setWidget(1, 1, new AjaxLoaderImage(true));
            settingsTable.setWidget(3, 1, new AjaxLoaderImage(true));
            settingsTable.setWidget(4, 1, new AjaxLoaderImage(true));
            settingsTable.setWidget(5, 1, new AjaxLoaderImage(true));
            settingsTable.setWidget(7, 1, new AjaxLoaderImage(true));
        }

        @Override
        public void onError(PerunError error) {
            settingsTable.setWidget(1, 1, new AjaxLoaderImage(true).loadingError(error));
            settingsTable.setWidget(3, 1, new AjaxLoaderImage(true).loadingError(error));
            settingsTable.setWidget(4, 1, new AjaxLoaderImage(true).loadingError(error));
            settingsTable.setWidget(5, 1, new AjaxLoaderImage(true).loadingError(error));
            settingsTable.setWidget(7, 1, new AjaxLoaderImage(true).loadingError(error));
        }
    });
    attrsCall.getListOfAttributes(ids, list);
    FlexTable quickLinks = new FlexTable();
    quickHeader.setStyleName("inputFormFlexTable");
    String span = "<span style=\"font-weight: bold; padding-left: 25px; line-height: 2;\">";
    Anchor name = new Anchor(span + "Edit name titles</span>", true);
    name.addClickHandler(new ClickHandler() {

        @Override
        public void onClick(ClickEvent event) {
            session.getTabManager().addTabToCurrentTab(new EditUserDetailsTabItem(user, new JsonCallbackEvents() {

                @Override
                public void onFinished(JavaScriptObject jso) {
                    // refresh parent tab
                    SelfDetailTabItem item = (SelfDetailTabItem) session.getTabManager().getActiveTab();
                    item.setUser((User) jso);
                    item.open();
                    item.draw();
                }
            }));
        }
    });
    quickLinks.setWidget(0, 0, name);
    Anchor password = new Anchor(span + "Change / reset password</span>", true);
    password.addClickHandler(new ClickHandler() {

        @Override
        public void onClick(ClickEvent event) {
            tabPanel.selectTab(tabPanel.getSelectedIndex() + 3);
        }
    });
    quickLinks.setWidget(1, 0, password);
    Anchor cert = new Anchor(span + "<a href=\"" + Utils.getIdentityConsolidatorLink(false) + "\" target=\"_blank\">Add certificate</a></span>", true);
    quickLinks.setWidget(2, 0, cert);
    Anchor ssh = new Anchor(span + "Manage SSH keys</span>", true);
    ssh.addClickHandler(new ClickHandler() {

        @Override
        public void onClick(ClickEvent event) {
            tabPanel.selectTab(tabPanel.getSelectedIndex() + 3);
        }
    });
    quickLinks.setWidget(3, 0, ssh);
    Anchor report = new Anchor(span + "Report new publication</span>", true);
    report.addClickHandler(new ClickHandler() {

        @Override
        public void onClick(ClickEvent event) {
            session.getTabManager().addTab(new AddPublicationsTabItem(user));
        }
    });
    quickLinks.setWidget(4, 0, report);
    Anchor request = new Anchor(span + "Request data/files quota change</span>", true);
    request.addClickHandler(new ClickHandler() {

        @Override
        public void onClick(ClickEvent event) {
            tabPanel.selectTab(tabPanel.getSelectedIndex() + 2);
        }
    });
    quickLinks.setWidget(5, 0, request);
    if (session.getEditableUsers().size() > 1) {
        Anchor serv = new Anchor(span + "Manage service identities</span>", true);
        serv.addClickHandler(new ClickHandler() {

            @Override
            public void onClick(ClickEvent event) {
                tabPanel.selectTab(tabPanel.getSelectedIndex() + 6);
            }
        });
        quickLinks.setWidget(6, 0, serv);
    }
    rightPanel.add(settingsTable);
    leftPanel.add(quickLinks);
    Scheduler.get().scheduleDeferred(new Command() {

        @Override
        public void execute() {
            sp.scrollToTop();
        }
    });
    this.contentWidget.setWidget(sp);
    return getWidget();
}
Also used : JsonCallbackEvents(cz.metacentrum.perun.webgui.json.JsonCallbackEvents) HashMap(java.util.HashMap) ClickEvent(com.google.gwt.event.dom.client.ClickEvent) ArrayList(java.util.ArrayList) SetAttributes(cz.metacentrum.perun.webgui.json.attributesManager.SetAttributes) CustomButton(cz.metacentrum.perun.webgui.widgets.CustomButton) GetPendingPreferredEmailChanges(cz.metacentrum.perun.webgui.json.usersManager.GetPendingPreferredEmailChanges) AddPublicationsTabItem(cz.metacentrum.perun.webgui.tabs.cabinettabs.AddPublicationsTabItem) GetListOfAttributes(cz.metacentrum.perun.webgui.json.attributesManager.GetListOfAttributes) RequestPreferredEmailChange(cz.metacentrum.perun.webgui.json.usersManager.RequestPreferredEmailChange) ClickHandler(com.google.gwt.event.dom.client.ClickHandler) JavaScriptObject(com.google.gwt.core.client.JavaScriptObject) Command(com.google.gwt.user.client.Command) HashMap(java.util.HashMap) Map(java.util.Map)

Aggregations

JavaScriptObject (com.google.gwt.core.client.JavaScriptObject)6 ClickEvent (com.google.gwt.event.dom.client.ClickEvent)6 ClickHandler (com.google.gwt.event.dom.client.ClickHandler)6 JsonCallbackEvents (cz.metacentrum.perun.webgui.json.JsonCallbackEvents)6 GetListOfAttributes (cz.metacentrum.perun.webgui.json.attributesManager.GetListOfAttributes)6 HashMap (java.util.HashMap)6 CustomButton (cz.metacentrum.perun.webgui.widgets.CustomButton)5 ArrayList (java.util.ArrayList)5 Attribute (cz.metacentrum.perun.webgui.model.Attribute)3 TabMenu (cz.metacentrum.perun.webgui.widgets.TabMenu)3 SetAttributes (cz.metacentrum.perun.webgui.json.attributesManager.SetAttributes)2 PerunError (cz.metacentrum.perun.webgui.model.PerunError)2 AjaxLoaderImage (cz.metacentrum.perun.webgui.widgets.AjaxLoaderImage)2 Command (com.google.gwt.user.client.Command)1 GetAttributes (cz.metacentrum.perun.webgui.json.attributesManager.GetAttributes)1 GetLogins (cz.metacentrum.perun.webgui.json.attributesManager.GetLogins)1 RemoveAttributes (cz.metacentrum.perun.webgui.json.attributesManager.RemoveAttributes)1 GetMemberGroups (cz.metacentrum.perun.webgui.json.groupsManager.GetMemberGroups)1 GetMemberByUser (cz.metacentrum.perun.webgui.json.membersManager.GetMemberByUser)1 GetPendingPreferredEmailChanges (cz.metacentrum.perun.webgui.json.usersManager.GetPendingPreferredEmailChanges)1