]> git.proxmox.com Git - pve-manager.git/blobdiff - www/manager6/Utils.js
add new xtermjs viewer window to Utils
[pve-manager.git] / www / manager6 / Utils.js
index e9c64d1a88a9c89a8dfe81ced0bcefbc1a7b6449..578ba81ece2b9ed04a0e9a6555214584007467e4 100644 (file)
@@ -58,16 +58,24 @@ Ext.define('PVE.Utils', { utilities: {
     noSubKeyHtml: 'You do not have a valid subscription for this server. Please visit <a target="_blank" href="http://www.proxmox.com/products/proxmox-ve/subscription-service-plans">www.proxmox.com</a> to get a list of available options.',
 
     kvm_ostypes: {
-       other: gettext('Other OS types'),
-       wxp: 'Microsoft Windows XP/2003',
-       w2k: 'Microsoft Windows 2000',
-       w2k8: 'Microsoft Windows Vista/2008',
-       win7: 'Microsoft Windows 7/2008r2',
-       win8: 'Microsoft Windows 8.x/2012/2012r2',
-       win10: 'Microsoft Windows 10/2016',
-       l24: 'Linux 2.4 Kernel',
-       l26: 'Linux 4.X/3.X/2.6 Kernel',
-       solaris: 'Solaris Kernel'
+       'Linux': [
+           { desc: '4.X/3.X/2.6 Kernel', val: 'l26' },
+           { desc: '2.4 Kernel', val: 'l24' }
+       ],
+       'Microsoft Windows': [
+           { desc: '10/2016', val: 'win10' },
+           { desc: '8.x/2012/2012r2', val: 'win8' },
+           { desc: '7/2008r2', val: 'win7' },
+           { desc: 'Vista/2008', val: 'w2k8' },
+           { desc: 'XP/2003', val: 'wxp' },
+           { desc: '2000', val: 'w2k' }
+       ],
+       'Solaris Kernel': [
+           { desc: '-', val: 'solaris'}
+       ],
+       'Other': [
+           { desc: '-', val: 'other'}
+       ]
     },
 
     get_health_icon: function(state, circle) {
@@ -106,33 +114,45 @@ Ext.define('PVE.Utils', { utilities: {
        'HEALTH_ERR':'critical'
     },
 
-    render_ceph_health: function(record) {
+    render_ceph_health: function(healthObj) {
        var state = {
            iconCls: PVE.Utils.get_health_icon(),
            text: ''
        };
 
-       if (!record || !record.data) {
+       if (!healthObj || !healthObj.status) {
            return state;
        }
 
-       var health = PVE.Utils.map_ceph_health[record.data.health.overall_status];
+       var health = PVE.Utils.map_ceph_health[healthObj.status];
 
        state.iconCls = PVE.Utils.get_health_icon(health, true);
-       state.text = record.data.health.overall_status;
+       state.text = healthObj.status;
 
        return state;
     },
 
-    render_kvm_ostype: function (value) {
-       if (!value) {
-           return gettext('Other OS types');
+    get_kvm_osinfo: function(value) {
+       var info = { base: 'Other' }; // default
+       if (value) {
+           Ext.each(Object.keys(PVE.Utils.kvm_ostypes), function(k) {
+               Ext.each(PVE.Utils.kvm_ostypes[k], function(e) {
+                   if (e.val === value) {
+                       info = { desc: e.desc, base: k };
+                   }
+               });
+           });
        }
-       var text = PVE.Utils.kvm_ostypes[value];
-       if (text) {
-           return text;
+       return info;
+    },
+
+    render_kvm_ostype: function (value) {
+       var osinfo = PVE.Utils.get_kvm_osinfo(value);
+       if (osinfo.desc && osinfo.desc !== '-') {
+           return osinfo.base + ' ' + osinfo.desc;
+       } else {
+           return osinfo.base;
        }
-       return value;
     },
 
     render_hotplug_features: function (value) {
@@ -253,7 +273,6 @@ Ext.define('PVE.Utils', { utilities: {
     kvm_vga_drivers: {
        std: gettext('Standard VGA'),
        vmware: gettext('VMware compatible'),
-       cirrus: 'Cirrus Logic GD5446',
        qxl: 'SPICE',
        qxl2: 'SPICE dual monitor',
        qxl3: 'SPICE three monitors',
@@ -613,6 +632,7 @@ Ext.define('PVE.Utils', { utilities: {
        cephdestroymon: ['Ceph Monitor', gettext('Destroy') ],
        cephcreateosd: ['Ceph OSD', gettext('Create') ],
        cephdestroyosd: ['Ceph OSD', gettext('Destroy') ],
+       cephcreatepool: ['Ceph Pool', gettext('Create') ],
        cephdestroypool: ['Ceph Pool', gettext('Destroy') ],
        imgcopy: ['', gettext('Copy data') ],
        imgdel: ['', gettext('Erase data') ],
@@ -775,7 +795,10 @@ Ext.define('PVE.Utils', { utilities: {
        return Ext.Date.format(date, "Y-m-d");
     },
 
-    format_storage_type: function(value) {
+    format_storage_type: function(value, md, record) {
+       if (value === 'rbd' && record) {
+           value = (record.get('monhost')?'rbd_ext':'pveceph');
+       }
        if (value === 'dir') {
            return PVE.Utils.directoryText;
        } else if (value === 'nfs') {
@@ -790,6 +813,10 @@ Ext.define('PVE.Utils', { utilities: {
            return 'iSCSI';
        } else if (value === 'rbd') {
            return 'RBD';
+       } else if (value === 'rbd_ext') {
+           return 'RBD (external)';
+       } else if (value === 'pveceph') {
+           return 'RBD (PVE)';
        } else if (value === 'sheepdog') {
            return 'Sheepdog';
        } else if (value === 'zfs') {
@@ -825,11 +852,10 @@ Ext.define('PVE.Utils', { utilities: {
     },
 
     format_ha: function(value) {
-       var text = PVE.Utils.format_boolean(value.managed);
+       var text = PVE.Utils.noneText;
 
        if (value.managed) {
-           text += ', ' + PVE.Utils.stateText + ': ';
-           text += value.state || PVE.Utils.noneText;
+           text = value.state || PVE.Utils.noneText;
 
            text += ', ' +  PVE.Utils.groupText + ': ';
            text += value.group || PVE.Utils.noneText;
@@ -1006,48 +1032,36 @@ Ext.define('PVE.Utils', { utilities: {
        return PVE.Utils.render_size(value);
     },
 
-    render_resource_type: function(value, metaData, record, rowIndex, colIndex, store) {
+    get_object_icon_class: function(type, record) {
+       var status = '';
+       var objType = type;
 
-       var icon = '';
-       var gridcls = '';
-
-       switch (value) {
-           case 'lxc': icon = 'cube';
-                       gridcls = '-stopped';
-                       break;
-           case 'qemu': icon = 'desktop';
-                        gridcls = '-stopped';
-                        break;
-           case 'node': icon = 'building';
-                        gridcls = '-offline';
-                        break;
-           case 'storage': icon = 'database'; break;
-           case 'pool': icon = 'tags'; break;
-           default: icon = 'file';
-       }
-
-       if (value === 'lxc' || value === 'qemu') {
-           if (record.data.running && record.data.status !== 'paused') {
-               gridcls = '-running';
-           } else if (record.data.running) {
-               gridcls = '-paused';
-           }
-           if (record.data.template) {
-               icon = 'file-o';
-               gridcls = '-template-' + value;
-           }
-       } else if (value === 'node') {
-           if (record.data.running) {
-               gridcls = '-online';
-           }
+       if (type === 'type') {
+           // for folder view
+           objType = record.groupbyid;
+       } else if (record.template) {
+           // templates
+           objType = 'template';
+           status = type;
+       } else {
+           // everything else
+           status = record.status + ' ha-' + record.hastate;
        }
 
-       // overwrite anything else
-       if (record.data.hastate === 'error') {
-           gridcls = '-offline';
+       var defaults = PVE.tree.ResourceTree.typeDefaults[objType];
+       if (defaults && defaults.iconCls) {
+           var retVal = defaults.iconCls + ' ' + status;
+           return retVal;
        }
 
-       var fa = '<i class="fa fa-fw x-fa-grid' + gridcls  +  ' fa-' + icon  + '"></i> ';
+       return '';
+    },
+
+    render_resource_type: function(value, metaData, record, rowIndex, colIndex, store) {
+
+       var cls = PVE.Utils.get_object_icon_class(value,record.data);
+
+       var fa = '<i class="fa-fw x-grid-icon-custom ' + cls  + '"></i> ';
        return fa + value;
     },
 
@@ -1142,6 +1156,8 @@ Ext.define('PVE.Utils', { utilities: {
 
        if (viewer === 'html5') {
            PVE.Utils.openVNCViewer(vmtype, vmid, nodename, vmname);
+       } else if (viewer === 'xtermjs') {
+           PVE.Utils.openXtermJSviewer(vmtype, vmid, nodename, vmname);
        } else if (viewer === 'vv') {
            var url;
            var params = { proxy: PVE.Utils.windowHostname() };
@@ -1174,6 +1190,18 @@ Ext.define('PVE.Utils', { utilities: {
        return dv;
     },
 
+    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();
+    },
+
     openVNCViewer: function(vmtype, vmid, nodename, vmname) {
        var url = Ext.urlEncode({
            console: vmtype, // kvm, lxc, upgrade or shell