Search in sources :

Example 1 with BasicOverlayType

use of cz.metacentrum.perun.webgui.model.BasicOverlayType in project perun by CESNET.

the class IsLoginAvailable method onFinished.

/**
 * If last request OR NOT AVAILABLE, triggers the final events
 */
public void onFinished(JavaScriptObject jso) {
    checkedNamespaces++;
    BasicOverlayType ot = jso.cast();
    int available = ot.getInt();
    if (available == 0) {
        isAvailable = false;
        finalEvents.onFinished(generateFinalResponse());
        return;
    }
    // is available, is the last
    if (checkedNamespaces == namespacesToCheck.size()) {
        finalEvents.onFinished(generateFinalResponse());
        return;
    }
}
Also used : BasicOverlayType(cz.metacentrum.perun.webgui.model.BasicOverlayType)

Example 2 with BasicOverlayType

use of cz.metacentrum.perun.webgui.model.BasicOverlayType in project perun by CESNET.

the class WebGui method checkIfMailVerification.

/**
 * Check if URL parameters contains data for mail verification and display different GUI instead.
 *
 * @return TRUE if parameters are contained and valid in URL, FALSE otherwise.
 */
public boolean checkIfMailVerification() {
    // Trigger validation if necessary
    if (Location.getParameterMap().keySet().contains("token") && Location.getParameterMap().keySet().contains("u")) {
        String verifyToken = Location.getParameter("token");
        String verifyU = Location.getParameter("u");
        if (verifyToken != null && !verifyToken.isEmpty() && verifyU != null && !verifyU.isEmpty() && JsonUtils.checkParseInt(verifyU)) {
            ValidatePreferredEmailChange call = new ValidatePreferredEmailChange(verifyToken, Integer.parseInt(verifyU), new JsonCallbackEvents() {

                @Override
                public void onFinished(JavaScriptObject jso) {
                    BasicOverlayType over = jso.cast();
                    RootLayoutPanel body = RootLayoutPanel.get();
                    body.clear();
                    FlexTable ft = new FlexTable();
                    ft.setSize("100%", "300px");
                    ft.setHTML(0, 0, new Image(LargeIcons.INSTANCE.acceptIcon()) + "<h2>" + "The email address: <i>" + (SafeHtmlUtils.fromString(over.getString())).asString() + "</i></h2><h2>was verified and set as your preferred email.</h2>");
                    ft.getFlexCellFormatter().setHorizontalAlignment(0, 0, HasHorizontalAlignment.ALIGN_CENTER);
                    ft.getFlexCellFormatter().setVerticalAlignment(0, 0, HasVerticalAlignment.ALIGN_MIDDLE);
                    body.add(ft);
                }

                @Override
                public void onLoadingStart() {
                    RootLayoutPanel body = RootLayoutPanel.get();
                    body.clear();
                    FlexTable ft = new FlexTable();
                    ft.setSize("100%", "300px");
                    ft.getFlexCellFormatter().setHorizontalAlignment(0, 0, HasHorizontalAlignment.ALIGN_CENTER);
                    ft.getFlexCellFormatter().setVerticalAlignment(0, 0, HasVerticalAlignment.ALIGN_MIDDLE);
                    ft.setWidget(0, 0, new AjaxLoaderImage());
                    body.add(ft);
                }

                @Override
                public void onError(PerunError error) {
                    RootLayoutPanel body = RootLayoutPanel.get();
                    body.clear();
                    FlexTable ft = new FlexTable();
                    ft.setSize("100%", "300px");
                    ft.setHTML(0, 0, new Image(LargeIcons.INSTANCE.deleteIcon()) + "<h2>Your new email address couldn't be verified !</h2>");
                    ft.getFlexCellFormatter().setHorizontalAlignment(0, 0, HasHorizontalAlignment.ALIGN_CENTER);
                    ft.getFlexCellFormatter().setVerticalAlignment(0, 0, HasVerticalAlignment.ALIGN_MIDDLE);
                    if (error == null) {
                        ft.setHTML(1, 0, "Request timeout exceeded.");
                        ft.getFlexCellFormatter().setStyleName(1, 0, "serverResponseLabelError");
                    } else {
                        // display raw message
                        ft.setHTML(1, 0, "<strong>" + error.getErrorInfo() + "</strong>");
                    }
                    ft.getFlexCellFormatter().setHorizontalAlignment(1, 0, HasHorizontalAlignment.ALIGN_CENTER);
                    ft.getFlexCellFormatter().setVerticalAlignment(1, 0, HasVerticalAlignment.ALIGN_MIDDLE);
                    body.add(ft);
                }
            });
            call.retrieveData();
        }
        return true;
    }
    return false;
}
Also used : ValidatePreferredEmailChange(cz.metacentrum.perun.webgui.json.usersManager.ValidatePreferredEmailChange) JsonCallbackEvents(cz.metacentrum.perun.webgui.json.JsonCallbackEvents) AjaxLoaderImage(cz.metacentrum.perun.webgui.widgets.AjaxLoaderImage) JavaScriptObject(com.google.gwt.core.client.JavaScriptObject) BasicOverlayType(cz.metacentrum.perun.webgui.model.BasicOverlayType) PerunError(cz.metacentrum.perun.webgui.model.PerunError) AjaxLoaderImage(cz.metacentrum.perun.webgui.widgets.AjaxLoaderImage)

