Alona Kaplan has uploaded a new change for review.

Change subject: webadmin: [SetupNetworks] Bond created using net with nic name 
(#848362)
......................................................................

webadmin: [SetupNetworks] Bond created using net with nic name (#848362)

https://bugzilla.redhat.com/848362

When giving a network the same name as one of the nics. When trying
to drags the network on a nic it causes bond instread of attaching
the nwtworks.

Change-Id: I1036927c3a52ac30b28695b82cb21e6821f490b1
Signed-off-by: Alona Kaplan <[email protected]>
---
M 
frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/hosts/HostSetupNetworksModel.java
M 
frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/hosts/network/LogicalNetworkModel.java
M 
frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/hosts/network/NetworkInterfaceModel.java
M 
frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/hosts/network/NetworkItemModel.java
M 
frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/section/main/view/popup/host/panels/NetworkGroup.java
M 
frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/section/main/view/popup/host/panels/NetworkItemPanel.java
M 
frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/section/main/view/popup/host/panels/UnassignedNetworksPanel.java
7 files changed, 39 insertions(+), 7 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/70/7770/1

diff --git 
a/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/hosts/HostSetupNetworksModel.java
 
b/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/hosts/HostSetupNetworksModel.java
index 9d0ff3d..787552d 100644
--- 
a/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/hosts/HostSetupNetworksModel.java
+++ 
b/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/hosts/HostSetupNetworksModel.java
@@ -122,6 +122,9 @@
     private NetworkItemModel<?> currentOp1;
     private NetworkItemModel<?> currentOp2;
 
+    public static final String NIC = "nic"; //$NON-NLS-1$
+    public static final String NETWORK = "network"; //$NON-NLS-1$
+
     public HostSetupNetworksModel(HostInterfaceListModel 
hostInterfaceListModel) {
         this.hostInterfaceListModel = hostInterfaceListModel;
         networkToLastDetachParams = new HashMap<String, NetworkParameters>();
@@ -148,12 +151,24 @@
 
     }
 
-    public boolean candidateOperation(String op1Key, String op2Key, boolean 
drop) {
-        NetworkInterfaceModel nic1 = nicMap.get(op1Key);
-        LogicalNetworkModel network1 = networkMap.get(op1Key);
+    public boolean candidateOperation(String op1Key, String op1Type, String 
op2Key, String op2Type, boolean drop) {
 
-        NetworkInterfaceModel nic2 = nicMap.get(op2Key);
-        LogicalNetworkModel network2 = networkMap.get(op2Key);
+        NetworkInterfaceModel nic1 = null;
+        LogicalNetworkModel network1 = null;
+        NetworkInterfaceModel nic2 = null;
+        LogicalNetworkModel network2 = null;
+
+        if (op1Type != null && op1Type.equals(NIC)){
+            nic1 = nicMap.get(op1Key);
+        }else if (op1Type != null && op1Type.equals(NETWORK)){
+            network1 = networkMap.get(op1Key);
+        }
+
+        if (op2Type != null && op2Type.equals(NIC)){
+            nic2 = nicMap.get(op2Key);
+        }else if (op2Type != null && op2Type.equals(NETWORK)){
+            network2 = networkMap.get(op2Key);
+        }
 
         NetworkItemModel<?> op1 = nic1 == null ? network1 : nic1;
         NetworkItemModel<?> op2 = nic2 == null ? network2 : nic2;
diff --git 
a/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/hosts/network/LogicalNetworkModel.java
 
b/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/hosts/network/LogicalNetworkModel.java
index 10c33e8..50905dd 100644
--- 
a/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/hosts/network/LogicalNetworkModel.java
+++ 
b/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/hosts/network/LogicalNetworkModel.java
@@ -223,4 +223,9 @@
         VdsNetworkInterface nic = hasVlan() ? getBridge().getEntity() : 
getAttachedToNic().getEntity();
         return nic.getNetworkImplementationDetails();
     }
+
+    @Override
+    public String getType() {
+        return HostSetupNetworksModel.NETWORK;
+    }
 }
diff --git 
a/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/hosts/network/NetworkInterfaceModel.java
 
b/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/hosts/network/NetworkInterfaceModel.java
index 62997cc..f71f074 100644
--- 
a/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/hosts/network/NetworkInterfaceModel.java
+++ 
b/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/hosts/network/NetworkInterfaceModel.java
@@ -72,4 +72,9 @@
     public void setBonded(boolean bonded) {
         this.bonded = bonded;
     }
+
+    @Override
+    public String getType() {
+        return HostSetupNetworksModel.NIC;
+    }
 }
diff --git 
a/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/hosts/network/NetworkItemModel.java
 
b/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/hosts/network/NetworkItemModel.java
index 29293a2..d16a0ee 100644
--- 
a/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/hosts/network/NetworkItemModel.java
+++ 
b/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/hosts/network/NetworkItemModel.java
@@ -72,4 +72,6 @@
 
     }
 
