<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"><rodrigo.trujillo@linux.vnet.ibm.com></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>
$('input').attr('checked', 'checked');<br>
$('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 @@
<input type="radio" id="networkTypeBri" name="networkType" value="bridged">
<label for="networkTypeBri">$_("Bridged: Virtual machines are connected to physical network directly")</label>
</div>
- <div class="destination">
- <label>$_("Destination"): </label>
- <select id="networkInterface"></select>
- </div>
- <div class="VLAN">
- <label for="enableVlan">$_("Enable VLAN"): </label>
- <input id="enableVlan" type="checkbox" value=""/>
- <label>$_("VLAN ID"): </label>
- <input type="text" id="networkVlanID" disabled>
+ <div id=bridge-options></pre>
</blockquote>
<div id=<b>"</b><b>bridge-options</b><b>"</b>><br>
<blockquote
cite="mid:1393443095-2187-1-git-send-email-rodrigo.trujillo@linux.vnet.ibm.com"
type="cite">
<pre wrap="">+ <div class="destination">
+ <label>$_("Destination"): </label></pre>
</blockquote>
include <b>for</b> attribute for <label> element.
<blockquote
cite="mid:1393443095-2187-1-git-send-email-rodrigo.trujillo@linux.vnet.ibm.com"
type="cite">
<pre wrap="">+ <select id="networkInterface"></select>
+ </div>
+ <div class="VLAN">
+ <label for="enableVlan">$_("Enable VLAN"): </label>
+ <input id="enableVlan" type="checkbox" value=""/>
+ <label>$_("VLAN ID"): </label></pre>
</blockquote>
include <b>for</b> attribute for <label> element.<br>
<blockquote
cite="mid:1393443095-2187-1-git-send-email-rodrigo.trujillo@linux.vnet.ibm.com"
type="cite">
<pre wrap="">+ <input type="text" id="networkVlanID" disabled>
+ </div>
</div>
</div>
</div>
</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>