Ext.define('PVE.data.ResourceStore', {
- extend: 'PVE.data.UpdateStore',
+ extend: 'Proxmox.data.UpdateStore',
singleton: true,
findVMID: function(vmid) {
return nodes;
},
+ storageIsShared: function(storage_path) {
+ var me = this;
+
+ var index = me.findExact('id', storage_path);
+
+ return me.getAt(index).data.shared;
+ },
+
+ guestNode: function(vmid) {
+ var me = this;
+
+ var index = me.findExact('vmid', parseInt(vmid, 10));
+
+ return me.getAt(index).data.node;
+ },
+
constructor: function(config) {
// fixme: how to avoid those warnings
/*jslint confusion: true */
running: {
header: gettext('Online'),
type: 'boolean',
- renderer: PVE.Utils.format_boolean,
+ renderer: Proxmox.Utils.format_boolean,
hidden: true,
convert: function(value, record) {
var info = record.data;
- if (info.type === 'qemu' || info.type === 'lxc' || info.type === 'node') {
- return (Ext.isNumeric(info.uptime) && (info.uptime > 0));
- } else {
- return false;
- }
+ return (Ext.isNumeric(info.uptime) && (info.uptime > 0));
}
},
text: {
return value;
}
- if (info.type === 'node') {
- text = info.node;
- } else if (info.type === 'pool') {
- text = info.pool;
- } else if (info.type === 'storage') {
- text = info.storage + ' (' + info.node + ')';
- } else if (info.type === 'qemu' || info.type === 'lxc') {
+ if (Ext.isNumeric(info.vmid) && info.vmid > 0) {
text = String(info.vmid);
if (info.name) {
text += " (" + info.name + ')';
}
- } else {
- text = info.id;
+ } else { // node, pool, storage
+ text = info[info.type] || info.id;
+ if (info.node && info.type !== 'node') {
+ text += " (" + info.node + ")";
+ }
}
+
return text;
}
},
type: 'integer',
hidden: true,
sortable: true,
- renderer: PVE.Utils.format_size,
+ renderer: Proxmox.Utils.format_size,
width: 100
},
diskwrite: {
type: 'integer',
hidden: true,
sortable: true,
- renderer: PVE.Utils.format_size,
+ renderer: Proxmox.Utils.format_size,
width: 100
},
netin: {
type: 'integer',
hidden: true,
sortable: true,
- renderer: PVE.Utils.format_size,
+ renderer: Proxmox.Utils.format_size,
width: 100
},
netout: {
type: 'integer',
hidden: true,
sortable: true,
- renderer: PVE.Utils.format_size,
+ renderer: Proxmox.Utils.format_size,
width: 100
},
template: {
uptime: {
header: gettext('Uptime'),
type: 'integer',
- renderer: PVE.Utils.render_uptime,
+ renderer: Proxmox.Utils.render_uptime,
sortable: true,
width: 110
},
hastate: {
header: gettext('HA State'),
type: 'string',
- defaultValue: '',
+ defaultValue: 'unmanaged',
hidden: true,
sortable: true
+ },
+ status: {
+ header: gettext('Status'),
+ type: 'string',
+ hidden: true,
+ sortable: true,
+ width: 110
+ },
+ lock: {
+ header: gettext('Lock'),
+ type: 'string',
+ hidden: true,
+ sortable: true,
+ width: 110
}
};
var fields = [];
var fieldNames = [];
Ext.Object.each(field_defaults, function(key, value) {
- if (!Ext.isDefined(value.convert) && !Ext.isDefined(value.calculate)) {
- fields.push({name: key, type: value.type});
- fieldNames.push(key);
- } else if (key === 'text' || key === 'running') {
- fields.push({name: key, type: value.type, convert: value.convert});
- fieldNames.push(key);
- } else {
- value.name = key;
- fields.push(value);
+ var field = {name: key, type: value.type};
+ if (Ext.isDefined(value.convert)) {
+ field.convert = value.convert;
+ }
+
+ if (Ext.isDefined(value.calculate)) {
+ field.calculate = value.calculate;
}
+
+ if (Ext.isDefined(value.defaultValue)) {
+ field.defaultValue = value.defaultValue;
+ }
+
+ fields.push(field);
+ fieldNames.push(key);
});
Ext.define('PVEResources', {
extend: "Ext.data.Model",
fields: fields,
proxy: {
- type: 'pve',
+ type: 'proxmox',
url: '/api2/json/cluster/resources'
}
});