From 1c69926a5fcdd964b41d00844a4e1cfd5ae774e4 Mon Sep 17 00:00:00 2001 From: Jorge Lobo Date: Mon, 4 Nov 2019 18:16:56 +0100 Subject: [PATCH] B #3268: disable support no show error Signed-off-by: Jorge Lobo --- .../services/legacy/ubuntu/opennebula-novnc | 0 src/sunstone/public/app/main.js | 1 + src/sunstone/public/app/sunstone.js | 13 ++- .../public/app/tabs/official-support-tab.js | 42 ++++++++ .../app/tabs/official-support-tab/actions.js | 98 +++++++++++++++++++ .../app/tabs/official-support-tab/tabId.js | 19 ++++ .../tabs/official-support-tab/utils/common.js | 67 +++++++++++++ src/sunstone/public/app/tabs/support-tab.js | 7 -- .../public/app/tabs/support-tab/actions.js | 47 --------- .../app/tabs/support-tab/utils/common.js | 13 +-- 10 files changed, 239 insertions(+), 68 deletions(-) mode change 100755 => 100644 share/pkgs/services/legacy/ubuntu/opennebula-novnc create mode 100644 src/sunstone/public/app/tabs/official-support-tab.js create mode 100644 src/sunstone/public/app/tabs/official-support-tab/actions.js create mode 100644 src/sunstone/public/app/tabs/official-support-tab/tabId.js create mode 100644 src/sunstone/public/app/tabs/official-support-tab/utils/common.js diff --git a/share/pkgs/services/legacy/ubuntu/opennebula-novnc b/share/pkgs/services/legacy/ubuntu/opennebula-novnc old mode 100755 new mode 100644 diff --git a/src/sunstone/public/app/main.js b/src/sunstone/public/app/main.js index cf25784ac5e..e8346c73d63 100644 --- a/src/sunstone/public/app/main.js +++ b/src/sunstone/public/app/main.js @@ -151,6 +151,7 @@ require.config({ "tabs/secgroups-tab", "tabs/settings-tab", "tabs/support-tab", + "tabs/official-support-tab", "tabs/upgrade-top-tab", "tabs/vmgroup-tab", "addons/start", diff --git a/src/sunstone/public/app/sunstone.js b/src/sunstone/public/app/sunstone.js index 18d2d526161..273d89f608c 100644 --- a/src/sunstone/public/app/sunstone.js +++ b/src/sunstone/public/app/sunstone.js @@ -64,6 +64,7 @@ define(function(require) { "vnets-topology-tab", "vnets-topology-tab", "support-tab", + "official-support-tab", "settings-tab", "upgrade-top-tab", "vmgroup-tab", @@ -135,6 +136,9 @@ define(function(require) { $.each(Config.allTabs(), function(i, tabName){ _addAction(i, tabName); }); + + //add actions official support + _addAction(null, 'official-support-tab'); }; var _addDialogs = function(dialogs) { @@ -179,7 +183,6 @@ define(function(require) { _insertTab(tabName); _insertButtonsInTab(tabName); _setupDataTable(tabName); - var hooks = SunstoneCfg["tabs"][tabName].initHooks; if (hooks) { @@ -189,6 +192,7 @@ define(function(require) { } } var support_tab = "support-tab"; + var official_support_tab = "official-support-tab"; if(SunstoneCfg && SunstoneCfg.tabs && !SunstoneCfg.tabs[support_tab] @@ -207,6 +211,11 @@ define(function(require) { _insertTab(support_tab); _setupDataTable(support_tab); } + + //Separate the logic be supported with the banner + _addMainTab(official_support_tab); + _insertTab(official_support_tab); + _setupTabs(); }; @@ -256,7 +265,7 @@ define(function(require) { $("div#menu ul#navigation").append(liItem); if(config && config.user_config){ if(tabName === "support-tab" && config.user_config.default_view === "cloud"){ - _addAction(null, "support-tab"); + _addAction(null, "official-support-tab"); $(".sunstone-header").addClass("support_place").append(title); $("#support-tab").remove(); } diff --git a/src/sunstone/public/app/tabs/official-support-tab.js b/src/sunstone/public/app/tabs/official-support-tab.js new file mode 100644 index 00000000000..45d124e7faa --- /dev/null +++ b/src/sunstone/public/app/tabs/official-support-tab.js @@ -0,0 +1,42 @@ +/* -------------------------------------------------------------------------- */ +/* Copyright 2002-2019, OpenNebula Project, OpenNebula Systems */ +/* */ +/* Licensed under the Apache License, Version 2.0 (the "License"); you may */ +/* not use this file except in compliance with the License. You may obtain */ +/* a copy of the License at */ +/* */ +/* http://www.apache.org/licenses/LICENSE-2.0 */ +/* */ +/* Unless required by applicable law or agreed to in writing, software */ +/* distributed under the License is distributed on an "AS IS" BASIS, */ +/* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. */ +/* See the License for the specific language governing permissions and */ +/* limitations under the License. */ +/* -------------------------------------------------------------------------- */ + +define(function(require) { + var Actions = require("./official-support-tab/actions"); + var Notifier = require("utils/notifier"); + var SupportUtils = require("./official-support-tab/utils/common"); + var Sunstone = require("sunstone"); + var Locale = require("utils/locale"); + var TAB_ID = require("./official-support-tab/tabId"); + + var Tab = { + tabId: TAB_ID, + resource: "official-support", + actions: Actions, + setup: _setup + }; + + return Tab; + + function _setup(context) { + SupportUtils.checkValidateOfficialSupport(); + SupportUtils.checkLastVersionSupport(); + $(".support_not_connected > button").on("click", function(e){ + e.stopPropagation(); + window.open("http://opennebula.systems/opennebula-support/", "_blank"); + }); + } +}); diff --git a/src/sunstone/public/app/tabs/official-support-tab/actions.js b/src/sunstone/public/app/tabs/official-support-tab/actions.js new file mode 100644 index 00000000000..2c7b08e8b05 --- /dev/null +++ b/src/sunstone/public/app/tabs/official-support-tab/actions.js @@ -0,0 +1,98 @@ +/* -------------------------------------------------------------------------- */ +/* Copyright 2002-2019, OpenNebula Project, OpenNebula Systems */ +/* */ +/* Licensed under the Apache License, Version 2.0 (the "License"); you may */ +/* not use this file except in compliance with the License. You may obtain */ +/* a copy of the License at */ +/* */ +/* http://www.apache.org/licenses/LICENSE-2.0 */ +/* */ +/* Unless required by applicable law or agreed to in writing, software */ +/* distributed under the License is distributed on an "AS IS" BASIS, */ +/* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. */ +/* See the License for the specific language governing permissions and */ +/* limitations under the License. */ +/* -------------------------------------------------------------------------- */ + +define(function(require) { + var Sunstone = require("sunstone"); + var Notifier = require("utils/notifier"); + var OpenNebulaSupport = require("opennebula/support"); + var SupportUtils = require("./utils/common"); + + var RESOURCE = "official-support"; + var TAB_ID = require("./tabId"); + + var majorVersion = function(version){ + var r = 0; + if(version && version.length){ + var major = version.substring(0, version.lastIndexOf(".")); + if(major && major.length){ + r = parseFloat(major); + } + } + return r; + }; + + var minorVersion = function(version){ + var r = 0; + if(version && version.length){ + var minor = version.substring(version.lastIndexOf(".")+1); + if(minor && minor.length){ + r = parseFloat(minor); + } + } + return r; + }; + + var _actions = { + "Support.check":{ + type: "list", + call: OpenNebulaSupport.check, + callback: function(req, lst, res){ + SupportUtils.showSupportConnect(); + }, + error: function(request){ + if (request && request.status && request.status >= 400) { + SupportUtils.stopIntervalRefresh(); + } + SupportUtils.hideSupportConnect(); + } + }, + "Support.checkversion":{ + type: "list", + call: OpenNebulaSupport.checkversion, + callback: function(req, lst, res){ + if($("#footer>a").length){ + var localVersion = $("#footer>a").text().replace("OpenNebula ", ""); + if(req && req.version && req.version!=="0" && localVersion.length){ + var version = req.version; + var remoteMajorVersion = majorVersion(version); + var remoteMinorVersion = minorVersion(version); + var localMajorVersion = majorVersion(localVersion); + var localMinorVersion = minorVersion(localVersion); + var link = $("", {href:"https://opennebula.org/software/"}).text( + "(new version available: " + version + ")" + ); + if(remoteMajorVersion > localMajorVersion){ + $("#latest_version").show().empty().append(link); + return; + } + if(remoteMajorVersion === localMajorVersion && remoteMinorVersion > localMinorVersion){ + $("#latest_version").show().empty().append(link); + return; + } + } + } + $("#latest_version").hide().empty(); + }, + error: function(request){ + if (request && request.status && request.status >= 400) { + SupportUtils.stopIntervalRefresh(); + } + $("#latest_version").hide().empty(); + } + } + }; + return _actions; +}); diff --git a/src/sunstone/public/app/tabs/official-support-tab/tabId.js b/src/sunstone/public/app/tabs/official-support-tab/tabId.js new file mode 100644 index 00000000000..5c4d5bbb5f8 --- /dev/null +++ b/src/sunstone/public/app/tabs/official-support-tab/tabId.js @@ -0,0 +1,19 @@ +/* -------------------------------------------------------------------------- */ +/* Copyright 2002-2019, OpenNebula Project, OpenNebula Systems */ +/* */ +/* Licensed under the Apache License, Version 2.0 (the "License"); you may */ +/* not use this file except in compliance with the License. You may obtain */ +/* a copy of the License at */ +/* */ +/* http://www.apache.org/licenses/LICENSE-2.0 */ +/* */ +/* Unless required by applicable law or agreed to in writing, software */ +/* distributed under the License is distributed on an "AS IS" BASIS, */ +/* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. */ +/* See the License for the specific language governing permissions and */ +/* limitations under the License. */ +/* -------------------------------------------------------------------------- */ + +define(function(require){ + return 'official-support-tab'; +}); diff --git a/src/sunstone/public/app/tabs/official-support-tab/utils/common.js b/src/sunstone/public/app/tabs/official-support-tab/utils/common.js new file mode 100644 index 00000000000..2c237153e81 --- /dev/null +++ b/src/sunstone/public/app/tabs/official-support-tab/utils/common.js @@ -0,0 +1,67 @@ +/* -------------------------------------------------------------------------- */ +/* Copyright 2002-2019, OpenNebula Project, OpenNebula Systems */ +/* */ +/* Licensed under the Apache License, Version 2.0 (the "License"); you may */ +/* not use this file except in compliance with the License. You may obtain */ +/* a copy of the License at */ +/* */ +/* http://www.apache.org/licenses/LICENSE-2.0 */ +/* */ +/* Unless required by applicable law or agreed to in writing, software */ +/* distributed under the License is distributed on an "AS IS" BASIS, */ +/* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. */ +/* See the License for the specific language governing permissions and */ +/* limitations under the License. */ +/* -------------------------------------------------------------------------- */ + +define(function(require) { + /* + Common functions for the support tab + */ + + var Sunstone = require("sunstone"); + + var TAB_ID = require("../../support-tab/tabId"); + + var support_interval_function; + + function _show_support_connect() { + $(".support_info").hide(); + $("#"+Sunstone.getDataTable(TAB_ID).dataTableId+"Container", "#"+TAB_ID).hide(); + $(".actions_row", "#"+TAB_ID).hide(); + $(".support_not_connected").hide(); + $(".support_connect").show(); + } + + function _hide_support_connect() { + $(".support_info").hide(); + $("#"+Sunstone.getDataTable(TAB_ID).dataTableId+"Container", "#"+TAB_ID).hide(); + $(".support_connect").hide(); + $(".actions_row", "#"+TAB_ID).hide(); + $(".support_not_connected").show(); + } + + function _show_support_list() { + $(".support_info").show(); + $(".support_connect").hide(); + $(".support_not_connected").hide(); + $(".actions_row", "#"+TAB_ID).show(); + $("#"+Sunstone.getDataTable(TAB_ID).dataTableId+"Container", "#"+TAB_ID).show(); + } + + function _check_validate_official_support(){ + Sunstone.runAction("Support.check"); + } + + function _check_last_version_support(){ + Sunstone.runAction("Support.checkversion"); + } + + return { + "showSupportConnect": _show_support_connect, + "showSupportList": _show_support_list, + "hideSupportConnect": _hide_support_connect, + "checkValidateOfficialSupport": _check_validate_official_support, + "checkLastVersionSupport": _check_last_version_support + }; +}); diff --git a/src/sunstone/public/app/tabs/support-tab.js b/src/sunstone/public/app/tabs/support-tab.js index 1d4a3a8e9b8..bd183cb2048 100644 --- a/src/sunstone/public/app/tabs/support-tab.js +++ b/src/sunstone/public/app/tabs/support-tab.js @@ -64,16 +64,9 @@ define(function(require) { return Tab; function _setup(context) { - //SupportUtils.startIntervalRefresh(); //esto de debe de borrar porque me esta listando el login de un usuario - SupportUtils.checkValidateOfficialSupport(); - SupportUtils.checkLastVersionSupport(); $("#li_support-tab > a").on("click", function(e){ e.preventDefault(); }); - $(".support_not_connected > button").on("click", function(e){ - e.stopPropagation(); - window.open("http://opennebula.systems/opennebula-support/", "_blank"); - }); if(config && config.user_config && config.user_config.default_view === "admin"){ $("#support_credentials_form", context).on("submit", function(){ $(".support_button").on("click", function(e){ diff --git a/src/sunstone/public/app/tabs/support-tab/actions.js b/src/sunstone/public/app/tabs/support-tab/actions.js index 69fc912456f..06c698a7e8b 100644 --- a/src/sunstone/public/app/tabs/support-tab/actions.js +++ b/src/sunstone/public/app/tabs/support-tab/actions.js @@ -45,53 +45,6 @@ define(function(require) { return r; }; var _actions = { - "Support.check":{ - type: "list", - call: OpenNebulaSupport.check, - callback: function(req, lst, res){ - SupportUtils.showSupportConnect(); - }, - error: function(request){ - if (request && request.status && request.status >= 400) { - SupportUtils.stopIntervalRefresh(); - } - SupportUtils.hideSupportConnect(); - } - }, - "Support.checkversion":{ - type: "list", - call: OpenNebulaSupport.checkversion, - callback: function(req, lst, res){ - if($("#footer>a").length){ - var localVersion = $("#footer>a").text().replace("OpenNebula ", ""); - if(req && req.version && req.version!=="0" && localVersion.length){ - var version = req.version; - var remoteMajorVersion = majorVersion(version); - var remoteMinorVersion = minorVersion(version); - var localMajorVersion = majorVersion(localVersion); - var localMinorVersion = minorVersion(localVersion); - var link = $("", {href:"https://opennebula.org/software/"}).text( - "(new version available: " + version + ")" - ); - if(remoteMajorVersion > localMajorVersion){ - $("#latest_version").show().empty().append(link); - return; - } - if(remoteMajorVersion === localMajorVersion && remoteMinorVersion > localMinorVersion){ - $("#latest_version").show().empty().append(link); - return; - } - } - } - $("#latest_version").hide().empty(); - }, - error: function(request){ - if (request && request.status && request.status >= 400) { - SupportUtils.stopIntervalRefresh(); - } - $("#latest_version").hide().empty(); - } - }, "Support.list" : { type: "list", call: OpenNebulaSupport.list, diff --git a/src/sunstone/public/app/tabs/support-tab/utils/common.js b/src/sunstone/public/app/tabs/support-tab/utils/common.js index 2f3557be233..a924a61f64e 100644 --- a/src/sunstone/public/app/tabs/support-tab/utils/common.js +++ b/src/sunstone/public/app/tabs/support-tab/utils/common.js @@ -41,14 +41,6 @@ define(function(require) { $(".support_not_connected").show(); } - function _check_validate_official_support(){ - Sunstone.runAction("Support.check"); - } - - function _check_last_version_support(){ - Sunstone.runAction("Support.checkversion"); - } - function _show_support_list() { $(".support_info").show(); $(".support_connect").hide(); @@ -58,7 +50,6 @@ define(function(require) { } function _startIntervalRefresh() { - //Sunstone.runAction("Support.list"); //esto no se que pinta!!! support_interval_function = setInterval(function(){ Sunstone.runAction("Support.list"); }, Sunstone.TOP_INTERVAL); @@ -73,8 +64,6 @@ define(function(require) { "showSupportList": _show_support_list, "hideSupportConnect": _hide_support_connect, "startIntervalRefresh": _startIntervalRefresh, - "stopIntervalRefresh": _stopIntervalRefresh, - "checkValidateOfficialSupport": _check_validate_official_support, - "checkLastVersionSupport": _check_last_version_support + "stopIntervalRefresh": _stopIntervalRefresh }; });