+    public abstract String getType();
+
 }
diff --git 
a/frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/section/main/view/popup/host/panels/NetworkGroup.java
 
b/frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/section/main/view/popup/host/panels/NetworkGroup.java
index b216139..c4f1675 100644
--- 
a/frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/section/main/view/popup/host/panels/NetworkGroup.java
+++ 
b/frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/section/main/view/popup/host/panels/NetworkGroup.java
@@ -127,8 +127,9 @@
     private void doDrag(DragDropEventBase<?> event, boolean isDrop) {
         HostSetupNetworksModel setupModel = nicModel.getSetupModel();
         String data = event.getData(NetworkItemPanel.SETUP_NETWORKS_DATA);
+        String type = event.getData(NetworkItemPanel.SETUP_NETWORKS_TYPE); 
//$NON-NLS-1$
         if (data != null) {
-            if (setupModel.candidateOperation(data, nicModel.getName(), 
isDrop)) {
+            if (setupModel.candidateOperation(data, type, nicModel.getName(), 
HostSetupNetworksModel.NIC, isDrop)) {
                 table.getElement().addClassName(style.networkGroupDragOver());
                 // allow drag/drop (look at 
http://www.w3.org/TR/html5/dnd.html#dndevents)
                 event.preventDefault();
diff --git 
a/frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/section/main/view/popup/host/panels/NetworkItemPanel.java
 
b/frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/section/main/view/popup/host/panels/NetworkItemPanel.java
index 1d71dbc..b886d54 100644
--- 
a/frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/section/main/view/popup/host/panels/NetworkItemPanel.java
+++ 
b/frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/section/main/view/popup/host/panels/NetworkItemPanel.java
@@ -35,6 +35,7 @@
 public abstract class NetworkItemPanel extends DnDPanel {
 
     public static final String SETUP_NETWORKS_DATA = "SetupNetworksData"; 
//$NON-NLS-1$
+    public static final String SETUP_NETWORKS_TYPE = "SetupNetworksType"; 
//$NON-NLS-1$
     final ApplicationResources resources = 
ClientGinjectorProvider.instance().getApplicationResources();
     final ApplicationMessages messages = 
ClientGinjectorProvider.instance().getApplicationMessages();
     final Image dragImage = new Image(resources.itemDraggable());
@@ -135,6 +136,8 @@
                 NetworkItemPanel sourcePanel = (NetworkItemPanel) 
event.getSource();
                 // Required: set data for the event.
                 event.setData(SETUP_NETWORKS_DATA, sourcePanel.item.getName());
+                event.setData(SETUP_NETWORKS_TYPE, sourcePanel.item.getType());
+
                 // show a ghost of the widget under cursor.
                 NativeEvent nativeEvent = event.getNativeEvent();
                 int x = nativeEvent.getClientX() - 
sourcePanel.getAbsoluteLeft();
diff --git 
a/frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/section/main/view/popup/host/panels/UnassignedNetworksPanel.java
 
b/frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/section/main/view/popup/host/panels/UnassignedNetworksPanel.java
index 4ed19d1..7186289 100644
--- 
a/frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/section/main/view/popup/host/panels/UnassignedNetworksPanel.java
+++ 
b/frontend/webadmin/modules/webadmin/src/main/java/org/ovirt/engine/ui/webadmin/section/main/view/popup/host/panels/UnassignedNetworksPanel.java
@@ -132,8 +132,9 @@
 
     private void doDrag(DragDropEventBase<?> event, boolean isDrop) {
         String data = event.getData(NetworkItemPanel.SETUP_NETWORKS_DATA);
+        String type = event.getData(NetworkItemPanel.SETUP_NETWORKS_TYPE);
         if (data != null) {
-            if (setupModel.candidateOperation(data, null, isDrop)) {
+            if (setupModel.candidateOperation(data, type, null, null, isDrop)) 
{
                
animatedPanel.getElement().addClassName(style.networkGroupDragOver());
                 // allow drag/drop (look at 
http://www.w3.org/TR/html5/dnd.html#dndevents)
                 event.preventDefault();


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

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

Reply via email to