'Accept': 'application/json'
};
+/*jslint confusion: true */
Ext.define('PVE.Utils', { utilities: {
// this singleton contains miscellaneous utilities
return state;
},
+ 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;
+ case 'REMOVED':
+ case 'DEGRADED':
+ iconCls = 'exclamation-circle warning';
+ break;
+ case 'UNAVAIL':
+ case 'FAULTED':
+ case 'OFFLINE':
+ iconCls = 'times-circle critical';
+ break;
+ default: //unknown
+ }
+
+ return '<i class="fa fa-' + iconCls + '"></i> ' + value;
+
+ },
+
get_kvm_osinfo: function(value) {
var info = { base: 'Other' }; // default
if (value) {
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)';
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) {
'__default__': Proxmox.Utils.defaultText + ' (HTML5)',
'vv': 'SPICE (remote-viewer)',
'html5': 'HTML5 (noVNC)',
- 'xtermjs': 'xterm.js',
+ 'xtermjs': 'xterm.js'
},
render_console_viewer: 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'
},
- rbd: {
- name: 'RBD',
- ipanel: 'RBDInputPanel',
+ cephfs: {
+ name: 'CephFS',
+ ipanel: 'CephFSInputPanel',
+ faIcon: 'building'
+ },
+ pvecephfs: {
+ name: 'CephFS (PVE)',
+ ipanel: 'CephFSInputPanel',
hideAdd: true,
faIcon: 'building'
},
- rbd_ext: {
- name: 'RBD (external)',
+ rbd: {
+ name: 'RBD',
ipanel: 'RBDInputPanel',
faIcon: 'building'
},
pveceph: {
name: 'RBD (PVE)',
- ipanel: 'PVERBDInputPanel',
+ ipanel: 'RBDInputPanel',
+ hideAdd: true,
faIcon: 'building'
},
zfs: {
},
format_storage_type: function(value, md, record) {
- if (value === 'rbd' && record) {
- value = (record.get('monhost')?'rbd_ext':'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 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;
+ },
+
+ 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; });
allowXtermjs = true;
} else if (typeof consoles === 'object') {
allowSpice = consoles.spice;
- allowXtermjs = consoles.xtermjs;
+ allowXtermjs = !!consoles.xtermjs;
}
var vncdefault = 'html5';
var dv = PVE.VersionInfo.console || 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);
}
});
}
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;