Commit 0b0f539a authored by Dietmar Maurer's avatar Dietmar Maurer

use anchor with download tag to open spice console

That way we can specify a filename (required for android client).
parent 514bbd58
...@@ -928,7 +928,33 @@ Ext.define('PVE.Utils', { statics: { ...@@ -928,7 +928,33 @@ Ext.define('PVE.Utils', { statics: {
return PVE.VersionInfo.console || 'applet'; return PVE.VersionInfo.console || 'applet';
}, },
openSpiceViewer: function(url, params){ openSpiceViewer: function(url, params){
var downloadWithName = function(uri, name) {
var link = Ext.DomHelper.append(document.body, {
tag: 'a',
href: uri,
css : 'display:none;visibility:hidden;height:0px;',
});
// Note: we need to tell android the correct file name extension
// but we do not set 'download' tag for other environments, because
// It can have strange side effects (additional user prompt on firefox)
var andriod = navigator.userAgent.match(/Android/i) ? true : false;
if (andriod) {
link.download = name;
}
if (link.fireEvent) {
link.fireEvent('onclick');
} else {
var evt = document.createEvent("MouseEvents");
evt.initMouseEvent('click', true, true, window, 1, 0, 0, 0, 0, false, false, false, false, 0, null);
link.dispatchEvent(evt);
}
};
PVE.Utils.API2Request({ PVE.Utils.API2Request({
url: url, url: url,
params: params, params: params,
...@@ -944,7 +970,7 @@ Ext.define('PVE.Utils', { statics: { ...@@ -944,7 +970,7 @@ Ext.define('PVE.Utils', { statics: {
var url = 'data:application/x-virt-viewer;charset=UTF-8,' + var url = 'data:application/x-virt-viewer;charset=UTF-8,' +
encodeURIComponent(raw); encodeURIComponent(raw);
window.open(url, "_top"); downloadWithName(url, "pve-spice.vv");
} }
}); });
}, },
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment