[Kimchi-devel] [PATCH] [Kimchi] Issue #788: Network information mismatch in template creation

sguimaraes943 at gmail.com sguimaraes943 at gmail.com
Thu Mar 17 21:42:58 UTC 2016


From: Samuel Guimarães <sguimaraes943 at gmail.com>

This commit fixes Issue #788.
-If a Template is using a network, Kimchi will prevent this network from being stopped. However the user can still stop it using virt-manager.
-Now if a network is disabled and the user edits a Template, the user can see the current network associated with this template: the dropdown will show the current network + all the active networks in the list.
-If only 'default' network is created and it is stopped by virt-manager, when the user attempts to edit the Template interfaces it still shows the default network.

This commit also fix a small glith in the UI when trying to enable a network.

Signed-off-by: Samuel Guimarães <sguimaraes943 at gmail.com>
---
 ui/js/src/kimchi.network.js            | 6 +++---
 ui/js/src/kimchi.template_edit_main.js | 8 +++++---
 2 files changed, 8 insertions(+), 6 deletions(-)

diff --git a/ui/js/src/kimchi.network.js b/ui/js/src/kimchi.network.js
index 5d6e52e..d362010 100644
--- a/ui/js/src/kimchi.network.js
+++ b/ui/js/src/kimchi.network.js
@@ -123,7 +123,7 @@ kimchi.addNetworkActions = function(network) {
     $('#' + wok.escapeStr(network.name)).on('click', '.dropdown-menu li', function(evt) {
         var menu = $(evt.currentTarget).parent();
         if ($(evt.currentTarget).attr("nwAct") === "start") {
-            $(".network-state", $("#" + wok.escapeStr(network.name))).switchClass("down", "nw-loading");
+            $(".network-state", $("#" + wok.escapeStr(network.name))).switchClass("down", "loading");
             $("[nwAct='start']", menu).addClass("disabled");
             $("[nwAct='delete']", menu).addClass("disabled");
             $(":first-child", $("[nwAct='delete']", menu)).attr("disabled", true);
@@ -135,9 +135,9 @@ kimchi.addNetworkActions = function(network) {
                 if (network.in_use) {
                     $("[nwAct='stop']", menu).addClass("disabled");
                 }
-                $(".network-state", $("#" + wok.escapeStr(network.name))).switchClass("nw-loading", "up");
+                $(".network-state", $("#" + wok.escapeStr(network.name))).switchClass("loading", "up");
             }, function(err) {
-                $(".network-state", $("#" + wok.escapeStr(network.name))).switchClass("nw-loading","down");
+                $(".network-state", $("#" + wok.escapeStr(network.name))).switchClass("loading","down");
                 $("[nwAct='start']", menu).removeClass("disabled");
                 if (!network.in_use) {
                     $("[nwAct='delete']", menu).removeClass("disabled");
diff --git a/ui/js/src/kimchi.template_edit_main.js b/ui/js/src/kimchi.template_edit_main.js
index 046194d..eda83b2 100644
--- a/ui/js/src/kimchi.template_edit_main.js
+++ b/ui/js/src/kimchi.template_edit_main.js
@@ -221,9 +221,11 @@ kimchi.template_edit_main = function() {
                 });
                 var networkOptions = '';
                 for(var i=0;i<result.length;i++){
-                    if(result[i].state === "active") {
-                        var isSlected = networkName===result[i].name ? ' selected' : '';
-                        networkOptions += '<option' + isSlected + '>' + result[i].name + '</option>';
+                    if(networkName===result[i].name) {
+                        networkOptions += '<option selected="selected">' + result[i].name + '</option>';
+                    }
+                    if(result[i].state === "active" && networkName!==result[i].name) {
+                        networkOptions += '<option>' + result[i].name + '</option>';
                     }
                 }
                 $('select', '#form-template-interface #networkID' + networkItemNum).append(networkOptions);
-- 
1.9.3




More information about the Kimchi-devel mailing list