Shubhendu Tripathi has uploaded a new change for review. Change subject: gluster: UI to set the volume snapshot configurations ......................................................................
gluster: UI to set the volume snapshot configurations Introduced UI to set gluster volume snapshot configration parameters. Change-Id: I08b5e592b818266106bc1891c3aa2f3ba3541d36 Signed-off-by: Shubhendu Tripathi <[email protected]> --- M frontend/webadmin/modules/gwt-common/src/main/resources/org/ovirt/engine/core/Common.gwt.xml M frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/Linq.java M frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/dataprovider/AsyncDataProvider.java M frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/help/HelpTag.java A frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/gluster/GlusterVolumeSnapshotConfigModel.java M frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/gluster/GlusterVolumeSnapshotListModel.java A frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/gluster/VolumeSnapshotConfigModel.java M frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/volumes/VolumeListModel.java M frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/place/WebAdminApplicationPlaces.java M frontend/webadmin/modules/uicompat/src/main/java/org/ovirt/engine/ui/uicompat/UIConstants.java M frontend/webadmin/modules/uicompat/src/main/java/org/ovirt/engine/ui/uicompat/UIMessages.java M frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/ApplicationConstants.java M frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/gin/PresenterModule.java M frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/gin/uicommon/VolumeModule.java A frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/section/main/presenter/popup/gluster/GlusterVolumeSnapshotConfigurePopupPresenterWidget.java A frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/section/main/view/popup/gluster/GlusterVolumeSnapshotConfigurePopupView.java A frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/section/main/view/popup/gluster/GlusterVolumeSnapshotConfigurePopupView.ui.xml M frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/section/main/view/popup/gluster/GlusterVolumeSnapshotCreatePopupView.java M frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/section/main/view/tab/MainTabVolumeView.java 19 files changed, 694 insertions(+), 18 deletions(-) git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/95/36295/1 diff --git a/frontend/webadmin/modules/gwt-common/src/main/resources/org/ovirt/engine/core/Common.gwt.xml b/frontend/webadmin/modules/gwt-common/src/main/resources/org/ovirt/engine/core/Common.gwt.xml index 8fb3500..134c98a 100644 --- a/frontend/webadmin/modules/gwt-common/src/main/resources/org/ovirt/engine/core/Common.gwt.xml +++ b/frontend/webadmin/modules/gwt-common/src/main/resources/org/ovirt/engine/core/Common.gwt.xml @@ -353,7 +353,8 @@ <include name="common/businessentities/gluster/GlusterGeoRepSessionConfiguration.java"/> <include name="common/businessentities/gluster/GlusterVolumeSnapshotEntity.java"/> <include name="common/businessentities/gluster/GlusterSnapshotStatus.java"/> - <!-- Scheduling --> + <include name="common/businessentities/gluster/GlusterVolumeSnapshotConfigParam.java"/> + <!-- Scheduling --> <include name="common/scheduling/*.java"/> <include name="common/scheduling/parameters/*.java"/> <!-- Numa --> diff --git a/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/Linq.java b/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/Linq.java index e9e7f1a..c1fef1b 100644 --- a/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/Linq.java +++ b/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/Linq.java @@ -40,8 +40,9 @@ import org.ovirt.engine.core.common.businessentities.comparators.NameableComparator; import org.ovirt.engine.core.common.businessentities.gluster.GlusterBrickEntity; import org.ovirt.engine.core.common.businessentities.gluster.GlusterGeoRepSession; -import org.ovirt.engine.core.common.businessentities.network.HostNetworkQos; +import org.ovirt.engine.core.common.businessentities.gluster.GlusterVolumeSnapshotConfigParam; import org.ovirt.engine.core.common.businessentities.gluster.GlusterVolumeSnapshotEntity; +import org.ovirt.engine.core.common.businessentities.network.HostNetworkQos; import org.ovirt.engine.core.common.businessentities.network.Network; import org.ovirt.engine.core.common.businessentities.network.NetworkInterface; import org.ovirt.engine.core.common.businessentities.network.NetworkQoS; @@ -140,6 +141,15 @@ } } + public static class GlusterVolumeSnapshotConfigParamComparator implements Comparator<GlusterVolumeSnapshotConfigParam>, Serializable { + private static final long serialVersionUID = 2L; + + @Override + public int compare(GlusterVolumeSnapshotConfigParam param0, GlusterVolumeSnapshotConfigParam param1) { + return param0.getParamName().compareTo(param1.getParamName()); + } + } + public static class GlusterVolumeSnapshotComparer implements Comparator<GlusterVolumeSnapshotEntity>, Serializable { private static final long serialVersionUID = -6085272225112945249L; diff --git a/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/dataprovider/AsyncDataProvider.java b/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/dataprovider/AsyncDataProvider.java index b483c42..bb273b1 100644 --- a/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/dataprovider/AsyncDataProvider.java +++ b/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/dataprovider/AsyncDataProvider.java @@ -1674,6 +1674,10 @@ Frontend.getInstance().runQuery(VdcQueryType.GetEngineTimestamp, new VdcQueryParametersBase(), aQuery); } + public void getVolumeSnapshotConfig(AsyncQuery aQuery, Guid clusterId, Guid volumeId) { + Frontend.getInstance().runQuery(VdcQueryType.GetGlusterVolumeSnapshotConfig, new GlusterVolumeQueriesParameters(clusterId, volumeId), aQuery); + } + public void getGlusterVolumeProfilingStatistics(AsyncQuery aQuery, Guid clusterId, Guid volumeId, boolean nfs) { aQuery.setHandleFailure(true); GlusterVolumeProfileParameters parameters = new GlusterVolumeProfileParameters(clusterId, volumeId, nfs); diff --git a/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/help/HelpTag.java b/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/help/HelpTag.java index 068984b..8ad21e0 100644 --- a/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/help/HelpTag.java +++ b/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/help/HelpTag.java @@ -332,6 +332,8 @@ new_volume_snapshot("new_volume_snapshot", HelpTagType.WEBADMIN, "[gluster] Volumes main tab -> Snapshot -> New"), //$NON-NLS-1$ //$NON-NLS-2$ + configure_volume_snapshot("configure_volume_snapshot", HelpTagType.WEBADMIN, "[gluster] Volumes main tab -> Snapshot -> Options"), //$NON-NLS-1$ //$NON-NLS-2$ + parameters("parameters", HelpTagType.UNKNOWN), //$NON-NLS-1$ permissions("permissions", HelpTagType.UNKNOWN), //$NON-NLS-1$ diff --git a/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/gluster/GlusterVolumeSnapshotConfigModel.java b/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/gluster/GlusterVolumeSnapshotConfigModel.java new file mode 100644 index 0000000..9384b2a --- /dev/null +++ b/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/gluster/GlusterVolumeSnapshotConfigModel.java @@ -0,0 +1,179 @@ +package org.ovirt.engine.ui.uicommonweb.models.gluster; + +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; + +import org.ovirt.engine.core.common.businessentities.VDSGroup; +import org.ovirt.engine.core.common.businessentities.gluster.GlusterVolumeEntity; +import org.ovirt.engine.core.common.businessentities.gluster.GlusterVolumeSnapshotConfigParam; +import org.ovirt.engine.core.common.queries.VdcQueryReturnValue; +import org.ovirt.engine.core.common.utils.Pair; +import org.ovirt.engine.ui.frontend.AsyncQuery; +import org.ovirt.engine.ui.frontend.INewAsyncCallback; +import org.ovirt.engine.ui.uicommonweb.Linq; +import org.ovirt.engine.ui.uicommonweb.dataprovider.AsyncDataProvider; +import org.ovirt.engine.ui.uicommonweb.models.EntityModel; +import org.ovirt.engine.ui.uicommonweb.models.ListModel; +import org.ovirt.engine.ui.uicommonweb.models.Model; +import org.ovirt.engine.ui.uicompat.ConstantsManager; +import org.ovirt.engine.ui.uicompat.Event; +import org.ovirt.engine.ui.uicompat.EventArgs; +import org.ovirt.engine.ui.uicompat.IEventListener; + +public class GlusterVolumeSnapshotConfigModel extends Model { + private EntityModel<String> dataCenter; + private ListModel<VDSGroup> clusters; + private EntityModel<String> volumeName; + private ListModel<EntityModel<VolumeSnapshotConfigModel>> clusterConfigOptions; + private ListModel<EntityModel<VolumeSnapshotConfigModel>> volumeConfigOptions; + + public EntityModel<String> getDataCenter() { + return this.dataCenter; + } + + public void setDataCenter(EntityModel<String> dataCenter) { + this.dataCenter = dataCenter; + } + + public ListModel<VDSGroup> getClusters() { + return this.clusters; + } + + public void setClusters(ListModel<VDSGroup> clusters) { + this.clusters = clusters; + } + + public EntityModel<String> getVolumeName() { + return volumeName; + } + + public void setVolumeName(EntityModel<String> volumeName) { + this.volumeName = volumeName; + } + + public ListModel<EntityModel<VolumeSnapshotConfigModel>> getClusterConfigOptions() { + return clusterConfigOptions; + } + + public void setClusterConfigOptions(ListModel<EntityModel<VolumeSnapshotConfigModel>> clusterConfigOptions) { + this.clusterConfigOptions = clusterConfigOptions; + } + + public ListModel<EntityModel<VolumeSnapshotConfigModel>> getVolumeConfigOptions() { + return this.volumeConfigOptions; + } + + public void setVolumeConfigOptions(ListModel<EntityModel<VolumeSnapshotConfigModel>> volumeConfigOptions) { + this.volumeConfigOptions = volumeConfigOptions; + } + + private GlusterVolumeEntity selectedVolumeEntity; + + public GlusterVolumeEntity getSelectedVolumeEntity() { + return this.selectedVolumeEntity; + } + + public void setSelectedVolumeEntity(GlusterVolumeEntity volume) { + this.selectedVolumeEntity = volume; + } + + private boolean isVolumeTabAvailable; + + public boolean getIsVolumeTabAvailable() { + return this.isVolumeTabAvailable; + } + + public void setIsVolumeTabAvailable(boolean value) { + this.isVolumeTabAvailable = value; + } + + public GlusterVolumeSnapshotConfigModel() { + init(); + setAvailabilities(); + } + + private void init() { + setDataCenter(new EntityModel<String>()); + setClusters(new ListModel<VDSGroup>()); + getClusters().getSelectedItemChangedEvent().addListener(new IEventListener<EventArgs>() { + @Override + public void eventRaised(Event<? extends EventArgs> ev, Object sender, EventArgs args) { + clusterSelectedItemChanged(); + } + }); + setVolumeName(new EntityModel<String>()); + setClusterConfigOptions(new ListModel<EntityModel<VolumeSnapshotConfigModel>>()); + setVolumeConfigOptions(new ListModel<EntityModel<VolumeSnapshotConfigModel>>()); + } + + private void setAvailabilities() { + getClusters().setIsAvailable(true); + getVolumeName().setIsAvailable(true); + getClusterConfigOptions().setIsAvailable(true); + getVolumeConfigOptions().setIsAvailable(true); + } + + public boolean validate() { + boolean isValid = true; + setMessage(null); + Iterable<EntityModel<VolumeSnapshotConfigModel>> items1 = getClusterConfigOptions().getItems(); + for (EntityModel<VolumeSnapshotConfigModel> model : items1) { + VolumeSnapshotConfigModel option = model.getEntity(); + if (option.getOptionValue().trim().length() == 0) { + setMessage(ConstantsManager.getInstance() + .getMessages() + .clusterSnapshotOptionValueEmpty(option.getOptionName())); + isValid = false; + break; + } + } + Iterable<EntityModel<VolumeSnapshotConfigModel>> items2 = getVolumeConfigOptions().getItems(); + for (EntityModel<VolumeSnapshotConfigModel> model : items2) { + VolumeSnapshotConfigModel option = model.getEntity(); + if (option.getOptionValue().trim().length() == 0) { + setMessage(ConstantsManager.getInstance() + .getMessages() + .volumeSnapshotOptionValueEmpty(option.getOptionName())); + isValid = false; + break; + } + } + + return isValid; + } + + private void clusterSelectedItemChanged() { + AsyncDataProvider.getInstance().getVolumeSnapshotConfig(new AsyncQuery(this, new INewAsyncCallback() { + + @Override + public void onSuccess(Object model, Object returnValue) { + VdcQueryReturnValue vdcValue = (VdcQueryReturnValue) returnValue; + Pair<List<GlusterVolumeSnapshotConfigParam>, List<GlusterVolumeSnapshotConfigParam>> configs = + (Pair<List<GlusterVolumeSnapshotConfigParam>, List<GlusterVolumeSnapshotConfigParam>>) vdcValue.getReturnValue(); + List<GlusterVolumeSnapshotConfigParam> clusterConfigOptions = configs.getFirst(); + List<GlusterVolumeSnapshotConfigParam> volumeConfigOptions = configs.getSecond(); + Collections.sort(clusterConfigOptions, new Linq.GlusterVolumeSnapshotConfigParamComparator()); + Collections.sort(volumeConfigOptions, new Linq.GlusterVolumeSnapshotConfigParamComparator()); + setModelItems(getClusterConfigOptions(), clusterConfigOptions); + setModelItems(getVolumeConfigOptions(), volumeConfigOptions); + } + + private void setModelItems(ListModel<EntityModel<VolumeSnapshotConfigModel>> listModel, + List<GlusterVolumeSnapshotConfigParam> cfgs) { + List<EntityModel<VolumeSnapshotConfigModel>> coll = + new ArrayList<EntityModel<VolumeSnapshotConfigModel>>(); + for (GlusterVolumeSnapshotConfigParam cfg : cfgs) { + EntityModel<VolumeSnapshotConfigModel> cfgModel = new EntityModel<VolumeSnapshotConfigModel>(); + cfgModel.setEntity(new VolumeSnapshotConfigModel(cfg.getParamName(), cfg.getParamValue())); + coll.add(cfgModel); + } + + // set the entity items + listModel.setItems(coll); + } + }), + getClusters().getSelectedItem().getId(), + (selectedVolumeEntity == null) ? null : selectedVolumeEntity.getId()); + } +} diff --git a/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/gluster/GlusterVolumeSnapshotListModel.java b/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/gluster/GlusterVolumeSnapshotListModel.java index 05263cf..9ac6f53 100644 --- a/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/gluster/GlusterVolumeSnapshotListModel.java +++ b/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/gluster/GlusterVolumeSnapshotListModel.java @@ -37,7 +37,7 @@ @Override public String getListName() { - return "GlusterVolumeSnapshotModel"; //$NON-NLS-1$ + return "GlusterVolumeSnapshotListModel"; //$NON-NLS-1$ } public GlusterVolumeSnapshotListModel() { @@ -128,7 +128,7 @@ final GlusterVolumeSnapshotModel snapshotModel = new GlusterVolumeSnapshotModel(); snapshotModel.setHelpTag(HelpTag.new_volume_snapshot); snapshotModel.setHashName("new_volume_snapshot"); //$NON-NLS-1$ - snapshotModel.setTitle(ConstantsManager.getInstance().getConstants().createSnapshotTitle()); + snapshotModel.setTitle(ConstantsManager.getInstance().getConstants().createVolumeSnapshotTitle()); setWindow(snapshotModel); snapshotModel.getClusterName().setEntity(volumeEntity.getVdsGroupName()); @@ -185,8 +185,6 @@ } public void postOnCreateSnapshot(VdcReturnValueBase returnValue, GlusterVolumeSnapshotEntity snapshot) { - GlusterVolumeSnapshotModel model = (GlusterVolumeSnapshotModel) getWindow(); - if (returnValue != null && returnValue.getSucceeded()) { setWindow(null); } diff --git a/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/gluster/VolumeSnapshotConfigModel.java b/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/gluster/VolumeSnapshotConfigModel.java new file mode 100644 index 0000000..5e0765c --- /dev/null +++ b/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/gluster/VolumeSnapshotConfigModel.java @@ -0,0 +1,34 @@ +package org.ovirt.engine.ui.uicommonweb.models.gluster; + +import java.io.Serializable; + +public class VolumeSnapshotConfigModel implements Serializable { + private static final long serialVersionUID = 1L; + + private String optionName; + private String optionValue; + + public VolumeSnapshotConfigModel() { + } + + public VolumeSnapshotConfigModel(String optionName, String optionValue) { + this.optionName = optionName; + this.optionValue = optionValue; + } + + public String getOptionName() { + return optionName; + } + + public void setOptionName(String optionName) { + this.optionName = optionName; + } + + public String getOptionValue() { + return optionValue; + } + + public void setOptionValue(String optionValue) { + this.optionValue = optionValue; + } +} diff --git a/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/volumes/VolumeListModel.java b/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/volumes/VolumeListModel.java index 35e6476..bc467fa 100644 --- a/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/volumes/VolumeListModel.java +++ b/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/volumes/VolumeListModel.java @@ -13,6 +13,7 @@ import org.ovirt.engine.core.common.action.gluster.GlusterVolumeOptionParameters; import org.ovirt.engine.core.common.action.gluster.GlusterVolumeParameters; import org.ovirt.engine.core.common.action.gluster.GlusterVolumeRebalanceParameters; +import org.ovirt.engine.core.common.action.gluster.UpdateGlusterVolumeSnapshotConfigParameters; import org.ovirt.engine.core.common.asynctasks.gluster.GlusterAsyncTask; import org.ovirt.engine.core.common.asynctasks.gluster.GlusterTaskType; import org.ovirt.engine.core.common.businessentities.StoragePool; @@ -21,6 +22,7 @@ import org.ovirt.engine.core.common.businessentities.gluster.GlusterStatus; import org.ovirt.engine.core.common.businessentities.gluster.GlusterVolumeEntity; import org.ovirt.engine.core.common.businessentities.gluster.GlusterVolumeOptionEntity; +import org.ovirt.engine.core.common.businessentities.gluster.GlusterVolumeSnapshotConfigParam; import org.ovirt.engine.core.common.businessentities.gluster.GlusterVolumeTaskStatusEntity; import org.ovirt.engine.core.common.businessentities.gluster.GlusterVolumeType; import org.ovirt.engine.core.common.businessentities.gluster.TransportType; @@ -51,6 +53,8 @@ import org.ovirt.engine.ui.uicommonweb.models.SystemTreeItemModel; import org.ovirt.engine.ui.uicommonweb.models.SystemTreeItemType; import org.ovirt.engine.ui.uicommonweb.models.configure.PermissionListModel; +import org.ovirt.engine.ui.uicommonweb.models.gluster.GlusterVolumeSnapshotConfigModel; +import org.ovirt.engine.ui.uicommonweb.models.gluster.GlusterVolumeSnapshotListModel; import org.ovirt.engine.ui.uicommonweb.models.gluster.VolumeBrickListModel; import org.ovirt.engine.ui.uicommonweb.models.gluster.VolumeEventListModel; import org.ovirt.engine.ui.uicommonweb.models.gluster.VolumeGeneralModel; @@ -59,8 +63,8 @@ import org.ovirt.engine.ui.uicommonweb.models.gluster.VolumeParameterListModel; import org.ovirt.engine.ui.uicommonweb.models.gluster.VolumeProfileStatisticsModel; import org.ovirt.engine.ui.uicommonweb.models.gluster.VolumeRebalanceStatusModel; +import org.ovirt.engine.ui.uicommonweb.models.gluster.VolumeSnapshotConfigModel; import org.ovirt.engine.ui.uicommonweb.place.WebAdminApplicationPlaces; -import org.ovirt.engine.ui.uicommonweb.models.gluster.GlusterVolumeSnapshotListModel; import org.ovirt.engine.ui.uicompat.ConstantsManager; import org.ovirt.engine.ui.uicompat.FrontendActionAsyncResult; import org.ovirt.engine.ui.uicompat.FrontendMultipleActionAsyncResult; @@ -108,6 +112,7 @@ private UICommand showVolumeProfileDetailsCommand; private UICommand stopVolumeProfilingCommand; private UICommand createSnapshotCommand; + private UICommand configureSnapshotCommand; public UICommand getStartRebalanceCommand() { return startRebalanceCommand; @@ -209,6 +214,14 @@ this.createSnapshotCommand = command; } + public UICommand getConfigureSnapshotCommand() { + return this.configureSnapshotCommand; + } + + public void setConfigureSnapshotCommand(UICommand command) { + this.configureSnapshotCommand = command; + } + @Inject public VolumeListModel(final VolumeBrickListModel volumeBrickListModel, final VolumeGeneralModel volumeGeneralModel, @@ -242,6 +255,7 @@ setStopVolumeProfilingCommand(new UICommand("stopProfiling", this));//$NON-NLS-1$ setOptimizeForVirtStoreCommand(new UICommand("OptimizeForVirtStore", this)); //$NON-NLS-1$ setCreateSnapshotCommand(new UICommand("createSnapshot", this)); //$NON-NLS-1$ + setConfigureSnapshotCommand(new UICommand("configureSnapshot", this)); //$NON-NLS-1$ getRemoveVolumeCommand().setIsExecutionAllowed(false); getStartCommand().setIsExecutionAllowed(false); @@ -466,6 +480,7 @@ boolean allowStopProfiling = false; boolean allowProfileStatisticsDetails = false; boolean allowCreateSnapshot = false; + boolean allowConfigureSnapshot = true; if (getSelectedItems() == null || getSelectedItems().size() == 0) { allowStart = false; @@ -512,7 +527,7 @@ } allowStatusRebalance = getRebalanceStatusAvailability(getSelectedItems()); allowProfileStatisticsDetails = getProfileStatisticsAvailability(list); - allowCreateSnapshot = isCreateSnapshotAvailable(list); + allowCreateSnapshot = isSnapshotActionsAvailable(list); } getStartCommand().setIsExecutionAllowed(allowStart); getStopCommand().setIsExecutionAllowed(allowStop); @@ -522,6 +537,7 @@ getStatusRebalanceCommand().setIsExecutionAllowed(allowStatusRebalance); getOptimizeForVirtStoreCommand().setIsExecutionAllowed(allowOptimize); getCreateSnapshotCommand().setIsExecutionAllowed(allowCreateSnapshot); + getConfigureSnapshotCommand().setIsExecutionAllowed(allowConfigureSnapshot); // System tree dependent actions. boolean isAvailable = @@ -534,7 +550,7 @@ getShowVolumeProfileDetailsCommand().setIsExecutionAllowed(allowProfileStatisticsDetails); } - private boolean isCreateSnapshotAvailable(List<GlusterVolumeEntity> list) { + private boolean isSnapshotActionsAvailable(List<GlusterVolumeEntity> list) { if (getSelectedItems().size() == 1) { GlusterVolumeEntity volumeEntity = list.get(0); return (volumeEntity.getStatus() == GlusterStatus.UP); @@ -658,6 +674,10 @@ optimizeVolumesForVirtStore(selectedVolumes); } else if (command.equals(getCreateSnapshotCommand())) { getSnapshotListModel().getNewSnapshotCommand().execute(); + } else if (command.equals(getConfigureSnapshotCommand())) { + configureSnapshot(); + } else if (command.getName().equalsIgnoreCase("onConfigureSnapshot")) {//$NON-NLS-1$ + onConfigureSnapshot(); } } @@ -1174,6 +1194,105 @@ } } + /** + * This action is handled here in VolumeLisModel only, because there is a use case where no volume would be selected + * for setting the configuration. And in this scenario the GlusrerVolumeSnapshotListModel would not be initialized. + */ + public void configureSnapshot() { + if (getWindow() != null) { + return; + } + + final UIConstants constants = ConstantsManager.getInstance().getConstants(); + + GlusterVolumeEntity volumeEntity = + (getSelectedItems() == null || getSelectedItems().size() == 0) ? null + : (GlusterVolumeEntity) getSelectedItems().get(0); + final GlusterVolumeSnapshotConfigModel snapshotConfigModel = new GlusterVolumeSnapshotConfigModel(); + snapshotConfigModel.setHelpTag(HelpTag.configure_volume_snapshot); + snapshotConfigModel.setHashName("configure_volume_snapshot"); //$NON-NLS-1$ + snapshotConfigModel.setTitle(ConstantsManager.getInstance().getConstants().configureVolumeSnapshotTitle()); + snapshotConfigModel.setIsVolumeTabAvailable(volumeEntity == null ? false : true); + setWindow(snapshotConfigModel); + + AsyncDataProvider.getInstance().getClusterList(new AsyncQuery(this, new INewAsyncCallback() { + + @Override + public void onSuccess(Object model, Object returnValue) { + snapshotConfigModel.getClusters().setItems((List<VDSGroup>) returnValue); + } + })); + + snapshotConfigModel.setSelectedVolumeEntity(volumeEntity); + snapshotConfigModel.getVolumeConfigOptions().setTitle(ConstantsManager.getInstance() + .getConstants() + .configureVolumeSnapshotTitle()); + snapshotConfigModel.getClusterConfigOptions().setTitle(ConstantsManager.getInstance() + .getConstants() + .configureVolumeSnapshotTitle()); + snapshotConfigModel.getVolumeName().setEntity(volumeEntity == null ? "" : volumeEntity.getName()); + + if (getSystemTreeSelectedItem() != null) { + VDSGroup selectedCluster = (VDSGroup) getSystemTreeSelectedItem().getEntity(); + snapshotConfigModel.getClusters().setSelectedItem(selectedCluster); + } + + UICommand updateCommand = new UICommand("onConfigureSnapshot", this); //$NON-NLS-1$ + updateCommand.setTitle(constants.snapshotConfigUpdateButtonLabel()); + updateCommand.setIsDefault(true); + snapshotConfigModel.getCommands().add(updateCommand); + + UICommand cancelCommand = new UICommand("Cancel", this); //$NON-NLS-1$ + cancelCommand.setTitle(constants.cancel()); + cancelCommand.setIsCancel(false); + snapshotConfigModel.getCommands().add(cancelCommand); + } + + public void onConfigureSnapshot() { + GlusterVolumeSnapshotConfigModel snapshotConfigModel = (GlusterVolumeSnapshotConfigModel) getWindow(); + + if (!snapshotConfigModel.validate()) { + return; + } + + Guid clusterId = snapshotConfigModel.getClusters().getSelectedItem().getId(); + List<GlusterVolumeSnapshotConfigParam> vdsParams = new ArrayList<GlusterVolumeSnapshotConfigParam>(); + for (EntityModel<VolumeSnapshotConfigModel> clusterCfg : snapshotConfigModel.getClusterConfigOptions() + .getItems()) { + vdsParams.add(new GlusterVolumeSnapshotConfigParam(clusterId, + null, + clusterCfg.getEntity().getOptionName(), + clusterCfg.getEntity().getOptionValue())); + } + GlusterVolumeEntity volumeEntity = + (getSelectedItems() == null || getSelectedItems().size() == 0) ? null + : (GlusterVolumeEntity) getSelectedItems().get(0); + if (volumeEntity != null) { + for (EntityModel<VolumeSnapshotConfigModel> volumeCfg : snapshotConfigModel.getVolumeConfigOptions() + .getItems()) { + vdsParams.add(new GlusterVolumeSnapshotConfigParam(snapshotConfigModel.getClusters() + .getSelectedItem() + .getId(), + volumeEntity.getId(), + volumeCfg.getEntity().getOptionName(), + volumeCfg.getEntity().getOptionValue())); + } + } + + Frontend.getInstance().runAction(VdcActionType.UpdateGlusterVolumeSnapshotConfig, + new UpdateGlusterVolumeSnapshotConfigParameters(clusterId, volumeEntity == null ? null + : volumeEntity.getId(), vdsParams), + new IFrontendActionAsyncCallback() { + @Override + public void executed(FrontendActionAsyncResult result) { + if (result.getReturnValue() != null && result.getReturnValue().getSucceeded()) { + cancel(); + } + } + }, + this); + } + @Override protected String getListName() { return "VolumeListModel"; //$NON-NLS-1$ diff --git a/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/place/WebAdminApplicationPlaces.java b/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/place/WebAdminApplicationPlaces.java index 459b9cb..211a32b 100644 --- a/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/place/WebAdminApplicationPlaces.java +++ b/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/place/WebAdminApplicationPlaces.java @@ -311,7 +311,7 @@ public static final String volumeGeoRepSubTabPlace = volumeMainTabPlace + SUB_TAB_PREFIX + "geo_rep"; //$NON-NLS-1$ - public static final String volumeSnapshotSubTabPlace = volumeMainTabPlace + SUB_TAB_PREFIX + "volume_snapshots"; //$NON-NLS-1$ + public static final String volumeSnapshotSubTabPlace = volumeMainTabPlace + SUB_TAB_PREFIX + "snapshots"; //$NON-NLS-1$ // Disk diff --git a/frontend/webadmin/modules/uicompat/src/main/java/org/ovirt/engine/ui/uicompat/UIConstants.java b/frontend/webadmin/modules/uicompat/src/main/java/org/ovirt/engine/ui/uicompat/UIConstants.java index 906c11e..3cbb17a 100644 --- a/frontend/webadmin/modules/uicompat/src/main/java/org/ovirt/engine/ui/uicompat/UIConstants.java +++ b/frontend/webadmin/modules/uicompat/src/main/java/org/ovirt/engine/ui/uicompat/UIConstants.java @@ -2479,4 +2479,13 @@ @DefaultStringValue("Remove the Data Center(s) will move the entities residing on the storage domain(s) to an unregistered state. For further information please consult documentation.") String removeDataCenterWarnningNote(); + + @DefaultStringValue("New Snapshot") + String createVolumeSnapshotTitle(); + + @DefaultStringValue("Snapshot Options") + String configureVolumeSnapshotTitle(); + + @DefaultStringValue("Update") + String snapshotConfigUpdateButtonLabel(); } diff --git a/frontend/webadmin/modules/uicompat/src/main/java/org/ovirt/engine/ui/uicompat/UIMessages.java b/frontend/webadmin/modules/uicompat/src/main/java/org/ovirt/engine/ui/uicompat/UIMessages.java index 64d019b..b4f817d 100644 --- a/frontend/webadmin/modules/uicompat/src/main/java/org/ovirt/engine/ui/uicompat/UIMessages.java +++ b/frontend/webadmin/modules/uicompat/src/main/java/org/ovirt/engine/ui/uicompat/UIMessages.java @@ -1,6 +1,5 @@ package org.ovirt.engine.ui.uicompat; -import java.util.Date; import java.util.List; public interface UIMessages extends com.google.gwt.i18n.client.Messages { @@ -415,4 +414,10 @@ @DefaultMessage("Do you approve trusting self signed certificate subject {0}, SHA-1 fingerprint {1}?") String approveRootCertificateTrust(String subject, String sha1Fingerprint); + + @DefaultMessage("Value of cluster configuration parameter {0} is empty") + String clusterSnapshotOptionValueEmpty(String option); + + @DefaultMessage("Value of volume configuration parameter {0} is empty") + String volumeSnapshotOptionValueEmpty(String option); } diff --git a/frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/ApplicationConstants.java b/frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/ApplicationConstants.java index 1d98020..2e803cd 100644 --- a/frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/ApplicationConstants.java +++ b/frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/ApplicationConstants.java @@ -3979,6 +3979,9 @@ @DefaultStringValue("New") String newVolumeSnapshot(); + @DefaultStringValue("Options") + String configureVolumeSnapshotOptions(); + @DefaultStringValue("Snapshot") String volumeSnapshotMainTabTitle(); @@ -4028,4 +4031,19 @@ @DefaultStringValue("Deactivate") String deactivateVolumeSnapshot(); + + @DefaultStringValue("Option") + String volumeSnapshotConfigName(); + + @DefaultStringValue("Value") + String volumeSnapshotConfigValue(); + + @DefaultStringValue("Cluster") + String configTabClusterLable(); + + @DefaultStringValue("Volume") + String configTabVolumeLabel(); + + @DefaultStringValue("Snapshot Options") + String snapshotConfigHeaderLabel(); } diff --git a/frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/gin/PresenterModule.java b/frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/gin/PresenterModule.java index 0adb707..46c1bda 100644 --- a/frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/gin/PresenterModule.java +++ b/frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/gin/PresenterModule.java @@ -43,6 +43,7 @@ import org.ovirt.engine.ui.webadmin.section.main.presenter.popup.gluster.AddBrickPopupPresenterWidget; import org.ovirt.engine.ui.webadmin.section.main.presenter.popup.gluster.BrickAdvancedDetailsPopupPresenterWidget; import org.ovirt.engine.ui.webadmin.section.main.presenter.popup.gluster.DetachGlusterHostsPopupPresenterWidget; +import org.ovirt.engine.ui.webadmin.section.main.presenter.popup.gluster.GlusterVolumeSnapshotConfigurePopupPresenterWidget; import org.ovirt.engine.ui.webadmin.section.main.presenter.popup.gluster.GlusterVolumeSnapshotCreatePopupPresenterWidget; import org.ovirt.engine.ui.webadmin.section.main.presenter.popup.gluster.RemoveBrickPopupPresenterWidget; import org.ovirt.engine.ui.webadmin.section.main.presenter.popup.gluster.RemoveBrickStatusPopupPresenterWidget; @@ -163,13 +164,13 @@ import org.ovirt.engine.ui.webadmin.section.main.presenter.tab.disk.SubTabDiskStoragePresenter; import org.ovirt.engine.ui.webadmin.section.main.presenter.tab.disk.SubTabDiskTemplatePresenter; import org.ovirt.engine.ui.webadmin.section.main.presenter.tab.disk.SubTabDiskVmPresenter; +import org.ovirt.engine.ui.webadmin.section.main.presenter.tab.gluster.SubTabGlusterVolumeSnapshotPresenter; import org.ovirt.engine.ui.webadmin.section.main.presenter.tab.gluster.SubTabVolumeBrickPresenter; import org.ovirt.engine.ui.webadmin.section.main.presenter.tab.gluster.SubTabVolumeEventPresenter; import org.ovirt.engine.ui.webadmin.section.main.presenter.tab.gluster.SubTabVolumeGeneralPresenter; import org.ovirt.engine.ui.webadmin.section.main.presenter.tab.gluster.SubTabVolumeGeoRepPresenter; import org.ovirt.engine.ui.webadmin.section.main.presenter.tab.gluster.SubTabVolumeParameterPresenter; import org.ovirt.engine.ui.webadmin.section.main.presenter.tab.gluster.SubTabVolumePermissionPresenter; -import org.ovirt.engine.ui.webadmin.section.main.presenter.tab.gluster.SubTabGlusterVolumeSnapshotPresenter; import org.ovirt.engine.ui.webadmin.section.main.presenter.tab.gluster.VolumeSubTabPanelPresenter; import org.ovirt.engine.ui.webadmin.section.main.presenter.tab.host.HostSubTabPanelPresenter; import org.ovirt.engine.ui.webadmin.section.main.presenter.tab.host.SubTabHostBrickPresenter; @@ -283,6 +284,7 @@ import org.ovirt.engine.ui.webadmin.section.main.view.popup.gluster.AddBrickPopupView; import org.ovirt.engine.ui.webadmin.section.main.view.popup.gluster.BrickAdvancedDetailsPopupView; import org.ovirt.engine.ui.webadmin.section.main.view.popup.gluster.DetachGlusterHostsPopupView; +import org.ovirt.engine.ui.webadmin.section.main.view.popup.gluster.GlusterVolumeSnapshotConfigurePopupView; import org.ovirt.engine.ui.webadmin.section.main.view.popup.gluster.GlusterVolumeSnapshotCreatePopupView; import org.ovirt.engine.ui.webadmin.section.main.view.popup.gluster.RemoveBrickPopupView; import org.ovirt.engine.ui.webadmin.section.main.view.popup.gluster.RemoveBrickStatusPopupView; @@ -409,13 +411,13 @@ import org.ovirt.engine.ui.webadmin.section.main.view.tab.disk.SubTabDiskStorageView; import org.ovirt.engine.ui.webadmin.section.main.view.tab.disk.SubTabDiskTemplateView; import org.ovirt.engine.ui.webadmin.section.main.view.tab.disk.SubTabDiskVmView; +import org.ovirt.engine.ui.webadmin.section.main.view.tab.gluster.SubTabGlusterVolumeSnapshotView; import org.ovirt.engine.ui.webadmin.section.main.view.tab.gluster.SubTabVolumeBrickView; import org.ovirt.engine.ui.webadmin.section.main.view.tab.gluster.SubTabVolumeEventView; import org.ovirt.engine.ui.webadmin.section.main.view.tab.gluster.SubTabVolumeGeneralView; import org.ovirt.engine.ui.webadmin.section.main.view.tab.gluster.SubTabVolumeGeoRepView; import org.ovirt.engine.ui.webadmin.section.main.view.tab.gluster.SubTabVolumeParameterView; import org.ovirt.engine.ui.webadmin.section.main.view.tab.gluster.SubTabVolumePermissionView; -import org.ovirt.engine.ui.webadmin.section.main.view.tab.gluster.SubTabGlusterVolumeSnapshotView; import org.ovirt.engine.ui.webadmin.section.main.view.tab.gluster.VolumeSubTabPanelView; import org.ovirt.engine.ui.webadmin.section.main.view.tab.host.HostSubTabPanelView; import org.ovirt.engine.ui.webadmin.section.main.view.tab.host.SubTabHostBrickView; @@ -787,6 +789,9 @@ bindPresenterWidget(GlusterVolumeSnapshotCreatePopupPresenterWidget.class, GlusterVolumeSnapshotCreatePopupPresenterWidget.ViewDef.class, GlusterVolumeSnapshotCreatePopupView.class); + bindPresenterWidget(GlusterVolumeSnapshotConfigurePopupPresenterWidget.class, + GlusterVolumeSnapshotConfigurePopupPresenterWidget.ViewDef.class, + GlusterVolumeSnapshotConfigurePopupView.class); // Host bindPresenter(HostSubTabPanelPresenter.class, diff --git a/frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/gin/uicommon/VolumeModule.java b/frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/gin/uicommon/VolumeModule.java index ac1a2dc..617ffd3 100644 --- a/frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/gin/uicommon/VolumeModule.java +++ b/frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/gin/uicommon/VolumeModule.java @@ -31,6 +31,7 @@ import org.ovirt.engine.ui.webadmin.section.main.presenter.popup.event.EventPopupPresenterWidget; import org.ovirt.engine.ui.webadmin.section.main.presenter.popup.gluster.AddBrickPopupPresenterWidget; import org.ovirt.engine.ui.webadmin.section.main.presenter.popup.gluster.BrickAdvancedDetailsPopupPresenterWidget; +import org.ovirt.engine.ui.webadmin.section.main.presenter.popup.gluster.GlusterVolumeSnapshotConfigurePopupPresenterWidget; import org.ovirt.engine.ui.webadmin.section.main.presenter.popup.gluster.GlusterVolumeSnapshotCreatePopupPresenterWidget; import org.ovirt.engine.ui.webadmin.section.main.presenter.popup.gluster.RemoveBrickPopupPresenterWidget; import org.ovirt.engine.ui.webadmin.section.main.presenter.popup.gluster.RemoveBrickStatusPopupPresenterWidget; @@ -61,7 +62,8 @@ final Provider<VolumeRebalanceStatusPopupPresenterWidget> rebalanceStatusPopupProvider, final Provider<VolumeProfileStatisticsPopupPresenterWidget> volumeProfileStatsPopupProvider, final Provider<VolumeListModel> modelProvider, - final Provider<CommonModel> commonModelProvider) { + final Provider<CommonModel> commonModelProvider, + final Provider<GlusterVolumeSnapshotConfigurePopupPresenterWidget> snapshotConfigPopupProvider) { MainTabModelProvider<GlusterVolumeEntity, VolumeListModel> result = new MainTabModelProvider<GlusterVolumeEntity, VolumeListModel>(eventBus, defaultConfirmPopupProvider, @@ -80,8 +82,9 @@ else if (lastExecutedCommand == getModel().getShowVolumeProfileDetailsCommand() || lastExecutedCommand.getName().equals("showProfileDetails")) {//$NON-NLS-1$ return volumeProfileStatsPopupProvider.get(); - } - else { + } else if (lastExecutedCommand == getModel().getConfigureSnapshotCommand()) { + return snapshotConfigPopupProvider.get(); + } else { return super.getModelPopup(source, lastExecutedCommand, windowModel); } } diff --git a/frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/section/main/presenter/popup/gluster/GlusterVolumeSnapshotConfigurePopupPresenterWidget.java b/frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/section/main/presenter/popup/gluster/GlusterVolumeSnapshotConfigurePopupPresenterWidget.java new file mode 100644 index 0000000..5cb91cb --- /dev/null +++ b/frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/section/main/presenter/popup/gluster/GlusterVolumeSnapshotConfigurePopupPresenterWidget.java @@ -0,0 +1,27 @@ +package org.ovirt.engine.ui.webadmin.section.main.presenter.popup.gluster; + +import org.ovirt.engine.ui.common.presenter.AbstractModelBoundPopupPresenterWidget; +import org.ovirt.engine.ui.common.presenter.popup.DefaultConfirmationPopupPresenterWidget; +import org.ovirt.engine.ui.uicommonweb.models.gluster.GlusterVolumeSnapshotConfigModel; + +import com.google.gwt.event.shared.EventBus; +import com.google.inject.Inject; +import com.google.inject.Provider; + +public class GlusterVolumeSnapshotConfigurePopupPresenterWidget extends AbstractModelBoundPopupPresenterWidget<GlusterVolumeSnapshotConfigModel, GlusterVolumeSnapshotConfigurePopupPresenterWidget.ViewDef> { + @Inject + public GlusterVolumeSnapshotConfigurePopupPresenterWidget(EventBus eventBus, + ViewDef view, + Provider<GlusterVolumeSnapshotConfigurePopupPresenterWidget> snapshotPopupProvider, + Provider<DefaultConfirmationPopupPresenterWidget> defaultConfirmPopupPrivder) { + super(eventBus, view); + } + + @Override + public void init(final GlusterVolumeSnapshotConfigModel model) { + super.init(model); + } + + public interface ViewDef extends AbstractModelBoundPopupPresenterWidget.ViewDef<GlusterVolumeSnapshotConfigModel> { + } +} diff --git a/frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/section/main/view/popup/gluster/GlusterVolumeSnapshotConfigurePopupView.java b/frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/section/main/view/popup/gluster/GlusterVolumeSnapshotConfigurePopupView.java new file mode 100644 index 0000000..c846a13 --- /dev/null +++ b/frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/section/main/view/popup/gluster/GlusterVolumeSnapshotConfigurePopupView.java @@ -0,0 +1,186 @@ +package org.ovirt.engine.ui.webadmin.section.main.view.popup.gluster; + +import org.ovirt.engine.core.common.businessentities.VDSGroup; +import org.ovirt.engine.ui.common.idhandler.ElementIdHandler; +import org.ovirt.engine.ui.common.idhandler.WithElementId; +import org.ovirt.engine.ui.common.view.popup.AbstractModelBoundPopupView; +import org.ovirt.engine.ui.common.widget.dialog.SimpleDialogPanel; +import org.ovirt.engine.ui.common.widget.dialog.tab.DialogTab; +import org.ovirt.engine.ui.common.widget.editor.EntityModelCellTable; +import org.ovirt.engine.ui.common.widget.editor.ListModelListBoxEditor; +import org.ovirt.engine.ui.common.widget.editor.generic.StringEntityModelLabelEditor; +import org.ovirt.engine.ui.common.widget.renderer.NullSafeRenderer; +import org.ovirt.engine.ui.common.widget.table.column.EntityModelTextColumn; +import org.ovirt.engine.ui.uicommonweb.models.EntityModel; +import org.ovirt.engine.ui.uicommonweb.models.ListModel; +import org.ovirt.engine.ui.uicommonweb.models.gluster.GlusterVolumeSnapshotConfigModel; +import org.ovirt.engine.ui.uicommonweb.models.gluster.VolumeSnapshotConfigModel; +import org.ovirt.engine.ui.webadmin.ApplicationConstants; +import org.ovirt.engine.ui.webadmin.ApplicationResources; +import org.ovirt.engine.ui.webadmin.section.main.presenter.popup.gluster.GlusterVolumeSnapshotConfigurePopupPresenterWidget; + +import com.google.gwt.cell.client.FieldUpdater; +import com.google.gwt.cell.client.TextInputCell; +import com.google.gwt.core.shared.GWT; +import com.google.gwt.editor.client.SimpleBeanEditorDriver; +import com.google.gwt.event.shared.EventBus; +import com.google.gwt.uibinder.client.UiBinder; +import com.google.gwt.uibinder.client.UiField; +import com.google.gwt.user.cellview.client.Column; +import com.google.gwt.user.client.ui.Label; +import com.google.inject.Inject; + +public class GlusterVolumeSnapshotConfigurePopupView extends AbstractModelBoundPopupView<GlusterVolumeSnapshotConfigModel> implements GlusterVolumeSnapshotConfigurePopupPresenterWidget.ViewDef { + interface Driver extends SimpleBeanEditorDriver<GlusterVolumeSnapshotConfigModel, GlusterVolumeSnapshotConfigurePopupView> { + } + + interface ViewUiBinder extends UiBinder<SimpleDialogPanel, GlusterVolumeSnapshotConfigurePopupView> { + ViewUiBinder uiBinder = GWT.create(ViewUiBinder.class); + } + + interface ViewIdHandler extends ElementIdHandler<GlusterVolumeSnapshotConfigurePopupView> { + ViewIdHandler idHandler = GWT.create(ViewIdHandler.class); + } + + @UiField + DialogTab clusterTab; + + @UiField + DialogTab volumeTab; + + @UiField + @Ignore + @WithElementId + Label clusterSnapshotConfigHeader; + + @UiField + @Ignore + @WithElementId + Label volumeSnapshotConfigHeader; + + @UiField(provided = true) + @Path(value = "clusters.selectedItem") + @WithElementId + ListModelListBoxEditor<VDSGroup> clusterEditor; + + @UiField + @Path(value = "volumeName.entity") + @WithElementId + StringEntityModelLabelEditor volumeNameEditor; + + @UiField(provided = true) + @Ignore + @WithElementId + EntityModelCellTable<ListModel<EntityModel<VolumeSnapshotConfigModel>>> clusterConfigsTable; + + @UiField(provided = true) + @Ignore + @WithElementId + EntityModelCellTable<ListModel<EntityModel<VolumeSnapshotConfigModel>>> volumeConfigsTable; + + private final ApplicationConstants constants; + + private final Driver driver = GWT.create(Driver.class); + + @Inject + public GlusterVolumeSnapshotConfigurePopupView(EventBus eventBus, + ApplicationResources resources, + ApplicationConstants constants) { + super(eventBus, resources); + this.constants = constants; + initEditors(); + initWidget(ViewUiBinder.uiBinder.createAndBindUi(this)); + ViewIdHandler.idHandler.generateAndSetIds(this); + localize(); + driver.initialize(this); + } + + private void initEditors() { + clusterEditor = new ListModelListBoxEditor<VDSGroup>(new NullSafeRenderer<VDSGroup>() { + @Override + protected String renderNullSafe(VDSGroup object) { + return object.getName(); + } + }); + + clusterConfigsTable = new EntityModelCellTable<ListModel<EntityModel<VolumeSnapshotConfigModel>>>(false, true); + + clusterConfigsTable.addColumn(new EntityModelTextColumn<VolumeSnapshotConfigModel>() { + @Override + public String getText(VolumeSnapshotConfigModel object) { + return object.getOptionName(); + } + }, constants.volumeSnapshotConfigName(), "200px"); //$NON-NLS-1$ + + Column<EntityModel, String> valueColumn1 = new Column<EntityModel, String>(new TextInputCell()) { + @Override + public String getValue(EntityModel object) { + return ((VolumeSnapshotConfigModel) object.getEntity()).getOptionValue(); + } + }; + clusterConfigsTable.addColumn(valueColumn1, constants.volumeSnapshotConfigName(), "250px"); //$NON-NLS-1$ + + valueColumn1.setFieldUpdater(new FieldUpdater<EntityModel, String>() { + + @Override + public void update(int index, EntityModel object, String value) { + ((VolumeSnapshotConfigModel) object.getEntity()).setOptionValue(value); + } + }); + + volumeConfigsTable = new EntityModelCellTable<ListModel<EntityModel<VolumeSnapshotConfigModel>>>(false, true); + + volumeConfigsTable.addColumn(new EntityModelTextColumn<VolumeSnapshotConfigModel>() { + @Override + public String getText(VolumeSnapshotConfigModel object) { + return object.getOptionName(); + } + }, constants.volumeSnapshotConfigName(), "200px"); //$NON-NLS-1$ + + Column<EntityModel, String> valueColumn2 = new Column<EntityModel, String>(new TextInputCell()) { + @Override + public String getValue(EntityModel object) { + return ((VolumeSnapshotConfigModel) object.getEntity()).getOptionValue(); + } + }; + volumeConfigsTable.addColumn(valueColumn2, constants.volumeSnapshotConfigName(), "250px"); //$NON-NLS-1$ + + valueColumn2.setFieldUpdater(new FieldUpdater<EntityModel, String>() { + + @Override + public void update(int index, EntityModel object, String value) { + ((VolumeSnapshotConfigModel) object.getEntity()).setOptionValue(value); + } + }); + } + + private void localize() { + clusterEditor.setLabel(constants.volumeClusterLabel()); + volumeNameEditor.setLabel(constants.volumeNameLabel()); + clusterTab.setLabel(constants.configTabClusterLable()); + volumeTab.setLabel(constants.configTabVolumeLabel()); + clusterSnapshotConfigHeader.setText(constants.snapshotConfigHeaderLabel()); + volumeSnapshotConfigHeader.setText(constants.snapshotConfigHeaderLabel()); + } + + @Override + public void edit(final GlusterVolumeSnapshotConfigModel object) { + driver.edit(object); + clusterConfigsTable.asEditor().edit(object.getClusterConfigOptions()); + volumeConfigsTable.asEditor().edit(object.getVolumeConfigOptions()); + volumeTab.setVisible(object.getIsVolumeTabAvailable()); + } + + @Override + public GlusterVolumeSnapshotConfigModel flush() { + return driver.flush(); + } + + public DialogTab getVolumeTab() { + return this.volumeTab; + } + + public DialogTab getClusterTab() { + return this.clusterTab; + } +} diff --git a/frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/section/main/view/popup/gluster/GlusterVolumeSnapshotConfigurePopupView.ui.xml b/frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/section/main/view/popup/gluster/GlusterVolumeSnapshotConfigurePopupView.ui.xml new file mode 100644 index 0000000..aae93b9 --- /dev/null +++ b/frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/section/main/view/popup/gluster/GlusterVolumeSnapshotConfigurePopupView.ui.xml @@ -0,0 +1,68 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!DOCTYPE ui:UiBinder SYSTEM "http://dl.google.com/gwt/DTD/xhtml.ent"> +<ui:UiBinder xmlns:ui="urn:ui:com.google.gwt.uibinder" + xmlns:g="urn:import:com.google.gwt.user.client.ui" xmlns:d="urn:import:org.ovirt.engine.ui.common.widget.dialog" + xmlns:e="urn:import:org.ovirt.engine.ui.common.widget.editor" xmlns:w="urn:import:org.ovirt.engine.ui.common.widget" + xmlns:ge="urn:import:org.ovirt.engine.ui.common.widget.editor.generic" + xmlns:t="urn:import:org.ovirt.engine.ui.common.widget.dialog.tab"> + + <ui:style> + .tablePanel { + padding: 5px; + border: 1px solid #CED8DF; + width: + 450px; + } + + .headerLabel { + font-weight: bold; + padding-bottom: 5px; + padding-top: 30px; + } + + .messageLabel { + color: #FF0000; + left: 10px; + padding-left: 5px; + } + </ui:style> + + <d:SimpleDialogPanel width="650px" height="400px"> + <d:content> + <t:DialogTabPanel height="100%" width="100%"> + <t:tab> + <t:DialogTab ui:field="clusterTab"> + <t:content> + <g:SimplePanel> + <g:VerticalPanel> + <e:ListModelListBoxEditor ui:field="clusterEditor" /> + <g:Label ui:field="clusterSnapshotConfigHeader" + addStyleNames="{style.headerLabel}" /> + <e:EntityModelCellTable ui:field="clusterConfigsTable" + addStyleNames="{style.tablePanel}" /> + </g:VerticalPanel> + </g:SimplePanel> + </t:content> + </t:DialogTab> + </t:tab> + <t:tab> + <t:DialogTab ui:field="volumeTab"> + <t:content> + <g:SimplePanel> + <g:VerticalPanel> + <ge:StringEntityModelLabelEditor + ui:field="volumeNameEditor" /> + <g:Label ui:field="volumeSnapshotConfigHeader" + addStyleNames="{style.headerLabel}" /> + <e:EntityModelCellTable ui:field="volumeConfigsTable" + addStyleNames="{style.tablePanel}" /> + </g:VerticalPanel> + </g:SimplePanel> + </t:content> + </t:DialogTab> + </t:tab> + </t:DialogTabPanel> + </d:content> + </d:SimpleDialogPanel> + +</ui:UiBinder> diff --git a/frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/section/main/view/popup/gluster/GlusterVolumeSnapshotCreatePopupView.java b/frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/section/main/view/popup/gluster/GlusterVolumeSnapshotCreatePopupView.java index 3eba211..710f184 100644 --- a/frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/section/main/view/popup/gluster/GlusterVolumeSnapshotCreatePopupView.java +++ b/frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/section/main/view/popup/gluster/GlusterVolumeSnapshotCreatePopupView.java @@ -82,7 +82,6 @@ localize(); addStyles(); driver.initialize(this); - setTitle(constants.newVolumeSnapshot()); } private void initEditors() { diff --git a/frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/section/main/view/tab/MainTabVolumeView.java b/frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/section/main/view/tab/MainTabVolumeView.java index 9aede32..c340553 100644 --- a/frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/section/main/view/tab/MainTabVolumeView.java +++ b/frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/section/main/view/tab/MainTabVolumeView.java @@ -23,6 +23,7 @@ import org.ovirt.engine.ui.webadmin.section.main.view.AbstractMainTabWithDetailsTableView; import org.ovirt.engine.ui.webadmin.widget.action.WebAdminButtonDefinition; import org.ovirt.engine.ui.webadmin.widget.action.WebAdminMenuBarButtonDefinition; +import org.ovirt.engine.ui.webadmin.widget.table.column.GlusterVolumeSnapshotsCountColumn; import org.ovirt.engine.ui.webadmin.widget.table.column.MenuCell; import org.ovirt.engine.ui.webadmin.widget.table.column.VolumeActivityColumn; import org.ovirt.engine.ui.webadmin.widget.table.column.VolumeActivityCompositeCell; @@ -30,7 +31,6 @@ import org.ovirt.engine.ui.webadmin.widget.table.column.VolumeActivityStatusColumn; import org.ovirt.engine.ui.webadmin.widget.table.column.VolumeBrickStatusColumn; import org.ovirt.engine.ui.webadmin.widget.table.column.VolumeCapacityCell; -import org.ovirt.engine.ui.webadmin.widget.table.column.GlusterVolumeSnapshotsCountColumn; import org.ovirt.engine.ui.webadmin.widget.table.column.VolumeStatusColumn; import org.ovirt.engine.ui.webadmin.widget.table.column.VolumeTaskWaitingCell; @@ -229,7 +229,16 @@ return getMainModel().getCreateSnapshotCommand(); } }; + + WebAdminButtonDefinition<GlusterVolumeEntity> configureSnapshotButton = new WebAdminButtonDefinition<GlusterVolumeEntity>(constants.configureVolumeSnapshotOptions()) { + @Override + protected UICommand resolveCommand() { + return getMainModel().getConfigureSnapshotCommand(); + } + }; + snapshotMenu.add(newSnapshotButton); + snapshotMenu.add(configureSnapshotButton); return snapshotMenu; } -- To view, visit http://gerrit.ovirt.org/36295 To unsubscribe, visit http://gerrit.ovirt.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I08b5e592b818266106bc1891c3aa2f3ba3541d36 Gerrit-PatchSet: 1 Gerrit-Project: ovirt-engine Gerrit-Branch: master Gerrit-Owner: Shubhendu Tripathi <[email protected]> _______________________________________________ Engine-patches mailing list [email protected] http://lists.ovirt.org/mailman/listinfo/engine-patches
