diff --git a/src/sunstone/public/app/app.js b/src/sunstone/public/app/app.js index d3becbf95c8..4d1bd8f80d3 100644 --- a/src/sunstone/public/app/app.js +++ b/src/sunstone/public/app/app.js @@ -56,33 +56,33 @@ var _commonDialogs = [ // $('#loading').hide(); //}); -$(document).ready(function() { -Sunstone.addDialogs(_commonDialogs); -Sunstone.addMainTabs(); -Sunstone.insertTabs(); - -if (Config.isTabEnabled(PROVISION_TAB_ID)){ - Menu.insertProvision(); -}else{ - Menu.insert(); - Sunstone.setupNavigoRoutes(); -} - -_setupAccordion(); -_setupCloseDropdownsOnClick(); -_insertUserAndZoneSelector(); - -if (Config.isTabEnabled(PROVISION_TAB_ID)) { - Sunstone.showTab(PROVISION_TAB_ID); -} - -var create_socket = function(token){ - if (Websocket.disconnected()){ - Websocket.start(token); - } -} + $(document).ready(function() { + Sunstone.addDialogs(_commonDialogs); + Sunstone.addMainTabs(); + Sunstone.insertTabs(); + + if (Config.isTabEnabled(PROVISION_TAB_ID)){ + Menu.insertProvision(); + }else{ + Menu.insert(); + Sunstone.setupNavigoRoutes(); + } + + _setupAccordion(); + _setupCloseDropdownsOnClick(); + _insertUserAndZoneSelector(); + + if (Config.isTabEnabled(PROVISION_TAB_ID)) { + Sunstone.showTab(PROVISION_TAB_ID); + } + + var create_socket = function(token){ + if (Websocket.disconnected()){ + Websocket.start(token); + } + } - FireedgeValidator.checkFireedgePublicURL(FireedgeValidator.validateFireedgeToken, create_socket); + FireedgeValidator.checkFireedgePublicURL(FireedgeValidator.validateFireedgeToken, create_socket); $('#loading').hide(); }); diff --git a/src/sunstone/public/app/tabs/vms-tab/hooks/state.js b/src/sunstone/public/app/tabs/vms-tab/hooks/state.js index eeea62a77b7..b7f724bb73c 100644 --- a/src/sunstone/public/app/tabs/vms-tab/hooks/state.js +++ b/src/sunstone/public/app/tabs/vms-tab/hooks/state.js @@ -136,7 +136,7 @@ define(function(require) { } var show_buttons = function(fireedgeToken) { - if (fireedgeToken != "") { + if ((fireedgeToken && fireedgeToken != "") || is_fireedge_configured) { show_fireedge_buttons(); } else{ @@ -144,7 +144,7 @@ define(function(require) { } } - FireedgeValidator.validateFireedgeToken(show_buttons, show_noVNC_buttons); + FireedgeValidator.validateFireedgeToken(show_buttons, show_buttons); } diff --git a/src/sunstone/public/app/utils/fireedge-validator.js b/src/sunstone/public/app/utils/fireedge-validator.js index 7c2799f849a..74776d0930c 100644 --- a/src/sunstone/public/app/utils/fireedge-validator.js +++ b/src/sunstone/public/app/utils/fireedge-validator.js @@ -22,26 +22,6 @@ define(function (require) { // user config const fireedge_endpoint = Config.publicFireedgeEndpoint; - const STATUS = { - DISCONNECTED: 0, - CONNECTED: 1, - PROCESSING: 2 - }; - - var connection = STATUS.DISCONNECTED; - - var _connected = function(){ - return connection == STATUS.CONNECTED; - }; - - var _disconnected = function(){ - return connection == STATUS.DISCONNECTED; - }; - - var _processing = function(){ - return connection == STATUS.PROCESSING; - }; - /** * Aux function to change the fireedge_token value. * @@ -65,7 +45,12 @@ define(function (require) { * be "". */ var _validate_fireedge_token = function(success, error) { - if (is_fireedge_configured && fireedge_token == "" && fireedge_endpoint){ + /* + * sunstone_fireedge_active is a variable to control if we already did + * validations. If that variable is true, that means that fireedge + * endpoint was working last time we checked it. + */ + if (sunstone_fireedge_active && fireedge_token == "" && fireedge_endpoint){ $.ajax({ url: "/fireedge", type: "GET", @@ -77,7 +62,7 @@ define(function (require) { }, error: function(request, response, data) { Notifier.onError(request, {error:{ message: "FireEdge private endpoint is not working, please contact your cloud administrator"}}); - is_fireedge_configured = false; + sunstone_fireedge_active = false; clear_fireedge_token(); if (typeof error === "function"){ error(); @@ -85,11 +70,17 @@ define(function (require) { } }); } - else if (is_fireedge_configured){ + /** + * is_fireedge_configured is a variable to control if fireedge + * configurations are available on sunstone-server.conf. + * If they are available then we must use fireedge for everything. + */ + else if (sunstone_fireedge_active || is_fireedge_configured){ if (typeof success === "function"){ success(fireedge_token); } } + // If fireedge it is not available and not configured then we dont use it else{ if (typeof error === "function"){ error(); @@ -103,14 +94,14 @@ define(function (require) { url: fireedge_endpoint, type: "GET", success: function() { - is_fireedge_configured = true; + sunstone_fireedge_active = true; if (typeof success === "function" && typeof aux === "function"){ success(aux); } }, error: function(request, response, data) { Notifier.onError(request, {error:{ message: "FireEdge public endpoint is not working, please contact your cloud administrator"}}); - is_fireedge_configured = false; + sunstone_fireedge_active = false; if (typeof error === "function"){ error(); } @@ -118,7 +109,7 @@ define(function (require) { }); } else { - is_fireedge_configured = false; + sunstone_fireedge_active = false; if (typeof error === "function"){ error(); } diff --git a/src/sunstone/public/app/utils/remote-actions.js b/src/sunstone/public/app/utils/remote-actions.js index df7d97e9766..fec56807ad4 100644 --- a/src/sunstone/public/app/utils/remote-actions.js +++ b/src/sunstone/public/app/utils/remote-actions.js @@ -289,12 +289,8 @@ define(function(require) { id: data.id, success: function(response) { FireedgeValidator.validateFireedgeToken( - function(fireedgeToken) { - if (fireedgeToken !== '') { + function() { OpenNebulaVM.isVMRCSupported(response) ? _callVMRC(data) : _callGuacVNC(data) - } else { - _callVNC(data) - } }, function() { _callVNC(data) diff --git a/src/sunstone/views/index.erb b/src/sunstone/views/index.erb index f3f52be2552..b9feea00349 100644 --- a/src/sunstone/views/index.erb +++ b/src/sunstone/views/index.erb @@ -20,6 +20,7 @@ var csrftoken = '<%= session[:csrftoken] %>'; var fireedge_token = '<%= session[:fireedge_token] %>'; var is_fireedge_configured = <%= !$conf[:public_fireedge_endpoint].nil? && !$conf[:private_fireedge_endpoint].nil? %> + var sunstone_fireedge_active = is_fireedge_configured; var view = JSON.parse('<%= view.to_json %>') var available_views = JSON.parse('["<%= $views_config.available_views(session[:user], session[:user_gname]).join('","')