Search in sources :

Example 1 with UserFormLayoutInfo

use of org.apache.syncope.client.console.layout.UserFormLayoutInfo in project syncope by apache.

the class Realm method buildTabList.

private List<ITab> buildTabList(final PageReference pageRef) {
    List<ITab> tabs = new ArrayList<>();
    tabs.add(new ITabComponent(new Model<>("DETAILS"), StandardEntitlement.REALM_CREATE, StandardEntitlement.REALM_UPDATE, StandardEntitlement.REALM_DELETE) {

        private static final long serialVersionUID = -5861786415855103549L;

        @Override
        public Panel getPanel(final String panelId) {
            final ActionsPanel<RealmTO> actionPanel = new ActionsPanel<>("actions", null);
            if (realmTO.getFullPath().startsWith(SyncopeConstants.ROOT_REALM)) {
                actionPanel.add(new ActionLink<RealmTO>(realmTO) {

                    private static final long serialVersionUID = 2802988981431379827L;

                    @Override
                    public void onClick(final AjaxRequestTarget target, final RealmTO ignore) {
                        onClickCreate(target);
                    }
                }, ActionLink.ActionType.CREATE, StandardEntitlement.REALM_CREATE).hideLabel();
                actionPanel.add(new ActionLink<RealmTO>(realmTO) {

                    private static final long serialVersionUID = 2802988981431379828L;

                    @Override
                    public void onClick(final AjaxRequestTarget target, final RealmTO ignore) {
                        onClickEdit(target, realmTO);
                    }
                }, ActionLink.ActionType.EDIT, StandardEntitlement.REALM_UPDATE).hideLabel();
                actionPanel.add(new ActionLink<RealmTO>(realmTO) {

                    private static final long serialVersionUID = 2802988981431379827L;

                    @Override
                    public void onClick(final AjaxRequestTarget target, final RealmTO ignore) {
                        onClickTemplate(target);
                    }
                }, ActionLink.ActionType.TEMPLATE, StandardEntitlement.REALM_UPDATE).hideLabel();
                actionPanel.add(new ActionLink<RealmTO>(realmTO) {

                    private static final long serialVersionUID = 2802988981431379829L;

                    @Override
                    public void onClick(final AjaxRequestTarget target, final RealmTO ignore) {
                        onClickDelete(target, realmTO);
                    }
                }, ActionLink.ActionType.DELETE, StandardEntitlement.REALM_DELETE, true).hideLabel();
            }
            RealmDetails panel = new RealmDetails(panelId, realmTO, actionPanel, false);
            panel.setContentEnabled(false);
            actionPanel.setEnabled(true);
            return panel;
        }

        @Override
        public boolean isVisible() {
            return SyncopeConsoleApplication.get().getSecuritySettings().getAuthorizationStrategy().isActionAuthorized(this, RENDER);
        }
    });
    final Triple<UserFormLayoutInfo, GroupFormLayoutInfo, Map<String, AnyObjectFormLayoutInfo>> formLayoutInfo = FormLayoutInfoUtils.fetch(anyTypes.stream().map(EntityTO::getKey).collect(Collectors.toList()));
    for (final AnyTypeTO anyType : anyTypes) {
        tabs.add(new ITabComponent(new Model<>(anyType.getKey()), String.format("%s_SEARCH", anyType.getKey())) {

            private static final long serialVersionUID = 1169585538404171118L;

            @Override
            public WebMarkupContainer getPanel(final String panelId) {
                return new AnyPanel(panelId, anyType, realmTO, formLayoutInfo, true, pageRef);
            }

            @Override
            public boolean isVisible() {
                return SyncopeConsoleApplication.get().getSecuritySettings().getAuthorizationStrategy().isActionAuthorized(this, RENDER);
            }
        });
    }
    return tabs;
}
Also used : ActionsPanel(org.apache.syncope.client.console.wicket.markup.html.form.ActionsPanel) ArrayList(java.util.ArrayList) RealmTO(org.apache.syncope.common.lib.to.RealmTO) AnyTypeTO(org.apache.syncope.common.lib.to.AnyTypeTO) ITab(org.apache.wicket.extensions.markup.html.tabs.ITab) WebMarkupContainer(org.apache.wicket.markup.html.WebMarkupContainer) AjaxRequestTarget(org.apache.wicket.ajax.AjaxRequestTarget) EntityTO(org.apache.syncope.common.lib.to.EntityTO) ActionsPanel(org.apache.syncope.client.console.wicket.markup.html.form.ActionsPanel) ConnObjectPanel(org.apache.syncope.client.console.wizards.any.ConnObjectPanel) AjaxBootstrapTabbedPanel(de.agilecoders.wicket.core.markup.html.bootstrap.tabs.AjaxBootstrapTabbedPanel) Panel(org.apache.wicket.markup.html.panel.Panel) WizardMgtPanel(org.apache.syncope.client.console.wizards.WizardMgtPanel) Model(org.apache.wicket.model.Model) GroupFormLayoutInfo(org.apache.syncope.client.console.layout.GroupFormLayoutInfo) ITabComponent(org.apache.syncope.client.console.commons.ITabComponent) UserFormLayoutInfo(org.apache.syncope.client.console.layout.UserFormLayoutInfo) Map(java.util.Map)

