[pve-devel] r4892 - in pve-manager/pve2/www/manager: . store

svn-commits at proxmox.com svn-commits at proxmox.com
Wed Jul 14 11:55:25 CEST 2010


Author: dietmar
Date: 2010-07-14 09:55:25 +0000 (Wed, 14 Jul 2010)
New Revision: 4892

Added:
   pve-manager/pve2/www/manager/store/
   pve-manager/pve2/www/manager/store/ObjectReader.js
   pve-manager/pve2/www/manager/store/ObjectStore.js
Log:


Added: pve-manager/pve2/www/manager/store/ObjectReader.js
===================================================================
--- pve-manager/pve2/www/manager/store/ObjectReader.js	                        (rev 0)
+++ pve-manager/pve2/www/manager/store/ObjectReader.js	2010-07-14 09:55:25 UTC (rev 4892)
@@ -0,0 +1,43 @@
+Ext.ns("PVE");
+
+// a reader to store a single JSON Object (hash) into a storage
+
+PVE.ObjectReader = Ext.extend(Ext.data.JsonReader, {
+
+    constructor: function(config){
+        PVE.ObjectReader.superclass.constructor.call(this, Ext.apply(config, {
+	    root: 'data',
+	    idProperty: 'name',
+	    fields: [
+		{name: 'name', type: 'text'},
+		{name: 'value', type: 'text'}
+	    ]	    
+	}));
+	this.rows = config.rows;
+    },
+
+    extractData : function(root, returnRecords) {
+
+       if (returnRecords !== true)
+	    throw "not implemented";
+
+        var Record = this.recordType;
+ 	var rs = [];
+	var rows = this.rows;
+
+	if (rows) {
+	    Ext.iterate(rows, function(key, rowdef) {
+		var value = root[key];
+		var rec = new Record({ name: key, value: value }, key);
+		rs.push(rec);
+	    });
+	} else {
+	    Ext.iterate(root, function(key, value) { 
+		var rec = new Record({ name: key, value: value }, key);
+		rs.push(rec);
+	    });
+	}
+
+	return rs;
+     }
+});

Added: pve-manager/pve2/www/manager/store/ObjectStore.js
===================================================================
--- pve-manager/pve2/www/manager/store/ObjectStore.js	                        (rev 0)
+++ pve-manager/pve2/www/manager/store/ObjectStore.js	2010-07-14 09:55:25 UTC (rev 4892)
@@ -0,0 +1,11 @@
+Ext.ns("PVE");
+
+// a store for simple JSON Object (hash)
+
+PVE.ObjectStore = Ext.extend(Ext.data.Store, {
+    constructor: function(config) {
+        PVE.ObjectStore.superclass.constructor.call(this, Ext.apply(config, {
+            reader: new PVE.ObjectReader(config)
+        }));
+    },
+});




More information about the pve-devel mailing list