]> git.proxmox.com Git - pve-manager.git/blobdiff - www/manager6/Utils.js
added new parameter to pass a command to the newly opened terminal
[pve-manager.git] / www / manager6 / Utils.js
index c2007f6d318ee7a08441bd3809ba0b53165adc2f..b9fa25b72784200529eaf2da651712b1e826bff4 100644 (file)
@@ -19,6 +19,7 @@ Ext.Ajax.defaultHeaders = {
     'Accept': 'application/json'
 };
 
+/*jslint confusion: true */
 Ext.define('PVE.Utils', { utilities: {
 
     // this singleton contains miscellaneous utilities
@@ -123,8 +124,12 @@ Ext.define('PVE.Utils', { utilities: {
     },
 
     render_zfs_health: function(value) {
+       if (typeof value == 'undefined'){
+           return "";
+       }
        var iconCls = 'question-circle';
        switch (value) {
+           case 'AVAIL':
            case 'ONLINE':
                iconCls = 'check-circle good';
                break;
@@ -141,6 +146,7 @@ Ext.define('PVE.Utils', { utilities: {
        }
 
        return '<i class="fa fa-' + iconCls + '"></i> ' + value;
+
     },
 
     get_kvm_osinfo: function(value) {
@@ -302,7 +308,9 @@ Ext.define('PVE.Utils', { utilities: {
        serial0: gettext('Serial terminal') + ' 0',
        serial1: gettext('Serial terminal') + ' 1',
        serial2: gettext('Serial terminal') + ' 2',
-       serial3: gettext('Serial terminal') + ' 3'
+       serial3: gettext('Serial terminal') + ' 3',
+       virtio: 'VirtIO-GPU',
+       none: Proxmox.Utils.noneText
     },
 
     render_kvm_language: function (value) {
@@ -350,7 +358,11 @@ Ext.define('PVE.Utils', { utilities: {
        if (!value) {
            return Proxmox.Utils.defaultText;
        }
-       var text = PVE.Utils.kvm_vga_drivers[value];
+       var vga = PVE.Parser.parsePropertyString(value, 'type');
+       var text = PVE.Utils.kvm_vga_drivers[vga.type];
+       if (!vga.type) {
+           text = Proxmox.Utils.defaultText;
+       }
        if (text) {
            return text + ' (' + value + ')';
        }
@@ -426,11 +438,14 @@ Ext.define('PVE.Utils', { utilities: {
        return days.toFixed(1) + 'd';
     },
 
-    imagesText: gettext('Disk image'),
-    backupFileText: gettext('VZDump backup file'),
-    vztmplText: gettext('Container template'),
-    isoImageText: gettext('ISO image'),
-    containersText: gettext('Container'),
+    contentTypes: {
+       'images': gettext('Disk image'),
+       'backup': gettext('VZDump backup file'),
+       'vztmpl': gettext('Container template'),
+       'iso': gettext('ISO image'),
+       'rootdir': gettext('Container'),
+       'snippets': gettext('Snippets')
+    },
 
     storageSchema: {
        dir: {
@@ -474,6 +489,17 @@ Ext.define('PVE.Utils', { utilities: {
            hideAdd: true,
            faIcon: 'building'
        },
+       cephfs: {
+           name: 'CephFS',
+           ipanel: 'CephFSInputPanel',
+           faIcon: 'building'
+       },
+       pvecephfs: {
+           name: 'CephFS (PVE)',
+           ipanel: 'CephFSInputPanel',
+           hideAdd: true,
+           faIcon: 'building'
+       },
        rbd: {
            name: 'RBD',
            ipanel: 'RBDInputPanel',
@@ -502,8 +528,10 @@ Ext.define('PVE.Utils', { utilities: {
     },
 
     format_storage_type: function(value, md, record) {
-       if (value === 'rbd' && record) {
-           value = (record.get('monhost') ? 'rbd' : 'pveceph');
+       if (value === 'rbd') {
+           value = (!record || record.get('monhost') ? 'rbd' : 'pveceph');
+       } else if (value === 'cephfs') {
+           value = (!record || record.get('monhost') ? 'cephfs' : 'pvecephfs');
        }
 
        var schema = PVE.Utils.storageSchema[value];
@@ -527,23 +555,9 @@ Ext.define('PVE.Utils', { utilities: {
     },
 
     format_content_types: function(value) {
-       var cta = [];
-
-       Ext.each(value.split(',').sort(), function(ct) {
-           if (ct === 'images') {
-               cta.push(PVE.Utils.imagesText);
-           } else if (ct === 'backup') {
-               cta.push(PVE.Utils.backupFileText);
-           } else if (ct === 'vztmpl') {
-               cta.push(PVE.Utils.vztmplText);
-           } else if (ct === 'iso') {
-               cta.push(PVE.Utils.isoImageText);
-           } else if (ct === 'rootdir') {
-               cta.push(PVE.Utils.containersText);
-           }
-       });
-
-       return cta.join(', ');
+       return value.split(',').sort().map(function(ct) {
+           return PVE.Utils.contentTypes[ct] || ct;
+       }).join(', ');
     },
 
     render_storage_content: function(value, metaData, record) {
@@ -784,17 +798,23 @@ Ext.define('PVE.Utils', { utilities: {
        return value;
     },
 
+    render_full_name: function(firstname, metaData, record) {
+       var first = firstname || '';
+       var last = record.data.lastname || '';
+       return Ext.htmlEncode(first + " " + last);
+    },
+
     windowHostname: function() {
        return window.location.hostname.replace(Proxmox.Utils.IP6_bracket_match,
             function(m, addr, offset, original) { return addr; });
     },
 
-    openDefaultConsoleWindow: function(consoles, vmtype, vmid, nodename, vmname) {
+    openDefaultConsoleWindow: function(consoles, vmtype, vmid, nodename, vmname, cmd) {
        var dv = PVE.Utils.defaultViewer(consoles);
-       PVE.Utils.openConsoleWindow(dv, vmtype, vmid, nodename, vmname);
+       PVE.Utils.openConsoleWindow(dv, vmtype, vmid, nodename, vmname, cmd);
     },
 
-    openConsoleWindow: function(viewer, vmtype, vmid, nodename, vmname) {
+    openConsoleWindow: function(viewer, vmtype, vmid, nodename, vmname, cmd) {
        // kvm, lxc, shell, upgrade
 
        if (vmid == undefined && (vmtype === 'kvm' || vmtype === 'lxc')) {
@@ -806,9 +826,9 @@ Ext.define('PVE.Utils', { utilities: {
        }
 
        if (viewer === 'html5') {
-           PVE.Utils.openVNCViewer(vmtype, vmid, nodename, vmname);
+           PVE.Utils.openVNCViewer(vmtype, vmid, nodename, vmname, cmd);
        } else if (viewer === 'xtermjs') {
-           Proxmox.Utils.openXtermJsViewer(vmtype, vmid, nodename, vmname);
+           Proxmox.Utils.openXtermJsViewer(vmtype, vmid, nodename, vmname, cmd);
        } else if (viewer === 'vv') {
            var url;
            var params = { proxy: PVE.Utils.windowHostname() };
@@ -825,6 +845,10 @@ Ext.define('PVE.Utils', { utilities: {
                url = '/nodes/' + nodename + '/spiceshell';
                params.upgrade = 1;
                PVE.Utils.openSpiceViewer(url, params);
+           } else if (vmtype === 'cmd') {
+               url = '/nodes/' + nodename + '/spiceshell';
+               params.cmd = cmd;
+               PVE.Utils.openSpiceViewer(url, params);
            }
        } else {
            throw "unknown viewer type";
@@ -851,17 +875,20 @@ Ext.define('PVE.Utils', { utilities: {
        return dv;
     },
 
-    openVNCViewer: function(vmtype, vmid, nodename, vmname) {
-       var url = Ext.urlEncode({
+    openVNCViewer: function(vmtype, vmid, nodename, vmname, cmd) {
+       var url = Ext.Object.toQueryString({
            console: vmtype, // kvm, lxc, upgrade or shell
            novnc: 1,
            vmid: vmid,
            vmname: vmname,
            node: nodename,
-           resize: 'off'
+           resize: 'off',
+           cmd: cmd
        });
        var nw = window.open("?" + url, '_blank', "innerWidth=745,innerheight=427");
-       nw.focus();
+       if (nw) {
+           nw.focus();
+       }
     },
 
     openSpiceViewer: function(url, params){
@@ -975,6 +1002,7 @@ Ext.define('PVE.Utils', { utilities: {
        }
 
        menu.showAt(event.getXY());
+       return menu;
     },
 
     // helper for deleting field which are set to there default values
@@ -1042,7 +1070,7 @@ Ext.define('PVE.Utils', { utilities: {
        }
     },
 
-    mp_counts: { mps: 10, unused: 10 },
+    mp_counts: { mps: 256, unused: 256 },
 
     forEachMP: function(func, includeUnused) {
        var i, cont;