Commit d484c7cf authored by Gianluca Filippone's avatar Gianluca Filippone
Browse files

Working on extensions

parent e2db681c
......@@ -15,6 +15,7 @@
*/
package org.apache.syncope.client.console.panels;
import de.agilecoders.wicket.core.markup.html.bootstrap.dialog.Modal;
import java.util.ArrayList;
import java.util.List;
import org.apache.commons.lang3.StringUtils;
......@@ -59,6 +60,9 @@ public class ChoreographyDirectoryPanel extends GroupDirectoryPanel {
super(id, new Builder(AnyTypeKind.GROUP.name(), pageRef), false);
choreographyRestClient = new ChoreographyRestClient();
utilityModal.addSubmitButton();
utilityModal.size(Modal.Size.Small);
}
@Override
......@@ -129,6 +133,22 @@ public class ChoreographyDirectoryPanel extends GroupDirectoryPanel {
}
}, ChoreographyActionsPanel.ChoreographyActionType.SHOW);
choreographyActionsPanel.addAction(new IndicatingAjaxLink<Void>("link") {
private static final long serialVersionUID = 5283601360187316340L;
@Override
public void onClick(final AjaxRequestTarget target) {
utilityModal.setContent(new ResizeModalPanel(
utilityModal,
model.getObject().getPlainAttrMap().get("id").getValues().iterator().next(),
pageRef)
);
utilityModal.show(true);
target.add(utilityModal);
}
}, ChoreographyActionsPanel.ChoreographyActionType.RESIZE);
if (model.getObject().getPlainAttrMap().get("status").getValues().iterator().next().equals("STARTED")) {
choreographyActionsPanel.addAction(new IndicatingAjaxLink<Void>("link") {
......
......@@ -15,16 +15,28 @@
*/
package org.apache.syncope.client.console.panels;
import de.agilecoders.wicket.core.markup.html.bootstrap.dialog.Modal;
import eu.chorevolution.idm.common.to.ChoreographyTO;
import eu.chorevolution.idm.common.to.VirtualMachineInfoTO;
import java.io.Serializable;
import java.util.List;
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 static org.apache.syncope.client.console.panels.DirectoryPanel.LOG;
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.widgets.ResourceWidget;
import org.apache.syncope.common.lib.SyncopeClientException;
import org.apache.syncope.common.lib.to.AnyObjectTO;
import org.apache.wicket.PageReference;
import org.apache.wicket.ajax.AjaxRequestTarget;
import org.apache.wicket.extensions.ajax.markup.html.IndicatingAjaxLink;
import org.apache.wicket.markup.html.basic.Label;
import org.apache.wicket.markup.html.panel.Panel;
import org.apache.wicket.markup.repeater.RepeatingView;
import org.apache.wicket.model.Model;
public class ChoreographyEEResourcesPanel extends Panel {
......@@ -34,14 +46,26 @@ public class ChoreographyEEResourcesPanel extends Panel {
private final EEStatisticBundle bundle;
public ChoreographyEEResourcesPanel(final String id, final PageReference pageRef, final String choreographyId) {
private final BaseModal<Serializable> utilityModal = new BaseModal<>("resizeEEModal");
private final ChoreographyTO choreography;
public ChoreographyEEResourcesPanel(
final String id,
final PageReference pageRef,
final String choreographyId) {
super(id);
setOutputMarkupId(true);
this.restClient = new ChoreographyRestClient();
this.enactmentEngine = restClient.getChoreographyEE(choreographyId);
this.bundle = new EEStatisticBundle(restClient.getChoreographyVmList(enactmentEngine.getKey(), choreographyId));
this.choreography = restClient.getChoreography(choreographyId);
this.enactmentEngine = restClient.getChoreographyEE(choreography.getId());
this.bundle = new EEStatisticBundle(
restClient.getChoreographyVmList(enactmentEngine.getKey(), choreography.getId()));
add(new Label("eeName", getString("enactmentEngine") + " " + enactmentEngine.getName()));
add(utilityModal);
add(new Label("eeName", enactmentEngine.getName()));
RepeatingView resourcesOverview = new RepeatingView("resourceWidget");
resourcesOverview.add(new ResourceWidget(
......@@ -58,7 +82,101 @@ public class ChoreographyEEResourcesPanel extends Panel {
"Storage occupancy", bundle.percentageStorage, "GB", "fa fa-database"));
add(resourcesOverview);
add(new ChoreographyVMDirectoryPanel("virtualMachinesList", pageRef, enactmentEngine.getKey(), choreographyId));
ChoreographyActionsPanel actionsPanel = new ChoreographyActionsPanel("actionsPanel");
add(actionsPanel);
actionsPanel.addAction(new IndicatingAjaxLink<Void>("link") {
private static final long serialVersionUID = 5283601360187316340L;
@Override
public void onClick(final AjaxRequestTarget target) {
utilityModal.size(Modal.Size.Small);
utilityModal.addSubmitButton();
utilityModal.header(Model.of("Resize"));
utilityModal.setContent(new ResizeModalPanel(utilityModal, choreography.getId(), pageRef));
utilityModal.show(true);
target.add(utilityModal);
}
}, ChoreographyActionsPanel.ChoreographyActionType.RESIZE);
if (choreography.getStatus().equals("STARTED")) {
actionsPanel.addAction(new IndicatingAjaxLink<Void>("link") {
private static final long serialVersionUID = 3104631231085231035L;
@Override
public void onClick(final AjaxRequestTarget target) {
try {
restClient.stopChoreography(choreography.getId());
SyncopeConsoleSession.get().info(getString(Constants.OPERATION_SUCCEEDED));
} catch (SyncopeClientException e) {
LOG.error("While stopping choreography {}", choreography.getGroupKey(), e);
SyncopeConsoleSession.get().error(StringUtils.isBlank(e.getMessage())
? e.getClass().getName() : e.getMessage());
}
((BasePage) pageRef.getPage()).getNotificationPanel().refresh(target);
}
}, ChoreographyActionsPanel.ChoreographyActionType.STOP);
actionsPanel.addAction(new IndicatingAjaxLink<Void>("link") {
private static final long serialVersionUID = 3104631231085231035L;
@Override
public void onClick(final AjaxRequestTarget target) {
try {
restClient.freezeChoreography(choreography.getId());
SyncopeConsoleSession.get().info(getString(Constants.OPERATION_SUCCEEDED));
} catch (SyncopeClientException e) {
LOG.error("While freezing choreography {}", choreography.getGroupKey(), e);
SyncopeConsoleSession.get().error(StringUtils.isBlank(e.getMessage())
? e.getClass().getName() : e.getMessage());
}
((BasePage) pageRef.getPage()).getNotificationPanel().refresh(target);
}
}, ChoreographyActionsPanel.ChoreographyActionType.FREEZE);
}
if (choreography.getStatus().equals("STOPPED")) {
actionsPanel.addAction(new IndicatingAjaxLink<Void>("link") {
private static final long serialVersionUID = 3104631231085231035L;
@Override
public void onClick(final AjaxRequestTarget target) {
try {
restClient.startChoreography(choreography.getId());
SyncopeConsoleSession.get().info(getString(Constants.OPERATION_SUCCEEDED));
} catch (SyncopeClientException e) {
LOG.error("While starting choreography {}", choreography.getGroupKey(), e);
SyncopeConsoleSession.get().error(StringUtils.isBlank(e.getMessage())
? e.getClass().getName() : e.getMessage());
}
((BasePage) pageRef.getPage()).getNotificationPanel().refresh(target);
}
}, ChoreographyActionsPanel.ChoreographyActionType.START);
}
if (choreography.getStatus().equals("FROZEN")) {
actionsPanel.addAction(new IndicatingAjaxLink<Void>("link") {
private static final long serialVersionUID = 3104631231085231035L;
@Override
public void onClick(final AjaxRequestTarget target) {
try {
restClient.unfreezeChoreography(choreography.getId());
SyncopeConsoleSession.get().info(getString(Constants.OPERATION_SUCCEEDED));
} catch (SyncopeClientException e) {
LOG.error("While unfreezing choreography {}", choreography.getGroupKey(), e);
SyncopeConsoleSession.get().error(StringUtils.isBlank(e.getMessage())
? e.getClass().getName() : e.getMessage());
}
((BasePage) pageRef.getPage()).getNotificationPanel().refresh(target);
}
}, ChoreographyActionsPanel.ChoreographyActionType.UNFREEZE);
}
add(new ChoreographyVMDirectoryPanel(
"virtualMachinesList", pageRef, enactmentEngine.getKey(), choreography.getId()));
}
private class EEStatisticBundle implements Serializable {
......
......@@ -15,7 +15,6 @@
*/
package org.apache.syncope.client.console.panels;
import de.agilecoders.wicket.core.markup.html.bootstrap.dialog.Modal;
import eu.chorevolution.idm.common.to.VirtualMachineInfoTO;
import java.io.Serializable;
import java.util.ArrayList;
......@@ -28,7 +27,6 @@ import org.apache.syncope.client.console.commons.DirectoryDataProvider;
import org.apache.syncope.client.console.pages.ChoreographyDetailPage;
import org.apache.syncope.client.console.panels.ChoreographyVMDirectoryPanel.VirtualMachinesDataProvider;
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.ActionLink;
import org.apache.syncope.client.console.wizards.WizardMgtPanel;
import org.apache.wicket.PageReference;
......@@ -41,7 +39,6 @@ import org.apache.wicket.extensions.markup.html.repeater.data.table.PropertyColu
import org.apache.wicket.markup.repeater.Item;
import org.apache.wicket.model.CompoundPropertyModel;
import org.apache.wicket.model.IModel;
import org.apache.wicket.model.Model;
import org.apache.wicket.model.ResourceModel;
public class ChoreographyVMDirectoryPanel extends DirectoryPanel<
......@@ -53,8 +50,6 @@ public class ChoreographyVMDirectoryPanel extends DirectoryPanel<
private String choreographyId;
private final BaseModal<Serializable> utilityModal = new BaseModal<>("outer");
public ChoreographyVMDirectoryPanel(final String id, final PageReference pageRef,
final String enactmentEngineKey, final String choreographyId) {
......@@ -73,9 +68,6 @@ public class ChoreographyVMDirectoryPanel extends DirectoryPanel<
this.choreographyId = choreographyId;
setFooterVisibility(true);
addOuterObject(utilityModal);
utilityModal.addSubmitButton();
utilityModal.size(Modal.Size.Small);
initResultTable();
}
......@@ -105,9 +97,14 @@ public class ChoreographyVMDirectoryPanel extends DirectoryPanel<
protected List<IColumn<VirtualMachineInfoTO, String>> getColumns() {
final List<IColumn<VirtualMachineInfoTO, String>> columns = new ArrayList<>();
columns.add(new PropertyColumn<>(new ResourceModel("id"), "Id", "id"));
columns.add(new PropertyColumn<>(new ResourceModel("ipAddress", "IP"), "IP", "ipAddress"));
columns.add(new PropertyColumn<>(new ResourceModel("hostname", "Hostname"), "Hostname", "hostname"));
columns.add(new PropertyColumn<>(new ResourceModel("os"), "OS", "os"));
columns.add(new PropertyColumn<>(new ResourceModel("type", "Type"), "Type", "type"));
columns.add(new PropertyColumn<>(new ResourceModel(
"choreography", "Deployed Choreography"), "Deployed Choreography", "choreography"));
columns.add(new PropertyColumn<>(new ResourceModel("cpuNumber", "CPU"), "CPU", "cpuNumber"));
columns.add(new PropertyColumn<>(new ResourceModel(
"cpuUtilization", "CPU Utilization (%)"), "CPU Utilization (%)", "cpuUtilization"));
......@@ -120,7 +117,7 @@ public class ChoreographyVMDirectoryPanel extends DirectoryPanel<
columns.add(new PropertyColumn<>(new ResourceModel(
"totalStorage", "Total Storage (GB)"), "Total Storage (GB)", "totalStorage"));
columns.add(new AbstractColumn<VirtualMachineInfoTO, String>(new ResourceModel("actions", "")) {
columns.add(new AbstractColumn<VirtualMachineInfoTO, String>(new ResourceModel("", "")) {
private static final long serialVersionUID = -1374917837616789356L;
......@@ -133,21 +130,6 @@ public class ChoreographyVMDirectoryPanel extends DirectoryPanel<
public void populateItem(final Item<ICellPopulator<VirtualMachineInfoTO>> item, final String componentId,
final IModel<VirtualMachineInfoTO> model) {
ChoreographyActionsPanel choreographyActionsPanel = new ChoreographyActionsPanel(componentId);
if (model.getObject().getType().equals("Choreography")) {
choreographyActionsPanel.addAction(new IndicatingAjaxLink<Void>("link") {
private static final long serialVersionUID = 3104631231085231035L;
@Override
public void onClick(final AjaxRequestTarget target) {
utilityModal.header(Model.of("Resize"));
utilityModal.setContent(new ResizeModalPanel(
utilityModal, model.getObject(), pageRef));
utilityModal.show(true);
target.add(utilityModal);
}
}, ChoreographyActionsPanel.ChoreographyActionType.RESIZE);
}
choreographyActionsPanel.addAction(new IndicatingAjaxLink<Void>("link") {
private static final long serialVersionUID = 3104631231085231035L;
......
......@@ -15,12 +15,17 @@
*/
package org.apache.syncope.client.console.panels;
import eu.chorevolution.idm.common.to.VirtualMachineInfoTO;
import eu.chorevolution.idm.common.to.ChoreographyTO;
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.wicket.PageReference;
import org.apache.wicket.ajax.AjaxRequestTarget;
import org.apache.wicket.markup.html.WebMarkupContainer;
......@@ -33,7 +38,7 @@ public class ResizeModalPanel extends AbstractModalPanel<Serializable> {
private final BaseModal<Serializable> resizeModal;
private final VirtualMachineInfoTO virtualMachineInfoTO;
private final ChoreographyTO choreography;
private final ChoreographyRestClient choreographyRestClient;
......@@ -41,12 +46,14 @@ public class ResizeModalPanel extends AbstractModalPanel<Serializable> {
public ResizeModalPanel(
final BaseModal<Serializable> modal,
final VirtualMachineInfoTO virtualMachineInfoTO,
final String choreographyId,
final PageReference pageRef) {
super(modal, pageRef);
this.resizeModal = modal;
this.virtualMachineInfoTO = virtualMachineInfoTO;
this.choreographyRestClient = new ChoreographyRestClient();
this.choreography = choreographyRestClient.getChoreography(choreographyId);
modal.header(Model.of("Resize Choreography"));
final WebMarkupContainer container = new WebMarkupContainer("container");
container.setOutputMarkupId(true);
......@@ -67,17 +74,16 @@ public class ResizeModalPanel extends AbstractModalPanel<Serializable> {
@Override
public void onSubmit(final AjaxRequestTarget target, final Form<?> form) {
/*try {
choreographyRestClient.resizeChoreography(
choreography.getPlainAttrMap().get("id").getValues().iterator().next(), sizeInput.getModelObject());
try {
choreographyRestClient.resizeChoreography(choreography.getId(), sizeInput.getModelObject());
resizeModal.close(target);
SyncopeConsoleSession.get().info(getString(Constants.OPERATION_SUCCEEDED));
} catch (SyncopeClientException e) {
LOG.error("While deleting object {}", choreography.getKey(), e);
LOG.error("While deleting object {}", choreography.getGroupKey(), e);
SyncopeConsoleSession.get().error(StringUtils.isBlank(e.getMessage())
? e.getClass().getName() : e.getMessage());
}
((BasePage) pageRef.getPage()).getNotificationPanel().refresh(target);*/
((BasePage) pageRef.getPage()).getNotificationPanel().refresh(target);
}
}
......@@ -17,7 +17,7 @@ limitations under the License.
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:wicket="http://wicket.apache.org">
<wicket:head>
<style>
div.tab-content {
div.dataTable {
overflow-x: scroll;
}
</style>
......
......@@ -17,7 +17,7 @@ limitations under the License.
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:wicket="http://wicket.apache.org">
<wicket:head>
<style>
div.tab-content {
div.dataTable {
overflow-x: scroll;
}
</style>
......
......@@ -17,7 +17,7 @@ limitations under the License.
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:wicket="http://wicket.apache.org">
<wicket:head>
<style>
div.tab-content {
div.dataTable {
overflow-x: scroll;
}
</style>
......
......@@ -17,7 +17,7 @@ limitations under the License.
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:wicket="http://wicket.apache.org">
<wicket:head>
<style>
div.tab-content {
div.dataTable {
overflow-x: scroll;
}
</style>
......
......@@ -15,6 +15,13 @@ 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:head>
<style>
div.dataTable {
overflow-x: scroll;
}
</style>
</wicket:head>
<wicket:extend>
<section class="content-header">
<h1>
......
......@@ -15,6 +15,13 @@ 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:head>
<style>
div.dataTable {
overflow-x: scroll;
}
</style>
</wicket:head>
<wicket:extend>
<section class="content-header">
<h1>
......
......@@ -17,7 +17,7 @@ limitations under the License.
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:wicket="http://wicket.apache.org">
<wicket:head>
<style>
div.tab-content {
div.dataTable {
overflow-x: scroll;
}
</style>
......
......@@ -17,7 +17,7 @@ limitations under the License.
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:wicket="http://wicket.apache.org">
<wicket:head>
<style>
div.tab-content {
div.dataTable {
overflow-x: scroll;
}
</style>
......
......@@ -16,11 +16,14 @@ limitations under the License.
-->
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:wicket="http://wicket.apache.org">
<wicket:panel>
<h3><span wicket:id="eeName"/></h3>
<h3><wicket:message key="enactmentEngine"/>&nbsp;<span wicket:id="eeName"/></h3>
<div class="row">
<span wicket:id="resourceWidget"/>
</div>
<h3><wicket:message key="actions"/></h3>
<div wicket:id="actionsPanel"/>
<h3><wicket:message key="virtualMachines"/></h3>
<div wicket:id="virtualMachinesList"/>
<div wicket:id="resizeEEModal"/>
</wicket:panel>
</html>
......@@ -15,3 +15,4 @@
#
enactmentEngine=Enactment Engine
virtualMachines=Virtual Machines
actions=Actions
......@@ -15,3 +15,4 @@
#
enactmentEngine=Enactment Engine
virtualMachines=Macchine Virtuali
actions=Azioni
......@@ -15,3 +15,4 @@
#
enactmentEngine=Enactment Engine
virtualMachines=M\u00e1quinas virtuais
actions=Actions
......@@ -39,6 +39,8 @@ public class ChoreographyTO extends AbstractBaseBean {
private byte[] image;
private String status;
public String getId() {
return id;
}
......@@ -95,4 +97,12 @@ public class ChoreographyTO extends AbstractBaseBean {
this.image = image;
}
public String getStatus() {
return status;
}
public void setStatus(final String status) {
this.status = status;
}
}
......@@ -23,6 +23,10 @@ public class VirtualMachineInfoTO extends AbstractBaseBean {
private String id;
private String ipAddress;
private String hostname;
private String os;
private int cpuNumber;
......@@ -39,6 +43,8 @@ public class VirtualMachineInfoTO extends AbstractBaseBean {
private String type;
private String choreography;
public String getId() {
return id;
}
......@@ -47,6 +53,22 @@ public class VirtualMachineInfoTO extends AbstractBaseBean {
this.id = id;
}
public String getIpAddress() {
return ipAddress;
}
public void setIpAddress(final String ipAddress) {
this.ipAddress = ipAddress;
}
public String getHostname() {
return hostname;
}
public void setHostname(final String hostname) {
this.hostname = hostname;
}
public String getOs() {
return os;
}