]> git.proxmox.com Git - pve-manager.git/blobdiff - www/manager6/Utils.js
ui: eslint: fix trailing comma and comma related whitespaces errors
[pve-manager.git] / www / manager6 / Utils.js
index 19f0b039bb7515f278168d490b35530ba326a1a9..eb21357dfa26bf280fabfe4935abe8ba376d3bdd 100644 (file)
@@ -10,16 +10,15 @@ Ext.enableAriaPanels = false;
 // avoid errors when running without development tools
 if (!Ext.isDefined(Ext.global.console)) {
     var console = {
-       log: function() {}
+       log: function() {},
     };
 }
 console.log("Starting PVE Manager");
 
 Ext.Ajax.defaultHeaders = {
-    'Accept': 'application/json'
+    'Accept': 'application/json',
 };
 
-/*jslint confusion: true */
 Ext.define('PVE.Utils', { utilities: {
 
     // this singleton contains miscellaneous utilities
@@ -36,37 +35,37 @@ Ext.define('PVE.Utils', { utilities: {
        4: "warning",
        5: "notice",
        6: "info",
-       7: "debug"
+       7: "debug",
     },
 
     support_level_hash: {
        'c': gettext('Community'),
        'b': gettext('Basic'),
        's': gettext('Standard'),
-       'p': gettext('Premium')
+       'p': gettext('Premium'),
     },
 
-    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.',
+    noSubKeyHtml: 'You do not have a valid subscription for this server. Please visit <a target="_blank" href="https://www.proxmox.com/products/proxmox-ve/subscription-service-plans">www.proxmox.com</a> to get a list of available options.',
 
     kvm_ostypes: {
        'Linux': [
-           { desc: '4.X/3.X/2.6 Kernel', val: 'l26' },
-           { desc: '2.4 Kernel', val: 'l24' }
+           { desc: '5.x - 2.6 Kernel', val: 'l26' },
+           { desc: '2.4 Kernel', val: 'l24' },
        ],
        'Microsoft Windows': [
-           { desc: '10/2016', val: 'win10' },
+           { desc: '10/2016/2019', 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' }
+           { desc: '2000', val: 'w2k' },
        ],
        'Solaris Kernel': [
-           { desc: '-', val: 'solaris'}
+           { desc: '-', val: 'solaris'},
        ],
        'Other': [
-           { desc: '-', val: 'other'}
-       ]
+           { desc: '-', val: 'other'},
+       ],
     },
 
     get_health_icon: function(state, circle) {
@@ -83,6 +82,9 @@ Ext.define('PVE.Utils', { utilities: {
            case 'good':
                icon = 'good fa-check';
                break;
+           case 'upgrade':
+               icon = 'warning fa-upload';
+               break;
            case 'old':
                icon = 'warning fa-refresh';
                break;
@@ -118,11 +120,24 @@ Ext.define('PVE.Utils', { utilities: {
     },
 
     compare_ceph_versions: function(a, b) {
+       let avers = [];
+       let bvers = [];
+
        if (a === b) {
            return 0;
        }
-       let avers = a.toString().split('.');
-       let bvers = b.toString().split('.');
+
+       if (Ext.isArray(a)) {
+           avers = a.slice(); // copy array
+       } else {
+           avers = a.toString().split('.');
+       }
+
+       if (Ext.isArray(b)) {
+           bvers = b.slice(); // copy array
+       } else {
+           bvers = b.toString().split('.');
+       }
 
        while (true) {
            let av = avers.shift();
@@ -154,15 +169,16 @@ Ext.define('PVE.Utils', { utilities: {
 
     map_ceph_health: {
        'HEALTH_OK':'good',
+       'HEALTH_UPGRADE':'upgrade',
        'HEALTH_OLD':'old',
        'HEALTH_WARN':'warning',
-       'HEALTH_ERR':'critical'
+       'HEALTH_ERR':'critical',
     },
 
     render_ceph_health: function(healthObj) {
        var state = {
            iconCls: PVE.Utils.get_health_icon(),
-           text: ''
+           text: '',
        };
 
        if (!healthObj || !healthObj.status) {
@@ -203,6 +219,138 @@ Ext.define('PVE.Utils', { utilities: {
 
     },
 
+    render_pbs_fingerprint: fp => fp.substring(0, 23),
+
+    render_backup_encryption: function(v, meta, record) {
+       if (!v) {
+           return gettext('No');
+       }
+
+       let tip = '';
+       if (v.match(/^[a-fA-F0-9]{2}:/)) { // fingerprint
+           tip = `Key fingerprint ${PVE.Utils.render_pbs_fingerprint(v)}`;
+       }
+       let icon = `<i class="fa fa-fw fa-lock good"></i>`;
+       return `<span data-qtip="${tip}">${icon} ${gettext('Encrypted')}</span>`;
+    },
+
+    render_backup_verification: function(v, meta, record) {
+       let i = (cls, txt) => `<i class="fa fa-fw fa-${cls}"></i> ${txt}`;
+       if (v === undefined || v === null) {
+           return i('question-circle-o warning', gettext('None'));
+       }
+       let tip = ""
+       let txt = gettext('Failed');
+       let iconCls = 'times critical';
+       if (v.state === 'ok') {
+           txt = gettext('OK');
+           iconCls = 'check good';
+           let now = Date.now() / 1000;
+           let task = Proxmox.Utils.parse_task_upid(v.upid);
+           let verify_time = Proxmox.Utils.render_timestamp(task.starttime);
+           tip = `Last verify task started on ${verify_time}`;
+           if (now - v.starttime > 30 * 24 * 60 * 60) {
+               tip = `Last verify task over 30 days ago: ${verify_time}`;
+               iconCls = 'check warning';
+           }
+       }
+       return `<span data-qtip="${tip}"> ${i(iconCls, txt)} </span>`;
+    },
+
+    render_backup_status: function(value, meta, record) {
+       if (typeof value == 'undefined') {
+           return "";
+       }
+
+       let iconCls = 'check-circle good';
+       let text = gettext('Yes');
+
+       if (!PVE.Parser.parseBoolean(value.toString())) {
+           iconCls = 'times-circle critical';
+
+           text = gettext('No');
+
+           let reason = record.get('reason');
+           if (typeof reason !== 'undefined') {
+               if (reason in PVE.Utils.backup_reasons_table) {
+                   reason = PVE.Utils.backup_reasons_table[record.get('reason')];
+               }
+               text = `${text} - ${reason}`;
+           }
+       }
+
+       return `<i class="fa fa-${iconCls}"></i> ${text}`;
+    },
+
+    render_backup_days_of_week: function(val) {
+       var dows = ['sun', 'mon', 'tue', 'wed', 'thu', 'fri', 'sat'];
+       var selected = [];
+       var cur = -1;
+       val.split(',').forEach(function(day){
+           cur++;
+           var dow = (dows.indexOf(day)+6)%7;
+           if (cur === dow) {
+               if (selected.length === 0 || selected[selected.length-1] === 0) {
+                   selected.push(1);
+               } else {
+                   selected[selected.length-1]++;
+               }
+           } else {
+               while (cur < dow) {
+                   cur++;
+                   selected.push(0);
+               }
+               selected.push(1);
+           }
+       });
+
+       cur = -1;
+       var days = [];
+       selected.forEach(function(item) {
+           cur++;
+           if (item > 2) {
+               days.push(Ext.Date.dayNames[(cur+1)] + '-' + Ext.Date.dayNames[(cur+item)%7]);
+               cur += item-1;
+           } else if (item == 2) {
+               days.push(Ext.Date.dayNames[cur+1]);
+               days.push(Ext.Date.dayNames[(cur+2)%7]);
+               cur++;
+           } else if (item == 1) {
+               days.push(Ext.Date.dayNames[(cur+1)%7]);
+           }
+       });
+       return days.join(', ');
+    },
+
+    render_backup_selection: function(value, metaData, record) {
+       let allExceptText = gettext('All except {0}');
+       let allText = '-- ' + gettext('All') + ' --';
+       if (record.data.all) {
+           if (record.data.exclude) {
+               return Ext.String.format(allExceptText, record.data.exclude);
+           }
+           return allText;
+       }
+       if (record.data.vmid) {
+           return record.data.vmid;
+       }
+
+       if (record.data.pool) {
+           return "Pool '"+ record.data.pool + "'";
+       }
+
+       return "-";
+    },
+
+    backup_reasons_table: {
+       'backup=yes': gettext('Enabled'),
+       'backup=no': gettext('Disabled'),
+       'enabled': gettext('Enabled'),
+       'disabled': gettext('Disabled'),
+       'not a volume': gettext('Not a volume'),
+       'efidisk but no OMVF BIOS': gettext('EFI Disk without OMVF BIOS'),
+    },
+
     get_kvm_osinfo: function(value) {
        var info = { base: 'Other' }; // default
        if (value) {
@@ -256,6 +404,13 @@ Ext.define('PVE.Utils', { utilities: {
        return fa.join(', ');
     },
 
+    render_localtime: function(value) {
+       if (value === '__default__') {
+           return Proxmox.Utils.defaultText + ' (' + gettext('Enabled for Windows') + ')';
+       }
+       return Proxmox.Utils.format_boolean(value);
+    },
+
     render_qga_features: function(value) {
        if (!value) {
            return Proxmox.Utils.defaultText + ' (' + Proxmox.Utils.disabledText  + ')';
@@ -272,10 +427,18 @@ Ext.define('PVE.Utils', { utilities: {
            var keystring = '' ;
            agentstring += ', ' + key + ': ';
 
-           if (PVE.Parser.parseBoolean(value)) {
-               agentstring += Proxmox.Utils.enabledText;
+           if (key === 'type') {
+               let map = {
+                   isa: "ISA",
+                   virtio: "VirtIO",
+               };
+               agentstring += map[value] || Proxmox.Utils.unknownText;
            } else {
-               agentstring += Proxmox.Utils.disabledText;
+               if (PVE.Parser.parseBoolean(value)) {
+                   agentstring += Proxmox.Utils.enabledText;
+               } else {
+                   agentstring += Proxmox.Utils.disabledText;
+               }
            }
        });
 
@@ -330,6 +493,22 @@ Ext.define('PVE.Utils', { utilities: {
        }
     },
 
+    render_spice_enhancements: function(values) {
+       let props = PVE.Parser.parsePropertyString(values);
+       if (Ext.Object.isEmpty(props)) {
+           return Proxmox.Utils.noneText;
+       }
+
+       let output = [];
+       if (PVE.Parser.parseBoolean(props.foldersharing)) {
+           output.push('Folder Sharing: ' + gettext('Enabled'));
+       }
+       if (props.videostreaming === 'all' || props.videostreaming === 'filter') {
+           output.push('Video Streaming: ' + props.videostreaming);
+       }
+       return output.join(', ');
+    },
+
     // fixme: auto-generate this
     // for now, please keep in sync with PVE::Tools::kvmkeymaps
     kvm_keymaps: {
@@ -365,7 +544,7 @@ Ext.define('PVE.Utils', { utilities: {
        sl: 'Slovenian',
        sv: 'Swedish',
        //th: 'Thai',
-       tr: 'Turkish'
+       tr: 'Turkish',
     },
 
     kvm_vga_drivers: {
@@ -380,7 +559,7 @@ Ext.define('PVE.Utils', { utilities: {
        serial2: gettext('Serial terminal') + ' 2',
        serial3: gettext('Serial terminal') + ' 3',
        virtio: 'VirtIO-GPU',
-       none: Proxmox.Utils.noneText
+       none: Proxmox.Utils.noneText,
     },
 
     render_kvm_language: function (value) {
@@ -404,10 +583,10 @@ Ext.define('PVE.Utils', { utilities: {
     },
 
     console_map: {
-       '__default__': Proxmox.Utils.defaultText + ' (HTML5)',
+       '__default__': Proxmox.Utils.defaultText + ' (xterm.js)',
        'vv': 'SPICE (remote-viewer)',
        'html5': 'HTML5 (noVNC)',
-       'xtermjs': 'xterm.js'
+       'xtermjs': 'xterm.js',
     },
 
     render_console_viewer: function(value) {
@@ -488,107 +667,215 @@ Ext.define('PVE.Utils', { utilities: {
        return msg;
     },
 
-    format_duration_short: function(ut) {
-
-       if (ut < 60) {
-           return ut.toFixed(1) + 's';
-       }
-
-       if (ut < 3600) {
-           var mins = ut / 60;
-           return mins.toFixed(1) + 'm';
-       }
-
-       if (ut < 86400) {
-           var hours = ut / 3600;
-           return hours.toFixed(1) + 'h';
-       }
-
-       var days = ut / 86400;
-       return days.toFixed(1) + 'd';
-    },
-
     contentTypes: {
        'images': gettext('Disk image'),
        'backup': gettext('VZDump backup file'),
        'vztmpl': gettext('Container template'),
        'iso': gettext('ISO image'),
        'rootdir': gettext('Container'),
-       'snippets': gettext('Snippets')
+       'snippets': gettext('Snippets'),
+    },
+
+    volume_is_qemu_backup: function(volid, format) {
+       return format === 'pbs-vm' || volid.match(':backup/vzdump-qemu-');
+    },
+
+    volume_is_lxc_backup: function(volid, format) {
+       return format === 'pbs-ct' || volid.match(':backup/vzdump-(lxc|openvz)-');
+    },
+
+    authSchema: {
+       ad: {
+           name: gettext('Active Directory Server'),
+           ipanel: 'pveAuthADPanel',
+           syncipanel: 'pveAuthLDAPSyncPanel',
+           add: true,
+       },
+       ldap: {
+           name: gettext('LDAP Server'),
+           ipanel: 'pveAuthLDAPPanel',
+           syncipanel: 'pveAuthLDAPSyncPanel',
+           add: true,
+       },
+       pam: {
+           name: 'Linux PAM',
+           ipanel: 'pveAuthBasePanel',
+           add: false,
+       },
+       pve: {
+           name: 'Proxmox VE authentication server',
+           ipanel: 'pveAuthBasePanel',
+           add: false,
+       },
     },
 
     storageSchema: {
        dir: {
            name: Proxmox.Utils.directoryText,
            ipanel: 'DirInputPanel',
-           faIcon: 'folder'
+           faIcon: 'folder',
+           backups: true,
        },
        lvm: {
            name: 'LVM',
            ipanel: 'LVMInputPanel',
-           faIcon: 'folder'
+           faIcon: 'folder',
+           backups: false,
        },
        lvmthin: {
            name: 'LVM-Thin',
            ipanel: 'LvmThinInputPanel',
-           faIcon: 'folder'
+           faIcon: 'folder',
+           backups: false,
        },
        nfs: {
            name: 'NFS',
            ipanel: 'NFSInputPanel',
-           faIcon: 'building'
+           faIcon: 'building',
+           backups: true,
        },
        cifs: {
            name: 'CIFS',
            ipanel: 'CIFSInputPanel',
-           faIcon: 'building'
+           faIcon: 'building',
+           backups: true,
        },
        glusterfs: {
            name: 'GlusterFS',
            ipanel: 'GlusterFsInputPanel',
-           faIcon: 'building'
+           faIcon: 'building',
+           backups: true,
        },
        iscsi: {
            name: 'iSCSI',
            ipanel: 'IScsiInputPanel',
-           faIcon: 'building'
+           faIcon: 'building',
+           backups: false,
        },
        cephfs: {
            name: 'CephFS',
            ipanel: 'CephFSInputPanel',
-           faIcon: 'building'
+           faIcon: 'building',
+           backups: true,
        },
        pvecephfs: {
            name: 'CephFS (PVE)',
            ipanel: 'CephFSInputPanel',
            hideAdd: true,
-           faIcon: 'building'
+           faIcon: 'building',
+           backups: true,
        },
        rbd: {
            name: 'RBD',
            ipanel: 'RBDInputPanel',
-           faIcon: 'building'
+           faIcon: 'building',
+           backups: false,
        },
        pveceph: {
            name: 'RBD (PVE)',
            ipanel: 'RBDInputPanel',
            hideAdd: true,
-           faIcon: 'building'
+           faIcon: 'building',
+           backups: false,
        },
        zfs: {
            name: 'ZFS over iSCSI',
            ipanel: 'ZFSInputPanel',
-           faIcon: 'building'
+           faIcon: 'building',
+           backups: false,
        },
        zfspool: {
            name: 'ZFS',
            ipanel: 'ZFSPoolInputPanel',
-           faIcon: 'folder'
+           faIcon: 'folder',
+           backups: false,
+       },
+       pbs: {
+           name: 'Proxmox Backup Server',
+           ipanel: 'PBSInputPanel',
+           faIcon: 'floppy-o',
+           backups: true,
        },
        drbd: {
            name: 'DRBD',
-           hideAdd: true
+           hideAdd: true,
+           backups: false,
+       },
+    },
+
+    sdnvnetSchema: {
+       vnet: {
+           name: 'vnet',
+           faIcon: 'folder',
+       },
+    },
+
+    sdnzoneSchema: {
+       zone: {
+            name: 'zone',
+            hideAdd: true,
+       },
+       simple: {
+           name: 'Simple',
+           ipanel: 'SimpleInputPanel',
+           faIcon: 'th',
+       },
+       vlan: {
+           name: 'VLAN',
+           ipanel: 'VlanInputPanel',
+           faIcon: 'th',
+       },
+       qinq: {
+           name: 'QinQ',
+           ipanel: 'QinQInputPanel',
+           faIcon: 'th',
+       },
+       vxlan: {
+           name: 'VXLAN',
+           ipanel: 'VxlanInputPanel',
+           faIcon: 'th',
+       },
+       evpn: {
+           name: 'EVPN',
+           ipanel: 'EvpnInputPanel',
+           faIcon: 'th',
+       },
+    },
+
+    sdncontrollerSchema: {
+       controller: {
+            name: 'controller',
+            hideAdd: true,
+       },
+       evpn: {
+           name: 'evpn',
+           ipanel: 'EvpnInputPanel',
+           faIcon: 'crosshairs',
+       },
+    },
+
+    format_sdnvnet_type: function(value, md, record) {
+       var schema = PVE.Utils.sdnvnetSchema[value];
+       if (schema) {
+           return schema.name;
        }
+       return Proxmox.Utils.unknownText;
+    },
+
+    format_sdnzone_type: function(value, md, record) {
+       var schema = PVE.Utils.sdnzoneSchema[value];
+       if (schema) {
+           return schema.name;
+       }
+       return Proxmox.Utils.unknownText;
+    },
+
+    format_sdncontroller_type: function(value, md, record) {
+       var schema = PVE.Utils.sdncontrollerSchema[value];
+       if (schema) {
+           return schema.name;
+       }
+       return Proxmox.Utils.unknownText;
     },
 
     format_storage_type: function(value, md, record) {
@@ -630,10 +917,10 @@ Ext.define('PVE.Utils', { utilities: {
            Ext.isNumber(data.id) &&
            Ext.isNumber(data.lun)) {
            return "CH " +
-               Ext.String.leftPad(data.channel,2, '0') +
+               Ext.String.leftPad(data.channel, 2, '0') +
                " ID " + data.id + " LUN " + data.lun;
        }
-       return data.volid.replace(/^.*:(.*\/)?/,'');
+       return data.volid.replace(/^.*?:(.*?\/)?/, '');
     },
 
     render_serverity: function (value) {
@@ -658,7 +945,6 @@ Ext.define('PVE.Utils', { utilities: {
     },
 
     render_size: function(value, metaData, record, rowIndex, colIndex, store) {
-       /*jslint confusion: true */
 
        if (!Ext.isNumeric(value)) {
            return '';
@@ -679,13 +965,6 @@ Ext.define('PVE.Utils', { utilities: {
        return Ext.Date.format(new Date(value * 1000), 'l d F Y H:i:s');
     },
 
-    render_duration: function(value) {
-       if (value === undefined) {
-           return '-';
-       }
-       return PVE.Utils.format_duration_short(value);
-    },
-
     calculate_mem_usage: function(data) {
        if (!Ext.isNumeric(data.mem) ||
            data.maxmem === 0 ||
@@ -783,6 +1062,10 @@ Ext.define('PVE.Utils', { utilities: {
            status = record.status + ' ha-' + record.hastate;
        }
 
+       if (record.lock) {
+           status += ' locked lock-' + record.lock;
+       }
+
        var defaults = PVE.tree.ResourceTree.typeDefaults[objType];
        if (defaults && defaults.iconCls) {
            var retVal = defaults.iconCls + ' ' + status;
@@ -794,7 +1077,7 @@ Ext.define('PVE.Utils', { utilities: {
 
     render_resource_type: function(value, metaData, record, rowIndex, colIndex, store) {
 
-       var cls = PVE.Utils.get_object_icon_class(value,record.data);
+       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;
@@ -874,7 +1157,7 @@ Ext.define('PVE.Utils', { utilities: {
            '2': gettext('Bad Request'),
            '3': gettext('Configuration Unsupported'),
            '4': gettext('Device Ineligible'),
-           '5': gettext('Timeout')
+           '5': gettext('Timeout'),
        };
        return "U2F Error: "  + ErrorNames[error] || Proxmox.Utils.unknownText;
     },
@@ -884,49 +1167,42 @@ Ext.define('PVE.Utils', { utilities: {
             function(m, addr, offset, original) { return addr; });
     },
 
-    openDefaultConsoleWindow: function(consoles, vmtype, vmid, nodename, vmname, cmd) {
+    openDefaultConsoleWindow: function(consoles, consoleType, vmid, nodename, vmname, cmd) {
        var dv = PVE.Utils.defaultViewer(consoles);
-       PVE.Utils.openConsoleWindow(dv, vmtype, vmid, nodename, vmname, cmd);
+       PVE.Utils.openConsoleWindow(dv, consoleType, vmid, nodename, vmname, cmd);
     },
 
-    openConsoleWindow: function(viewer, vmtype, vmid, nodename, vmname, cmd) {
-       // kvm, lxc, shell, upgrade
-
-       if (vmid == undefined && (vmtype === 'kvm' || vmtype === 'lxc')) {
+    openConsoleWindow: function(viewer, consoleType, vmid, nodename, vmname, cmd) {
+       if (vmid == undefined && (consoleType === 'kvm' || consoleType === 'lxc')) {
            throw "missing vmid";
        }
-
        if (!nodename) {
            throw "no nodename specified";
        }
 
        if (viewer === 'html5') {
-           PVE.Utils.openVNCViewer(vmtype, vmid, nodename, vmname, cmd);
+           PVE.Utils.openVNCViewer(consoleType, vmid, nodename, vmname, cmd);
        } else if (viewer === 'xtermjs') {
-           Proxmox.Utils.openXtermJsViewer(vmtype, vmid, nodename, vmname, cmd);
+           Proxmox.Utils.openXtermJsViewer(consoleType, vmid, nodename, vmname, cmd);
        } else if (viewer === 'vv') {
-           var url;
-           var params = { proxy: PVE.Utils.windowHostname() };
-           if (vmtype === 'kvm') {
+           let url = '/nodes/' + nodename + '/spiceshell';
+           let params = {
+               proxy: PVE.Utils.windowHostname(),
+           };
+           if (consoleType === 'kvm') {
                url = '/nodes/' + nodename + '/qemu/' + vmid.toString() + '/spiceproxy';
-               PVE.Utils.openSpiceViewer(url, params);
-           } else if (vmtype === 'lxc') {
+           } else if (consoleType === 'lxc') {
                url = '/nodes/' + nodename + '/lxc/' + vmid.toString() + '/spiceproxy';
-               PVE.Utils.openSpiceViewer(url, params);
-           } else if (vmtype === 'shell') {
-               url = '/nodes/' + nodename + '/spiceshell';
-               PVE.Utils.openSpiceViewer(url, params);
-           } else if (vmtype === 'upgrade') {
-               url = '/nodes/' + nodename + '/spiceshell';
-               params.upgrade = 1;
-               PVE.Utils.openSpiceViewer(url, params);
-           } else if (vmtype === 'cmd') {
-               url = '/nodes/' + nodename + '/spiceshell';
+           } else if (consoleType === 'upgrade') {
+               params.cmd = 'upgrade';
+           } else if (consoleType === 'cmd') {
                params.cmd = cmd;
-               PVE.Utils.openSpiceViewer(url, params);
+           } else if (consoleType !== 'shell') {
+               throw `unknown spice viewer type '${consoleType}'`;
            }
+           PVE.Utils.openSpiceViewer(url, params);
        } else {
-           throw "unknown viewer type";
+           throw `unknown viewer type '${viewer}'`;
        }
     },
 
@@ -941,24 +1217,30 @@ Ext.define('PVE.Utils', { utilities: {
            allowSpice = consoles.spice;
            allowXtermjs = !!consoles.xtermjs;
        }
-       var vncdefault = 'html5';
-       var dv = PVE.VersionInfo.console || vncdefault;
-       if ((dv === 'vv' && !allowSpice) || (dv === 'xtermjs' && !allowXtermjs)) {
-           dv = vncdefault;
+       var dv = PVE.VersionInfo.console || 'xtermjs';
+       if (dv === 'vv' && !allowSpice) {
+           dv = (allowXtermjs) ? 'xtermjs' : 'html5';
+       } else if (dv === 'xtermjs' && !allowXtermjs) {
+           dv = (allowSpice) ? 'vv' : 'html5';
        }
 
        return dv;
     },
 
     openVNCViewer: function(vmtype, vmid, nodename, vmname, cmd) {
+       let scaling = 'off';
+       if (Proxmox.Utils.toolkit !== 'touch') {
+           var sp = Ext.state.Manager.getProvider();
+           scaling = sp.get('novnc-scaling', 'off');
+       }
        var url = Ext.Object.toQueryString({
            console: vmtype, // kvm, lxc, upgrade or shell
            novnc: 1,
            vmid: vmid,
            vmname: vmname,
            node: nodename,
-           resize: 'off',
-           cmd: cmd
+           resize: scaling,
+           cmd: cmd,
        });
        var nw = window.open("?" + url, '_blank', "innerWidth=745,innerheight=427");
        if (nw) {
@@ -972,7 +1254,7 @@ Ext.define('PVE.Utils', { utilities: {
            var link = Ext.DomHelper.append(document.body, {
                tag: 'a',
                href: uri,
-               css : 'display:none;visibility:hidden;height:0px;'
+               css : 'display:none;visibility:hidden;height:0px;',
            });
 
            // Note: we need to tell android the correct file name extension
@@ -986,8 +1268,8 @@ Ext.define('PVE.Utils', { utilities: {
            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);
+               let evt = document.createEvent("MouseEvents");
+               evt.initMouseEvent('click', true, true, window, 1, 0, 0, 0, 0, false, false, false, false, 0, null);
                link.dispatchEvent(evt);
            }
        };
@@ -1008,7 +1290,7 @@ Ext.define('PVE.Utils', { utilities: {
                    encodeURIComponent(raw);
 
                downloadWithName(url, "pve-spice.vv");
-           }
+           },
        });
     },
 
@@ -1024,9 +1306,13 @@ Ext.define('PVE.Utils', { utilities: {
                    Ext.Msg.alert('Error', response.htmlStatus);
                },
                success: function(response, opts) {
-                   var allowSpice = !!response.result.data.spice;
-                   PVE.Utils.openDefaultConsoleWindow(allowSpice, 'kvm', vmid, nodename, vmname);
-               }
+                   let conf = response.result.data;
+                   var consoles = {
+                       spice: !!conf.spice,
+                       xtermjs: !!conf.serial,
+                   };
+                   PVE.Utils.openDefaultConsoleWindow(consoles, 'kvm', vmid, nodename, vmname);
+               },
            });
        } else if (record.data.type === 'lxc' && !record.data.template) {
            PVE.Utils.openDefaultConsoleWindow(true, 'lxc', vmid, nodename, vmname);
@@ -1062,7 +1348,7 @@ Ext.define('PVE.Utils', { utilities: {
        if (template) {
            if (type === 'qemu' || type == 'lxc') {
                menu = Ext.create('PVE.menu.TemplateMenu', {
-                   pveSelNode: record
+                   pveSelNode: record,
                });
            }
        } else if (type === 'qemu' ||
@@ -1070,7 +1356,7 @@ Ext.define('PVE.Utils', { utilities: {
                   type === 'node') {
            menu = Ext.create('PVE.' + type + '.CmdMenu', {
                pveSelNode: record,
-               nodename: record.data.node
+               nodename: record.data.node,
            });
        } else {
            return;
@@ -1085,7 +1371,11 @@ Ext.define('PVE.Utils', { utilities: {
        if (values[fieldname] === '' || values[fieldname] === default_val) {
            if (!create) {
                if (values['delete']) {
-                   values['delete'] += ',' + fieldname;
+                   if (Ext.isArray(values['delete'])) {
+                       values['delete'].push(fieldname);
+                   } else {
+                       values['delete'] += ',' + fieldname;
+                   }
                } else {
                    values['delete'] = fieldname;
                }
@@ -1114,11 +1404,30 @@ Ext.define('PVE.Utils', { utilities: {
        reader.readAsText(file);
     },
 
-    bus_counts: { ide: 4, sata: 6, scsi: 16, virtio: 16 },
+    loadTextFromFile: function(file, callback, maxBytes) {
+       let maxSize = maxBytes || 8192;
+       if (file.size > maxSize) {
+           Ext.Msg.alert(gettext('Error'), gettext("Invalid file size: ") + file.size);
+           return;
+       }
+       /*global
+         FileReader
+       */
+       let reader = new FileReader();
+       reader.onload = evt => callback(evt.target.result);
+       reader.readAsText(file);
+    },
+
+    diskControllerMaxIDs: {
+       ide: 4,
+       sata: 6,
+       scsi: 31,
+       virtio: 16,
+    },
 
     // types is either undefined (all busses), an array of busses, or a single bus
     forEachBus: function(types, func) {
-       var busses = Object.keys(PVE.Utils.bus_counts);
+       var busses = Object.keys(PVE.Utils.diskControllerMaxIDs);
        var i, j, count, cont;
 
        if (Ext.isArray(types)) {
@@ -1129,13 +1438,13 @@ Ext.define('PVE.Utils', { utilities: {
 
        // check if we only have valid busses
        for (i = 0; i < busses.length; i++) {
-           if (!PVE.Utils.bus_counts[busses[i]]) {
+           if (!PVE.Utils.diskControllerMaxIDs[busses[i]]) {
                throw "invalid bus: '" + busses[i] + "'";
            }
        }
 
        for (i = 0; i < busses.length; i++) {
-           count = PVE.Utils.bus_counts[busses[i]];
+           count = PVE.Utils.diskControllerMaxIDs[busses[i]];
            for (j = 0; j < count; j++) {
                cont = func(busses[i], j);
                if (!cont && cont !== undefined) {
@@ -1168,6 +1477,8 @@ Ext.define('PVE.Utils', { utilities: {
        }
     },
 
+    hardware_counts: { net: 32, usb: 5, hostpci: 16, audio: 1, efidisk: 1, serial: 4, rng: 1 },
+
     cleanEmptyObjectKeys: function (obj) {
        var propName;
        for (propName in obj) {
@@ -1179,6 +1490,29 @@ Ext.define('PVE.Utils', { utilities: {
        }
     },
 
+    acmedomain_count: 5,
+
+    add_domain_to_acme: function(acme, domain) {
+       if (acme.domains === undefined) {
+           acme.domains = [domain];
+       } else {
+           acme.domains.push(domain);
+           acme.domains = acme.domains.filter((value, index, self) => {
+               return self.indexOf(value) === index;
+           });
+       }
+       return acme;
+    },
+
+    remove_domain_from_acme: function(acme, domain) {
+       if (acme.domains !== undefined) {
+           acme.domains = acme.domains.filter((value, index, self) => {
+               return self.indexOf(value) === index && value !== domain;
+           });
+       }
+       return acme;
+    },
+
     handleStoreErrorOrMask: function(me, store, regex, callback) {
 
        me.mon(store, 'load', function (proxy, response, success, operation) {
@@ -1211,7 +1545,7 @@ Ext.define('PVE.Utils', { utilities: {
                if (!container.down('pveCephInstallWindow')){
                    var isInstalled = msg.match(/not initialized/i) ? true : false;
                    var win = Ext.create('PVE.ceph.Install', {
-                       nodename: nodename
+                       nodename: nodename,
                    });
                    win.getViewModel().set('isInstalled', isInstalled);
                    container.add(win);
@@ -1226,14 +1560,191 @@ Ext.define('PVE.Utils', { utilities: {
        } else {
            return false;
        }
-    }
+    },
+
+    propertyStringSet: function(target, source, name, value) {
+       if (source) {
+           if (value === undefined) {
+               target[name] = source;
+           } else {
+               target[name] = value;
+           }
+       } else {
+           delete target[name];
+       }
+    },
+
+    updateColumns: function(container) {
+       let mode = Ext.state.Manager.get('summarycolumns') || 'auto';
+       let factor;
+       if (mode !== 'auto') {
+           factor = parseInt(mode, 10);
+           if (Number.isNaN(factor)) {
+               factor = 1;
+           }
+       } else {
+           factor = container.getSize().width < 1400 ? 1 : 2;
+       }
+
+       if (container.oldFactor === factor) {
+           return;
+       }
+
+       let items = container.query('>'); // direct childs
+       factor = Math.min(factor, items.length);
+       container.oldFactor = factor;
+
+       items.forEach((item) => {
+           item.columnWidth = 1 / factor;
+       });
+
+       // we have to update the layout twice, since the first layout change
+       // can trigger the scrollbar which reduces the amount of space left
+       container.updateLayout();
+       container.updateLayout();
+    },
+
+    forEachCorosyncLink: function(nodeinfo, cb) {
+       let re = /(?:ring|link)(\d+)_addr/;
+       Ext.iterate(nodeinfo, (prop, val) => {
+           let match = re.exec(prop);
+           if (match) {
+               cb(Number(match[1]), val);
+           }
+       });
+    },
+
+    cpu_vendor_map: {
+       'default': 'QEMU',
+       'AuthenticAMD': 'AMD',
+       'GenuineIntel': 'Intel',
+    },
+
+    cpu_vendor_order: {
+       "AMD": 1,
+       "Intel": 2,
+       "QEMU": 3,
+       "Host": 4,
+       "_default_": 5, // includes custom models
+    },
+
+    verify_ip64_address_list: function(value, with_suffix) {
+       for (let addr of value.split(/[ ,;]+/)) {
+           if (addr === '') {
+               continue;
+           }
+
+           if (with_suffix) {
+               let parts = addr.split('%');
+               addr = parts[0];
+
+               if (parts.length > 2) {
+                   return false;
+               }
+
+               if (parts.length > 1 && !addr.startsWith('fe80:')) {
+                   return false;
+               }
+           }
+
+           if (!Proxmox.Utils.IP64_match.test(addr)) {
+               return false;
+           }
+       }
+
+       return true;
+    },
 },
 
     singleton: true,
     constructor: function() {
        var me = this;
        Ext.apply(me, me.utilities);
-    }
 
-});
+       Proxmox.Utils.override_task_descriptions({
+           acmedeactivate: ['ACME Account', gettext('Deactivate')],
+           acmenewcert: ['SRV', gettext('Order Certificate')],
+           acmerefresh: ['ACME Account', gettext('Refresh')],
+           acmeregister: ['ACME Account', gettext('Register')],
+           acmerenew: ['SRV', gettext('Renew Certificate')],
+           acmerevoke: ['SRV', gettext('Revoke Certificate')],
+           acmeupdate: ['ACME Account', gettext('Update')],
+           'auth-realm-sync': [gettext('Realm'), gettext('Sync')],
+           'auth-realm-sync-test': [gettext('Realm'), gettext('Sync Preview')],
+           cephcreatemds: ['Ceph Metadata Server', gettext('Create')],
+           cephcreatemgr: ['Ceph Manager', gettext('Create')],
+           cephcreatemon: ['Ceph Monitor', gettext('Create')],
+           cephcreateosd: ['Ceph OSD', gettext('Create')],
+           cephcreatepool: ['Ceph Pool', gettext('Create')],
+           cephdestroymds: ['Ceph Metadata Server', gettext('Destroy')],
+           cephdestroymgr: ['Ceph Manager', gettext('Destroy')],
+           cephdestroymon: ['Ceph Monitor', gettext('Destroy')],
+           cephdestroyosd: ['Ceph OSD', gettext('Destroy')],
+           cephdestroypool: ['Ceph Pool', gettext('Destroy')],
+           cephfscreate: ['CephFS', gettext('Create')],
+           clustercreate: ['', gettext('Create Cluster')],
+           clusterjoin: ['', gettext('Join Cluster')],
+           dircreate: [gettext('Directory Storage'), gettext('Create')],
+           dirremove: [gettext('Directory'), gettext('Remove')],
+           download: ['', gettext('Download')],
+           hamigrate: ['HA', gettext('Migrate')],
+           hashutdown: ['HA', gettext('Shutdown')],
+           hastart: ['HA', gettext('Start')],
+           hastop: ['HA', gettext('Stop')],
+           imgcopy: ['', gettext('Copy data')],
+           imgdel: ['', gettext('Erase data')],
+           lvmcreate: [gettext('LVM Storage'), gettext('Create')],
+           lvmthincreate: [gettext('LVM-Thin Storage'), gettext('Create')],
+           migrateall: ['', gettext('Migrate all VMs and Containers')],
+           'move_volume': ['CT', gettext('Move Volume')],
+           pull_file: ['CT', gettext('Pull file')],
+           push_file: ['CT', gettext('Push file')],
+           qmclone: ['VM', gettext('Clone')],
+           qmconfig: ['VM', gettext('Configure')],
+           qmcreate: ['VM', gettext('Create')],
+           qmdelsnapshot: ['VM', gettext('Delete Snapshot')],
+           qmdestroy: ['VM', gettext('Destroy')],
+           qmigrate: ['VM', gettext('Migrate')],
+           qmmove: ['VM', gettext('Move disk')],
+           qmpause: ['VM', gettext('Pause')],
+           qmreboot: ['VM', gettext('Reboot')],
+           qmreset: ['VM', gettext('Reset')],
+           qmrestore: ['VM', gettext('Restore')],
+           qmresume: ['VM', gettext('Resume')],
+           qmrollback: ['VM', gettext('Rollback')],
+           qmshutdown: ['VM', gettext('Shutdown')],
+           qmsnapshot: ['VM', gettext('Snapshot')],
+           qmstart: ['VM', gettext('Start')],
+           qmstop: ['VM', gettext('Stop')],
+           qmsuspend: ['VM', gettext('Hibernate')],
+           qmtemplate: ['VM', gettext('Convert to template')],
+           spiceproxy: ['VM/CT', gettext('Console') + ' (Spice)'],
+           spiceshell: ['', gettext('Shell') + ' (Spice)'],
+           startall: ['', gettext('Start all VMs and Containers')],
+           stopall: ['', gettext('Stop all VMs and Containers')],
+           unknownimgdel: ['', gettext('Destroy image from unknown guest')],
+           vncproxy: ['VM/CT', gettext('Console')],
+           vncshell: ['', gettext('Shell')],
+           vzclone: ['CT', gettext('Clone')],
+           vzcreate: ['CT', gettext('Create')],
+           vzdelsnapshot: ['CT', gettext('Delete Snapshot')],
+           vzdestroy: ['CT', gettext('Destroy')],
+           vzdump: (type, id) => id ? `VM/CT ${id} - ${gettext('Backup')}` : gettext('Backup Job'),
+           vzmigrate: ['CT', gettext('Migrate')],
+           vzmount: ['CT', gettext('Mount')],
+           vzreboot: ['CT', gettext('Reboot')],
+           vzrestore: ['CT', gettext('Restore')],
+           vzresume: ['CT', gettext('Resume')],
+           vzrollback: ['CT', gettext('Rollback')],
+           vzshutdown: ['CT', gettext('Shutdown')],
+           vzsnapshot: ['CT', gettext('Snapshot')],
+           vzstart: ['CT', gettext('Start')],
+           vzstop: ['CT', gettext('Stop')],
+           vzsuspend: ['CT', gettext('Suspend')],
+           vztemplate: ['CT', gettext('Convert to template')],
+           vzumount: ['CT', gettext('Unmount')],
+           zfscreate: [gettext('ZFS Storage'), gettext('Create')],
+       });
+    },
 
+});