Example 3 with BasicOverlayType

use of cz.metacentrum.perun.webgui.model.BasicOverlayType in project perun by CESNET.

the class RegistrarFormItemGenerator method generateUsernameBox.

/**
 * Generates the username textbox
 * @return
 */
private Widget generateUsernameBox() {
    final TextBox tbox = new ExtendedTextBox();
    tbox.setMaxLength(TEXT_BOX_MAX_LENGTH);
    strValueBox = tbox;
    tbox.setText(strValue);
    tbox.getElement().setClassName("apptextbox" + counter++);
    setCutCopyPasteHandler("apptextbox" + counter);
    setVariableWidth(tbox);
    // if username not empty - disable
    if (!tbox.getValue().equalsIgnoreCase("")) {
        tbox.setEnabled(false);
        // do not check prefilled logins
        inputChecker = getDefaultInputChecker();
    } else {
        // get namespace
        if (item.getPerunDestinationAttribute() != null && !item.getPerunDestinationAttribute().isEmpty()) {
            final String loginNamespace = item.getPerunDestinationAttribute().substring(PERUN_ATTRIBUTE_LOGIN_NAMESPACE_POSITION);
            // check if login is new
            inputChecker = new FormInputChecker() {

                private boolean validating = false;

                private boolean valid = true;

                private Map<String, Boolean> validMap = new HashMap<String, Boolean>();

                public boolean isValid(boolean forceNewValidation) {
                    // if not new, don't force
                    if (!forceNewValidation)
                        return valid;
                    final String str = tbox.getValue();
                    // missing?
                    valid = (!(item.isRequired() && str.equals("")));
                    if (!valid) {
                        statusCellWrapper.setWidget(new FormInputStatusWidget(ApplicationMessages.INSTANCE.missingValue(), Status.ERROR));
                        return false;
                    }
                    // length
                    valid = checkLength();
                    if (!valid) {
                        return false;
                    }
                    valid = checkValueRegex();
                    // regex check
                    if (!valid) {
                        return false;
                    }
                    // force check for base REGEX used in login attribute module
                    RegExp regExp = RegExp.compile(Utils.LOGIN_VALUE_MATCHER);
                    boolean match = regExp.test(str);
                    if (!match)
                        return false;
                    // has already checked it?
                    if (validMap.containsKey(str)) {
                        valid = validMap.get(str);
                        if (valid) {
                            statusCellWrapper.setWidget(new FormInputStatusWidget(ApplicationMessages.INSTANCE.usernameAvailable(), Status.OK));
                        } else {
                            statusCellWrapper.setWidget(new FormInputStatusWidget(ApplicationMessages.INSTANCE.usernameNotAvailable(), Status.ERROR));
                        }
                        return valid;
                    }
                    // check login
                    validating = true;
                    statusCellWrapper.setWidget(new FormInputStatusWidget(ApplicationMessages.INSTANCE.validating(), Status.LOADING));
                    // check login
                    new IsLoginAvailable(loginNamespace, str, new JsonCallbackEvents() {

                        @Override
                        public void onFinished(JavaScriptObject jso) {
                            // store result for the requested login
                            BasicOverlayType bo = jso.cast();
                            validMap.put(str, bo.getBoolean());
                            if (!str.equals(strValueBox.getValue())) {
                                // value changed before request finished, don't update the valid value
                                return;
                            }
                            valid = bo.getBoolean();
                            validating = false;
                            if (valid) {
                                statusCellWrapper.setWidget(new FormInputStatusWidget(ApplicationMessages.INSTANCE.usernameAvailable(), Status.OK));
                            } else {
                                statusCellWrapper.setWidget(new FormInputStatusWidget(ApplicationMessages.INSTANCE.usernameNotAvailable(), Status.ERROR));
                            }
                            validationTrigger.triggerValidation();
                        }

                        @Override
                        public void onError(PerunError error) {
                            if (!str.equals(strValueBox.getValue())) {
                                // value changed before request finished, don't update the valid value
                                return;
                            }
                            if ("InvalidLoginException".equalsIgnoreCase(error.getName())) {
                                validMap.put(str, false);
                                statusCellWrapper.setWidget(new FormInputStatusWidget("Login has invalid syntax." + error.getErrorInfo(), Status.ERROR));
                            } else {
                                // generic error
                                statusCellWrapper.setWidget(new FormInputStatusWidget("Unable to check if login is available!", Status.ERROR));
                            }
                            validating = false;
                            validationTrigger.triggerValidation();
                        }
                    }).retrieveData();
                    // check login end
                    valid = false;
                    return false;
                }

                public boolean isValidating() {
                    return validating;
                }

                public boolean useDefaultOkMessage() {
                    return false;
                }
            };
        } else {
            // Username has no "login-namespace"
            // prevent such malformed applications from submission
            tbox.setEnabled(false);
            tbox.setValue("Wrong form item configuration !!");
            inputChecker = new FormInputChecker() {

                @Override
                public boolean isValid(boolean forceNewValidation) {
                    return false;
                }

                @Override
                public boolean isValidating() {
                    return false;
                }

                @Override
                public boolean useDefaultOkMessage() {
                    return false;
                }
            };
        }
    }
    return tbox;
}
Also used : JsonCallbackEvents(cz.metacentrum.perun.webgui.json.JsonCallbackEvents) RegExp(com.google.gwt.regexp.shared.RegExp) BasicOverlayType(cz.metacentrum.perun.webgui.model.BasicOverlayType) IsLoginAvailable(cz.metacentrum.perun.webgui.json.usersManager.IsLoginAvailable) JavaScriptObject(com.google.gwt.core.client.JavaScriptObject) PerunError(cz.metacentrum.perun.webgui.model.PerunError)

