Commit 7842f59d authored by Gianluca Filippone's avatar Gianluca Filippone
Browse files

[CRV-228] Added support for resizing choreography

parent 21414b77
......@@ -15,6 +15,8 @@
*/
package org.apache.syncope.client.console.panels;
import de.agilecoders.wicket.core.markup.html.bootstrap.dialog.Modal;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;
import org.apache.commons.lang3.StringUtils;
......@@ -30,6 +32,7 @@ import org.apache.syncope.client.console.rest.AnyTypeClassRestClient;
import org.apache.syncope.client.console.rest.AnyTypeRestClient;
import org.apache.syncope.client.console.rest.ChoreographyRestClient;
import org.apache.syncope.client.console.wicket.extensions.markup.html.repeater.data.table.AttrColumn;
import org.apache.syncope.client.console.wicket.markup.html.bootstrap.dialog.BaseModal;
import org.apache.syncope.common.lib.SyncopeClientException;
import org.apache.syncope.common.lib.to.GroupTO;
import org.apache.syncope.client.console.wizards.WizardMgtPanel;
......@@ -45,6 +48,7 @@ import org.apache.wicket.extensions.markup.html.repeater.data.table.IColumn;
import org.apache.wicket.extensions.markup.html.repeater.data.table.PropertyColumn;
import org.apache.wicket.markup.repeater.Item;
import org.apache.wicket.model.IModel;
import org.apache.wicket.model.Model;
import org.apache.wicket.model.ResourceModel;
import org.apache.wicket.request.mapper.parameter.PageParameters;
......@@ -54,10 +58,16 @@ public class ChoreographyDirectoryPanel extends GroupDirectoryPanel {
private final ChoreographyRestClient choreographyRestClient;
private final BaseModal<Serializable> utilityModal = new BaseModal<>("outer");
public ChoreographyDirectoryPanel(final String id, final PageReference pageRef) {
super(id, new Builder(AnyTypeKind.GROUP.name(), pageRef), false);
choreographyRestClient = new ChoreographyRestClient();
addOuterObject(utilityModal);
utilityModal.size(Modal.Size.Small);
utilityModal.addSubmitButton();
}
@Override
......@@ -217,7 +227,11 @@ public class ChoreographyDirectoryPanel extends GroupDirectoryPanel {
@Override
public void onClick(final AjaxRequestTarget target) {
//Need to open a modal panel
utilityModal.header(Model.of("Resize Choreography"));
utilityModal.setContent(new ResizeChoreographyModalPanel(
utilityModal, model.getObject(), choreographyRestClient, pageRef));
utilityModal.show(true);
target.add(utilityModal);
}
}, ChoreographyActionsPanel.ChoreographyActionType.RESIZE);
item.add(choreographyActionsPanel);
......
/*
* Copyright 2016 The CHOReVOLUTION project.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.apache.syncope.client.console.panels;
import java.io.Serializable;
import org.apache.commons.lang3.StringUtils;
import org.apache.syncope.client.console.SyncopeConsoleSession;
import org.apache.syncope.client.console.commons.Constants;
import org.apache.syncope.client.console.pages.BasePage;
import org.apache.syncope.client.console.rest.ChoreographyRestClient;
import org.apache.syncope.client.console.wicket.markup.html.bootstrap.dialog.BaseModal;
import org.apache.syncope.client.console.wicket.markup.html.form.AjaxSpinnerFieldPanel;
import org.apache.syncope.client.console.wicket.markup.html.form.FieldPanel;
import org.apache.syncope.common.lib.SyncopeClientException;
import org.apache.syncope.common.lib.to.GroupTO;
import org.apache.wicket.PageReference;
import org.apache.wicket.ajax.AjaxRequestTarget;
import org.apache.wicket.markup.html.WebMarkupContainer;
import org.apache.wicket.markup.html.form.Form;
import org.apache.wicket.model.Model;
public class ResizeChoreographyModalPanel extends AbstractModalPanel<Serializable> {
private static final long serialVersionUID = 1570261203472359825L;
private final GroupTO choreography;
private final ChoreographyRestClient choreographyRestClient;
private final FieldPanel<Integer> sizeInput;
public ResizeChoreographyModalPanel(
final BaseModal<Serializable> modal,
final GroupTO choreography,
final ChoreographyRestClient choreographyRestClient,
final PageReference pageRef) {
super(modal, pageRef);
this.choreography = choreography;
this.choreographyRestClient = choreographyRestClient;
final WebMarkupContainer container = new WebMarkupContainer("container");
container.setOutputMarkupId(true);
add(container);
final Form<String> form = new Form<>("resizeChoreographyForm");
form.setMarkupId("resizeChoreographyForm");
form.setOutputMarkupId(true);
container.add(form);
this.sizeInput = new AjaxSpinnerFieldPanel.Builder<Integer>()
.build("size", "New Size", Integer.class, new Model<>()).setRequired(true);
form.add(sizeInput);
}
@Override
public void onSubmit(final AjaxRequestTarget target, final Form<?> form) {
try {
choreographyRestClient.resizeChoreography(
choreography.getPlainAttrMap().get("id").getValues().iterator().next(), sizeInput.getModelObject());
SyncopeConsoleSession.get().info(getString(Constants.OPERATION_SUCCEEDED));
} catch (SyncopeClientException e) {
LOG.error("While deleting object {}", choreography.getKey(), e);
SyncopeConsoleSession.get().error(StringUtils.isBlank(e.getMessage())
? e.getClass().getName() : e.getMessage());
}
((BasePage) pageRef.getPage()).getNotificationPanel().refresh(target);
}
}
<!DOCTYPE html>
<!--
Copyright 2016 The CHOReVOLUTION project
*
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
*
http://www.apache.org/licenses/LICENSE-2.0
*
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:wicket="http://wicket.apache.org">
<wicket:panel>
<span wicket:id="container">
<div class="form-group">
<form wicket:id="resizeChoreographyForm">
<div class="form-group">
<span wicket:id="size"/>
</div>
</form>
</div>
</span>
</wicket:panel>
</html>
\ No newline at end of file
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment