[Kimchi-devel] [PATCH] UI bug fix: Set vlan_id value only if 'Enable VLAN' is checked

Aline Manera alinefm at linux.vnet.ibm.com
Fri Jan 17 14:28:46 UTC 2014


From: Aline Manera <alinefm at br.ibm.com>

Commit 2f54aaba added a checkbox to provide choice of enabling vlan tagging
while creating a bridged network, but it doesn't check the checkbox before
setting the vlan_id to send server request.

Because that when the user tries to create a bridged network without enabling
VLAN the following error is raised:
Invalid parameter: 'None is not of type u'integer''

Fix it by setting vlan_id only if the vlan checkbox is checked.

Signed-off-by: Aline Manera <alinefm at br.ibm.com>
---
 po/en_US.po                 |   10 ++++++++--
 po/kimchi.pot               |    9 ++++++++-
 po/pt_BR.po                 |   10 ++++++++--
 po/zh_CN.po                 |   10 ++++++++--
 ui/js/src/kimchi.network.js |   14 +++++++++++---
 ui/pages/i18n.html.tmpl     |    1 +
 6 files changed, 44 insertions(+), 10 deletions(-)

diff --git a/po/en_US.po b/po/en_US.po
index ebbe1ee..2893946 100644
--- a/po/en_US.po
+++ b/po/en_US.po
@@ -6,14 +6,14 @@ msgid ""
 msgstr ""
 "Project-Id-Version: kimchi 0.1\n"
 "Report-Msgid-Bugs-To: \n"
-"POT-Creation-Date: 2014-01-05 22:33-0500\n"
+"POT-Creation-Date: 2014-01-17 12:24-0200\n"
 "PO-Revision-Date: 2013-07-11 17:32-0400\n"
 "Last-Translator: Crístian Viana <vianac at linux.vnet.ibm.com>\n"
 "Language-Team: English\n"
+"Language: en_US\n"
 "MIME-Version: 1.0\n"
 "Content-Type: text/plain; charset=UTF-8\n"
 "Content-Transfer-Encoding: 8bit\n"
-"Language: en_US\n"
 "Generated-By: pygettext.py 1.5\n"
 "Plural-Forms: nplurals=2; plural=(n != 1);\n"
 
@@ -249,6 +249,9 @@ msgstr "This is not a valid linux path."
 msgid "This is not a valid url."
 msgstr "This is not a valid url."
 
+msgid "The VLAN id must be between 1 and 4094."
+msgstr "The VLAN id must be between 1 and 4094."
+
 msgid "This is not a valid ISO file."
 msgstr "This is not a valid ISO file."
 
@@ -520,6 +523,9 @@ msgstr "Destination"
 msgid "Enable VLAN"
 msgstr "Enable VLAN"
 
+msgid "VLAN ID"
+msgstr "VLAN ID"
+
 msgid "No templates found."
 msgstr "No templates found."
 
diff --git a/po/kimchi.pot b/po/kimchi.pot
index a2bbcf5..738b070 100755
--- a/po/kimchi.pot
+++ b/po/kimchi.pot
@@ -8,10 +8,11 @@ msgid ""
 msgstr ""
 "Project-Id-Version: PACKAGE VERSION\n"
 "Report-Msgid-Bugs-To: \n"
-"POT-Creation-Date: 2014-01-05 22:33-0500\n"
+"POT-Creation-Date: 2014-01-17 12:24-0200\n"
 "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
 "Last-Translator: FULL NAME <EMAIL at ADDRESS>\n"
 "Language-Team: LANGUAGE <LL at li.org>\n"
+"Language: \n"
 "MIME-Version: 1.0\n"
 "Content-Type: text/plain; charset=CHARSET\n"
 "Content-Transfer-Encoding: 8bit\n"
@@ -240,6 +241,9 @@ msgstr ""
 msgid "This is not a valid url."
 msgstr ""
 
+msgid "The VLAN id must be between 1 and 4094."
+msgstr ""
+
 msgid "This is not a valid ISO file."
 msgstr ""
 
@@ -497,6 +501,9 @@ msgstr ""
 msgid "Enable VLAN"
 msgstr ""
 
+msgid "VLAN ID"
+msgstr ""
+
 msgid "No templates found."
 msgstr ""
 
diff --git a/po/pt_BR.po b/po/pt_BR.po
index 69bb554..d12564f 100644
--- a/po/pt_BR.po
+++ b/po/pt_BR.po
@@ -20,14 +20,14 @@ msgid ""
 msgstr ""
 "Project-Id-Version: kimchi 1.0\n"
 "Report-Msgid-Bugs-To: \n"
-"POT-Creation-Date: 2014-01-05 22:33-0500\n"
+"POT-Creation-Date: 2014-01-17 12:24-0200\n"
 "PO-Revision-Date: 2013-06-27 10:48+0000\n"
 "Last-Translator: Alexandre Hirata <hirata at linux.vnet.ibm.com>\n"
 "Language-Team: Aline Manera <alinefm at br.ibm.com>\n"
+"Language: pt_BR\n"
 "MIME-Version: 1.0\n"
 "Content-Type: text/plain; charset=UTF-8\n"
 "Content-Transfer-Encoding: 8bit\n"
-"Language: pt_BR\n"
 "Generated-By: pygettext.py 1.5\n"
 "X-Poedit-Country: Brazil\n"
 "X-Poedit-Language: Portuguese\n"
