[Kimchi-devel] [PATCH V2 2/2] Bug Fix #282: Handle toggleNetwork error returns

Rodrigo Trujillo rodrigo.trujillo at linux.vnet.ibm.com
Fri Feb 28 13:14:07 UTC 2014


This patch restores the UI to previous state if function toggleNetwork
returns an error, when user tries to start/stop a network.

Signed-off-by: Rodrigo Trujillo <rodrigo.trujillo at linux.vnet.ibm.com>
---
 ui/js/src/kimchi.network.js | 10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git a/ui/js/src/kimchi.network.js b/ui/js/src/kimchi.network.js
index 7cedc01..d68697a 100644
--- a/ui/js/src/kimchi.network.js
+++ b/ui/js/src/kimchi.network.js
@@ -93,6 +93,12 @@ kimchi.addNetworkActions = function(network) {
                     $("[nwAct='start']", menu).removeClass("ui-state-disabled");
                     $("[nwAct='stop']", menu).removeClass("hide-action-item");
                     $(".network-state", $("#" + network.name)).switchClass("nw-loading", "up");
+                }, function(err) {
+                    $(".network-state", $("#" + network.name)).switchClass("nw-loading","down");
+                    $("[nwAct='start']", menu).removeClass("ui-state-disabled");
+                    $("[nwAct='delete']", menu).removeClass("ui-state-disabled");
+                    $(":first-child", $("[nwAct='delete']", menu)).removeAttr("disabled");
+                    kimchi.message.error(err.responseJSON.reason);
                 });
             } else if ($(evt.currentTarget).attr("nwAct") === "stop") {
                 $(".network-state", $("#" + network.name)).switchClass("up", "nw-loading");
@@ -104,6 +110,10 @@ kimchi.addNetworkActions = function(network) {
                     $("[nwAct='delete']", menu).removeClass("ui-state-disabled");
                     $(":first-child", $("[nwAct='delete']", menu)).removeAttr("disabled");
                     $(".network-state", $("#" + network.name)).switchClass("nw-loading", "down");
+                }, function(err) {
+                    $(".network-state", $("#" + network.name)).switchClass("nw-loading", "up");
+                    $("[nwAct='stop']", menu).removeClass("ui-state-disabled");
+                    kimchi.message.error(err.responseJSON.reason);
                 });
             } else if ($(evt.currentTarget).attr("nwAct") === "delete") {
                 kimchi.confirm({
-- 
1.8.5.3




More information about the Kimchi-devel mailing list