X-Git-Url: https://git.proxmox.com/?a=blobdiff_plain;f=Utils.js;h=e7a589b5464a97389796d97ec0b2e2eba4a7b28c;hb=c47f5f46f41f33dd07d5d48cd7311476c533dcee;hp=93cba81ee8798f5c76daa57df753a82351a373f4;hpb=0ee4c725d369a3d02759ed6bb112bfe2a1326154;p=proxmox-widget-toolkit.git diff --git a/Utils.js b/Utils.js index 93cba81..e7a589b 100644 --- a/Utils.js +++ b/Utils.js @@ -218,7 +218,7 @@ Ext.define('Proxmox.Utils', { utilities: { if (clearMaskBeforeLoad) { me.mon(store, 'beforeload', function(s, operation, eOpts) { Proxmox.Utils.setErrorMask(me, false); - }) + }); } else { me.mon(store, 'beforeload', function(s, operation, eOpts) { if (!me.loadCount) { @@ -418,6 +418,19 @@ Ext.define('Proxmox.Utils', { utilities: { return type + ' ' + id; }, + format_size: function(size) { + /*jslint confusion: true */ + + var units = ['', 'Ki', 'Mi', 'Gi', 'Ti', 'Pi', 'Ei', 'Zi', 'Yi']; + var num = 0; + + while (size >= 1024 && ((num++)+1) < units.length) { + size = size / 1024; + } + + return size.toFixed((num > 0)?2:0) + " " + units[num] + "B"; + }, + render_upid: function(value, metaData, record) { var type = record.data.type; var id = record.data.id; @@ -465,7 +478,19 @@ Ext.define('Proxmox.Utils', { utilities: { return Ext.Date.format(servertime, 'Y-m-d H:i:s'); }, - }, + openXtermJsViewer: function(vmtype, vmid, nodename, vmname) { + var url = Ext.urlEncode({ + console: vmtype, // kvm, lxc, upgrade or shell + xtermjs: 1, + vmid: vmid, + vmname: vmname, + node: nodename + }); + var nw = window.open("?" + url, '_blank', 'toolbar=no,location=no,status=no,menubar=no,resizable=yes,width=800,height=420'); + nw.focus(); + } + +}, singleton: true, constructor: function() {