[pve-devel] r5773 - in pve-manager/pve2/www/new: . data form window

svn-commits at proxmox.com svn-commits at proxmox.com
Wed Mar 30 11:59:22 CEST 2011


Author: dietmar
Date: 2011-03-30 11:59:22 +0200 (Wed, 30 Mar 2011)
New Revision: 5773

Added:
   pve-manager/pve2/www/new/ResourceTree.js
   pve-manager/pve2/www/new/data/UpdateQueue.js
   pve-manager/pve2/www/new/data/UpdateStore.js
Modified:
   pve-manager/pve2/www/new/Makefile.am
   pve-manager/pve2/www/new/PVEUtils.js
   pve-manager/pve2/www/new/Workspace.js
   pve-manager/pve2/www/new/data/PVEProxy.js
   pve-manager/pve2/www/new/form/RealmComboBox.js
   pve-manager/pve2/www/new/window/LoginWindow.js
Log:
start ressource tree implementation, cleanups


Modified: pve-manager/pve2/www/new/Makefile.am
===================================================================
--- pve-manager/pve2/www/new/Makefile.am	2011-03-30 05:38:56 UTC (rev 5772)
+++ pve-manager/pve2/www/new/Makefile.am	2011-03-30 09:59:22 UTC (rev 5773)
@@ -1,10 +1,13 @@
 include $(top_builddir)/common.mk
 
 JSSRC= 				                 	\
+	PVEUtils.js					\
+	data/PVEProxy.js				\
+	data/UpdateQueue.js				\
+	data/UpdateStore.js				\
 	form/RealmComboBox.js				\
-	data/PVEProxy.js				\
 	window/LoginWindow.js				\
-	PVEUtils.js					\
+	ResourceTree.js					\
 	Workspace.js
 
 pvemanagerlib.js: ${JSSRC}

Modified: pve-manager/pve2/www/new/PVEUtils.js
===================================================================
--- pve-manager/pve2/www/new/PVEUtils.js	2011-03-30 05:38:56 UTC (rev 5772)
+++ pve-manager/pve2/www/new/PVEUtils.js	2011-03-30 09:59:22 UTC (rev 5773)
@@ -1,3 +1,5 @@
+Ext.ns('PVE');
+
 // avoid errors when running without development tools
 if (typeof console == "undefined") {
    var console = { 
@@ -18,51 +20,50 @@
     }
 });
 
-PVE.Utils = function() {
+Ext.define('PVE.Utils', {
+    singleton: true,
 
-    var log_severity_hash = {
-	0: "panic",
-	1: "alert",
-	2: "critical",
-	3: "error",
-	4: "warning",
-	5: "notice",
-	6: "info",
-	7: "debug"
-    };
+    authOK: function() {
+	return Ext.util.Cookies.get('PVEAuthCookie');
+    },
 
+    authClear: function() {
+	Ext.util.Cookies.clear("PVEAuthCookie");
+    },
 
-    var utils = {
+    render_upid: function(value, metaData, record) { 
+	var type = record.data.type;
+	var id = record.data.id;
 
-	authOK: function() {
-	    return Ext.util.Cookies.get('PVEAuthCookie');
-	},
+	if (type == 'vncproxy') {
+	    return "VNC connection to VM " + id;
+	}
+	if (type == 'vncshell') {
+	    return "VNC shell";
+	}
 
-	authClear: function() {
-	    Ext.util.Cookies.clear("PVEAuthCookie");
-	},
+	return value;
+    },			  
+ 
+    constructor : function(){
+        var self = this;
 
-	render_serverity: function (value) {
+	var log_severity_hash = {
+	    0: "panic",
+	    1: "alert",
+	    2: "critical",
+	    3: "error",
+	    4: "warning",
+	    5: "notice",
+	    6: "info",
+	    7: "debug"
+	};
 
-	    return log_severity_hash[value] || value;
-	},
-
-	render_upid: function(value, metaData, record) { 
-	    var type = record.data.type;
-	    var id = record.data.id;
-
-	    if (type == 'vncproxy') {
-		return "VNC connection to VM " + id;
+	Ext.apply(self, {
+	    render_serverity: function (value) {		
+		return log_severity_hash[value] || value;
 	    }
-	    if (type == 'vncshell') {
-		return "VNC shell";
-	    }
+	});
+    }
+});
 
-	    return value;
-	}			  
-    };
-
-    return utils;
-
-}();
-

Added: pve-manager/pve2/www/new/ResourceTree.js
===================================================================
--- pve-manager/pve2/www/new/ResourceTree.js	                        (rev 0)
+++ pve-manager/pve2/www/new/ResourceTree.js	2011-03-30 09:59:22 UTC (rev 5773)
@@ -0,0 +1,25 @@
+Ext.define('PVE.ResourceTree', {
+    extend: 'Ext.tree.TreePanel',
+    requires: ['PVE.Utils', 'PVE.data.UpdateStore'],
+    alias: ['widget.pveResourceTree'],
+
+    initComponent : function() {
+	var self = this;
+
+	var rstore = Ext.create('PVE.data.UpdateStore', {
+	    storeid: 'PVEResources',
+	    model: 'PVEResources',
+	    autoDestory: false
+	});
+
+	rstore.startUpdate();
+
+	Ext.apply(this, {
+            title: 'Resource Tree',
+	    tbar: [ 'TEST' ]
+	});
+
+	PVE.ResourceTree.superclass.initComponent.call(self);
+    }
+
+});

Modified: pve-manager/pve2/www/new/Workspace.js
===================================================================
--- pve-manager/pve2/www/new/Workspace.js	2011-03-30 05:38:56 UTC (rev 5772)
+++ pve-manager/pve2/www/new/Workspace.js	2011-03-30 09:59:22 UTC (rev 5773)
@@ -1,6 +1,6 @@
 Ext.define('PVE.Workspace', {
     extend: 'Ext.container.Viewport',
-    requires: ['PVE.window.LoginWindow', 'PVE.Utils'],
+    requires: ['PVE.window.LoginWindow', 'PVE.Utils', 'PVE.ResourceTree'],
 
     // private
     defaultView: {
@@ -123,12 +123,10 @@
 		    items: self.defaultView
 		},
 		{
-		    //xtype: 'pveResourceTree',
-		    html: 'tree',
+		    xtype: 'pveResourceTree',
 		    width: 200,
 		    region: 'west',
 		    margins: '0 0 0 5',
-		    //  collapsible: true
 		    split: true
 		},
 		{

Modified: pve-manager/pve2/www/new/data/PVEProxy.js
===================================================================
--- pve-manager/pve2/www/new/data/PVEProxy.js	2011-03-30 05:38:56 UTC (rev 5772)
+++ pve-manager/pve2/www/new/data/PVEProxy.js	2011-03-30 09:59:22 UTC (rev 5773)
@@ -30,5 +30,14 @@
 	    url: "/api2/json/access/domains"
 	}
     });
- 
+
+    Ext.regModel('PVEResources', {
+	fields: ['id', 'type', 'name', 'node', 'storage', 'cpu', 'maxcpu',
+		 'mem', 'maxmem', 'disk', 'maxdisk', 'uptime'],
+	idProperty: 'id',
+	proxy: {
+	    type: 'pve',
+	    url: '/api2/json/cluster/vms',
+	}
+    });
 });

