'Accept': 'application/json'
};
+/*jslint confusion: true */
Ext.define('PVE.Utils', { utilities: {
// this singleton contains miscellaneous 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;
}
return '<i class="fa fa-' + iconCls + '"></i> ' + value;
+
},
get_kvm_osinfo: function(value) {
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) {
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 + ')';
}
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: {
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',
},
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];
},
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) {
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')) {
}
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() };
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";
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){
}
menu.showAt(event.getXY());
+ return menu;
},
// helper for deleting field which are set to there default values
}
},
- mp_counts: { mps: 10, unused: 10 },
+ mp_counts: { mps: 256, unused: 256 },
forEachMP: function(func, includeUnused) {
var i, cont;