[pve-devel] r5968 - in pve-manager/pve2/www/new: . form node

svn-commits at proxmox.com svn-commits at proxmox.com
Thu May 12 11:30:59 CEST 2011


Author: dietmar
Date: 2011-05-12 11:30:59 +0200 (Thu, 12 May 2011)
New Revision: 5968

Added:
   pve-manager/pve2/www/new/form/RRDTypeSelector.js
Modified:
   pve-manager/pve2/www/new/Makefile.am
   pve-manager/pve2/www/new/form/ViewSelector.js
   pve-manager/pve2/www/new/node/Config.js
Log:
new RRDTypeSelector


Modified: pve-manager/pve2/www/new/Makefile.am
===================================================================
--- pve-manager/pve2/www/new/Makefile.am	2011-05-12 08:27:14 UTC (rev 5967)
+++ pve-manager/pve2/www/new/Makefile.am	2011-05-12 09:30:59 UTC (rev 5968)
@@ -11,6 +11,7 @@
 	data/UpdateStore.js				\
 	data/ObjectStore.js				\
 	data/ResourceStore.js				\
+	form/RRDTypeSelector.js				\
 	form/ComboGrid.js				\
 	form/NetworkCardSelector.js			\
 	form/DiskFormatSelector.js			\

Added: pve-manager/pve2/www/new/form/RRDTypeSelector.js
===================================================================
--- pve-manager/pve2/www/new/form/RRDTypeSelector.js	                        (rev 0)
+++ pve-manager/pve2/www/new/form/RRDTypeSelector.js	2011-05-12 09:30:59 UTC (rev 5968)
@@ -0,0 +1,67 @@
+Ext.define('PVE.form.RRDTypeSelector', {
+    extend: 'Ext.form.field.ComboBox',
+    requires: [
+	'Ext.state.Manager'
+    ],
+
+    alias: ['widget.pveRRDTypeSelector'],
+  
+    initComponent: function() {
+        var me = this;
+	
+	var store = new Ext.data.ArrayStore({
+            fields: [ 'id', 'timeframe', 'cf', 'text' ],
+            data : [
+		[ 'hour', 'hour', 'AVERAGE', "Hour (average)" ],
+		[ 'hourmax', 'hour', 'MAX', "Hour (max)" ],
+		[ 'day', 'day', 'AVERAGE', "Day (average)" ],
+		[ 'daymax', 'day', 'MAX', "Day (max)" ],
+		[ 'week', 'week', 'AVERAGE', "Week (average)" ],
+		[ 'weekmax', 'week', 'MAX', "Week (max)" ],
+		[ 'month', 'month', 'AVERAGE', "Month (average)" ],
+		[ 'monthmax', 'month', 'MAX', "Month (max)" ],
+		[ 'year', 'year', 'AVERAGE', "Year (average)" ],
+		[ 'yearmax', 'year', 'MAX', "Year (max)" ],
+	    ]
+	});
+
+	Ext.apply(me, {
+            store: store,
+            displayField: 'text',
+	    valueField: 'id',
+ 	    editable: false,
+            queryMode: 'local',
+	    value: 'hour',
+ 	    getState: function() {
+		var ind = store.findExact('id', me.getValue());
+		var rec = store.getAt(ind);
+		if (!rec) return;
+		return { 
+		    id: rec.data.id,
+		    timeframe: rec.data.timeframe,
+		    cf: rec.data.cf
+		};
+	    },
+	    applyState : function(state) {
+		if (state && state.id) {
+		    me.setValue(state.id);
+		}
+	    },
+	    stateEvents: [ 'select' ],
+	    stateful: true,
+	    id: 'pveRRDTypeSelection'        
+	});
+
+	me.callParent();
+
+	var statechange = function(sp, key, value) {
+	    if (key === me.id) {
+		me.applyState(value);
+	    }
+	};
+
+	var sp = Ext.state.Manager.getProvider();
+	me.mon(sp, 'statechange', statechange, me);
+    }
+});
+

Modified: pve-manager/pve2/www/new/form/ViewSelector.js
===================================================================
--- pve-manager/pve2/www/new/form/ViewSelector.js	2011-05-12 08:27:14 UTC (rev 5967)
+++ pve-manager/pve2/www/new/form/ViewSelector.js	2011-05-12 09:30:59 UTC (rev 5968)
@@ -6,8 +6,6 @@
     initComponent: function() {
 	var me = this;
 
-	var stateid = 'view';
-
 	var default_views = {
 	    server: {
 		text: 'Server View',
@@ -78,24 +76,19 @@
 	    },
 	    stateEvents: [ 'select' ],
 	    stateful: true,
-  	    id: stateid, // fixme: remove (Stateful does not work without)  
-	    stateID: stateid
+  	    id: 'view'
 	});
 
-	
 	me.callParent();
 
 	var statechange = function(sp, key, value) {
-	    if (key === stateid) {
+	    if (key === me.id) {
 		me.applyState(value, true);
 	    }
 	};
 
 	var sp = Ext.state.Manager.getProvider();
 
-	sp.on('statechange', statechange);
-	me.on('destroy', function() {
-	    sp.un('statechange', statechange);		    
-	});
+	me.mon(sp, 'statechange', statechange, me);
     }
 });
\ No newline at end of file

Modified: pve-manager/pve2/www/new/node/Config.js
===================================================================
--- pve-manager/pve2/www/new/node/Config.js	2011-05-12 08:27:14 UTC (rev 5967)
+++ pve-manager/pve2/www/new/node/Config.js	2011-05-12 09:30:59 UTC (rev 5968)
@@ -23,7 +23,7 @@
 		}
 	    });
 	};
-
+  
 	Ext.apply(me, {
 	    layout: 'table',
 	    layoutConfig: {
@@ -55,7 +55,7 @@
 			    node_command('shutdown');
 			});
 		    }
-		}, '->',
+		},
 		{ 
 		    text: 'Shell',
 		    handler: function() {
@@ -67,6 +67,9 @@
 					     "innerWidth=745,innerheight=427");
 			nw.focus();
 		    }
+		}, '->',
+		{
+		    xtype: 'pveRRDTypeSelector'
 		}
 	    ]
 	});




More information about the pve-devel mailing list