<html>
  <head>
    <meta content="text/html; charset=ISO-8859-1"
      http-equiv="Content-Type">
  </head>
  <body bgcolor="#FFFFFF" text="#000000">
    <div class="moz-cite-prefix">done <br>
      On 02/26/2014 11:32 PM, Hongliang Wang wrote:<br>
    </div>
    <blockquote cite="mid:530EA3AA.6030503@linux.vnet.ibm.com"
      type="cite">
      <meta content="text/html; charset=ISO-8859-1"
        http-equiv="Content-Type">
      <div class="moz-cite-prefix">On 02/27/2014 03:31 AM, Rodrigo
        Trujillo wrote:<br>
      </div>
      <blockquote
cite="mid:1393443095-2187-1-git-send-email-rodrigo.trujillo@linux.vnet.ibm.com"
        type="cite">
        <pre wrap="">VLans and Interfaces must only be available for selection if network
type Bridge is selected. This restriction was not implemented in the UI.
This patch fixes this problem.

Signed-off-by: Rodrigo Trujillo <a moz-do-not-send="true" class="moz-txt-link-rfc2396E" href="mailto:rodrigo.trujillo@linux.vnet.ibm.com">&lt;rodrigo.trujillo@linux.vnet.ibm.com&gt;</a>
---
 ui/js/src/kimchi.network.js     | 22 +++++++++++++++++++++-
 ui/pages/tabs/network.html.tmpl | 20 +++++++++++---------
 2 files changed, 32 insertions(+), 10 deletions(-)

diff --git a/ui/js/src/kimchi.network.js b/ui/js/src/kimchi.network.js
index faf1285..c0fe4ff 100644
--- a/ui/js/src/kimchi.network.js
+++ b/ui/js/src/kimchi.network.js
@@ -210,11 +210,28 @@ kimchi.openNetworkDialog = function(okCallback) {
     $("#networkConfig").dialog("open");
 };

+kimchi.enableBridgeOptions = function(enable) {
+    if (!enable) {
+        $("#enableVlan").attr("checked", false);
+        $("#networkVlanID").prop("disabled", true);</pre>
      </blockquote>
      Why one is .attr() and the other is .prop()? For input[checked] or
      input[disabled], I suggest always use .prop(). If you'd like to
      use .attr(), please use it as follows:<br>
      &nbsp; $('input').attr('checked', 'checked');<br>
      &nbsp; $('input').attr('disabled', 'disabled');<br>
      <blockquote
cite="mid:1393443095-2187-1-git-send-email-rodrigo.trujillo@linux.vnet.ibm.com"
        type="cite">
        <pre wrap="">+        $("#networkVlanID").val("");
+        $("#networkInterface").val("");
+        $("#bridge-options").slideUp(100);
+    } else if (!$("#networkInterface").val()){
+        $("#networkInterface").prop("selectedIndex", 0);
+        $("#bridge-options").slideDown(100);
+    }
+};</pre>
      </blockquote>
      <br>
      <blockquote
cite="mid:1393443095-2187-1-git-send-email-rodrigo.trujillo@linux.vnet.ibm.com"
        type="cite">
        <pre wrap="">+
 kimchi.setDefaultNetworkType = function(isInterfaceAvail) {
     $("#networkTypeBri").prop("checked", isInterfaceAvail);
     $("#networkTypeBri").prop("disabled", !isInterfaceAvail);
-    $("#networkInterface").prop("disabled", !isInterfaceAvail);
     $("#networkTypeNat").prop("checked", !isInterfaceAvail);
+    if (!isInterfaceAvail) {
+        kimchi.enableBridgeOptions(false);
+    } else {
+        $("#bridge-options").slideDown(100);
+    }
 };

 kimchi.getNetworkDialogValues = function() {
@@ -250,12 +267,15 @@ kimchi.setupNetworkFormEvent = function() {
     });
     $("#networkTypeIso").on("click", function(event) {
         $("#networkInterface").prop("disabled", true);
+        kimchi.enableBridgeOptions(false);
     });
     $("#networkTypeNat").on("click", function(event) {
         $("#networkInterface").prop("disabled", true);
+        kimchi.enableBridgeOptions(false);
     });
     $("#networkTypeBri").on("click", function(event) {
         $("#networkInterface").prop("disabled", false);
+        kimchi.enableBridgeOptions(true);
     });
 };

