From e975a352e37fe015fb2b082b3d804118a6bad665 Mon Sep 17 00:00:00 2001 From: Jorge Lobo <47326048+jloboescalona2@users.noreply.github.com> Date: Mon, 8 Jul 2019 13:15:41 +0200 Subject: [PATCH] B #3217: Create or update a virtual network in sunstone (#3461) * B #3217: Create or update a VN in Sunstone Signed-off-by: Jorge Lobo * B #3217: Create or update a VN in Sunstone Signed-off-by: Jorge Lobo (cherry picked from commit d087ed32b18c55f0f511d70e06bfda505225bd2f) --- src/sunstone/public/app/sunstone.js | 3 +-- .../app/tabs/images-tab/dialogs/clone.js | 1 - .../public/app/tabs/vnets-tab/actions.js | 3 ++- .../public/app/utils/dialogs/clusters.js | 5 ----- src/sunstone/public/app/utils/notifier.js | 18 ++++++++++++++++-- 5 files changed, 19 insertions(+), 11 deletions(-) diff --git a/src/sunstone/public/app/sunstone.js b/src/sunstone/public/app/sunstone.js index 39a06936d7e..ea8ce6ec124 100644 --- a/src/sunstone/public/app/sunstone.js +++ b/src/sunstone/public/app/sunstone.js @@ -1247,11 +1247,10 @@ define(function(require) { var dialogInstance = SunstoneCfg["dialogInstances"][dialogId]; if (dialogInstance == undefined) { var Dialog = SunstoneCfg["dialogs"][dialogId]; - var dialogInstance = new Dialog(); + dialogInstance = new Dialog(); dialogInstance.insert(); SunstoneCfg["dialogInstances"][dialogId] = dialogInstance; } - return dialogInstance; }; diff --git a/src/sunstone/public/app/tabs/images-tab/dialogs/clone.js b/src/sunstone/public/app/tabs/images-tab/dialogs/clone.js index db10728344f..f9b2a8ede9f 100644 --- a/src/sunstone/public/app/tabs/images-tab/dialogs/clone.js +++ b/src/sunstone/public/app/tabs/images-tab/dialogs/clone.js @@ -104,7 +104,6 @@ define(function(require) { Sunstone.getDialog(DIALOG_ID).hide(); Sunstone.getDialog(DIALOG_ID).reset(); setTimeout(function() { - console.log("d"); Sunstone.runAction("Image.refresh"); }, 1500); return false; diff --git a/src/sunstone/public/app/tabs/vnets-tab/actions.js b/src/sunstone/public/app/tabs/vnets-tab/actions.js index 65404452dc0..f337eea5394 100644 --- a/src/sunstone/public/app/tabs/vnets-tab/actions.js +++ b/src/sunstone/public/app/tabs/vnets-tab/actions.js @@ -152,7 +152,8 @@ define(function(require) { Sunstone.getDialog(CLUSTERS_DIALOG_ID).setParams({ element: response[XML_ROOT], resource:"vnet", - resource_name: RESOURCE + resource_name: RESOURCE, + only_update_template: false }); Sunstone.getDialog(CLUSTERS_DIALOG_ID).reset(); diff --git a/src/sunstone/public/app/utils/dialogs/clusters.js b/src/sunstone/public/app/utils/dialogs/clusters.js index 02a9169b0b2..5a88a7d93bd 100644 --- a/src/sunstone/public/app/utils/dialogs/clusters.js +++ b/src/sunstone/public/app/utils/dialogs/clusters.js @@ -82,9 +82,7 @@ define(function(require) { $("#" + DIALOG_ID + "Form", dialog).submit(function() { var selectedClustersList = that.clustersTable.retrieveResourceTableSelect(); - if ( that.only_update_template != undefined && that.only_update_template != true) { - $.each(selectedClustersList, function(index, clusterId) { if ($.inArray(clusterId, that.originalClusterIds) === -1) { if(that.resource == "datastore"){ @@ -94,7 +92,6 @@ define(function(require) { } } }); - $.each(that.originalClusterIds, function(index, clusterId) { if ($.inArray(clusterId, selectedClustersList) === -1) { if(that.resource == "datastore"){ @@ -111,9 +108,7 @@ define(function(require) { Sunstone.getDialog(DIALOG_ID).hide(); Sunstone.getDialog(DIALOG_ID).reset(); - setTimeout(function() { - console.log("n"); Sunstone.runAction(that.resource_name+".refresh"); }, 1500); diff --git a/src/sunstone/public/app/utils/notifier.js b/src/sunstone/public/app/utils/notifier.js index 9ef40cf68fb..cd46e9cf332 100644 --- a/src/sunstone/public/app/utils/notifier.js +++ b/src/sunstone/public/app/utils/notifier.js @@ -41,8 +41,22 @@ define(function(require) { //Notification on error var _notifyError = function(msg, target=undefined, context=undefined) { if(target && context){ - var tab = $(target).find($(".is-invalid-input",context)).closest(".tabs-panel",context); - tab.parent().siblings($(".tabs",context)).find($("a[href$=\"#"+tab.attr("id")+"\"]",context)).click(); + var tab = $(target).find($(".is-invalid-input",context)); + tab.parents().each( + function(id,element){ + var parent = $(element); + if(parent.hasClass("tabs-panel")){ + var tabs = parent.parent().siblings($(".tabs",context)); + if(tabs && tabs.length){ + var find = tabs.find($("a[href$=\"#"+parent.attr("id")+"\"]",context)) + if(find && find.length){ + find.click(); + return false; + } + } + } + } + ); } $.jGrowl(msg, {theme: "jGrowl-notify-error", position: "bottom-right", sticky: true}); };