[pve-devel] r5727 - in pve-manager/pve2: lib/PVE/API2 www/manager

svn-commits at proxmox.com svn-commits at proxmox.com
Fri Mar 18 13:56:36 CET 2011


Author: dietmar
Date: 2011-03-18 13:56:36 +0100 (Fri, 18 Mar 2011)
New Revision: 5727

Modified:
   pve-manager/pve2/lib/PVE/API2/Cluster.pm
   pve-manager/pve2/www/manager/StatusPanel.js
Log:
mplement cluster task view - first try


Modified: pve-manager/pve2/lib/PVE/API2/Cluster.pm
===================================================================
--- pve-manager/pve2/lib/PVE/API2/Cluster.pm	2011-03-18 10:20:36 UTC (rev 5726)
+++ pve-manager/pve2/lib/PVE/API2/Cluster.pm	2011-03-18 12:56:36 UTC (rev 5727)
@@ -241,7 +241,7 @@
 	my $rpcenv = PVE::RPCEnvironment::get();
 	my $user = $rpcenv->get_user();
 
-	my $tlist = PVE::RPCEnvironment::active_workers();
+	my $tlist = PVE::Cluster::get_tasklist();
 
 	my $res = [];
 

Modified: pve-manager/pve2/www/manager/StatusPanel.js
===================================================================
--- pve-manager/pve2/www/manager/StatusPanel.js	2011-03-18 10:20:36 UTC (rev 5726)
+++ pve-manager/pve2/www/manager/StatusPanel.js	2011-03-18 12:56:36 UTC (rev 5727)
@@ -55,6 +55,88 @@
     }
 });
 
+
+PVE.ClusterTasks = Ext.extend(Ext.grid.GridPanel, {
+
+    initComponent : function() {
+	var self = this;
+
+	var fields = [ 
+	    { name: 'starttime', type : 'date', dateFormat: 'timestamp' }, 
+	    { name: 'endtime', type : 'date', dateFormat: 'timestamp' }, 
+	    { name: 'pid', type: 'int' },
+	    'node', 'upid', 'user', 'status', 'type'];
+
+	// fixme: use/define a storage which append new values, but
+	// defer removing old values until a maximum numer of entries 
+	// is reached
+	var taskstore = new PVE.data.UpdateStore({
+	    itype: 'tasks',
+	    autoDestroy: true,
+	    url: '/api2/json/cluster/tasks',
+	    idProperty: 'upid',
+	    fields: fields
+	});
+
+	Ext.apply(self, {
+	    store: taskstore,
+	    border: false,
+	    startUpdate: function() { taskstore.startUpdate(); },
+	    stopUpdate: function() { taskstore.stopUpdate(); },
+	    columnSort: false,
+	    autoExpandColumn: 'status',
+	    viewConfig: {
+		getRowClass: function(record, index) {
+		    var status = record.get('status');
+
+		    if (status && status != 'OK') 
+			return "x-form-invalid";
+		}
+	    },
+	    columns: [
+		{ header: "Start Time", dataIndex: 'starttime',
+		  width: 100,
+		  renderer: function(value) { return value.format("M d H:i:s"); }
+		},
+		{ header: "End Time", dataIndex: 'endtime',
+		  width: 100,
+		  renderer: function(value, metaData, record) {
+		      if (record.data.pid) {
+			  metaData.css =  "x-grid-row-loading";
+			  return "";
+		      }
+		      return value.format("M d H:i:s"); 
+		  }
+		},
+		{ header: "Node", dataIndex: 'node',
+		  width: 100
+		},
+		{ header: "User", dataIndex: 'user',
+		  width: 150
+		},
+		{ id: 'desc', header: "Description", dataIndex: 'upid', 
+		  width: 400
+
+		},
+		{ id: 'status', header: "Status", dataIndex: 'status', 
+		  width: 200,
+		  renderer: function(value, metaData, record) { 
+		      if (record.data.pid) {
+			  metaData.css =  "x-grid-row-loading";
+			  return "";
+		      }
+		      if (value == 'OK')
+			  return 'OK';
+		      // metaData.attr = 'style="color:red;"'; 
+		      return "ERROR: " + value;
+		  }
+		}
+	    ]});
+
+	PVE.ClusterTasks.superclass.initComponent.call(self);
+    }
+});
+
 PVE.StatusPanel = Ext.extend(Ext.Panel, {
 
     initComponent : function() {
@@ -69,6 +151,7 @@
 	var cllogview = new PVE.LogViewer({ 
 	    url: '/api2/json/cluster/log',
 	});
+	var tasklist = new PVE.ClusterTasks();
 
 	self.items = {
 	    xtype: 'tabpanel',
@@ -104,7 +187,16 @@
 		    }
  		},
 		{
-                    title: 'Task list'
+                    title: 'Task list',
+		    items: tasklist,
+		    listeners: {
+			show: function() {
+			    tasklist.startUpdate();
+			},
+			hide: function() {
+			    tasklist.stopUpdate();
+			}
+		    }
 		}
 	    ]
  	};	




More information about the pve-devel mailing list