Search in sources :

Example 11 with JsonCallbackEvents

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

the class AssignService method assignService.

/**
	 * Attempts to assign service to resource
	 *
	 * @param serviceId ID of service which should be assigned
	 * @param resourceId ID of resource where should be assigned
	 */
public void assignService(final int serviceId, final int resourceId) {
    this.resourceId = resourceId;
    this.serviceId = serviceId;
    // test arguments
    if (!this.testAssigning()) {
        return;
    }
    // new events
    JsonCallbackEvents newEvents = new JsonCallbackEvents() {

        public void onError(PerunError error) {
            session.getUiElements().setLogErrorText("Assigning service: " + serviceId + " to resource: " + resourceId + " failed.");
            events.onError(error);
        }

        ;

        public void onFinished(JavaScriptObject jso) {
            session.getUiElements().setLogSuccessText("Service: " + serviceId + " sucessfully assigned to resource: " + resourceId);
            events.onFinished(jso);
        }

        ;

        public void onLoadingStart() {
            events.onLoadingStart();
        }

        ;
    };
    // sending data
    JsonPostClient jspc = new JsonPostClient(newEvents);
    jspc.sendData(JSON_URL, prepareJSONObject());
}
Also used : JsonCallbackEvents(cz.metacentrum.perun.webgui.json.JsonCallbackEvents) JavaScriptObject(com.google.gwt.core.client.JavaScriptObject) JsonPostClient(cz.metacentrum.perun.webgui.json.JsonPostClient) PerunError(cz.metacentrum.perun.webgui.model.PerunError)

Example 12 with JsonCallbackEvents

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

the class ChangeNonAuthzPassword method changeNonAuthzPassword.

/**
	 * Changes password for the user
	 *
	 * @param i        encrypted value 1
	 * @param m        encrypted value 2
	 * @param password new password to set
	 */
public void changeNonAuthzPassword(String i, String m, String password) {
    this.i = i;
    this.m = m;
    this.password = password;
    // new events
    JsonCallbackEvents newEvents = new JsonCallbackEvents() {

        public void onError(PerunError error) {
            session.getUiElements().setLogErrorText("Changing password failed.");
            // custom events
            events.onError(error);
        }

        public void onFinished(JavaScriptObject jso) {
            session.getUiElements().setLogSuccessText("Password changed successfully.");
            events.onFinished(jso);
        }

        public void onLoadingStart() {
            events.onLoadingStart();
        }
    };
    // sending data
    JsonPostClient jspc = new JsonPostClient(newEvents);
    jspc.sendData(JSON_URL, prepareJSONObject());
}
Also used : JsonCallbackEvents(cz.metacentrum.perun.webgui.json.JsonCallbackEvents) JavaScriptObject(com.google.gwt.core.client.JavaScriptObject) JsonPostClient(cz.metacentrum.perun.webgui.json.JsonPostClient) PerunError(cz.metacentrum.perun.webgui.model.PerunError)

Example 13 with JsonCallbackEvents

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

the class CreateCompleteService method createCompleteService.

/**
	 * Attempts to create a new Service including both ExecServices with dependency,
	 * it first tests the values and then submits them.
	 *
	 * @param name service Name
	 * @param scriptPath Path to the service script, default "./service_name"
	 * @param defaultDelay Delay in minutes when service is rescheduled (10 min is default)
	 * @param enabled TRUE if service should be enabled
	 */
public void createCompleteService(final String name, final String scriptPath, final int defaultDelay, final boolean enabled) {
    this.serviceName = name;
    this.scriptPath = scriptPath;
    this.defaultDelay = defaultDelay;
    this.enabled = enabled;
    // test arguments
    if (!this.testCreating()) {
        return;
    }
    // new events
    JsonCallbackEvents newEvents = new JsonCallbackEvents() {

        public void onError(PerunError error) {
            session.getUiElements().setLogErrorText("Creating service " + serviceName + " failed.");
            // custom events
            events.onError(error);
        }

        ;

        public void onFinished(JavaScriptObject jso) {
            session.getUiElements().setLogSuccessText("Service " + serviceName + " created.");
            events.onFinished(jso);
        }

        ;

        public void onLoadingStart() {
            events.onLoadingStart();
        }

        ;
    };
    // sending data
    JsonPostClient jspc = new JsonPostClient(newEvents);
    jspc.sendData(JSON_URL, prepareJSONObject());
}
Also used : JsonCallbackEvents(cz.metacentrum.perun.webgui.json.JsonCallbackEvents) JavaScriptObject(com.google.gwt.core.client.JavaScriptObject) JsonPostClient(cz.metacentrum.perun.webgui.json.JsonPostClient) PerunError(cz.metacentrum.perun.webgui.model.PerunError)

