Commit 5cc1530e authored by Gianluca Filippone's avatar Gianluca Filippone
Browse files

Updated EE data displayed

parent 5181aba9
......@@ -126,21 +126,6 @@ public class CDDirectoryPanel extends DirectoryPanel<
@Override
public void populateItem(final Item<ICellPopulator<CoordinationDelegateTO>> item, final String componentId,
final IModel<CoordinationDelegateTO> model) {
/* ActionLinksPanel.Builder<Serializable> actionLinks = ActionLinksPanel.builder();
* actionLinks.setDisableIndicator(true);
* actionLinks.add(new ActionLink<Serializable>() {
*
* private static final long serialVersionUID = -3722207913631435501L;
*
* @Override
* public void onClick(final AjaxRequestTarget target, final Serializable ignore) {
* PageParameters param = new PageParameters();
* param.add("instance", instanceId);
* param.add("cd", model.getObject().getName());
* setResponsePage(CDDetailPage.class, param);
* }
* }, ActionLink.ActionType.SEARCH);
* item.add(actionLinks.build(componentId)); */
ChoreographyActionsPanel choreographyActionsPanel = new ChoreographyActionsPanel(componentId);
choreographyActionsPanel.addAction(new IndicatingAjaxLink<Void>("link") {
......
......@@ -37,6 +37,7 @@ public class ChoreographyActionsPanel extends Panel {
super.add(new Fragment("freezePanel", "emptyFragment", this));
super.add(new Fragment("unfreezePanel", "emptyFragment", this));
super.add(new Fragment("resizePanel", "emptyFragment", this));
super.add(new Fragment("editPanel", "emptyFragment", this));
super.add(new Fragment("deletePanel", "emptyFragment", this));
}
......@@ -82,6 +83,11 @@ public class ChoreographyActionsPanel extends Panel {
fragment.addOrReplace(link.setVisible(true));
break;
case EDIT:
fragment = new Fragment("editPanel", "editFragment", this);
fragment.addOrReplace(link.setVisible(true));
break;
case DELETE:
fragment = new Fragment("deletePanel", "deleteFragment", this);
fragment.addOrReplace(new IndicatingOnConfirmAjaxLink<Void>("link", true) {
......@@ -111,6 +117,7 @@ public class ChoreographyActionsPanel extends Panel {
FREEZE,
UNFREEZE,
RESIZE,
EDIT,
DELETE
}
}
......@@ -15,8 +15,6 @@
*/
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;
......@@ -32,7 +30,6 @@ 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;
......@@ -49,7 +46,6 @@ import org.apache.wicket.extensions.markup.html.repeater.data.table.PropertyColu
import org.apache.wicket.markup.html.basic.Label;
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;
......@@ -59,16 +55,10 @@ 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
......@@ -244,19 +234,6 @@ public class ChoreographyDirectoryPanel extends GroupDirectoryPanel {
((BasePage) pageRef.getPage()).getNotificationPanel().refresh(target);
}
}, ChoreographyActionsPanel.ChoreographyActionType.DELETE);
choreographyActionsPanel.addAction(new IndicatingAjaxLink<Void>("link") {
private static final long serialVersionUID = 3104631231085231035L;
@Override
public void onClick(final AjaxRequestTarget target) {
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);
}
......
......@@ -26,25 +26,34 @@ import java.util.Iterator;
import java.util.List;
import org.apache.syncope.client.console.commons.DirectoryDataProvider;
import org.apache.syncope.client.console.pages.ChoreographyDetailPage;
import org.apache.syncope.client.console.panels.VirtualMachinesDirectoryPanel.VirtualMachinesDataProvider;
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;
import org.apache.wicket.ajax.AjaxRequestTarget;
import org.apache.wicket.extensions.ajax.markup.html.IndicatingAjaxLink;
import org.apache.wicket.extensions.markup.html.repeater.data.grid.ICellPopulator;
import org.apache.wicket.extensions.markup.html.repeater.data.table.AbstractColumn;
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.CompoundPropertyModel;
import org.apache.wicket.model.IModel;
import org.apache.wicket.model.Model;
import org.apache.wicket.model.ResourceModel;
public class VirtualMachinesDirectoryPanel extends DirectoryPanel<
public class ChoreographyVMDirectoryPanel extends DirectoryPanel<
VirtualMachineInfoTO, VirtualMachineInfoTO, VirtualMachinesDataProvider, ChoreographyRestClient> {
private static final long serialVersionUID = 3727444742501082182L;
private String enactmentEngineKey;
public VirtualMachinesDirectoryPanel(final String id, final PageReference pageRef,
private final BaseModal<Serializable> utilityModal = new BaseModal<>("outer");
public ChoreographyVMDirectoryPanel(final String id, final PageReference pageRef,
final String enactmentEngineKey) {
super(id, new DirectoryPanel.Builder<VirtualMachineInfoTO, VirtualMachineInfoTO, ChoreographyRestClient>(
......@@ -54,19 +63,20 @@ public class VirtualMachinesDirectoryPanel extends DirectoryPanel<
@Override
protected WizardMgtPanel<VirtualMachineInfoTO> newInstance(final String id, final boolean wizardInModal) {
return new VirtualMachinesDirectoryPanel(id, this);
return new ChoreographyVMDirectoryPanel(id, this);
}
}.disableCheckBoxes());
this.enactmentEngineKey = enactmentEngineKey;
setFooterVisibility(true);
modal.addSubmitButton();
modal.size(Modal.Size.Large);
addOuterObject(utilityModal);
utilityModal.addSubmitButton();
utilityModal.size(Modal.Size.Small);
initResultTable();
}
private VirtualMachinesDirectoryPanel(
private ChoreographyVMDirectoryPanel(
final String id,
final DirectoryPanel.Builder<VirtualMachineInfoTO, VirtualMachineInfoTO, ChoreographyRestClient> builder) {
......@@ -94,10 +104,49 @@ public class VirtualMachinesDirectoryPanel extends DirectoryPanel<
columns.add(new PropertyColumn<>(new ResourceModel("id"), "Id", "id"));
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("cpuNumber", "CPU"), "CPU", "cpuNumber"));
columns.add(new PropertyColumn<>(new ResourceModel("ram", "Memory (MB)"), "Memory (MB)", "ram"));
columns.add(new PropertyColumn<>(new ResourceModel("storage", "Storage (GB)"), "Storage (GB)", "storage"));
columns.add(new PropertyColumn<>(new ResourceModel(
"cpuUtilization", "CPU Utilization (%)"), "CPU Utilization (%)", "cpuUtilization"));
columns.add(new PropertyColumn<>(new ResourceModel(
"usedRam", "Used Memory (MB)"), "Used Memory (MB)", "usedRam"));
columns.add(new PropertyColumn<>(new ResourceModel(
"totalRam", "Total Memory (MB)"), "Total Memory (MB)", "totalRam"));
columns.add(new PropertyColumn<>(new ResourceModel(
"usedStorage", "Used Storage (GB)"), "Used Storage (GB)", "usedStorage"));
columns.add(new PropertyColumn<>(new ResourceModel(
"totalStorage", "Total Storage (GB)"), "Total Storage (GB)", "totalStorage"));
columns.add(new AbstractColumn<VirtualMachineInfoTO, String>(new ResourceModel("actions", "")) {
private static final long serialVersionUID = -1374917837616789356L;
@Override
public String getCssClass() {
return "action";
}
@Override
public void populateItem(final Item<ICellPopulator<VirtualMachineInfoTO>> item, final String componentId,
final IModel<VirtualMachineInfoTO> model) {
ChoreographyActionsPanel choreographyActionsPanel = new ChoreographyActionsPanel(componentId);
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);
item.add(choreographyActionsPanel);
}
});
return columns;
}
......
......@@ -50,12 +50,15 @@ public class EEResourcesPanel extends Panel {
resourcesOverview.add(new ResourceWidget(
resourcesOverview.newChildId(), "bg-red", bundle.cpus, "CPU", "fa fa-cogs"));
resourcesOverview.add(new ResourceWidget(
resourcesOverview.newChildId(), "bg-green", bundle.ram, "RAM", "MB", ""));
resourcesOverview.newChildId(),
"bg-green", bundle.usedRam, bundle.totalRam, "RAM utilization", bundle.percentageRam, "MB", ""));
resourcesOverview.add(new ResourceWidget(
resourcesOverview.newChildId(), "bg-aqua", bundle.storage, "Storage", "GB", "fa fa-database"));
resourcesOverview.newChildId(), "bg-aqua",
bundle.usedStorage, bundle.totalStorage,
"Storage occupancy", bundle.percentageStorage, "GB", "fa fa-database"));
add(resourcesOverview);
add(new VirtualMachinesDirectoryPanel("virtualMachinesList", pageRef, enactmentEngine.getKey()));
add(new ChoreographyVMDirectoryPanel("virtualMachinesList", pageRef, enactmentEngine.getKey()));
}
private class EEStatisticBundle implements Serializable {
......@@ -66,23 +69,38 @@ public class EEResourcesPanel extends Panel {
private int cpus;
private int ram;
private int usedRam;
private int totalRam;
private double percentageRam;
private int storage;
private int usedStorage;
private int totalStorage;
private double percentageStorage;
EEStatisticBundle(final List<VirtualMachineInfoTO> vms) {
this.virtualMachines = 0;
this.cpus = 0;
this.ram = 0;
this.storage = 0;
this.usedRam = 0;
this.totalRam = 0;
this.usedStorage = 0;
this.totalStorage = 0;
for (VirtualMachineInfoTO vm: vms) {
this.virtualMachines ++;
this.cpus += vm.getCpuNumber();
this.ram += vm.getRam();
this.storage += vm.getStorage();
this.usedRam += vm.getUsedRam();
this.totalRam += vm.getTotalRam();
this.usedStorage += vm.getUsedStorage();
this.totalStorage += vm.getTotalStorage();
}
this.percentageRam = Math.round(10000 * (usedRam / Float.valueOf(totalRam))) / 100d;
this.percentageStorage = Math.round(10000 * (usedStorage / Float.valueOf(totalStorage)) / 100d);
}
}
......
......@@ -15,44 +15,38 @@
*/
package org.apache.syncope.client.console.panels;
import eu.chorevolution.idm.common.to.VirtualMachineInfoTO;
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> {
public class ResizeModalPanel extends AbstractModalPanel<Serializable> {
private static final long serialVersionUID = 1570261203472359825L;
private final BaseModal<Serializable> resizeModal;
private final GroupTO choreography;
private final VirtualMachineInfoTO virtualMachineInfoTO;
private final ChoreographyRestClient choreographyRestClient;
private final FieldPanel<Integer> sizeInput;
public ResizeChoreographyModalPanel(
public ResizeModalPanel(
final BaseModal<Serializable> modal,
final GroupTO choreography,
final ChoreographyRestClient choreographyRestClient,
final VirtualMachineInfoTO virtualMachineInfoTO,
final PageReference pageRef) {
super(modal, pageRef);
this.resizeModal = modal;
this.choreography = choreography;
this.choreographyRestClient = choreographyRestClient;
this.virtualMachineInfoTO = virtualMachineInfoTO;
this.choreographyRestClient = new ChoreographyRestClient();
final WebMarkupContainer container = new WebMarkupContainer("container");
container.setOutputMarkupId(true);
......@@ -73,7 +67,7 @@ public class ResizeChoreographyModalPanel extends AbstractModalPanel<Serializabl
@Override
public void onSubmit(final AjaxRequestTarget target, final Form<?> form) {
try {
/*try {
choreographyRestClient.resizeChoreography(
choreography.getPlainAttrMap().get("id").getValues().iterator().next(), sizeInput.getModelObject());
resizeModal.close(target);
......@@ -83,7 +77,7 @@ public class ResizeChoreographyModalPanel extends AbstractModalPanel<Serializabl
SyncopeConsoleSession.get().error(StringUtils.isBlank(e.getMessage())
? e.getClass().getName() : e.getMessage());
}
((BasePage) pageRef.getPage()).getNotificationPanel().refresh(target);
((BasePage) pageRef.getPage()).getNotificationPanel().refresh(target);*/
}
}
......@@ -28,9 +28,11 @@ public class ResourceWidget extends BaseWidget {
public ResourceWidget(
final String id,
final String bg,
final int number,
final String bgColor,
final int usageResource,
final int totalResource,
final String label,
final double percentageUsage,
final String unit,
final String icon) {
......@@ -38,18 +40,30 @@ public class ResourceWidget extends BaseWidget {
setOutputMarkupId(true);
WebMarkupContainer box = new WebMarkupContainer("box");
box.add(new AttributeAppender("class", " " + bg));
add(box);
box.add(new Label("number", number));
box.add(new Label("label", label));
if (!unit.equals("")) {
box.add(new Label("unit", " (" + unit + ")"));
box.add(new AttributeAppender("class", " " + bgColor));
box.add(new Label("usageResource", usageResource));
if (totalResource != 0) {
box.add(new Label("totalResource", "/" + totalResource));
} else {
box.add(new Label("totalResource", ""));
}
if (unit != null && !unit.equals("")) {
box.add(new Label("unit", unit));
} else {
box.add(new Label("unit", ""));
}
box.add(new Label("label", label));
WebMarkupContainer progress = new WebMarkupContainer("progress");
progress.add(new AttributeAppender("style", " width: " + percentageUsage + "%"));
box.add(progress);
Label iconLabel = new Label("icon");
iconLabel.add(new AttributeAppender("class", icon));
box.add(iconLabel);
......@@ -57,10 +71,29 @@ public class ResourceWidget extends BaseWidget {
public ResourceWidget(
final String id,
final String bg,
final int number,
final String bgColor,
final int usageResource,
final String label,
final String unit,
final String icon) {
this(id, bgColor, usageResource, 0, label, 0, unit, icon);
}
public ResourceWidget(
final String id,
final String bgColor,
final int usageResource,
final String label,
final String icon) {
this(id, bgColor, usageResource, label, "", icon);
}
public ResourceWidget(
final String id,
final String bgColor,
final String label,
final double percentageUsage,
final String icon) {
this(id, bg, number, label, "", icon);
this(id, bgColor, (int) Math.floor(percentageUsage), 0, label, percentageUsage, "%", icon);
}
}
......@@ -15,50 +15,55 @@ 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="detailsPanel"></span>
<span wicket:id="startPanel"></span>
<span wicket:id="pausePanel"></span>
<span wicket:id="stopPanel"></span>
<span wicket:id="freezePanel"></span>
<span wicket:id="unfreezePanel"></span>
<span wicket:id="resizePanel"></span>
<span wicket:id="deletePanel"></span>
<wicket:panel>
<span wicket:id="detailsPanel"></span>
<span wicket:id="startPanel"></span>
<span wicket:id="pausePanel"></span>
<span wicket:id="stopPanel"></span>
<span wicket:id="freezePanel"></span>
<span wicket:id="unfreezePanel"></span>
<span wicket:id="resizePanel"></span>
<span wicket:id="editPanel"></span>
<span wicket:id="deletePanel"></span>
<wicket:fragment wicket:id="detailsFragment">
<a href="#" wicket:id="link" class="btn"><i class="fa fa-search" alt="show details" title="Show Details"></i></a>
</wicket:fragment>
<wicket:fragment wicket:id="detailsFragment">
<a href="#" wicket:id="link" class="btn"><i class="fa fa-search" alt="show details" title="Show Details"></i></a>
</wicket:fragment>
<wicket:fragment wicket:id="startFragment">
<a href="#" wicket:id="link" class="btn"><i class="fa fa-play" alt="start" title="Start"></i></a>
</wicket:fragment>
<wicket:fragment wicket:id="startFragment">
<a href="#" wicket:id="link" class="btn"><i class="fa fa-play" alt="start" title="Start"></i></a>
</wicket:fragment>
<wicket:fragment wicket:id="pauseFragment">
<a href="#" wicket:id="link" class="btn"><i class="fa fa-pause" alt="pause" title="Pause"></i></a>
</wicket:fragment>
<wicket:fragment wicket:id="pauseFragment">
<a href="#" wicket:id="link" class="btn"><i class="fa fa-pause" alt="pause" title="Pause"></i></a>
</wicket:fragment>
<wicket:fragment wicket:id="stopFragment">
<a href="#" wicket:id="link" class="btn"><i class="fa fa-stop" alt="stop" title="Stop"></i></a>
</wicket:fragment>
<wicket:fragment wicket:id="stopFragment">
<a href="#" wicket:id="link" class="btn"><i class="fa fa-stop" alt="stop" title="Stop"></i></a>
</wicket:fragment>
<wicket:fragment wicket:id="freezeFragment">
<a href="#" wicket:id="link" class="btn"><i class="fa fa-pause" alt="freeze icon" title="Freeze"></i></a>
</wicket:fragment>
<wicket:fragment wicket:id="freezeFragment">
<a href="#" wicket:id="link" class="btn"><i class="fa fa-pause" alt="freeze icon" title="Freeze"></i></a>
</wicket:fragment>
<wicket:fragment wicket:id="unfreezeFragment">
<a href="#" wicket:id="link" class="btn"><i class="fa fa-bolt" alt="unfreeze icon" title="Unfreeze"></i></a>
</wicket:fragment>
<wicket:fragment wicket:id="unfreezeFragment">
<a href="#" wicket:id="link" class="btn"><i class="fa fa-bolt" alt="unfreeze icon" title="Unfreeze"></i></a>
</wicket:fragment>
<wicket:fragment wicket:id="resizeFragment">
<a href="#" wicket:id="link" class="btn"><i class="fa fa-arrows" alt="resize icon" title="Resize"></i></a>
</wicket:fragment>
<wicket:fragment wicket:id="resizeFragment">
<a href="#" wicket:id="link" class="btn"><i class="fa fa-arrows" alt="resize icon" title="Resize"></i></a>
</wicket:fragment>
<wicket:fragment wicket:id="deleteFragment">
<a href="#" wicket:id="link" class="btn"><i class="fa fa-minus" alt="delete icon" title="Delete"></i></a>
</wicket:fragment>
<wicket:fragment wicket:id="editFragment">
<a href="#" wicket:id="link" class="btn"><i class="glyphicon glyphicon-pencil" alt="edit icon" title="Edit"></i></a>
</wicket:fragment>
<wicket:fragment wicket:id="emptyFragment">
</wicket:fragment>
</wicket:panel>
<wicket:fragment wicket:id="deleteFragment">
<a href="#" wicket:id="link" class="btn"><i class="fa fa-minus" alt="delete icon" title="Delete"></i></a>
</wicket:fragment>
<wicket:fragment wicket:id="emptyFragment">
</wicket:fragment>
</wicket:panel>
</html>
......@@ -33,17 +33,43 @@ specific language governing permissions and limitations
under the License.
-->