// avoid errors when running without development tools
if (!Ext.isDefined(Ext.global.console)) {
var console = {
- dir: function() {},
log: function() {}
};
}
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)';
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)];
});
},
isoImageText: gettext('ISO image'),
containersText: gettext('Container'),
+ storageSchema: {
+ dir: {
+ name: Proxmox.Utils.directoryText,
+ ipanel: 'DirInputPanel',
+ faIcon: 'folder'
+ },
+ lvm: {
+ name: 'LVM',
+ ipanel: 'LVMInputPanel',
+ faIcon: 'folder'
+ },
+ lvmthin: {
+ name: 'LVM-Thin',
+ ipanel: 'LvmThinInputPanel',
+ faIcon: 'folder'
+ },
+ nfs: {
+ name: 'NFS',
+ ipanel: 'NFSInputPanel',
+ faIcon: 'building'
+ },
+ cifs: {
+ name: 'CIFS',
+ ipanel: 'CIFSInputPanel',
+ faIcon: 'building'
+ },
+ glusterfs: {
+ name: 'GlusterFS',
+ ipanel: 'GlusterFsInputPanel',
+ faIcon: 'building'
+ },
+ iscsi: {
+ name: 'iSCSI',
+ ipanel: 'IScsiInputPanel',
+ faIcon: 'building'
+ },
+ sheepdog: {
+ name: 'Sheepdog',
+ ipanel: 'SheepdogInputPanel',
+ hideAdd: true,
+ faIcon: 'building'
+ },
+ rbd: {
+ name: 'RBD',
+ ipanel: 'RBDInputPanel',
+ faIcon: 'building'
+ },
+ pveceph: {
+ name: 'RBD (PVE)',
+ ipanel: 'RBDInputPanel',
+ hideAdd: true,
+ faIcon: 'building'
+ },
+ zfs: {
+ name: 'ZFS over iSCSI',
+ ipanel: 'ZFSInputPanel',
+ faIcon: 'building'
+ },
+ zfspool: {
+ name: 'ZFS',
+ ipanel: 'ZFSPoolInputPanel',
+ faIcon: 'folder'
+ },
+ drbd: {
+ name: 'DRBD',
+ hideAdd: true
+ }
+ },
+
format_storage_type: function(value, md, record) {
if (value === 'rbd' && record) {
- value = (record.get('monhost')?'rbd_ext':'pveceph');
- }
- if (value === 'dir') {
- return Proxmox.Utils.directoryText;
- } else if (value === 'nfs') {
- return 'NFS';
- } else if (value === 'cifs') {
- return 'CIFS';
- } else if (value === 'glusterfs') {
- return 'GlusterFS';
- } else if (value === 'lvm') {
- return 'LVM';
- } else if (value === 'lvmthin') {
- return 'LVM-Thin';
- } else if (value === 'iscsi') {
- 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') {
- return 'ZFS over iSCSI';
- } else if (value === 'zfspool') {
- return 'ZFS';
- } else if (value === 'iscsidirect') {
- return 'iSCSIDirect';
- } else if (value === 'drbd') {
- return 'DRBD';
- } else {
- return Proxmox.Utils.unknownText;
+ value = (record.get('monhost') ? 'rbd' : 'pveceph');
+ }
+
+ var schema = PVE.Utils.storageSchema[value];
+ if (schema) {
+ return schema.name;
}
+ return Proxmox.Utils.unknownText;
},
format_ha: function(value) {
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);
},
}
},
- 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;
}
novnc: 1,
vmid: vmid,
vmname: vmname,
- node: nodename
+ node: nodename,
+ resize: 'off'
});
var nw = window.open("?" + url, '_blank', "innerWidth=745,innerheight=427");
nw.focus();
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);
}
});
}
}
}
+ },
+
+ mp_counts: { mps: 10, unused: 10 },
+
+ forEachMP: function(func, includeUnused) {
+ var i, cont;
+ for (i = 0; i < PVE.Utils.mp_counts.mps; i++) {
+ cont = func('mp', i);
+ if (!cont && cont !== undefined) {
+ return;
+ }
+ }
+
+ if (!includeUnused) {
+ return;
+ }
+
+ for (i = 0; i < PVE.Utils.mp_counts.unused; i++) {
+ cont = func('unused', i);
+ if (!cont && cont !== undefined) {
+ return;
+ }
+ }
}
},