diff --git a/src/sunstone/public/app/sunstone-config.js b/src/sunstone/public/app/sunstone-config.js index 0a38242b44..d1c02c1f3e 100644 --- a/src/sunstone/public/app/sunstone-config.js +++ b/src/sunstone/public/app/sunstone-config.js @@ -145,7 +145,11 @@ define(function(require) { 'logo': (_config['view']["small_logo"] || "images/one_small_logo.png"), 'vmLogos': (_config['vm_logos']), 'enabledTabs': _config['view']['enabled_tabs'], - 'onedConf': _config['oned_conf'] + 'onedConf': _config['oned_conf'], + + "allTabs": function() { + return Object.keys(_config['view']['tabs']); + } } return Config; diff --git a/src/sunstone/public/app/sunstone.js b/src/sunstone/public/app/sunstone.js index b99b310e86..1267258694 100644 --- a/src/sunstone/public/app/sunstone.js +++ b/src/sunstone/public/app/sunstone.js @@ -42,17 +42,14 @@ define(function(require) { }; var _addMainTabs = function() { + _addActions(); + $.each(Config.enabledTabs, function(i, tabName){ var name = './tabs/' + tabName; var tabObj = require(name); var _tabId = tabObj.tabId; SunstoneCfg["tabs"][_tabId] = tabObj; - var actions = tabObj.actions; - if (actions) { - _addActions(actions) - } - var panels = tabObj.panels; if (panels) { _addPanels(_tabId, panels) @@ -80,11 +77,18 @@ define(function(require) { }); } - var _addActions = function(actions) { - $.each(actions, function(actionName, action) { - SunstoneCfg["actions"][actionName] = action; - }) - return false; + var _addActions = function() { + $.each(Config.allTabs(), function(i, tabName){ + var name = './tabs/' + tabName; + var tabObj = require(name); + + var actions = tabObj.actions; + if (actions) { + $.each(actions, function(actionName, action) { + SunstoneCfg["actions"][actionName] = action; + }); + } + }); } var _addDialogs = function(dialogs) { @@ -999,13 +1003,11 @@ define(function(require) { * tab will be used */ function _hideFormPanelLoading(tabId) { - var context; - if (tabId){ - context = $("#" + tabId); - } else { - context = $(".tab:visible"); // current tab - tabId = context.attr("id"); + if (tabId == undefined){ + tabId = _getTab() } + + var context = $("#" + tabId); //$(".sunstone-form", context).html(content); $(".loadingForm", context).hide(); @@ -1024,11 +1026,19 @@ define(function(require) { } function _hideFormPanel(tabId) { + if (tabId == undefined){ + tabId = _getTab() + } + var context = $("#" + tabId); $('[href="back"]', context).trigger("click"); } function _popFormPanelLoading(tabId) { + if (tabId == undefined){ + tabId = _getTab() + } + if (!_formPanelVisible($("#"+tabId)) && router != undefined){ router.navigate(tabId+"/form"); } @@ -1062,6 +1072,10 @@ define(function(require) { } function _enableFormPanelSubmit(tabId) { + if (tabId == undefined){ + tabId = _getTab() + } + var context = $("#" + tabId); $(".submit_button", context). removeAttr("disabled"). diff --git a/src/sunstone/public/app/tabs/oneflow-templates-tab/actions.js b/src/sunstone/public/app/tabs/oneflow-templates-tab/actions.js index b75abad94b..5c42e53e23 100644 --- a/src/sunstone/public/app/tabs/oneflow-templates-tab/actions.js +++ b/src/sunstone/public/app/tabs/oneflow-templates-tab/actions.js @@ -63,7 +63,7 @@ define(function(require) { type: "single", call: OpenNebulaResource.instantiate, callback: function(request, response){ - Sunstone.hideFormPanel(TAB_ID); + Sunstone.hideFormPanel(); OpenNebulaAction.clear_cache("SERVICE"); Notifier.notifyCustom(Locale.tr("Service created"), " ID: " + response.DOCUMENT.ID, false); @@ -72,7 +72,7 @@ define(function(require) { return Sunstone.getDataTable(TAB_ID).elements(opts); }, error: function(request, response){ - Sunstone.hideFormPanelLoading(TAB_ID); + Sunstone.hideFormPanelLoading(); Notifier.onError(request, response); }, notify: false diff --git a/src/sunstone/public/app/tabs/oneflow-templates-tab/form-panels/instantiate.js b/src/sunstone/public/app/tabs/oneflow-templates-tab/form-panels/instantiate.js index b6ead91f61..307afd2084 100644 --- a/src/sunstone/public/app/tabs/oneflow-templates-tab/form-panels/instantiate.js +++ b/src/sunstone/public/app/tabs/oneflow-templates-tab/form-panels/instantiate.js @@ -160,7 +160,7 @@ define(function(require) { n_roles_done += 1; if(n_roles_done == n_roles){ - Sunstone.enableFormPanelSubmit(TAB_ID); + Sunstone.enableFormPanelSubmit(); } }, error: function(request,error_json, container){ diff --git a/src/sunstone/public/app/tabs/templates-tab/actions-common.js b/src/sunstone/public/app/tabs/templates-tab/actions-common.js index 6783bca81f..8625d4d9ba 100644 --- a/src/sunstone/public/app/tabs/templates-tab/actions-common.js +++ b/src/sunstone/public/app/tabs/templates-tab/actions-common.js @@ -153,7 +153,7 @@ define(function(require) { type: "multiple", call: OpenNebulaResource.instantiate, callback: function(request, response) { - Sunstone.hideFormPanel(TAB_ID); + Sunstone.hideFormPanel(); OpenNebulaAction.clear_cache("VM"); Notifier.notifyCustom(Locale.tr("VM created"), " ID: " + response, false); @@ -172,7 +172,7 @@ define(function(require) { type: "single", call: OpenNebulaResource.instantiate, callback: function(request, response) { - Sunstone.hideFormPanel(TAB_ID); + Sunstone.hideFormPanel(); OpenNebulaAction.clear_cache("VM"); }, error: function(request, response){ @@ -198,7 +198,7 @@ define(function(require) { type: "single", call: OpenNebulaResource.instantiate_persistent, callback: function(request, response) { - Sunstone.hideFormPanel(TAB_ID); + Sunstone.hideFormPanel(); OpenNebulaAction.clear_cache("VM"); Notifier.notifyCustom(Locale.tr("VM created"), " ID: " + response, false); diff --git a/src/sunstone/public/app/tabs/templates-tab/form-panels/instantiate.js b/src/sunstone/public/app/tabs/templates-tab/form-panels/instantiate.js index 5d1b8943cd..d3ecbcc1fd 100644 --- a/src/sunstone/public/app/tabs/templates-tab/form-panels/instantiate.js +++ b/src/sunstone/public/app/tabs/templates-tab/form-panels/instantiate.js @@ -128,7 +128,7 @@ define(function(require) { if (!this.selected_nodes || this.selected_nodes.length == 0) { Notifier.notifyError(Locale.tr("No template selected")); - Sunstone.hideFormPanelLoading(this.tabId); + Sunstone.hideFormPanelLoading(); return false; }