From 4fcfbc6ea8003b84c93a29a6370f69f52bf14afb Mon Sep 17 00:00:00 2001 From: Frederick Borges Date: Mon, 21 Mar 2022 12:20:47 +0100 Subject: [PATCH] B #5707: Use VM_MAD to show VirtViewer (#1858) --- src/sunstone/public/app/opennebula/vm.js | 21 +++---------------- src/sunstone/public/app/utils/files.js | 1 + .../public/app/utils/remote-actions.js | 18 ++++++++++++++++ 3 files changed, 22 insertions(+), 18 deletions(-) diff --git a/src/sunstone/public/app/opennebula/vm.js b/src/sunstone/public/app/opennebula/vm.js index 4d5a4f909e..906b491455 100644 --- a/src/sunstone/public/app/opennebula/vm.js +++ b/src/sunstone/public/app/opennebula/vm.js @@ -1257,22 +1257,8 @@ define(function(require) { String(element.USER_TEMPLATE.HYPERVISOR).toLowerCase() === "vcenter"); } - function isKVMVM(hostID){ - var isKVM = false; - OpenNebulaHost.show({ - data : { - id: hostID - }, - timeout: true, - success: function (_, hostTemplate) { - isKVM = String(hostTemplate.HOST.VM_MAD).toLowerCase() === 'kvm'; - }, - error: function(request, response) { - isKVM = false; - }}, - false - ); - return isKVM; + function isKvmVm(history = {}){ + return Boolean(history.VM_MAD && String(history.VM_MAD).toLowerCase() === "kvm"); } function isVMRCSupported(element = {}) { @@ -1294,8 +1280,7 @@ define(function(require) { var actionEnabled = Config.isTabActionEnabled("vms-tab", "VM.save_virt_viewer"); var vncSupported = graphicSupported(element, "vnc"); var spiceSupported = graphicSupported(element, "spice"); - var hostId = history && history.HID - var isKVM = hostId ? isKVMVM(hostId) : false; + var isKVM = isKvmVm(history); return (actionEnabled && history && (vncSupported || spiceSupported) && isKVM) ? { diff --git a/src/sunstone/public/app/utils/files.js b/src/sunstone/public/app/utils/files.js index 26aa6869eb..660a7323c0 100644 --- a/src/sunstone/public/app/utils/files.js +++ b/src/sunstone/public/app/utils/files.js @@ -17,6 +17,7 @@ define(function(require) { var Config = require('sunstone-config'); var UtilsConnection = require("utils/info-connection/utils"); + var Notifier = require("utils/notifier"); return { "downloadWFile": _downloadWFile, diff --git a/src/sunstone/public/app/utils/remote-actions.js b/src/sunstone/public/app/utils/remote-actions.js index f7c5d7f6e7..a726aa978b 100644 --- a/src/sunstone/public/app/utils/remote-actions.js +++ b/src/sunstone/public/app/utils/remote-actions.js @@ -99,6 +99,21 @@ define(function(require) { return $("
").append(button.append(icon)).html(); } + function buttonWFile(id = "", wfile = {}) { + var icon = $("", { class: "fas fa-file-code" }); + + var button = $("