Search in sources :

Example 41 with JsonCallbackEvents

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

the class DeleteCategory method deleteCategory.

/**
 * Attempts to delete a Category, it first tests the values and then submits them.
 *
 * @param categoryId ID of category to be deleted
 */
public void deleteCategory(final int categoryId) {
    this.categoryId = categoryId;
    // test arguments
    if (!this.testDeleting()) {
        return;
    }
    // json object
    JSONObject jsonQuery = prepareJSONObject();
    // local events
    JsonCallbackEvents newEvents = new JsonCallbackEvents() {

        public void onError(PerunError error) {
            session.getUiElements().setLogErrorText("Deleting category " + categoryId + " failed.");
            events.onError(error);
        }

        public void onFinished(JavaScriptObject jso) {
            session.getUiElements().setLogSuccessText("Category " + categoryId + " deleted.");
            events.onFinished(jso);
        }

        public void onLoadingStart() {
            events.onLoadingStart();
        }
    };
    // create request
    JsonPostClient request = new JsonPostClient(newEvents);
    request.sendData(JSON_URL, jsonQuery);
}
Also used : JsonCallbackEvents(cz.metacentrum.perun.webgui.json.JsonCallbackEvents) 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 42 with JsonCallbackEvents

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

the class AddExtSource method addGroupExtSource.

/**
 * Attempts to add external source to Group in DB - make RPC call
 *
 * @param groupId ID of Group, where should be ext source added
 * @param extSourceId ID of external source to be added
 */
public void addGroupExtSource(final int groupId, final int extSourceId) {
    this.extSourceId = extSourceId;
    // create whole JSON query
    JSONObject jsonQuery = new JSONObject();
    jsonQuery.put("source", new JSONNumber(extSourceId));
    jsonQuery.put("group", new JSONNumber(groupId));
    // local events
    JsonCallbackEvents newEvents = new JsonCallbackEvents() {

        public void onError(PerunError error) {
            session.getUiElements().setLogErrorText("Adding external source: " + extSourceId + " to group: " + groupId + " failed.");
            events.onError(error);
        }

        public void onFinished(JavaScriptObject jso) {
            session.getUiElements().setLogSuccessText("External source: " + extSourceId + " successfully added to group: " + groupId);
            events.onFinished(jso);
        }

        public void onLoadingStart() {
            events.onLoadingStart();
        }
    };
    // create request
    JsonPostClient request = new JsonPostClient(newEvents);
    request.sendData(JSON_URL, jsonQuery);
}
Also used : JsonCallbackEvents(cz.metacentrum.perun.webgui.json.JsonCallbackEvents) JSONObject(com.google.gwt.json.client.JSONObject) JavaScriptObject(com.google.gwt.core.client.JavaScriptObject) JsonPostClient(cz.metacentrum.perun.webgui.json.JsonPostClient) JSONNumber(com.google.gwt.json.client.JSONNumber) PerunError(cz.metacentrum.perun.webgui.model.PerunError)

Example 43 with JsonCallbackEvents

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

the class PerunWebSession method setActiveVoId.

/**
 * Sets currently active VO (refresh links in menu)
 * when only ID is provided.
 *
 * @param voId ID of VO which user is editing now
 */
public void setActiveVoId(final int voId) {
    new GetEntityById(PerunEntity.VIRTUAL_ORGANIZATION, voId, new JsonCallbackEvents() {

        public void onFinished(JavaScriptObject jso) {
            VirtualOrganization vo = jso.cast();
            setActiveVo(vo);
        }
    }).retrieveData();
}
Also used : JsonCallbackEvents(cz.metacentrum.perun.webgui.json.JsonCallbackEvents) JavaScriptObject(com.google.gwt.core.client.JavaScriptObject) GetEntityById(cz.metacentrum.perun.webgui.json.GetEntityById)

Example 44 with JsonCallbackEvents

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

the class WebGui method showCurrentGDPRApproval.

