[pve-devel] r6275 - in pve-manager/pve2/www/manager: data grid tree

svn-commits at proxmox.com svn-commits at proxmox.com
Fri Jul 8 13:39:17 CEST 2011


Author: dietmar
Date: 2011-07-08 13:39:17 +0200 (Fri, 08 Jul 2011)
New Revision: 6275

Modified:
   pve-manager/pve2/www/manager/data/ResourceStore.js
   pve-manager/pve2/www/manager/grid/ObjectGrid.js
   pve-manager/pve2/www/manager/grid/ResourceGrid.js
   pve-manager/pve2/www/manager/grid/SelectFeature.js
   pve-manager/pve2/www/manager/tree/ResourceTree.js
Log:
make lint happy


Modified: pve-manager/pve2/www/manager/data/ResourceStore.js
===================================================================
--- pve-manager/pve2/www/manager/data/ResourceStore.js	2011-07-08 10:44:33 UTC (rev 6274)
+++ pve-manager/pve2/www/manager/data/ResourceStore.js	2011-07-08 11:39:17 UTC (rev 6275)
@@ -153,11 +153,14 @@
 	};
 
 	var fields = [];
+	var fieldNames = [];
 	Ext.Object.each(field_defaults, function(key, value) {
 	    if (!Ext.isDefined(value.convert)) {
 		fields.push({name: key, type: value.type});
+		fieldNames.push(key);
 	    } else if (key === 'text') { 
 		fields.push({name: key, type: value.type, convert: value.convert});
+		fieldNames.push(key);
 	    }		
 	});
 
@@ -188,7 +191,8 @@
 		});
 
 		return res;
-	    }
+	    },
+	    fieldNames: fieldNames
 	});
 
 	me.callParent([config]);

Modified: pve-manager/pve2/www/manager/grid/ObjectGrid.js
===================================================================
--- pve-manager/pve2/www/manager/grid/ObjectGrid.js	2011-07-08 10:44:33 UTC (rev 6274)
+++ pve-manager/pve2/www/manager/grid/ObjectGrid.js	2011-07-08 11:39:17 UTC (rev 6275)
@@ -9,8 +9,9 @@
     getObjectValue: function(key, defaultValue) {
 	var me = this;
 	var rec = me.store.getById(key);
-	if (rec)
+	if (rec) {
 	    return rec.data.value;
+	}
 	return defaultValue;
     },
 
@@ -28,8 +29,9 @@
 	var rowdef = (rows && rows[key]) ?  rows[key] : {};
 
 	var renderer = rowdef.renderer;
-	if (renderer)
+	if (renderer) {
 	    return renderer(value, metaData, record, rowIndex, colIndex, store);
+	}
 
 	return value;
     },
@@ -40,8 +42,9 @@
 	var rows = me.rows;
 
 	if (!me.rstore) {
-	    if (!me.url)
+	    if (!me.url) {
 		throw "no url specified";
+	    }
 
 	    me.rstore = Ext.create('PVE.data.ObjectStore', {
 		url: me.url,
@@ -118,8 +121,9 @@
 	});
 
 	me.on('afterlayout', function() {
-	    if (!load_count)
+	    if (!load_count) {
 		me.setLoading(true);
+	    }
 	});
 
 	me.callParent();

Modified: pve-manager/pve2/www/manager/grid/ResourceGrid.js
===================================================================
--- pve-manager/pve2/www/manager/grid/ResourceGrid.js	2011-07-08 10:44:33 UTC (rev 6274)
+++ pve-manager/pve2/www/manager/grid/ResourceGrid.js	2011-07-08 11:39:17 UTC (rev 6275)
@@ -37,7 +37,7 @@
 	var coldef = rstore.defaultColums();
 
 	var store = Ext.create('Ext.data.Store', {
- 	    model: 'PVEResources',
+	    model: 'PVEResources',
 	    sorters: [
 		{
 		    property : 'type',
@@ -81,14 +81,15 @@
 		var orgnode = rstore.data.get(cn.data.id);
 		if (orgnode) {
 		    if ((!filterfn || filterfn(cn)) &&
-			(!textfilter || textfilter_match(cn)))
+			(!textfilter || textfilter_match(cn))) {
 			nodeidx[cn.data.id] = orgnode;
+		    }
 		}
 	    
                 for (; i < len; i++) {
- 		    gather_child_nodes(cs[i]);
+		    gather_child_nodes(cs[i]);
 		}
- 	    };
+	    };
 	    gather_child_nodes(me.pveSelNode);
 
 	    // remove vanished items
@@ -101,46 +102,52 @@
 		}
 	    });
 
-	    if (rmlist.length)
+	    if (rmlist.length) {
 		store.remove(rmlist);
-	    
- 	    // add new items
+	    }
+
+	    // add new items
 	    var addlist = [];
