Yaniv Bronhaim has uploaded a new change for review. Change subject: [wip] Modifying Add\Edit Host popup view ......................................................................
[wip] Modifying Add\Edit Host popup view 1. Adding username and password fields for authentication. 2. Adding ssh fingerprint field and fetch button. 3. Adding port field to communicate with host. Change-Id: I4e59c8b89da7345733439db95bdb4c729435e372 Bug-Id: https://bugzilla.redhat.com/show_bug.cgi?id=848072 Signed-off-by: Yaniv Bronhaim <[email protected]> --- M frontend/webadmin/modules/gwt-common/src/main/java/org/ovirt/engine/ui/common/CommonApplicationConstants.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/models/hosts/HostListModel.java M frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/hosts/HostModel.java M frontend/webadmin/modules/uicompat/src/main/java/org/ovirt/engine/ui/uicompat/UIConstants.java M frontend/webadmin/modules/uicompat/src/main/resources/org/ovirt/engine/ui/uicompat/LocalizedEnums.properties 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/ApplicationMessages.java M frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/section/main/view/popup/cluster/ClusterPopupView.java M frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/section/main/view/popup/host/HostPopupView.java M frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/section/main/view/popup/host/HostPopupView.ui.xml M frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/section/main/view/popup/host/MultipleHostsPopupView.java 12 files changed, 454 insertions(+), 27 deletions(-) git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/48/16048/1 diff --git a/frontend/webadmin/modules/gwt-common/src/main/java/org/ovirt/engine/ui/common/CommonApplicationConstants.java b/frontend/webadmin/modules/gwt-common/src/main/java/org/ovirt/engine/ui/common/CommonApplicationConstants.java index 05bc25e..bad7695 100644 --- a/frontend/webadmin/modules/gwt-common/src/main/java/org/ovirt/engine/ui/common/CommonApplicationConstants.java +++ b/frontend/webadmin/modules/gwt-common/src/main/java/org/ovirt/engine/ui/common/CommonApplicationConstants.java @@ -1274,4 +1274,10 @@ @DefaultStringValue("Are you sure you want to remove the following items?") String removeConfirmationPopupMessage(); + + @DefaultStringValue("Password") + String hostPasswordLabel(); + + @DefaultStringValue("SSH PublicKey") + String hostPublicKeyLable(); } 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 75af146..00aa755 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 @@ -1159,6 +1159,17 @@ Frontend.RunQuery(VdcQueryType.GetServerSSHKeyFingerprint, new ServerParameters(hostAddress), aQuery); } + public static void getHostPublicKey(AsyncQuery aQuery, String hostAddress) { + aQuery.converterCallback = new IAsyncConverter() { + @Override + public Object Convert(Object source, AsyncQuery _asyncQuery) + { + return source != null ? (String) source : ""; //$NON-NLS-1$ + } + }; + //Frontend.RunQuery(VdcQueryType.GetServerSSHPublicKey, new ServerParameters(hostAddress), aQuery); + } + public static void getGlusterHosts(AsyncQuery aQuery, String hostAddress, String rootPassword, String fingerprint) { GlusterServersQueryParameters parameters = new GlusterServersQueryParameters(hostAddress, rootPassword); parameters.setFingerprint(fingerprint); diff --git a/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/hosts/HostListModel.java b/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/hosts/HostListModel.java index 9e0bf60..517b76b 100644 --- a/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/hosts/HostListModel.java +++ b/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/hosts/HostListModel.java @@ -796,7 +796,7 @@ // Save changes. host.setVdsName((String) model.getName().getEntity()); host.setHostName((String) model.getHost().getEntity()); - host.setPort(Integer.parseInt(model.getPort().getEntity().toString())); + host.setPort(Integer.parseInt(model.getHostPort().getEntity().toString())); host.setSSHKeyFingerprint(host.getSSHKeyFingerprint()); host.setVdsSpmPriority(model.getSpmPriorityValue()); boolean consoleAddressSet = (Boolean) model.getConsoleAddressEnabled().getEntity(); @@ -813,6 +813,7 @@ host.setPmPassword((String) model.getPmPassword().getEntity()); host.setPmType((String) model.getPmType().getSelectedItem()); host.setPmOptionsMap(new ValueObjectMap(model.getPmOptionsMap(), false)); + host.setPmPort(Integer.parseInt(model.getPort().getEntity().toString())); // Save secondary PM parameters. host.setPmSecondaryIp((String) model.getPmSecondaryIp().getEntity()); @@ -836,6 +837,7 @@ AddVdsActionParameters parameters = new AddVdsActionParameters(); parameters.setVdsId(host.getId()); parameters.setvds(host); + parameters.getVdsStaticData().setSSHKeyFingerprint((String) model.getFetchSshFingerprint().getEntity()); parameters.setRootPassword((String) model.getRootPassword().getEntity()); parameters.setOverrideFirewall((Boolean) model.getOverrideIpTables().getEntity()); parameters.setRebootAfterInstallation(isVirt) ; diff --git a/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/hosts/HostModel.java b/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/hosts/HostModel.java index 2de46c4..d1e2bcb 100644 --- a/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/hosts/HostModel.java +++ b/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/hosts/HostModel.java @@ -8,11 +8,11 @@ import org.ovirt.engine.core.common.businessentities.FenceAgentOrder; import org.ovirt.engine.core.common.businessentities.FenceStatusReturnValue; +import org.ovirt.engine.core.common.businessentities.StoragePool; import org.ovirt.engine.core.common.businessentities.VDS; import org.ovirt.engine.core.common.businessentities.VDSGroup; import org.ovirt.engine.core.common.businessentities.VDSStatus; import org.ovirt.engine.core.common.businessentities.VdsStatic; -import org.ovirt.engine.core.common.businessentities.StoragePool; import org.ovirt.engine.core.common.mode.ApplicationMode; import org.ovirt.engine.core.common.queries.GetNewVdsFenceStatusParameters; import org.ovirt.engine.core.common.queries.ValueObjectMap; @@ -39,12 +39,12 @@ import org.ovirt.engine.ui.uicommonweb.validation.KeyValuePairValidation; import org.ovirt.engine.ui.uicommonweb.validation.LengthValidation; import org.ovirt.engine.ui.uicommonweb.validation.NotEmptyValidation; -import org.ovirt.engine.ui.uicompat.UIConstants; 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; import org.ovirt.engine.ui.uicompat.PropertyChangedEventArgs; +import org.ovirt.engine.ui.uicompat.UIConstants; public abstract class HostModel extends Model { @@ -120,6 +120,66 @@ private void setName(EntityModel value) { privateName = value; + } + + private EntityModel privateUserName; + + public EntityModel getUserName() + { + return privateUserName; + } + + private void setUserName(EntityModel value) + { + privateUserName = value; + } + + private EntityModel privateFetchSshFingerprint; + + public EntityModel getFetchSshFingerprint() + { + return privateFetchSshFingerprint; + } + + private void setFetchSshFingerprint(EntityModel value) + { + privateFetchSshFingerprint = value; + } + + private EntityModel privateHostPort; + + public EntityModel getHostPort() + { + return privateHostPort; + } + + private void setHostPort(EntityModel value) + { + privateHostPort = value; + } + + private EntityModel privateUserPassword; + + public EntityModel getUserPassword() + { + return privateUserPassword; + } + + private void setUserPassword(EntityModel value) + { + privateUserPassword = value; + } + + private EntityModel privatePublicKey; + + public EntityModel getPublicKey() + { + return privatePublicKey; + } + + private void setPublicKey(EntityModel value) + { + privatePublicKey = value; } private EntityModel privateProviderSearchFilterLabel; @@ -216,6 +276,18 @@ private void setRootPassword(EntityModel value) { privateRootPassword = value; + } + + private EntityModel privateFetchResult; + + public EntityModel getFetchResult() + { + return privateFetchResult; + } + + private void setFetchResult(EntityModel value) + { + privateFetchResult = value; } private EntityModel privateOverrideIpTables; @@ -588,6 +660,16 @@ proxyDownCommand = value; } + private UICommand proxySSHFingerPrintCommand; + + public UICommand getSSHFingerPrint() { + return proxySSHFingerPrintCommand; + } + + public void setSSHFingerPrint(UICommand value) { + proxySSHFingerPrintCommand = value; + } + private Integer postponedSpmPriority; public void setSpmPriorityValue(Integer value) { @@ -698,9 +780,28 @@ proxyDown(); } })); + setSSHFingerPrint(new UICommand("fetch", new ICommandTarget() { //$NON-NLS-1$ + @Override + public void executeCommand(UICommand command) { + fetchSSHFingerprint(); + } + + @Override + public void executeCommand(UICommand uiCommand, Object... parameters) { + fetchSSHFingerprint(); + } + })); setName(new EntityModel()); setHost(new EntityModel()); + setHostPort(new EntityModel()); + getHostPort().setEntity(constants.defaultHostSSHPort()); + setUserName(new EntityModel()); + getUserName().setEntity(constants.defaultUserName()); + setFetchSshFingerprint(new EntityModel()); + setUserPassword(new EntityModel()); + setPublicKey(new EntityModel()); + getPublicKey().setEntity(constants.empty()); setDataCenter(new ListModel()); getDataCenter().getSelectedItemChangedEvent().addListener(this); getDataCenter().setIsAvailable(ApplicationModeHelper.getUiMode() != ApplicationMode.GlusterOnly); @@ -708,6 +809,7 @@ getCluster().getSelectedItemChangedEvent().addListener(this); setPort(new EntityModel()); setRootPassword(new EntityModel()); + setFetchResult(new EntityModel()); setOverrideIpTables(new EntityModel()); getOverrideIpTables().setEntity(false); @@ -835,6 +937,48 @@ } } + public void fetchPublicKey() { + AsyncQuery aQuery = new AsyncQuery(); + aQuery.setModel(this); + aQuery.asyncCallback = new INewAsyncCallback() { + @Override + public void onSuccess(Object model, Object result) + { + String pk = (String) result; + if (pk != null && pk.length() > 0) + { + getPublicKey().setEntity(result); + } + } + }; + AsyncDataProvider.getHostPublicKey(aQuery, getHost().getEntity().toString()); + } + + private void fetchSSHFingerprint() { + AsyncQuery aQuery = new AsyncQuery(); + aQuery.setModel(this); + aQuery.asyncCallback = new INewAsyncCallback() { + @Override + public void onSuccess(Object model, Object result) + { + String fingerprint = (String) result; + if (fingerprint != null && fingerprint.length() > 0) + { + getFetchSshFingerprint().setEntity(result); + getFetchResult().setEntity((String) + ConstantsManager.getInstance().getConstants().successLoadingFingerprint()); + } + else + { + getFetchResult().setEntity((String) + ConstantsManager.getInstance().getConstants().errorLoadingFingerprint()); + } + } + }; + AsyncDataProvider.getHostFingerprint(aQuery, getHost().getEntity().toString()); + getFetchResult().setEntity((String) ConstantsManager.getInstance().getConstants().loadingFingerprint()); + } + boolean spmInitialized; int maxSpmPriority; int defaultSpmPriority; 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 625084a..0c766e4 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 @@ -1748,6 +1748,9 @@ @DefaultStringValue("Error in fetching fingerprint") String errorLoadingFingerprint(); + @DefaultStringValue("Fetched fingerprint successfully") + String successLoadingFingerprint(); + @DefaultStringValue("Fingerprint needs to be verified before importing the gluster configuration") String fingerprintNotVerified(); @@ -1911,4 +1914,9 @@ @DefaultStringValue("Time Zone is not changeable for Linux VMs") String timeZoneNotChangeableForLinuxVms(); + @DefaultStringValue("22") + String defaultHostSSHPort(); + + @DefaultStringValue("root") + String defaultUserName(); } diff --git a/frontend/webadmin/modules/uicompat/src/main/resources/org/ovirt/engine/ui/uicompat/LocalizedEnums.properties b/frontend/webadmin/modules/uicompat/src/main/resources/org/ovirt/engine/ui/uicompat/LocalizedEnums.properties index 4d35189..931eede 100644 --- a/frontend/webadmin/modules/uicompat/src/main/resources/org/ovirt/engine/ui/uicompat/LocalizedEnums.properties +++ b/frontend/webadmin/modules/uicompat/src/main/resources/org/ovirt/engine/ui/uicompat/LocalizedEnums.properties @@ -285,11 +285,7 @@ VdcActionType___UpdateGlusterHook=Update Gluster Hook VdcActionType___AddGlusterHook=Add Gluster Hook VdcActionType___RemoveGlusterHook=Remove Gluster Hook -<<<<<<< HEAD VdcActionType___RefreshGlusterHook=Refresh Gluster Hook -======= -VdcActionType___ManageGlusterService=Manage Service ->>>>>>> gluster: bll command to start/stop/restart service VdcActionType___ActivateStorageDomain=Activate Storage Domain VdcActionType___FenceVdsManualy=Fence Host Manually VdcActionType___AddEmptyStoragePool=New Data Center 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 dc08cae..9761df9 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 @@ -394,14 +394,29 @@ @DefaultStringValue("Name") String hostPopupNameLabel(); + @DefaultStringValue("SSH Port") + String hostPopupPortLabel(); + @DefaultStringValue("Address") String hostPopupHostAddressLabel(); - @DefaultStringValue("Fingerprint") + @DefaultStringValue("SSH Fingerprint") String hostPopupHostFingerprintLabel(); - @DefaultStringValue("Root Password") - String hostPopupRootPasswordLabel(); + @DefaultStringValue("User Name") + String hostPopupUsernameLabel(); + + @DefaultStringValue("root") + String hostPopupDefaultUsername(); + + @DefaultStringValue("SSH Public Key") + String hostPopupPublicKeyLable(); + + @DefaultStringValue("Password") + String hostPopupPasswordLabel(); + + @DefaultStringValue("Authentication") + String hostPopupAuthLabel(); @DefaultStringValue("Automatically configure host firewall") String hostPopupOverrideIpTablesLabel(); @@ -436,7 +451,7 @@ @DefaultStringValue("Type") String hostPopupPmTypeLabel(); - @DefaultStringValue("Port") + @DefaultStringValue("SSH Port") String hostPopupPmPortLabel(); @DefaultStringValue("Slot") @@ -459,6 +474,9 @@ @DefaultStringValue("Down") String hostPopupDownButtonLabel(); + + @DefaultStringValue("Fetch") + String hostPopupFetchButtonLabel(); @DefaultStringValue("Source") String hostPopupSourceText(); @@ -2184,7 +2202,7 @@ @DefaultStringValue("Apply") String hostsPopupApply(); - @DefaultStringValue("Fingerprint") + @DefaultStringValue("SSH Fingerprint") String hostsPopupFingerprint(); // Tag diff --git a/frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/ApplicationMessages.java b/frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/ApplicationMessages.java index 52b4758..447aa78 100644 --- a/frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/ApplicationMessages.java +++ b/frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/ApplicationMessages.java @@ -81,4 +81,7 @@ @DefaultMessage("Some new hosts are detected in the cluster. You can <a>Import</a> them to engine or <a>Detach</a> them from the cluster.") String clusterHasNewGlusterHosts(); + + @DefaultMessage("Enter host fingerprint or <a>fetch</a> manually from host.") + String fetchingHostFingerprint(); } diff --git a/frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/section/main/view/popup/cluster/ClusterPopupView.java b/frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/section/main/view/popup/cluster/ClusterPopupView.java index 5ead769..463fe31 100644 --- a/frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/section/main/view/popup/cluster/ClusterPopupView.java +++ b/frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/section/main/view/popup/cluster/ClusterPopupView.java @@ -343,7 +343,7 @@ importGlusterExplanationLabel.setText(constants.clusterImportGlusterConfigurationExplanationLabel()); glusterHostAddressEditor.setLabel(constants.hostPopupHostAddressLabel()); glusterHostFingerprintEditor.setLabel(constants.hostPopupHostFingerprintLabel()); - glusterHostPasswordEditor.setLabel(constants.hostPopupRootPasswordLabel()); + glusterHostPasswordEditor.setLabel(constants.hostPopupPasswordLabel()); optimizationTab.setLabel(constants.clusterPopupOptimizationTabLabel()); diff --git a/frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/section/main/view/popup/host/HostPopupView.java b/frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/section/main/view/popup/host/HostPopupView.java index c6b6b1f..9d3bc55 100644 --- a/frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/section/main/view/popup/host/HostPopupView.java +++ b/frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/section/main/view/popup/host/HostPopupView.java @@ -3,9 +3,9 @@ import java.util.List; import org.ovirt.engine.core.common.businessentities.Provider; +import org.ovirt.engine.core.common.businessentities.StoragePool; import org.ovirt.engine.core.common.businessentities.VDS; import org.ovirt.engine.core.common.businessentities.VDSGroup; -import org.ovirt.engine.core.common.businessentities.StoragePool; import org.ovirt.engine.core.common.mode.ApplicationMode; import org.ovirt.engine.ui.common.CommonApplicationTemplates; import org.ovirt.engine.ui.common.idhandler.ElementIdHandler; @@ -14,16 +14,19 @@ import org.ovirt.engine.ui.common.widget.Align; import org.ovirt.engine.ui.common.widget.HasUiCommandClickHandlers; import org.ovirt.engine.ui.common.widget.UiCommandButton; +import org.ovirt.engine.ui.common.widget.dialog.AdvancedParametersExpander; import org.ovirt.engine.ui.common.widget.dialog.InfoIcon; 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.dialog.tab.DialogTabPanel; import org.ovirt.engine.ui.common.widget.editor.EntityModelCheckBoxEditor; import org.ovirt.engine.ui.common.widget.editor.EntityModelPasswordBoxEditor; +import org.ovirt.engine.ui.common.widget.editor.EntityModelTextAreaLabelEditor; import org.ovirt.engine.ui.common.widget.editor.EntityModelTextBoxEditor; import org.ovirt.engine.ui.common.widget.editor.ListModelListBoxEditor; import org.ovirt.engine.ui.common.widget.editor.ListModelListBoxOnlyEditor; import org.ovirt.engine.ui.common.widget.renderer.NullSafeRenderer; +import org.ovirt.engine.ui.uicommonweb.UICommand; import org.ovirt.engine.ui.uicommonweb.models.ApplicationModeHelper; import org.ovirt.engine.ui.uicommonweb.models.EntityModel; import org.ovirt.engine.ui.uicommonweb.models.ListModel; @@ -33,11 +36,16 @@ import org.ovirt.engine.ui.uicompat.IEventListener; import org.ovirt.engine.ui.uicompat.PropertyChangedEventArgs; import org.ovirt.engine.ui.webadmin.ApplicationConstants; +import org.ovirt.engine.ui.webadmin.ApplicationMessages; import org.ovirt.engine.ui.webadmin.ApplicationResources; +import org.ovirt.engine.ui.webadmin.gin.ClientGinjectorProvider; import org.ovirt.engine.ui.webadmin.section.main.presenter.popup.host.HostPopupPresenterWidget; import com.google.gwt.core.client.GWT; +import com.google.gwt.dom.client.Style; +import com.google.gwt.dom.client.Style.Visibility; import com.google.gwt.editor.client.SimpleBeanEditorDriver; +import com.google.gwt.editor.client.Editor.Ignore; import com.google.gwt.event.dom.client.ChangeEvent; import com.google.gwt.event.dom.client.ChangeHandler; import com.google.gwt.event.dom.client.ClickEvent; @@ -49,11 +57,13 @@ import com.google.gwt.resources.client.CssResource; import com.google.gwt.uibinder.client.UiBinder; import com.google.gwt.uibinder.client.UiField; +import com.google.gwt.user.client.ui.Anchor; import com.google.gwt.user.client.ui.FlowPanel; import com.google.gwt.user.client.ui.Image; import com.google.gwt.user.client.ui.Label; import com.google.gwt.user.client.ui.ListBox; import com.google.gwt.user.client.ui.RadioButton; +import com.google.gwt.user.client.ui.SimplePanel; import com.google.gwt.user.client.ui.VerticalPanel; import com.google.inject.Inject; @@ -102,6 +112,21 @@ EntityModelTextBoxEditor nameEditor; @UiField + @Path(value = "userName.entity") + @WithElementId("userName") + EntityModelTextBoxEditor userNameEditor; + + @UiField + @Path(value = "fetchSshFingerprint.entity") + @WithElementId("fetchSshFingerprint") + EntityModelTextBoxEditor fetchSshFingerprint; + + @UiField + @Ignore + @WithElementId("fetchResult") + Label fetchResult; + + @UiField @Path(value = "providerSearchFilter.entity") @WithElementId("providerSearchFilter") EntityModelTextBoxEditor providerSearchFilterEditor; @@ -122,9 +147,19 @@ EntityModelTextBoxEditor hostAddressEditor; @UiField - @Path(value = "rootPassword.entity") - @WithElementId("rootPassword") - EntityModelPasswordBoxEditor rootPasswordEditor; + @Path(value = "hostPort.entity") + @WithElementId("hostPort") + EntityModelTextBoxEditor hostPortEditor; + + @UiField + @Path(value = "userPassword.entity") + @WithElementId("userPassword") + EntityModelPasswordBoxEditor passwordEditor; + + @UiField + @Path(value = "publicKey.entity") + @WithElementId("publicKey") + EntityModelTextAreaLabelEditor publicKeyEditor; @UiField @Path(value = "OverrideIpTables.entity") @@ -255,6 +290,10 @@ UiCommandButton downButton; @UiField + @Ignore + SimplePanel fetchPanel; + + @UiField Image updateHostsButton; @UiField @@ -279,6 +318,24 @@ @UiField @Ignore VerticalPanel spmPanel; + + @UiField(provided = true) + @Ignore + @WithElementId("rbPublicKey") + public RadioButton rbPublicKey; + + @UiField(provided = true) + @Ignore + @WithElementId("rbPassword") + public RadioButton rbPassword; + + @UiField + @Ignore + Label authLabel; + + @UiField + @Ignore + Label fingerprintLabel; @UiField(provided=true) @Ignore @@ -307,24 +364,38 @@ @UiField FlowPanel externalProviderPanel; + @UiField + @Ignore + AdvancedParametersExpander expander; + + @UiField + @Ignore + FlowPanel expanderContent; + private final Driver driver = GWT.create(Driver.class); private final CommonApplicationTemplates applicationTemplates; private final ApplicationResources resources; + // We need this to get the text of the alert messages: + private final ApplicationMessages messages; + @Inject public HostPopupView(EventBus eventBus, ApplicationResources resources, ApplicationConstants constants, CommonApplicationTemplates applicationTemplates) { super(eventBus, resources); + + // Inject a reference to the messages: + messages = ClientGinjectorProvider.instance().getApplicationMessages(); this.resources = resources; this.applicationTemplates = applicationTemplates; initEditors(); initInfoIcon(constants); initWidget(ViewUiBinder.uiBinder.createAndBindUi(this)); + initExpander(); ViewIdHandler.idHandler.generateAndSetIds(this); localize(constants); addStyles(); - driver.initialize(this); applyModeCustomizations(); } @@ -344,6 +415,8 @@ providerSearchFilterEditor.setLabelStyleName(style.emptyEditor()); providerSearchFilterLabel.addContentWidgetStyleName(style.emptyEditor()); providerSearchFilterLabel.setStyleName(style.searchFilterLabel()); + fetchSshFingerprint.addContentWidgetStyleName(style.fingerprintEditor()); + expanderContent.setStyleName(style.expanderContent()); } private void initEditors() { @@ -400,6 +473,8 @@ // Check boxes pmEnabledEditor = new EntityModelCheckBoxEditor(Align.RIGHT); externalHostProviderEnabledEditor = new EntityModelCheckBoxEditor(Align.RIGHT); + rbPassword = new RadioButton("1"); //$NON-NLS-1$ + rbPublicKey = new RadioButton("1"); //$NON-NLS-1$ } void localize(ApplicationConstants constants) { @@ -408,12 +483,18 @@ dataCenterEditor.setLabel(constants.hostPopupDataCenterLabel()); clusterEditor.setLabel(constants.hostPopupClusterLabel()); nameEditor.setLabel(constants.hostPopupNameLabel()); + userNameEditor.setLabel(constants.hostPopupUsernameLabel()); hostAddressEditor.setLabel(constants.hostPopupHostAddressLabel()); - rootPasswordEditor.setLabel(constants.hostPopupRootPasswordLabel()); + hostPortEditor.setLabel(constants.hostPopupPortLabel()); + authLabel.setText(constants.hostPopupAuthLabel()); + //createAuthControls(constants); + + fingerprintLabel.setText(constants.hostPopupHostFingerprintLabel()); overrideIpTablesEditor.setLabel(constants.hostPopupOverrideIpTablesLabel()); externalHostProviderEnabledEditor.setLabel(constants.hostPopupEnableExternalHostProvider()); externalHostNameEditor.setLabel(constants.hostPopupExternalHostName()); providerSearchFilterLabel.setLabel(constants.hostPopupProviderSearchFilter()); + // Power Management tab powerManagementTab.setLabel(constants.hostPopupPowerManagementTabLabel()); pmEnabledEditor.setLabel(constants.hostPopupPmEnabledLabel()); @@ -489,6 +570,35 @@ powerManagementTab.markAsInvalid(null); } } + } + }); + + object.getFetchResult().getEntityChangedEvent().addListener(new IEventListener() { + @Override + public void eventRaised(Event ev, Object sender, EventArgs args) { + fetchResult.setText((String) object.getFetchResult().getEntity()); + } + }); + + rbPassword.setValue(true); + passwordEditor.getElement().getStyle().setVisibility(Visibility.VISIBLE); + publicKeyEditor.getElement().getStyle().setVisibility(Visibility.HIDDEN); + fetchSshFingerprint.hideLabel(); + publicKeyEditor.setEnabled(false); + + rbPassword.addValueChangeHandler(new ValueChangeHandler<Boolean>() { + @Override + public void onValueChange(ValueChangeEvent<Boolean> event) { + passwordEditor.getElement().getStyle().setVisibility(Visibility.VISIBLE); + publicKeyEditor.getElement().getStyle().setVisibility(Visibility.HIDDEN); + } + }); + + rbPublicKey.addValueChangeHandler(new ValueChangeHandler<Boolean>() { + @Override + public void onValueChange(ValueChangeEvent<Boolean> event) { + publicKeyEditor.getElement().getStyle().setVisibility(Visibility.VISIBLE); + passwordEditor.getElement().getStyle().setVisibility(Visibility.HIDDEN); } }); @@ -591,6 +701,11 @@ updatePmPanelsVisibility(true); externalProviderPanel.setVisible(object.showExternalProviderPanel()); + addTextAndLinkAlert(fetchPanel, messages.fetchingHostFingerprint(), object.getSSHFingerPrint()); + } + + private void initExpander() { + expander.initWithContent(expanderContent.getElement()); } private void updatePmPanelsVisibility(boolean primary) { @@ -654,6 +769,62 @@ tabPanel.switchTab(powerManagementTab); } + /** + * Create a widget containing text and a link that triggers the execution of a command. + * + * @param view + * the view where the alert should be added + * @param text + * the text content of the alert + * @param command + * the command that should be executed when the link is clicked + */ + private void addTextAndLinkAlert(SimplePanel view, final String text, final UICommand command) { + // Find the open and close positions of the link within the message: + final int openIndex = text.indexOf("<a>"); //$NON-NLS-1$ + final int closeIndex = text.indexOf("</a>"); //$NON-NLS-1$ + if (openIndex == -1 || closeIndex == -1 || closeIndex < openIndex) { + return; + } + + // Extract the text before, inside and after the tags: + final String beforeText = text.substring(0, openIndex); + final String betweenText = text.substring(openIndex + 3, closeIndex); + final String afterText = text.substring(closeIndex + 4); + + // Create a flow panel containing the text and the link: + final FlowPanel alertPanel = new FlowPanel(); + + // Create the label for the text before the tag: + final Label beforeLabel = new Label(beforeText); + beforeLabel.getElement().getStyle().setProperty("display", "inline"); //$NON-NLS-1$ //$NON-NLS-2$ + alertPanel.add(beforeLabel); + + // Create the anchor: + final Anchor betweenAnchor = new Anchor(betweenText); + betweenAnchor.getElement().getStyle().setProperty("display", "inline"); //$NON-NLS-1$ //$NON-NLS-2$ + alertPanel.add(betweenAnchor); + + // Add a listener to the anchor so that the command is executed when + // it is clicked: + betweenAnchor.addClickHandler( + new ClickHandler() { + @Override + public void onClick(ClickEvent event) { + command.execute(); + } + } + ); + + // Create the label for the text after the tag: + final Label afterLabel = new Label(afterText); + afterLabel.getElement().getStyle().setProperty("display", "inline"); //$NON-NLS-1$ //$NON-NLS-2$ + alertPanel.add(afterLabel); + + // Add the alert to the view: + view.add(alertPanel); + } + interface Style extends CssResource { String radioButton(); @@ -667,6 +838,9 @@ String searchFilterLabel(); String emptyEditor(); - } + String fingerprintEditor(); + + String expanderContent(); + } } diff --git a/frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/section/main/view/popup/host/HostPopupView.ui.xml b/frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/section/main/view/popup/host/HostPopupView.ui.xml index 1a1bf39..532cd08 100644 --- a/frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/section/main/view/popup/host/HostPopupView.ui.xml +++ b/frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/section/main/view/popup/host/HostPopupView.ui.xml @@ -42,6 +42,16 @@ margin-bottom: 10px; } + .headerAuthLabel { + font-weight: bold; + margin-top: 10px; + } + + .fetchResultLabel { + font-color: red; + color: red; + } + .sourceLabel { font-size: 13px; font-family: Verdana,sans-serif; @@ -73,13 +83,21 @@ margin-left: 10px; } + .buttonStyle { + margin-top: 10px; + margin-left: 10px; + height: 20px; + width: 100%; + } + .testMessage { margin-top: 10px; } .radioButton { - margin-right: 15px; + margin-right: 5px; } + .overrideIpStyle { width: 200px; } @@ -150,9 +168,33 @@ display: none; } + .fetchSshFingerprintField { + width: 300px; + enabled: false; + } + + .textBoxStyle { + height: 17px; + float: none; + display: inline; + } + + .fingerprintEditor { + width: 495px; + } + + .content { + width:100%; + } + + .expanderContent { + margin-left: 15px; + display: none; + } + </ui:style> - <d:SimpleDialogPanel width="700px" height="500px"> + <d:SimpleDialogPanel width="700px" height="660px"> <d:content> <t:DialogTabPanel ui:field="tabPanel" height="100%"> <t:tab> @@ -182,10 +224,33 @@ </g:FlowPanel> <e:ListModelListBoxEditor ui:field="externalHostNameEditor"/> </g:FlowPanel> - <e:EntityModelTextBoxEditor ui:field="nameEditor"/> - <e:EntityModelTextBoxEditor ui:field="hostAddressEditor"/> - <e:EntityModelPasswordBoxEditor ui:field="rootPasswordEditor"/> - <e:EntityModelCheckBoxEditor ui:field="overrideIpTablesEditor"/> + <g:FlowPanel> + <e:EntityModelTextBoxEditor ui:field="nameEditor"/> + <e:EntityModelTextBoxEditor ui:field="hostAddressEditor" /> + <e:EntityModelTextBoxEditor ui:field="hostPortEditor"/> + <g:VerticalPanel addStyleNames="{style.content}"> + <g:Label ui:field="authLabel" addStyleNames="{style.headerAuthLabel}"/> + <e:EntityModelTextBoxEditor ui:field="userNameEditor"/> + <g:HorizontalPanel width="100%"> + <g:RadioButton ui:field="rbPassword" /> + <g:Label text="{constants.hostPasswordLabel}" /> + <e:EntityModelPasswordBoxEditor ui:field="passwordEditor"/> + </g:HorizontalPanel> + <g:HorizontalPanel width="100%"> + <g:RadioButton ui:field="rbPublicKey" addStyleNames="{style.radioButton}" /> + <g:Label text="{constants.hostPublicKeyLable}" /> + <e:EntityModelTextAreaLabelEditor ui:field="publicKeyEditor"/> + </g:HorizontalPanel> + <d:AdvancedParametersExpander ui:field="expander"/> + <g:FlowPanel ui:field="expanderContent"> + <e:EntityModelCheckBoxEditor ui:field="overrideIpTablesEditor"/> + <g:Label ui:field="fingerprintLabel" /> + <e:EntityModelTextBoxEditor ui:field="fetchSshFingerprint"/> + <g:SimplePanel ui:field="fetchPanel"/> + <g:Label ui:field="fetchResult" addStyleNames="{style.fetchResultLabel}"/> + </g:FlowPanel> + </g:VerticalPanel> + </g:FlowPanel> </g:FlowPanel> </t:content> </t:DialogTab> diff --git a/frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/section/main/view/popup/host/MultipleHostsPopupView.java b/frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/section/main/view/popup/host/MultipleHostsPopupView.java index 1bd04d1..0a608de 100644 --- a/frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/section/main/view/popup/host/MultipleHostsPopupView.java +++ b/frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/section/main/view/popup/host/MultipleHostsPopupView.java @@ -124,7 +124,7 @@ return ((HostDetailModel) object.getEntity()).getPassword(); } }; - hostsTable.addColumn(passwordColumn, constants.hostPopupRootPasswordLabel(), "100px"); //$NON-NLS-1$ + hostsTable.addColumn(passwordColumn, constants.hostPopupPasswordLabel(), "100px"); //$NON-NLS-1$ passwordColumn.setFieldUpdater(new FieldUpdater<EntityModel, String>() { @Override -- To view, visit http://gerrit.ovirt.org/16048 To unsubscribe, visit http://gerrit.ovirt.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I4e59c8b89da7345733439db95bdb4c729435e372 Gerrit-PatchSet: 1 Gerrit-Project: ovirt-engine Gerrit-Branch: master Gerrit-Owner: Yaniv Bronhaim <[email protected]> _______________________________________________ Engine-patches mailing list [email protected] http://lists.ovirt.org/mailman/listinfo/engine-patches