Example 4 with BasicOverlayType

use of cz.metacentrum.perun.webgui.model.BasicOverlayType in project perun by CESNET.

the class IsServiceBlockedOnFacility method onFinished.

/**
 * Called when loading successfully finishes
 *
 * @param jso javascript object (array) returned from RPC
 */
public void onFinished(JavaScriptObject jso) {
    BasicOverlayType bot = jso.cast();
    this.update(bot);
    session.getUiElements().setLogText("Loading denied info about service finished.");
    events.onFinished(bot);
}
Also used : BasicOverlayType(cz.metacentrum.perun.webgui.model.BasicOverlayType)

Example 5 with BasicOverlayType

use of cz.metacentrum.perun.webgui.model.BasicOverlayType in project perun by CESNET.

the class GetGroupMembersCount method onFinished.

/**
 * Called when loading successfully finishes.
 */
public void onFinished(JavaScriptObject jso) {
    BasicOverlayType count = (BasicOverlayType) jso;
    session.getUiElements().setLogText("Loading group members count finished: " + count.getInt());
    this.events.onFinished(jso);
}
Also used : BasicOverlayType(cz.metacentrum.perun.webgui.model.BasicOverlayType)

Aggregations

BasicOverlayType (cz.metacentrum.perun.webgui.model.BasicOverlayType)18 JavaScriptObject (com.google.gwt.core.client.JavaScriptObject)8 JsonCallbackEvents (cz.metacentrum.perun.webgui.json.JsonCallbackEvents)8 PerunError (cz.metacentrum.perun.webgui.model.PerunError)6 ClickEvent (com.google.gwt.event.dom.client.ClickEvent)4 ClickHandler (com.google.gwt.event.dom.client.ClickHandler)4 RegExp (com.google.gwt.regexp.shared.RegExp)4 CustomButton (cz.metacentrum.perun.webgui.widgets.CustomButton)4 TabMenu (cz.metacentrum.perun.webgui.widgets.TabMenu)3 GetGuiConfiguration (cz.metacentrum.perun.webgui.json.GetGuiConfiguration)2 GetPerunPrincipal (cz.metacentrum.perun.webgui.json.authzResolver.GetPerunPrincipal)2 KeepAlive (cz.metacentrum.perun.webgui.json.authzResolver.KeepAlive)2 IsLoginAvailable (cz.metacentrum.perun.webgui.json.usersManager.IsLoginAvailable)2 SetLogin (cz.metacentrum.perun.webgui.json.usersManager.SetLogin)2 PerunPrincipal (cz.metacentrum.perun.webgui.model.PerunPrincipal)2 TabItem (cz.metacentrum.perun.webgui.tabs.TabItem)2 Confirm (cz.metacentrum.perun.webgui.widgets.Confirm)2 ExtendedTextBox (cz.metacentrum.perun.webgui.widgets.ExtendedTextBox)2 Scheduler (com.google.gwt.core.client.Scheduler)1 ChangeEvent (com.google.gwt.event.dom.client.ChangeEvent)1