From 4ecff42131eeab34c5ea11fb2fb2172ce303e152 Mon Sep 17 00:00:00 2001 From: Jaime Melis Date: Fri, 10 Jun 2016 17:54:26 +0200 Subject: [PATCH] Refactor Sunstone Upgrade notification --- src/sunstone/public/app/tabs/upgrade-top-tab.js | 10 +++------- src/sunstone/sunstone-server.rb | 9 ++++++++- src/sunstone/views/index.erb | 3 ++- 3 files changed, 13 insertions(+), 9 deletions(-) diff --git a/src/sunstone/public/app/tabs/upgrade-top-tab.js b/src/sunstone/public/app/tabs/upgrade-top-tab.js index 62e272c02c..f7a9858b3e 100644 --- a/src/sunstone/public/app/tabs/upgrade-top-tab.js +++ b/src/sunstone/public/app/tabs/upgrade-top-tab.js @@ -18,10 +18,6 @@ define(function(require) { var Locale = require('utils/locale'); var TAB_ID = 'upgrade-top-tab'; - var UPGRADE = "Upgrade Available "; - var NO_UPGRADE = ""; - var UPGRADE_URL = "http://opennebula.org/software/"; - var Tab = { tabId: TAB_ID, title: "", @@ -33,7 +29,7 @@ define(function(require) { function _setup() { $('#li_upgrade-top-tab > a').on("click", function(e){ - window.location = UPGRADE_URL; + window.location = config['upgrade']['url']; return false; }); @@ -50,9 +46,9 @@ define(function(require) { var tab_title; if (remote_version && (version < remote_version)) { - tab_title = UPGRADE; + tab_title = config['upgrade']['upgrade']; } else { - tab_title = NO_UPGRADE; + tab_title = config['upgrade']['no_upgrade']; } $("li[id$='upgrade-top-tab'] > a").html(tab_title); diff --git a/src/sunstone/sunstone-server.rb b/src/sunstone/sunstone-server.rb index 3996cc4612..c70d24ed75 100755 --- a/src/sunstone/sunstone-server.rb +++ b/src/sunstone/sunstone-server.rb @@ -204,6 +204,12 @@ SUPPORT = { :project => "OpenNebula" } +UPGRADE = { + :upgrade => "Upgrade Available ", + :no_upgrade => "", + :url => "http://opennebula.org/software/" +} + ############################################################################## # Helpers ############################################################################## @@ -465,7 +471,8 @@ get '/' do erb :index, :locals => { :logos_conf => logos_conf, :oned_conf => oned_conf, - :support => SUPPORT + :support => SUPPORT, + :upgrade => UPGRADE } end diff --git a/src/sunstone/views/index.erb b/src/sunstone/views/index.erb index 7425b0f1e5..cc4135dc62 100644 --- a/src/sunstone/views/index.erb +++ b/src/sunstone/views/index.erb @@ -48,7 +48,8 @@ 'zone_id' : '<%= session[:zone_id] %>', 'vm_logos' : <%= logos_conf.to_json %>, 'oned_conf' : <%= oned_conf.to_json %>, - 'support' : <%= support.to_json %> + 'support' : <%= support.to_json %>, + 'upgrade' : <%= upgrade.to_json %> };