Example 14 with JsonCallbackEvents

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

the class ApplicationFormGui method prepareGui.

/**
	 * Prepares the GUI
	 * @param entity PerunEntity GROUP or VO
	 * @param applicationType INITIAL | EXTENSION
	 */
protected void prepareGui(PerunEntity entity, String applicationType) {
    if (Location.getParameterMap().keySet().contains("m") && Location.getParameterMap().keySet().contains("i")) {
        String verifyI = Location.getParameter("i");
        String verifyM = Location.getParameter("m");
        if (verifyI != null && !verifyI.isEmpty() && verifyM != null && !verifyM.isEmpty()) {
            final SimplePanel verifContent = new SimplePanel();
            Anchor a = leftMenu.addItem(ApplicationMessages.INSTANCE.emailValidationMenuItem(), SmallIcons.INSTANCE.emailIcon(), verifContent);
            a.fireEvent(new ClickEvent() {
            });
            ValidateEmail request = new ValidateEmail(verifyI, verifyM, new JsonCallbackEvents() {

                @Override
                public void onLoadingStart() {
                    verifContent.clear();
                    verifContent.add(new AjaxLoaderImage());
                }

                @Override
                public void onFinished(JavaScriptObject jso) {
                    BasicOverlayType obj = jso.cast();
                    if (obj.getBoolean() == true) {
                        verifContent.clear();
                        FlexTable ft = new FlexTable();
                        ft.setSize("100%", "300px");
                        ft.setHTML(0, 0, new Image(LargeIcons.INSTANCE.acceptIcon()) + "<h2>" + ApplicationMessages.INSTANCE.emailValidationSuccess() + "</h2>");
                        ft.getFlexCellFormatter().setHorizontalAlignment(0, 0, HasHorizontalAlignment.ALIGN_CENTER);
                        ft.getFlexCellFormatter().setVerticalAlignment(0, 0, HasVerticalAlignment.ALIGN_MIDDLE);
                        verifContent.add(ft);
                    } else {
                        verifContent.clear();
                        FlexTable ft = new FlexTable();
                        ft.setSize("100%", "300px");
                        ft.setHTML(0, 0, new Image(LargeIcons.INSTANCE.deleteIcon()) + "<h2>" + ApplicationMessages.INSTANCE.emailValidationFail() + "</h2>");
                        ft.getFlexCellFormatter().setHorizontalAlignment(0, 0, HasHorizontalAlignment.ALIGN_CENTER);
                        ft.getFlexCellFormatter().setVerticalAlignment(0, 0, HasVerticalAlignment.ALIGN_MIDDLE);
                        verifContent.add(ft);
                    }
                }

                @Override
                public void onError(PerunError error) {
                    ((AjaxLoaderImage) verifContent.getWidget()).loadingError(error);
                }
            });
            request.retrieveData();
            leftMenu.addLogoutItem();
            return;
        }
    }
    // group and extension is not allowed
    if (group != null && applicationType.equalsIgnoreCase("EXTENSION")) {
        RootLayoutPanel panel = RootLayoutPanel.get();
        panel.clear();
        FlexTable ft = new FlexTable();
        ft.setSize("100%", "300px");
        ft.setHTML(0, 0, new Image(LargeIcons.INSTANCE.errorIcon()) + "<h2>Error: " + ApplicationMessages.INSTANCE.groupMembershipCantBeExtended(group.getName()) + "</h2>");
        ft.getFlexCellFormatter().setHorizontalAlignment(0, 0, HasHorizontalAlignment.ALIGN_CENTER);
        ft.getFlexCellFormatter().setVerticalAlignment(0, 0, HasVerticalAlignment.ALIGN_MIDDLE);
        panel.add(ft);
        // redirect if possible
        if (Location.getParameter("targetexisting") != null) {
            Location.replace(Location.getParameter("targetexisting"));
        }
        return;
    }
    // application form page
    ApplicationFormPage formPage = new ApplicationFormPage(vo, group, applicationType);
    // even user "not yet in perun" can have some applications sent (therefore display by session info)
    UsersApplicationsPage appsPage = new UsersApplicationsPage();
    // if rt test
    if ("true".equals(Location.getParameter("rttest"))) {
        TestRtReportingTabItem tabItem = new TestRtReportingTabItem();
        Widget rtTab = tabItem.draw();
        leftMenu.addItem("RT test", SmallIcons.INSTANCE.settingToolsIcon(), rtTab);
    }
    // proper menu text
    String appMenuText = ApplicationMessages.INSTANCE.applicationFormForVo(vo.getName());
    if (group != null) {
        appMenuText = ApplicationMessages.INSTANCE.applicationFormForGroup(group.getName());
    }
    if (applicationType.equalsIgnoreCase("EXTENSION")) {
        appMenuText = ApplicationMessages.INSTANCE.membershipExtensionForVo(vo.getName());
        if (group != null) {
            appMenuText = ApplicationMessages.INSTANCE.membershipExtensionForGroup(group.getName());
        }
    }
    // load list of applications first if param in session
    if ("apps".equals(Location.getParameter("page"))) {
        Anchor a = leftMenu.addItem(ApplicationMessages.INSTANCE.applications(), SmallIcons.INSTANCE.applicationFromStorageIcon(), appsPage);
        leftMenu.addItem(appMenuText, SmallIcons.INSTANCE.applicationFormIcon(), formPage);
        a.fireEvent(new ClickEvent() {
        });
    //appsPage.menuClick(); // load list of apps
    } else {
        Anchor a = leftMenu.addItem(appMenuText, SmallIcons.INSTANCE.applicationFormIcon(), formPage);
        leftMenu.addItem(ApplicationMessages.INSTANCE.applications(), SmallIcons.INSTANCE.applicationFromStorageIcon(), appsPage);
        a.fireEvent(new ClickEvent() {
        });
    //formPage.menuClick(); // load application form
    }
    leftMenu.addLogoutItem();
}
Also used : JsonCallbackEvents(cz.metacentrum.perun.webgui.json.JsonCallbackEvents) ValidateEmail(cz.metacentrum.perun.webgui.json.registrarManager.ValidateEmail) TestRtReportingTabItem(cz.metacentrum.perun.webgui.tabs.testtabs.TestRtReportingTabItem) AjaxLoaderImage(cz.metacentrum.perun.webgui.widgets.AjaxLoaderImage) RecaptchaWidget(cz.metacentrum.perun.webgui.widgets.recaptcha.RecaptchaWidget) AjaxLoaderImage(cz.metacentrum.perun.webgui.widgets.AjaxLoaderImage) UsersApplicationsPage(cz.metacentrum.perun.webgui.client.applicationresources.pages.UsersApplicationsPage) ApplicationFormPage(cz.metacentrum.perun.webgui.client.applicationresources.pages.ApplicationFormPage)

Example 15 with JsonCallbackEvents

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

the class DeleteTask method deleteTask.

/**
	 * Deletes Task from DB
	 *
	 * @param taskId id of Task to be deleted
	 */
public void deleteTask(final int taskId) {
    this.taskId = taskId;
    // test arguments
    if (!this.testArguments()) {
        return;
    }
    // whole JSON query
    JSONObject jsonQuery = new JSONObject();
    jsonQuery.put("task", new JSONNumber(taskId));
    // new events
    JsonCallbackEvents newEvents = new JsonCallbackEvents() {

        public void onError(PerunError error) {
            session.getUiElements().setLogErrorText("Deleting of Task: " + taskId + " failed.");
            events.onError(error);
        }

        ;

        public void onFinished(JavaScriptObject jso) {
            session.getUiElements().setLogSuccessText("Task: " + taskId + " deleted successfully.");
            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) 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)

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