singleton: true,
findVMID: function(vmid) {
- var me = this, i;
-
+ let me = this;
return me.findExact('vmid', parseInt(vmid, 10)) >= 0;
},
// returns the cached data from all nodes
getNodes: function() {
- var me = this;
+ let me = this;
- var nodes = [];
+ let nodes = [];
me.each(function(record) {
- if (record.get('type') == "node") {
+ if (record.get('type') === "node") {
nodes.push(record.getData());
}
});
},
storageIsShared: function(storage_path) {
- var me = this;
-
- var index = me.findExact('id', storage_path);
+ let me = this;
- return me.getAt(index).data.shared;
+ let index = me.findExact('id', storage_path);
+ if (index >= 0) {
+ return me.getAt(index).data.shared;
+ } else {
+ return undefined;
+ }
},
guestNode: function(vmid) {
- var me = this;
+ let me = this;
- var index = me.findExact('vmid', parseInt(vmid, 10));
+ let index = me.findExact('vmid', parseInt(vmid, 10));
return me.getAt(index).data.node;
},
},
constructor: function(config) {
- // fixme: how to avoid those warnings
-
- var me = this;
+ let me = this;
config = config || {};
- var field_defaults = {
+ let field_defaults = {
type: {
header: gettext('Type'),
type: 'string',
sortable: true,
width: 200,
convert: function(value, record) {
- var info = record.data;
- var text;
-
if (value) {
return value;
}
+ let info = record.data, text;
if (Ext.isNumeric(info.vmid) && info.vmid > 0) {
text = String(info.vmid);
if (info.name) {
calculate: PVE.Utils.calculate_hostcpu,
sortType: 'asFloat',
sortable: true,
- width: 100
+ width: 100,
},
hostmemuse: {
header: gettext('Host Memory usage') + " %",
calculate: PVE.Utils.calculate_hostmem_usage,
sortType: 'asFloat',
sortable: true,
- width: 100
+ width: 100,
},
};
- var fields = [];
- var fieldNames = [];
+ let fields = [];
+ let fieldNames = [];
Ext.Object.each(field_defaults, function(key, value) {
var field = { name: key, type: value.type };
if (Ext.isDefined(value.convert)) {
storeid: 'PVEResources',
model: 'PVEResources',
defaultColumns: function() {
- var res = [];
+ let res = [];
Ext.Object.each(field_defaults, function(field, info) {
- var fi = Ext.apply({ dataIndex: field }, info);
- res.push(fi);
+ let fieldInfo = Ext.apply({ dataIndex: field }, info);
+ res.push(fieldInfo);
});
return res;
},