add getNodes function to PVEResource store
Add the getNodes function to the periodically asynchronous updated PVEResource store. This allows a component to get the node data directly, without making an API call and waiting that it's finished, the data is also up to date. A usage example would be: var data = PVE.data.ResourceStore.getNodes(); var store = Ext.create('Ext.data.Store', { fields: [ 'node', 'mem', 'cpu', ... ], // or a model data: data, proxy: { type: 'memory', reader: {type: 'json'} }, ... }); I'll use it in a later patch to avoid two asynchrony store loads where I'd have logic in place for the case that either one finishes first, this function helps me to avoid such logic while achieving the same functionallity. Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com> Reviewed-by: Dominik Csapak <d.csapak@proxmox.com>
This commit is contained in:
parent
74f4a7cf55
commit
032758ff63
@ -8,6 +8,20 @@ Ext.define('PVE.data.ResourceStore', {
|
||||
return (me.findExact('vmid', parseInt(vmid, 10)) >= 0);
|
||||
},
|
||||
|
||||
// returns the cached data from all nodes
|
||||
getNodes: function() {
|
||||
var me = this;
|
||||
|
||||
var nodes = [];
|
||||
me.each(function(record) {
|
||||
if (record.get('type') == "node") {
|
||||
nodes.push( record.getData() );
|
||||
}
|
||||
});
|
||||
|
||||
return nodes;
|
||||
},
|
||||
|
||||
constructor: function(config) {
|
||||
// fixme: how to avoid those warnings
|
||||
/*jslint confusion: true */
|
||||
|
Loading…
x
Reference in New Issue
Block a user