Lior Vernia has uploaded a new change for review.

Change subject: webadmin: Added authentication fields to Provider popup
......................................................................

webadmin: Added authentication fields to Provider popup

Added checkbox to mark whether the provider requires authentication, and
if so then username and password text boxes may be filled.

Change-Id: I6153b80d0cb3d60baae8c1782239578eeb64d95c
Signed-off-by: Lior Vernia <[email protected]>
---
M 
frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/providers/ProviderModel.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/section/main/view/popup/provider/ProviderPopupView.java
M 
frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/section/main/view/popup/provider/ProviderPopupView.ui.xml
4 files changed, 98 insertions(+), 7 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/58/14758/1

diff --git 
a/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/providers/ProviderModel.java
 
b/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/providers/ProviderModel.java
index 1bdba28..7e15e3e 100644
--- 
a/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/providers/ProviderModel.java
+++ 
b/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/providers/ProviderModel.java
@@ -16,7 +16,10 @@
 import org.ovirt.engine.ui.uicommonweb.validation.NotEmptyValidation;
 import org.ovirt.engine.ui.uicommonweb.validation.UrlValidation;
 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.FrontendActionAsyncResult;
+import org.ovirt.engine.ui.uicompat.IEventListener;
 import org.ovirt.engine.ui.uicompat.IFrontendActionAsyncCallback;
 
 @SuppressWarnings("deprecation")
@@ -33,6 +36,9 @@
     private EntityModel privateType;
     private EntityModel privateDescription;
     private EntityModel privateUrl;
+    private EntityModel privateRequiresAuthentication;
+    private EntityModel privateUsername;
+    private EntityModel privatePassword;
 
     public EntityModel getName() {
         return privateName;
@@ -66,15 +72,53 @@
         privateUrl = value;
     }
 
