]> git.proxmox.com Git - pve-manager.git/blobdiff - www/manager6/Utils.js
ui/qemu: Extend Qemu Guest agent
[pve-manager.git] / www / manager6 / Utils.js
index af03958c58aa6bad26fda30f8b6f5e221edff021..912cd3f70a836d9b19169587d11ae1077d18fb51 100644 (file)
@@ -175,6 +175,32 @@ Ext.define('PVE.Utils', { utilities: {
        return fa.join(', ');
     },
 
+    render_qga_features: function(value) {
+       if (!value) {
+           return Proxmox.Utils.defaultText + ' (' + Proxmox.Utils.disabledText  + ')';
+       }
+       var props = PVE.Parser.parsePropertyString(value, 'enabled');
+       if (!PVE.Parser.parseBoolean(props.enabled)) {
+           return Proxmox.Utils.disabledText;
+       }
+
+       delete props.enabled;
+       var agentstring = Proxmox.Utils.enabledText;
+
+       Ext.Object.each(props, function(key, value) {
+           var keystring = '' ;
+           agentstring += ', ' + key + ': ';
+
+           if (PVE.Parser.parseBoolean(value)) {
+               agentstring += Proxmox.Utils.enabledText;
+           } else {
+               agentstring += Proxmox.Utils.disabledText;
+           }
+       });
+
+       return agentstring;
+    },
+
     render_qemu_bios: function(value) {
        if (!value) {
            return Proxmox.Utils.defaultText + ' (SeaBIOS)';
@@ -278,20 +304,23 @@ Ext.define('PVE.Utils', { utilities: {
        return data;
     },
 
+    console_map: {
+       '__default__': Proxmox.Utils.defaultText + ' (HTML5)',
+       'vv': 'SPICE (remote-viewer)',
+       'html5': 'HTML5 (noVNC)',
+       'xtermjs': 'xterm.js'
+    },
+
     render_console_viewer: function(value) {
-       if (!value || value === '__default__') {
-           return Proxmox.Utils.defaultText + ' (HTML5)';
-       } else if (value === 'vv') {
-           return  'SPICE (remote-viewer)';
-       } else if (value === 'html5') {
-           return  'HTML5 (noVNC)';
-       } else {
-           return value;
+       value = value || '__default__';
+       if (PVE.Utils.console_map[value]) {
+           return PVE.Utils.console_map[value];
        }
+       return value;
     },
 
     console_viewer_array: function() {
-       return Ext.Array.map(['__default__','vv', 'html5'], function(v) {
+       return Ext.Array.map(Object.keys(PVE.Utils.console_map), function(v) {
            return [v, PVE.Utils.render_console_viewer(v)];
        });
     },
@@ -427,17 +456,12 @@ Ext.define('PVE.Utils', { utilities: {
        rbd: {
            name: 'RBD',
            ipanel: 'RBDInputPanel',
-           hideAdd: true,
-           faIcon: 'building'
-       },
-       rbd_ext: {
-           name: 'RBD (external)',
-           ipanel: 'RBDInputPanel',
            faIcon: 'building'
        },
        pveceph: {
            name: 'RBD (PVE)',
-           ipanel: 'PVERBDInputPanel',
+           ipanel: 'RBDInputPanel',
+           hideAdd: true,
            faIcon: 'building'
        },
        zfs: {
@@ -458,7 +482,7 @@ Ext.define('PVE.Utils', { utilities: {
 
     format_storage_type: function(value, md, record) {
        if (value === 'rbd' && record) {
-           value = (record.get('monhost')?'rbd_ext':'pveceph');
+           value = (record.get('monhost') ? 'rbd' : 'pveceph');
        }
 
        var schema = PVE.Utils.storageSchema[value];
@@ -718,13 +742,34 @@ Ext.define('PVE.Utils', { utilities: {
        return PVE.Utils.render_size_usage(record.used, record.total);
     },
 
+    render_optional_url: function(value) {
+       var match;
+       if (value && (match = value.match(/^https?:\/\//)) !== null) {
+           return '<a target="_blank" href="' + value + '">' + value + '</a>';
+       }
+       return value;
+    },
+
+    render_san: function(value) {
+       var names = [];
+       if (Ext.isArray(value)) {
+           value.forEach(function(val) {
+               if (!Ext.isNumber(val)) {
+                   names.push(val);
+               }
+           });
+           return names.join('<br>');
+       }
+       return value;
+    },
+
     windowHostname: function() {
        return window.location.hostname.replace(Proxmox.Utils.IP6_bracket_match,
             function(m, addr, offset, original) { return addr; });
     },
 
-    openDefaultConsoleWindow: function(allowSpice, vmtype, vmid, nodename, vmname) {
-       var dv = PVE.Utils.defaultViewer(allowSpice);
+    openDefaultConsoleWindow: function(consoles, vmtype, vmid, nodename, vmname) {
+       var dv = PVE.Utils.defaultViewer(consoles);
        PVE.Utils.openConsoleWindow(dv, vmtype, vmid, nodename, vmname);
     },
 
@@ -765,10 +810,20 @@ Ext.define('PVE.Utils', { utilities: {
        }
     },
 
-    defaultViewer: function(allowSpice) {
+    defaultViewer: function(consoles) {
+
+       var allowSpice, allowXtermjs;
+
+       if (consoles === true) {
+           allowSpice = true;
+           allowXtermjs = true;
+       } else if (typeof consoles === 'object') {
+           allowSpice = consoles.spice;
+           allowXtermjs = !!consoles.xtermjs;
+       }
        var vncdefault = 'html5';
        var dv = PVE.VersionInfo.console || vncdefault;
-       if (dv === 'vv' && !allowSpice) {
+       if ((dv === 'vv' && !allowSpice) || (dv === 'xtermjs' && !allowXtermjs)) {
            dv = vncdefault;
        }
 
@@ -781,7 +836,8 @@ Ext.define('PVE.Utils', { utilities: {
            novnc: 1,
            vmid: vmid,
            vmname: vmname,
-           node: nodename
+           node: nodename,
+           resize: 'off'
        });
        var nw = window.open("?" + url, '_blank', "innerWidth=745,innerheight=427");
        nw.focus();
@@ -845,7 +901,7 @@ Ext.define('PVE.Utils', { utilities: {
                    Ext.Msg.alert('Error', response.htmlStatus);
                },
                success: function(response, opts) {
-                   var allowSpice = response.result.data.spice;
+                   var allowSpice = !!response.result.data.spice;
                    PVE.Utils.openDefaultConsoleWindow(allowSpice, 'kvm', vmid, nodename, vmname);
                }
            });