[pve-devel] r6034 - in pve-manager/pve2: lib/PVE/API2 www/css www/new www/new/cluster www/new/data www/new/node www/new/panel

svn-commits at proxmox.com svn-commits at proxmox.com
Fri May 27 15:08:25 CEST 2011


Author: dietmar
Date: 2011-05-27 15:08:25 +0200 (Fri, 27 May 2011)
New Revision: 6034

Added:
   pve-manager/pve2/www/new/cluster/
   pve-manager/pve2/www/new/cluster/Tasks.js
Modified:
   pve-manager/pve2/lib/PVE/API2/Tasks.pm
   pve-manager/pve2/www/css/ext-pve.css
   pve-manager/pve2/www/new/Makefile.am
   pve-manager/pve2/www/new/data/DiffStore.js
   pve-manager/pve2/www/new/data/PVEProxy.js
   pve-manager/pve2/www/new/node/Tasks.js
   pve-manager/pve2/www/new/panel/StatusPanel.js
Log:
impl. cluster task grid


Modified: pve-manager/pve2/lib/PVE/API2/Tasks.pm
===================================================================
--- pve-manager/pve2/lib/PVE/API2/Tasks.pm	2011-05-27 11:22:37 UTC (rev 6033)
+++ pve-manager/pve2/lib/PVE/API2/Tasks.pm	2011-05-27 13:08:25 UTC (rev 6034)
@@ -262,6 +262,13 @@
 
 	close($fh);
 
+	# HACK: ExtJS store.guaranteeRange() does not like empty array
+	# so we add a line
+	if (!$count) {
+	    $count++;
+	    push @$lines, { n => $count, t => "no content"};
+	}
+
 	$rpcenv->set_result_count($count);
 	    
 	return $lines;

Modified: pve-manager/pve2/www/css/ext-pve.css
===================================================================
--- pve-manager/pve2/www/css/ext-pve.css	2011-05-27 11:22:37 UTC (rev 6033)
+++ pve-manager/pve2/www/css/ext-pve.css	2011-05-27 13:08:25 UTC (rev 6034)
@@ -3,6 +3,12 @@
     line-height: 13px;
 }
 
+.x-grid-row-loading {
+    background-color: #fff;
+    background: no-repeat center center;
+    background-image:url(../ext4/resources/themes/images/default/shared/loading-balls.gif);
+}
+
 .x-selectable, .x-selectable * {
     -moz-user-select: text!important;
     -khtml-user-select: text!important;

Modified: pve-manager/pve2/www/new/Makefile.am
===================================================================
--- pve-manager/pve2/www/new/Makefile.am	2011-05-27 11:22:37 UTC (rev 6033)
+++ pve-manager/pve2/www/new/Makefile.am	2011-05-27 13:08:25 UTC (rev 6034)
@@ -25,6 +25,7 @@
 	form/NodeSelector.js				\
 	form/FileSelector.js				\
 	form/StorageSelector.js				\
+	cluster/Tasks.js				\
 	panel/StatusPanel.js				\
 	panel/RRDView.js				\
 	window/LoginWindow.js				\

Added: pve-manager/pve2/www/new/cluster/Tasks.js
===================================================================
--- pve-manager/pve2/www/new/cluster/Tasks.js	                        (rev 0)
+++ pve-manager/pve2/www/new/cluster/Tasks.js	2011-05-27 13:08:25 UTC (rev 6034)
@@ -0,0 +1,120 @@
+Ext.define('PVE.cluster.Tasks', {
+    extend: 'Ext.grid.GridPanel',
+
+    alias: ['widget.pveClusterTasks'],
+
+    initComponent : function() {
+	var me = this;
+
+	var taskstore = new PVE.data.UpdateStore({
+	    storeid: 'pve-cluster-tasks',
+	    model: 'pve-tasks',
+	    proxy: {
+                type: 'pve',
+		url: '/api2/json/cluster/tasks'
+	    },
+	    sorters: [
+		{
+		    property : 'starttime',
+		    direction: 'ASC'
+		}
+	    ]
+	});
+
+	var store = Ext.create('PVE.data.DiffStore', { 
+	    rstore: taskstore,
+	    appendAtStart: true 
+	});
+
+	var run_task_viewer = function() {
+	    var sm = me.getSelectionModel();
+	    var rec = sm.getLastSelected();
+	    if (!rec)
+		return;
+
+	    var win = Ext.create('PVE.window.TaskViewer', { 
+		upid: rec.data.upid
+	    });
+	    win.show();
+	};
+
+	Ext.apply(me, {
+	    store: store,
+	    stateful: false,
+
+	    viewConfig: {
+		trackOver: false,
+		stripeRows: false, // does not work with getRowClass()
+ 
+		getRowClass: function(record, index) {
+		    var status = record.get('status');
+
+		    if (status && status != 'OK') 
+			return "x-form-invalid-field";
+		}
+	    },
+	    sortableColumns: false,
+	    columns: [
+		{ 
+		    header: "Start Time", 
+		    dataIndex: 'starttime',
+		    width: 100,
+		    renderer: function(value) { 
+			return Ext.Date.format(value, "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 Ext.Date.format(value, "M d H:i:s"); 
+		    }
+		},
+		{ 
+		    header: "Node", 
+		    dataIndex: 'node',
+		    width: 100
+		},
+		{ 
+		    header: "User", 
+		    dataIndex: 'user',
+		    width: 150
+		},
+		{ 
+		    header: "Description", 
+		    dataIndex: 'upid', 
+		    flex: 1,		  
+		    renderer: PVE.Utils.render_upid
+		},
+		{ 
+		    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;
+		    }
+		}
+	    ],
+	    listeners: {
+		itemdblclick: run_task_viewer,
+		show: taskstore.startUpdate,
+		hide: taskstore.stopUpdate,
+		destroy: taskstore.stopUpdate
+	    }
+	});
+
+ 	me.callParent();
+    }
+});
\ No newline at end of file

Modified: pve-manager/pve2/www/new/data/DiffStore.js
===================================================================
--- pve-manager/pve2/www/new/data/DiffStore.js	2011-05-27 11:22:37 UTC (rev 6033)
+++ pve-manager/pve2/www/new/data/DiffStore.js	2011-05-27 13:08:25 UTC (rev 6034)
@@ -36,7 +36,8 @@
 		olditem.commit(); 
 	    } else {
 		var newrec = Ext.ModelMgr.create(data, me.model, id);
-		me.add(newrec);
+		var pos = me.appendAtStart ? 0 : me.data.length;
+		me.insert(pos, newrec);
 	    }
 	};
 

