[Kimchi-devel] [PATCH] Fix Add Network window
Rodrigo Trujillo
rodrigo.trujillo at linux.vnet.ibm.com
Tue Feb 25 19:17:29 UTC 2014
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 <rodrigo.trujillo at linux.vnet.ibm.com>
---
ui/js/src/kimchi.network.js | 25 +++++++++++++++++++++++++
1 file changed, 25 insertions(+)
diff --git a/ui/js/src/kimchi.network.js b/ui/js/src/kimchi.network.js
index faf1285..4c25ad0 100644
--- a/ui/js/src/kimchi.network.js
+++ b/ui/js/src/kimchi.network.js
@@ -210,11 +210,33 @@ kimchi.openNetworkDialog = function(okCallback) {
$("#networkConfig").dialog("open");
};
+kimchi.enableBridgeOptions = function(enable) {
+ var ifaces = document.getElementById("networkInterface").getElementsByTagName("option");
+ for (var i = 0; i < ifaces.length; i++) {
+ ifaces[i].disabled = (!enable);
+ if (!enable) {
+ ifaces[i].selected = false;
+ }
+ else if (!$("#networkInterface").val()) {
+ ifaces[0].selected = true;
+ }
+ }
+ $("#enableVlan").prop("disabled", !enable);
+ if (!$("#networkTypeBri").prop("checked")) {
+ $("#enableVlan").attr("checked", false);
+ $("#networkVlanID").prop("disabled", true);
+ $("#networkVlanID").val("");
+ }
+};
+
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);
+ }
};
kimchi.getNetworkDialogValues = function() {
@@ -250,12 +272,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);
});
};
--
1.8.5.3
More information about the Kimchi-devel
mailing list