private void showCurrentGDPRApproval(Map<String, Integer> ids, Attribute a, Map<String, String> approvedAdminGDPR, String currentVersion, JsonCallbackEvents finishEvents) {
    String gdprApprovalText = session.getConfiguration().getGDPRproperty("text");
    String agreeButtonText = session.getConfiguration().getGDPRproperty("agree");
    String disagreeButtonText = session.getConfiguration().getGDPRproperty("disagree");
    String disagreeResult = session.getConfiguration().getGDPRproperty("disagree_result");
    String title = session.getConfiguration().getGDPRproperty("title");
    String backToGdprConfirm = session.getConfiguration().getGDPRproperty("disagree_back");
    HTML html = new HTML("<div height=\"500\" width=\"420\">" + gdprApprovalText + "</div>");
    Confirm gdprConfirm = new Confirm(title, html, new ClickHandler() {

        @Override
        public void onClick(ClickEvent event) {
            SetAttribute setAttribute = new SetAttribute(new JsonCallbackEvents() {

                @Override
                public void onFinished(JavaScriptObject jso) {
                    // approved finish loading UI
                    finishEvents.onFinished(null);
                }

                @Override
                public void onError(PerunError error) {
                    error.setErrorInfo("Failed to store your GDPR approval for version: " + currentVersion);
                    finishEvents.onError(error);
                }
            });
            approvedAdminGDPR.put(currentVersion, JsonUtils.getCurrentDateAsString());
            a.setValueAsMap(approvedAdminGDPR);
            setAttribute.setAttribute(ids, a);
        }
    }, new ClickHandler() {

        @Override
        public void onClick(ClickEvent event) {
            Confirm disagreeConfirm = new Confirm(title, new HTML(disagreeResult), false);
            disagreeConfirm.setNonScrollable(true);
            disagreeConfirm.setAutoHide(false);
            disagreeConfirm.setOkButtonText(backToGdprConfirm);
            disagreeConfirm.setOkClickHandler(new ClickHandler() {

                @Override
                public void onClick(ClickEvent event) {
                    finishEvents.onError(null);
                    Window.Location.reload();
                }
            });
            disagreeConfirm.show();
        }
    }, agreeButtonText, disagreeButtonText, true);
    gdprConfirm.setNonScrollable(true);
    gdprConfirm.setAutoHide(false);
    gdprConfirm.show();
}
Also used : JsonCallbackEvents(cz.metacentrum.perun.webgui.json.JsonCallbackEvents) ClickHandler(com.google.gwt.event.dom.client.ClickHandler) JavaScriptObject(com.google.gwt.core.client.JavaScriptObject) ClickEvent(com.google.gwt.event.dom.client.ClickEvent) Confirm(cz.metacentrum.perun.webgui.widgets.Confirm) PerunError(cz.metacentrum.perun.webgui.model.PerunError) SetAttribute(cz.metacentrum.perun.webgui.json.attributesManager.SetAttribute)

Example 45 with JsonCallbackEvents

use of cz.metacentrum.perun.webgui.json.JsonCallbackEvents 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)

Aggregations

JsonCallbackEvents (cz.metacentrum.perun.webgui.json.JsonCallbackEvents)380 JavaScriptObject (com.google.gwt.core.client.JavaScriptObject)333 PerunError (cz.metacentrum.perun.webgui.model.PerunError)206 JsonPostClient (cz.metacentrum.perun.webgui.json.JsonPostClient)181 ClickEvent (com.google.gwt.event.dom.client.ClickEvent)143 ClickHandler (com.google.gwt.event.dom.client.ClickHandler)143 CustomButton (cz.metacentrum.perun.webgui.widgets.CustomButton)142 ArrayList (java.util.ArrayList)125 TabMenu (cz.metacentrum.perun.webgui.widgets.TabMenu)108 JSONObject (com.google.gwt.json.client.JSONObject)69 TabItem (cz.metacentrum.perun.webgui.tabs.TabItem)60 ExtendedSuggestBox (cz.metacentrum.perun.webgui.widgets.ExtendedSuggestBox)41 ChangeEvent (com.google.gwt.event.dom.client.ChangeEvent)34 ChangeHandler (com.google.gwt.event.dom.client.ChangeHandler)34 HashMap (java.util.HashMap)33 JSONNumber (com.google.gwt.json.client.JSONNumber)30 PerunSearchEvent (cz.metacentrum.perun.webgui.client.resources.PerunSearchEvent)24 ListBoxWithObjects (cz.metacentrum.perun.webgui.widgets.ListBoxWithObjects)24 Group (cz.metacentrum.perun.webgui.model.Group)23 Map (java.util.Map)23