diff --git a/ui/pages/tabs/network.html.tmpl b/ui/pages/tabs/network.html.tmpl
index 83c1d7e..4340e19 100644
--- a/ui/pages/tabs/network.html.tmpl
+++ b/ui/pages/tabs/network.html.tmpl
@@ -71,15 +71,17 @@
                     &lt;input type="radio" id="networkTypeBri" name="networkType" value="bridged"&gt;
                     &lt;label for="networkTypeBri"&gt;$_("Bridged: Virtual machines are connected to physical network directly")&lt;/label&gt;
                 &lt;/div&gt;
-                &lt;div class="destination"&gt;
-                    &lt;label&gt;$_("Destination"): &lt;/label&gt;
-                    &lt;select id="networkInterface"&gt;&lt;/select&gt;
-                &lt;/div&gt;
-                &lt;div class="VLAN"&gt;
-                    &lt;label for="enableVlan"&gt;$_("Enable VLAN"): &lt;/label&gt;
-                    &lt;input id="enableVlan" type="checkbox" value=""/&gt;
-                    &lt;label&gt;$_("VLAN ID"): &lt;/label&gt;
-                    &lt;input type="text" id="networkVlanID" disabled&gt;
+                &lt;div id=bridge-options&gt;</pre>
      </blockquote>
      &lt;div id=<b>"</b><b>bridge-options</b><b>"</b>&gt;<br>
      <blockquote
cite="mid:1393443095-2187-1-git-send-email-rodrigo.trujillo@linux.vnet.ibm.com"
        type="cite">
        <pre wrap="">+                    &lt;div class="destination"&gt;
+                        &lt;label&gt;$_("Destination"): &lt;/label&gt;</pre>
      </blockquote>
      include <b>for</b> attribute for &lt;label&gt; element.
      <blockquote
cite="mid:1393443095-2187-1-git-send-email-rodrigo.trujillo@linux.vnet.ibm.com"
        type="cite">
        <pre wrap="">+                        &lt;select id="networkInterface"&gt;&lt;/select&gt;
+                    &lt;/div&gt;
+                    &lt;div class="VLAN"&gt;
+                        &lt;label for="enableVlan"&gt;$_("Enable VLAN"): &lt;/label&gt;
+                        &lt;input id="enableVlan" type="checkbox" value=""/&gt;
+                        &lt;label&gt;$_("VLAN ID"): &lt;/label&gt;</pre>
      </blockquote>
      include <b>for</b> attribute for &lt;label&gt; element.<br>
      <blockquote
cite="mid:1393443095-2187-1-git-send-email-rodrigo.trujillo@linux.vnet.ibm.com"
        type="cite">
        <pre wrap="">+                        &lt;input type="text" id="networkVlanID" disabled&gt;
+                    &lt;/div&gt;
                 &lt;/div&gt;
             &lt;/div&gt;
         &lt;/div&gt;
</pre>
      </blockquote>
      <br>
      <br>
      <fieldset class="mimeAttachmentHeader"></fieldset>
      <br>
      <pre wrap="">_______________________________________________
Kimchi-devel mailing list
<a class="moz-txt-link-abbreviated" href="mailto:Kimchi-devel@ovirt.org">Kimchi-devel@ovirt.org</a>
<a class="moz-txt-link-freetext" href="http://lists.ovirt.org/mailman/listinfo/kimchi-devel">http://lists.ovirt.org/mailman/listinfo/kimchi-devel</a>
</pre>
    </blockquote>
    <br>
  </body>
</html>