Example 2 with UserFormLayoutInfo

use of org.apache.syncope.client.console.layout.UserFormLayoutInfo in project syncope by apache.

the class SAML2IdPsDirectoryPanel method getActions.

@Override
public ActionsPanel<SAML2IdPTO> getActions(final IModel<SAML2IdPTO> model) {
    final ActionsPanel<SAML2IdPTO> panel = super.getActions(model);
    panel.add(new ActionLink<SAML2IdPTO>() {

        private static final long serialVersionUID = -7978723352517770645L;

        @Override
        public void onClick(final AjaxRequestTarget target, final SAML2IdPTO ignore) {
            SAML2IdPTO object = restClient.read(model.getObject().getKey());
            metadataModal.header(Model.of(object.getName() + " - Metadata"));
            metadataModal.setContent(new XMLEditorPanel(metadataModal, Model.of(new String(Base64.decodeBase64(object.getMetadata()))), true, pageRef));
            metadataModal.show(true);
            target.add(metadataModal);
        }
    }, ActionLink.ActionType.HTML, SAML2SPEntitlement.IDP_READ);
    panel.add(new ActionLink<SAML2IdPTO>() {

        private static final long serialVersionUID = -3722207913631435501L;

        @Override
        public void onClick(final AjaxRequestTarget target, final SAML2IdPTO ignore) {
            SAML2IdPTO object = restClient.read(model.getObject().getKey());
            send(SAML2IdPsDirectoryPanel.this, Broadcast.EXACT, new AjaxWizard.EditItemActionEvent<>(object, target));
        }
    }, ActionLink.ActionType.EDIT, SAML2SPEntitlement.IDP_UPDATE);
    panel.add(new ActionLink<SAML2IdPTO>() {

        private static final long serialVersionUID = -3722207913631435501L;

        @Override
        public void onClick(final AjaxRequestTarget target, final SAML2IdPTO ignore) {
            final SAML2IdPTO object = restClient.read(model.getObject().getKey());
            UserTemplateWizardBuilder builder = new UserTemplateWizardBuilder(object.getUserTemplate(), new AnyTypeRestClient().read(AnyTypeKind.USER.name()).getClasses(), new UserFormLayoutInfo(), pageRef) {

                private static final long serialVersionUID = -7978723352517770634L;

                @Override
                protected Serializable onApplyInternal(final AnyWrapper<UserTO> modelObject) {
                    object.setUserTemplate(modelObject.getInnerObject());
                    restClient.update(object);
                    return modelObject;
                }
            };
            templateModal.header(Model.of(StringUtils.capitalize(new StringResourceModel("template.title", SAML2IdPsDirectoryPanel.this).getString())));
            templateModal.setContent(builder.build(BaseModal.CONTENT_ID));
            templateModal.show(true);
            target.add(templateModal);
        }
    }, ActionLink.ActionType.TEMPLATE, SAML2SPEntitlement.IDP_UPDATE);
    panel.add(new ActionLink<SAML2IdPTO>() {

        private static final long serialVersionUID = -5467832321897812767L;

        @Override
        public void onClick(final AjaxRequestTarget target, final SAML2IdPTO ignore) {
            try {
                restClient.delete(model.getObject().getKey());
                SyncopeConsoleSession.get().info(getString(Constants.OPERATION_SUCCEEDED));
                target.add(container);
            } catch (SyncopeClientException e) {
                LOG.error("While deleting object {}", model.getObject().getKey(), e);
                SyncopeConsoleSession.get().error(StringUtils.isBlank(e.getMessage()) ? e.getClass().getName() : e.getMessage());
            }
            ((BasePage) pageRef.getPage()).getNotificationPanel().refresh(target);
        }
    }, ActionLink.ActionType.DELETE, SAML2SPEntitlement.IDP_DELETE, true);
    return panel;
}
Also used : SAML2IdPTO(org.apache.syncope.common.lib.to.SAML2IdPTO) XMLEditorPanel(org.apache.syncope.client.console.wicket.markup.html.form.XMLEditorPanel) Serializable(java.io.Serializable) AnyTypeRestClient(org.apache.syncope.client.console.rest.AnyTypeRestClient) SyncopeClientException(org.apache.syncope.common.lib.SyncopeClientException) AjaxRequestTarget(org.apache.wicket.ajax.AjaxRequestTarget) UserTemplateWizardBuilder(org.apache.syncope.client.console.wizards.any.UserTemplateWizardBuilder) UserTO(org.apache.syncope.common.lib.to.UserTO) UserFormLayoutInfo(org.apache.syncope.client.console.layout.UserFormLayoutInfo) BasePage(org.apache.syncope.client.console.pages.BasePage) StringResourceModel(org.apache.wicket.model.StringResourceModel)