-	    for (var key in nodeidx) {
-		if (!nodeidx.hasOwnProperty(key))
-		    continue;
-
-		var item = nodeidx[key];
+	    var key;
+	    for (key in nodeidx) {
+		if (nodeidx.hasOwnProperty(key)) {
+		    var item = nodeidx[key];
 		
-		// getById() use find(), which is slow (ExtJS4 DP5) 
-		//var olditem = store.getById(item.data.id);
-		var olditem = store.data.get(item.data.id);
+		    // getById() use find(), which is slow (ExtJS4 DP5) 
+		    //var olditem = store.getById(item.data.id);
+		    var olditem = store.data.get(item.data.id);
 
-		if (!olditem) {
-		    //console.log("GRID ADD UID: " + item.data.id);
-		    var info = Ext.apply({}, item.data);
-		    var child = Ext.ModelMgr.create(info, store.model, info.id);
-		    addlist.push(item);
-		    continue;
-		}
-		// try to detect changes
-		var changes = false;
-		store.model.prototype.fields.eachKey(function(field) {
-		    if (field != 'id' && item.data[field] != olditem.data[field]) {
-			changes = true;
-			//console.log("changed item " + item.id + " " + field + " " + item.data[field] + " != " + olditem.data[field]);
-			olditem.beginEdit()
-			olditem.set(field, item.data[field]);
+		    if (!olditem) {
+			//console.log("GRID ADD UID: " + item.data.id);
+			var info = Ext.apply({}, item.data);
+			var child = Ext.ModelMgr.create(info, store.model, info.id);
+			addlist.push(item);
+			continue;
 		    }
-		});
-		if (changes) {
-		    olditem.endEdit(true)
-		    olditem.commit(true); 
+		    // try to detect changes
+		    var changes = false;
+		    var fieldkeys = PVE.data.ResourceStore.fieldNames;
+		    var fieldcount = fieldkeys.length;
+		    var fieldind;
+		    for (fieldind = 0; fieldind < fieldcount; fieldind++) {
+			var field = fieldkeys[fieldind];
+			if (field != 'id' && item.data[field] != olditem.data[field]) {
+			    changes = true;
+			    //console.log("changed item " + item.id + " " + field + " " + item.data[field] + " != " + olditem.data[field]);
+			    olditem.beginEdit();
+			    olditem.set(field, item.data[field]);
+			}
+		    }
+		    if (changes) {
+			olditem.endEdit(true);
+			olditem.commit(true); 
+		    }
 		}
-	    };
+	    }
 
-	    if (addlist.length)
+	    if (addlist.length) {
 		store.add(addlist);
+	    }
 
 	    store.sort();
 
@@ -151,14 +158,14 @@
 	    //console.log("END GRID UPDATE");
 	};
 
-
 	var filter_task = new Ext.util.DelayedTask(function(){
 	    updateGrid();
 	});
 
+	var load_cb = function() { 
+	    updateGrid(); 
+	};
 
-	var load_cb = function() { updateGrid(); };
-
 	Ext.apply(me, {
 	    title: 'Search',
 	    store: store,
@@ -179,7 +186,7 @@
 		    }
 		}
 	    ],
- 	    viewConfig: {
+	    viewConfig: {
 		stripeRows: true,
 		trackOver: false
             },
@@ -189,7 +196,7 @@
 		    ws.selectById(record.data.id);
 		},
 		destroy: function() {
-		    rstore.un("load", load_cb)
+		    rstore.un("load", load_cb);
 		}
 	    },
             columns: coldef

Modified: pve-manager/pve2/www/manager/grid/SelectFeature.js
===================================================================
--- pve-manager/pve2/www/manager/grid/SelectFeature.js	2011-07-08 10:44:33 UTC (rev 6274)
+++ pve-manager/pve2/www/manager/grid/SelectFeature.js	2011-07-08 11:39:17 UTC (rev 6275)
@@ -8,8 +8,9 @@
             scope: me
         });
 	if (!me.featuresMC ||
-	    (me.featuresMC.findIndex('ftype', 'selectable') < 0))
+	    (me.featuresMC.findIndex('ftype', 'selectable') < 0)) {
             me.el.unselectable();
+	}
 
         me.attachEventsForFeatures();
     }
@@ -20,7 +21,7 @@
     alias: 'feature.selectable',
 
     mutateMetaRowTpl: function(metaRowTpl) {
-	var i,
+	var tpl, i,
 	ln = metaRowTpl.length;
 	
 	for (i = 0; i < ln; i++) {
@@ -29,6 +30,6 @@
 	    tpl = tpl.replace(/x-grid-cell-inner x-unselectable/g, 'x-grid-cell-inner');
 	    tpl = tpl.replace(/unselectable="on"/g, '');
 	    metaRowTpl[i] = tpl;
-	};
+	}
     }	
 });

Modified: pve-manager/pve2/www/manager/tree/ResourceTree.js
===================================================================
--- pve-manager/pve2/www/manager/tree/ResourceTree.js	2011-07-08 10:44:33 UTC (rev 6274)
+++ pve-manager/pve2/www/manager/tree/ResourceTree.js	2011-07-08 11:39:17 UTC (rev 6275)
@@ -218,6 +218,11 @@
 			    break;
 			}
 		    }
+		    if (item.data.text != olditem.data.text) {
+			//console.log("changed text");
+			changed = true;
+		    }
+
 		    // fixme: also test filterfn()?
 		}
 




More information about the pve-devel mailing list