Modified: pve-manager/pve2/www/new/data/PVEProxy.js
===================================================================
--- pve-manager/pve2/www/new/data/PVEProxy.js	2011-05-27 11:22:37 UTC (rev 6033)
+++ pve-manager/pve2/www/new/data/PVEProxy.js	2011-05-27 13:08:25 UTC (rev 6034)
@@ -40,4 +40,16 @@
 	fields: [ 'key', 'value' ],
 	idProperty: 'key'
     });
+
+    Ext.define('pve-tasks', {
+	extend: 'Ext.data.Model',
+	fields:  [ 
+	    { name: 'starttime', type : 'date', dateFormat: 'timestamp' }, 
+	    { name: 'endtime', type : 'date', dateFormat: 'timestamp' }, 
+	    { name: 'pid', type: 'int' },
+	    'node', 'upid', 'user', 'status', 'type', 'id'
+	],
+	idProperty: 'upid'
+    });
+
 });

Modified: pve-manager/pve2/www/new/node/Tasks.js
===================================================================
--- pve-manager/pve2/www/new/node/Tasks.js	2011-05-27 11:22:37 UTC (rev 6033)
+++ pve-manager/pve2/www/new/node/Tasks.js	2011-05-27 13:08:25 UTC (rev 6034)
@@ -14,16 +14,7 @@
 	    pageSize: 500,
  	    buffered: true,
 	    remoteFilter: true,
-	    model: Ext.define('pve-tasks', {
-		extend: 'Ext.data.Model',
-		fields:  [ 
-		    { name: 'starttime', type : 'date', dateFormat: 'timestamp' }, 
-		    { name: 'endtime', type : 'date', dateFormat: 'timestamp' }, 
-		    { name: 'pid', type: 'int' },
-		    'node', 'upid', 'user', 'status', 'type', 'id'
-		],
-		idProperty: 'upid'
-	    }),
+	    model: 'pve-tasks',
 	    proxy: {
                 type: 'pve',
 		startParam: 'start',

Modified: pve-manager/pve2/www/new/panel/StatusPanel.js
===================================================================
--- pve-manager/pve2/www/new/panel/StatusPanel.js	2011-05-27 11:22:37 UTC (rev 6033)
+++ pve-manager/pve2/www/new/panel/StatusPanel.js	2011-05-27 13:08:25 UTC (rev 6034)
@@ -1,6 +1,9 @@
 Ext.define('PVE.panel.StatusPanel', {
     extend: 'Ext.tab.Panel',
-    requires: ['Ext.state.Manager'],
+    requires: [
+	'Ext.state.Manager',
+	'PVE.cluster.Tasks'
+    ],
     alias: 'widget.pveStatusPanel',
 
     title: "Realtime logfile viewer",
@@ -32,7 +35,8 @@
 		},
 		{
 		    itemId: 'tasks',
-		    title: 'Recent tasks'
+		    title: 'Recent tasks',
+		    xtype: 'pveClusterTasks'
 		}
 	    ]
 	});




More information about the pve-devel mailing list