Aggregations

UserFormLayoutInfo (org.apache.syncope.client.console.layout.UserFormLayoutInfo)2 AjaxRequestTarget (org.apache.wicket.ajax.AjaxRequestTarget)2 AjaxBootstrapTabbedPanel (de.agilecoders.wicket.core.markup.html.bootstrap.tabs.AjaxBootstrapTabbedPanel)1 Serializable (java.io.Serializable)1 ArrayList (java.util.ArrayList)1 Map (java.util.Map)1 ITabComponent (org.apache.syncope.client.console.commons.ITabComponent)1 GroupFormLayoutInfo (org.apache.syncope.client.console.layout.GroupFormLayoutInfo)1 BasePage (org.apache.syncope.client.console.pages.BasePage)1 AnyTypeRestClient (org.apache.syncope.client.console.rest.AnyTypeRestClient)1 ActionsPanel (org.apache.syncope.client.console.wicket.markup.html.form.ActionsPanel)1 XMLEditorPanel (org.apache.syncope.client.console.wicket.markup.html.form.XMLEditorPanel)1 WizardMgtPanel (org.apache.syncope.client.console.wizards.WizardMgtPanel)1 ConnObjectPanel (org.apache.syncope.client.console.wizards.any.ConnObjectPanel)1 UserTemplateWizardBuilder (org.apache.syncope.client.console.wizards.any.UserTemplateWizardBuilder)1 SyncopeClientException (org.apache.syncope.common.lib.SyncopeClientException)1 AnyTypeTO (org.apache.syncope.common.lib.to.AnyTypeTO)1 EntityTO (org.apache.syncope.common.lib.to.EntityTO)1 RealmTO (org.apache.syncope.common.lib.to.RealmTO)1 SAML2IdPTO (org.apache.syncope.common.lib.to.SAML2IdPTO)1