Added: pve-manager/pve2/www/new/data/UpdateQueue.js
===================================================================
--- pve-manager/pve2/www/new/data/UpdateQueue.js	                        (rev 0)
+++ pve-manager/pve2/www/new/data/UpdateQueue.js	2011-03-30 09:59:22 UTC (rev 5773)
@@ -0,0 +1,44 @@
+// Serialize load (avoid too many parallel connections)
+Ext.define('PVE.data.UpdateQueue', {
+    singleton: true,
+
+    constructor : function(){
+        var self = this;
+
+	var queue = [];
+	var queue_idx = {};
+
+	var idle = true;
+
+	var start_update = function() {
+	    if (!idle)
+		return;
+
+	    var store = queue.shift();
+	    if (!store)
+		return;
+
+	    queue_idx[store.storeid] = null;
+
+	    idle = false;
+	    store.load({
+		callback: function() {
+		    idle = true;
+		    start_update();
+		}
+	    });
+	};
+
+	Ext.apply(self, {
+	    queue: function(store) {
+		if (!store.storeid)
+		    throw "unable to queue store without storeid";
+		if (!queue_idx[store.storeid]) {
+		    queue_idx[store.storeid] = store;
+		    queue.push(store);
+		}
+		start_update();
+	    }
+	});
+    }
+});

Added: pve-manager/pve2/www/new/data/UpdateStore.js
===================================================================
--- pve-manager/pve2/www/new/data/UpdateStore.js	                        (rev 0)
+++ pve-manager/pve2/www/new/data/UpdateStore.js	2011-03-30 09:59:22 UTC (rev 5773)
@@ -0,0 +1,36 @@
+Ext.define('PVE.data.UpdateStore', {
+    extend: 'Ext.data.Store',
+    requires: ['PVE.Utils', 'Ext.util.*', 'PVE.data.UpdateQueue'],
+
+    constructor: function(config) {
+	var self = this;
+
+	if (!config.interval)
+	    config.interval = 3000;
+
+	if (!config.storeid)
+	    throw "no storeid specified";
+
+	var load_task = new Ext.util.DelayedTask();
+
+	var run_load_task = function() {
+	    if (PVE.Utils.authOK()) {
+		PVE.data.UpdateQueue.queue(self);
+		load_task.delay(config.interval, run_load_task);
+	    } else {
+		load_task.delay(1000, run_load_task);
+	    }
+	};
+
+	Ext.apply(config, {
+	    startUpdate: function() {
+		run_load_task();
+	    },
+	    stopUpdate: function() {
+		load_task.cancel();
+	    },
+	});
+
+	PVE.data.UpdateStore.superclass.constructor.call(self, config);
+    }
+});

Modified: pve-manager/pve2/www/new/form/RealmComboBox.js
===================================================================
--- pve-manager/pve2/www/new/form/RealmComboBox.js	2011-03-30 05:38:56 UTC (rev 5772)
+++ pve-manager/pve2/www/new/form/RealmComboBox.js	2011-03-30 09:59:22 UTC (rev 5773)
@@ -1,8 +1,7 @@
 Ext.define('PVE.form.RealmComboBox', {
     extend: 'Ext.form.ComboBox',
-    requires: ['Ext.data.Store'],
-    uses: ['PVE.RestProxy'],
-    alias: ['widget.PVERealmComboBox'],
+    requires: ['Ext.data.Store', 'PVE.RestProxy'],
+    alias: ['widget.pveRealmComboBox'],
 
     initComponent: function() {
 	var self = this;

Modified: pve-manager/pve2/www/new/window/LoginWindow.js
===================================================================
--- pve-manager/pve2/www/new/window/LoginWindow.js	2011-03-30 05:38:56 UTC (rev 5772)
+++ pve-manager/pve2/www/new/window/LoginWindow.js	2011-03-30 09:59:22 UTC (rev 5773)
@@ -94,7 +94,7 @@
 			}
 		    },
 		    {
-			xtype: 'PVERealmComboBox',
+			xtype: 'pveRealmComboBox',
 			name: 'realm'
 		    }
 		],



More information about the pve-devel mailing list