@@ -267,6 +267,9 @@ msgstr "Esse não é um caminho válido no linux"
 msgid "This is not a valid url."
 msgstr "Esse não é uma URL válida."
 
+msgid "The VLAN id must be between 1 and 4094."
+msgstr "VLAN id deve ser um número entre 1 e 4094."
+
 msgid "This is not a valid ISO file."
 msgstr "Esse não é um arquivo ISO válido."
 
@@ -534,6 +537,9 @@ msgstr "Destino"
 msgid "Enable VLAN"
 msgstr "Ativar VLAN"
 
+msgid "VLAN ID"
+msgstr "VLAN ID"
+
 msgid "No templates found."
 msgstr "Nenhum modelo encontrado."
 
diff --git a/po/zh_CN.po b/po/zh_CN.po
index 411fcaa..758af1d 100644
--- a/po/zh_CN.po
+++ b/po/zh_CN.po
@@ -20,14 +20,14 @@ msgid ""
 msgstr ""
 "Project-Id-Version: kimchi 0.1\n"
 "Report-Msgid-Bugs-To: \n"
-"POT-Creation-Date: 2014-01-05 22:33-0500\n"
+"POT-Creation-Date: 2014-01-17 12:24-0200\n"
 "PO-Revision-Date: 2013-06-27 10:48+0000\n"
 "Last-Translator: ShaoHe Feng <shaohef at linux.vnet.ibm.com>\n"
 "Language-Team: ShaoHe Feng <shaohef at linux.vnet.ibm.com>\n"
+"Language: zh_CN\n"
 "MIME-Version: 1.0\n"
 "Content-Type: text/plain; charset=UTF-8\n"
 "Content-Transfer-Encoding: 8bit\n"
-"Language: zh_CN\n"
 "Generated-By: pygettext.py 1.5\n"
 "X-Poedit-Country: CHINA\n"
 "X-Poedit-Language: Chinese\n"
@@ -257,6 +257,9 @@ msgstr "这不是一个有效的LINUX路径"
 msgid "This is not a valid url."
 msgstr "这不是一个有效的URL"
 
+msgid "The VLAN id must be between 1 and 4094."
+msgstr ""
+
 msgid "This is not a valid ISO file."
 msgstr "这不是一个有效的ISO文件"
 
@@ -516,6 +519,9 @@ msgstr "目标设备"
 msgid "Enable VLAN"
 msgstr "启用VLAN"
 
+msgid "VLAN ID"
+msgstr ""
+
 msgid "No templates found."
 msgstr "没有发现模板"
 
diff --git a/ui/js/src/kimchi.network.js b/ui/js/src/kimchi.network.js
index 65479b2..0a3026f 100644
--- a/ui/js/src/kimchi.network.js
+++ b/ui/js/src/kimchi.network.js
@@ -136,18 +136,24 @@ kimchi.initNetworkCreation = function() {
             var data = {
                 name : network.name,
                 connection: network.type,
-                vlan_id: network.vlan_id,
             };
             if (network.type === kimchi.NETWORK_TYPE_BRIDGE) {
                 data.connection = "bridge";
                 data.interface = network.interface;
-                data.vlan_id = network.vlan_id;
+                if ($("#enableVlan").prop("checked")) {
+                    data.vlan_id = network.vlan_id;
+                    if (!(data.vlan_id >=1 && data.vlan_id <= 4094)) {
+                        kimchi.message.error(i18n['msg.invalid.vlan_id']);
+                        return;
+                    }
+                }
             }
             kimchi.createNetwork(data, function(result) {
                 network.state = result.state === "active" ? "up" : "down";
                 network.interface = result.interface ? result.interface : i18n["value_unavailable"];
                 network.addrSpace = result.subnet ? result.subnet : i18n["value_unavailable"];
                 kimchi.addNetworkItem(network);
+                $("#networkConfig").dialog("close");
             });
         });
     });
@@ -194,10 +200,12 @@ kimchi.openNetworkDialog = function(okCallback) {
     });
     $("#networkFormOk").on("click", function() {
         okCallback();
-        $("#networkConfig").dialog("close");
     });
     $("#enableVlan").on("click", function() {
         $("#networkVlanID").prop("disabled", !this.checked);
+        if (!this.checked) {
+            $("#networkVlanID").val("");
+        }
     });
     $("#networkConfig").dialog("open");
 };
diff --git a/ui/pages/i18n.html.tmpl b/ui/pages/i18n.html.tmpl
index 603f8d7..e684f2e 100644
--- a/ui/pages/i18n.html.tmpl
+++ b/ui/pages/i18n.html.tmpl
@@ -90,6 +90,7 @@ var i18n = {
     'msg.fail.get.config': "$_("Failed to get application configuration")",
     'msg.invalid.path': "$_("This is not a valid linux path")",
     'msg.invalid.url': "$_("This is not a valid url.")",
+    'msg.invalid.vlan_id': "$_("The VLAN id must be between 1 and 4094.")",
     'msg.invalid.iso': "$_("This is not a valid ISO file.")",
     'msg.storagepool.confirm.delete':"$_("This will permanently delete the Storage Pool. Would you like to continue?")",
     'msg.pool.edit.name.blank':"$_("The storage pool name can not be blank.")",
-- 
1.7.10.4




More information about the Kimchi-devel mailing list