+    public EntityModel getRequiresAuthentication() {
+        return privateRequiresAuthentication;
+    }
+
+    private void setRequiresAuthentication(EntityModel value) {
+        privateRequiresAuthentication = value;
+    }
+
+    public EntityModel getUsername() {
+        return privateUsername;
+    }
+
+    private void setUsername(EntityModel value) {
+        privateUsername = value;
+    }
+
+    public EntityModel getPassword() {
+        return privatePassword;
+    }
+
+    private void setPassword(EntityModel value) {
+        privatePassword = value;
+    }
+
     public ProviderModel(SearchableListModel sourceListModel, VdcActionType 
action, Provider provider) {
         this.sourceListModel = sourceListModel;
         this.action = action;
         this.provider = provider;
 
+        setRequiresAuthentication(new EntityModel());
+        getRequiresAuthentication().getEntityChangedEvent().addListener(new 
IEventListener() {
+
+            @Override
+            public void eventRaised(Event ev, Object sender, EventArgs args) {
+                boolean requiresAuthentication = (Boolean) 
privateRequiresAuthentication.getEntity();
+                getUsername().setIsChangable(requiresAuthentication);
+                getPassword().setIsChangable(requiresAuthentication);
+            }
+        });
+
         setName(new EntityModel(provider.getName()));
         setType(new EntityModel(provider.getType()));
         setDescription(new EntityModel(provider.getDescription()));
         setUrl(new EntityModel(provider.getUrl()));
+        setUsername(new EntityModel(provider.getUsername()));
+        setPassword(new EntityModel(provider.getPassword()));
+        
getRequiresAuthentication().setEntity(provider.isRequiringAuthentication());
 
         UICommand tempVar = new UICommand(CMD_SAVE, this);
         tempVar.setTitle(ConstantsManager.getInstance().getConstants().ok());
@@ -89,6 +133,8 @@
     private boolean validate() {
         getName().validateEntity(new IValidation[] { new NotEmptyValidation() 
});
         getType().validateEntity(new IValidation[] { new NotEmptyValidation() 
});
+        getUsername().validateEntity(new IValidation[] { new 
NotEmptyValidation() });
+        getPassword().validateEntity(new IValidation[] { new 
NotEmptyValidation() });
 
         Uri url = new Uri((String) getUrl().getEntity());
         if (url.getScheme().isEmpty()) {
@@ -97,7 +143,8 @@
         }
         getUrl().validateEntity(new IValidation[] { new NotEmptyValidation(), 
new UrlValidation() });
 
-        return getName().getIsValid() && getType().getIsValid() && 
getUrl().getIsValid();
+        return getName().getIsValid() && getType().getIsValid() && 
getUrl().getIsValid() && getUsername().getIsValid()
+                && getPassword().getIsValid();
     }
 
     private void cancel() {
@@ -113,7 +160,10 @@
         provider.setType((ProviderType) privateType.getEntity());
         provider.setDescription((String) privateDescription.getEntity());
         provider.setUrl((String) privateUrl.getEntity());
-        
+        provider.setRequiringAuthentication((Boolean) 
privateRequiresAuthentication.getEntity());
+        provider.setUsername((String) privateUsername.getEntity());
+        provider.setPassword((String) privatePassword.getEntity());
+
         startProgress(null);
         Frontend.RunAction(action, new ProviderParameters(provider),
                 new IFrontendActionAsyncCallback() {
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 697e8e2..9cbb1a9 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
@@ -2638,6 +2638,15 @@
     @DefaultStringValue("URL")
     String urlProvider();
 
+    @DefaultStringValue("Requires Authentication")
+    String requiresAuthenticationProvider();
+
+    @DefaultStringValue("Username")
+    String usernameProvider();
+
+    @DefaultStringValue("Password")
+    String passwordProvider();
+
     @DefaultStringValue("Add")
     String addProvider();
 
diff --git 
a/frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/section/main/view/popup/provider/ProviderPopupView.java
 
b/frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/section/main/view/popup/provider/ProviderPopupView.java
index 1f00f23..5a06ebb 100644
--- 
a/frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/section/main/view/popup/provider/ProviderPopupView.java
+++ 
b/frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/section/main/view/popup/provider/ProviderPopupView.java
@@ -3,7 +3,10 @@
 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.Align;
 import org.ovirt.engine.ui.common.widget.dialog.SimpleDialogPanel;
+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.EntityModelTextBoxEditor;
 import org.ovirt.engine.ui.common.widget.editor.ListModelListBoxEditor;
 import org.ovirt.engine.ui.common.widget.renderer.EnumRenderer;
@@ -54,6 +57,21 @@
     @WithElementId
     EntityModelTextBoxEditor urlEditor;
 
+    @UiField(provided = true)
+    @Path(value = "requiresAuthentication.entity")
+    @WithElementId
+    EntityModelCheckBoxEditor requiresAuthenticationEditor;
+
+    @UiField
+    @Path(value = "username.entity")
+    @WithElementId
+    EntityModelTextBoxEditor usernameEditor;
+
+    @UiField
+    @Path(value = "password.entity")
+    @WithElementId
+    EntityModelPasswordBoxEditor passwordEditor;
+
     @UiField
     Style style;
 
@@ -61,7 +79,10 @@
     @Inject
     public ProviderPopupView(EventBus eventBus, ApplicationResources 
resources, ApplicationConstants constants) {
         super(eventBus, resources);
+
         typeEditor = new ListModelListBoxEditor<Object>(new EnumRenderer());
+        requiresAuthenticationEditor = new 
EntityModelCheckBoxEditor(Align.RIGHT);
+
         initWidget(ViewUiBinder.uiBinder.createAndBindUi(this));
         ViewIdHandler.idHandler.generateAndSetIds(this);
         localize(constants);
@@ -74,6 +95,9 @@
         typeEditor.setLabel(constants.typeProvider());
         descriptionEditor.setLabel(constants.descriptionProvider());
         urlEditor.setLabel(constants.urlProvider());
+        
requiresAuthenticationEditor.setLabel(constants.requiresAuthenticationProvider());
+        usernameEditor.setLabel(constants.usernameProvider());
+        passwordEditor.setLabel(constants.passwordProvider());
     }
 
     @Override
diff --git 
a/frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/section/main/view/popup/provider/ProviderPopupView.ui.xml
 
b/frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/section/main/view/popup/provider/ProviderPopupView.ui.xml
index 6df59f9..2f98c79 100644
--- 
a/frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/section/main/view/popup/provider/ProviderPopupView.ui.xml
+++ 
b/frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/section/main/view/popup/provider/ProviderPopupView.ui.xml
@@ -5,16 +5,24 @@
 
        <ui:style 
type="org.ovirt.engine.ui.webadmin.section.main.view.popup.provider.ProviderPopupView.Style">
                .contentStyle {
+                       margin-bottom: 20px
                }
        </ui:style>
 
-       <d:SimpleDialogPanel width="450px" height="320px">
+       <d:SimpleDialogPanel width="450px" height="360px">
                <d:content>
                        <g:FlowPanel>
-                               <e:EntityModelTextBoxEditor 
ui:field="nameEditor" />
-                               <e:ListModelListBoxEditor ui:field="typeEditor" 
/>
-                               <e:EntityModelTextBoxEditor 
ui:field="descriptionEditor" />
-                               <e:EntityModelTextBoxEditor 
ui:field="urlEditor" />
+                               <g:FlowPanel 
addStyleNames="{style.contentStyle}">
+                                       <e:EntityModelTextBoxEditor 
ui:field="nameEditor" />
+                                       <e:ListModelListBoxEditor 
ui:field="typeEditor" />
+                                       <e:EntityModelTextBoxEditor 
ui:field="descriptionEditor" />
+                                       <e:EntityModelTextBoxEditor 
ui:field="urlEditor" />
+                               </g:FlowPanel>
+                               <g:FlowPanel 
addStyleNames="{style.contentStyle}">
+                                       <e:EntityModelCheckBoxEditor 
ui:field="requiresAuthenticationEditor" />
+                                       <e:EntityModelTextBoxEditor 
ui:field="usernameEditor" />
+                                       <e:EntityModelPasswordBoxEditor 
ui:field="passwordEditor" />
+                               </g:FlowPanel>
                        </g:FlowPanel>
                </d:content>
        </d:SimpleDialogPanel>


--
To view, visit http://gerrit.ovirt.org/14758
To unsubscribe, visit http://gerrit.ovirt.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I6153b80d0cb3d60baae8c1782239578eeb64d95c
Gerrit-PatchSet: 1
Gerrit-Project: ovirt-engine
Gerrit-Branch: master
Gerrit-Owner: Lior Vernia <[email protected]>
_______________________________________________
Engine-patches mailing list
[email protected]
http://lists.ovirt.org/mailman/listinfo/engine-patches

Reply via email to