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

svn-commits at proxmox.com svn-commits at proxmox.com
Mon May 30 13:23:08 CEST 2011


Author: dietmar
Date: 2011-05-30 13:23:08 +0200 (Mon, 30 May 2011)
New Revision: 6044

Added:
   pve-manager/pve2/www/new/cluster/Log.js
Modified:
   pve-manager/pve2/lib/PVE/API2/Cluster.pm
   pve-manager/pve2/www/new/Makefile.am
   pve-manager/pve2/www/new/PVEUtils.js
   pve-manager/pve2/www/new/data/DiffStore.js
   pve-manager/pve2/www/new/data/PVEProxy.js
   pve-manager/pve2/www/new/node/Config.js
   pve-manager/pve2/www/new/panel/StatusPanel.js
Log:
impl. cluster log


Modified: pve-manager/pve2/lib/PVE/API2/Cluster.pm
===================================================================
--- pve-manager/pve2/lib/PVE/API2/Cluster.pm	2011-05-30 10:31:24 UTC (rev 6043)
+++ pve-manager/pve2/lib/PVE/API2/Cluster.pm	2011-05-30 11:23:08 UTC (rev 6044)
@@ -81,12 +81,13 @@
 	my $max = $param->{max} || 0;
 	my $user = $rpcenv->get_user();
 
-	my $res = decode_json(PVE::Cluster::get_cluster_log($user, $max));
+	my $admin = $rpcenv->check($user, "/", [ 'Sys.Syslog' ]);
 
-	# fixme: can we avoid that?
-	my $list = [ reverse @{$res->{data}} ];
+	my $loguser = $admin ? '' : $user;
 
-	return $list;
+	my $res = decode_json(PVE::Cluster::get_cluster_log($loguser, $max));
+
+	return $res->{data};
     }});
 
 __PACKAGE__->register_method ({

Modified: pve-manager/pve2/www/new/Makefile.am
===================================================================
--- pve-manager/pve2/www/new/Makefile.am	2011-05-30 10:31:24 UTC (rev 6043)
+++ pve-manager/pve2/www/new/Makefile.am	2011-05-30 11:23:08 UTC (rev 6044)
@@ -26,6 +26,7 @@
 	form/FileSelector.js				\
 	form/StorageSelector.js				\
 	cluster/Tasks.js				\
+	cluster/Log.js					\
 	panel/StatusPanel.js				\
 	panel/RRDView.js				\
 	window/LoginWindow.js				\

Modified: pve-manager/pve2/www/new/PVEUtils.js
===================================================================
--- pve-manager/pve2/www/new/PVEUtils.js	2011-05-30 10:31:24 UTC (rev 6043)
+++ pve-manager/pve2/www/new/PVEUtils.js	2011-05-30 11:23:08 UTC (rev 6044)
@@ -340,7 +340,7 @@
     },
 
     render_serverity: function (value) {
-	return PVE.Utils.log_severity_hash[value] || value;
+	return PVE.Utils.statics().log_severity_hash[value] || value;
     },
 
     render_cpu: function(value, metaData, record, rowIndex, colIndex, store) {

Added: pve-manager/pve2/www/new/cluster/Log.js
===================================================================
--- pve-manager/pve2/www/new/cluster/Log.js	                        (rev 0)
+++ pve-manager/pve2/www/new/cluster/Log.js	2011-05-30 11:23:08 UTC (rev 6044)
@@ -0,0 +1,89 @@
+Ext.define('PVE.cluster.Log', {
+    extend: 'Ext.grid.GridPanel',
+
+    alias: ['widget.pveClusterLog'],
+
+    initComponent : function() {
+	var me = this;
+
+	var logstore = new PVE.data.UpdateStore({
+	    storeid: 'pve-cluster-log',
+	    model: 'pve-cluster-log',
+	    proxy: {
+                type: 'pve',
+		url: '/api2/json/cluster/log'
+	    }
+	});
+
+	var store = Ext.create('PVE.data.DiffStore', { 
+	    rstore: logstore,
+	    appendAtStart: true 
+	});
+
+	Ext.apply(me, {
+	    store: store,
+	    stateful: false,
+
+	    viewConfig: {
+		trackOver: false,
+		stripeRows: false, // does not work with getRowClass()
+ 
+		getRowClass: function(record, index) {
+		    var pri = record.get('pri');
+
+		    if (pri && pri <= 3) 
+			return "x-form-invalid-field";
+		}
+	    },
+	    sortableColumns: false,
+	    columns: [
+		{ 
+		    header: "Start Time", 
+		    dataIndex: 'time',
+		    width: 100,
+		    renderer: function(value) { 
+			return Ext.Date.format(value, "M d H:i:s"); 
+		    }
+		},
+		{ 
+		    header: "Node", 
+		    dataIndex: 'node',
+		    width: 100
+		},
+		{ 
+		    header: "Tag", 
+		    dataIndex: 'tag',
+		    width: 100
+		},
+		{ 
+		    header: "PID", 
+		    dataIndex: 'pid',
+		    width: 100, 
+		},
+		{ 
+		    header: "User", 
+		    dataIndex: 'user',
+		    width: 150
+		},
+		{ 
+		    header: "Severity", 
+		    dataIndex: 'pri',
+		    renderer: PVE.Utils.render_serverity,
+		    width: 100 
+		},
+		{ 
+		    header: "Message", 
+		    dataIndex: 'msg',
+		    flex: 1	  
+		}
+	    ],
+	    listeners: {
+		show: logstore.startUpdate,
+		hide: logstore.stopUpdate,
+		destroy: logstore.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-30 10:31:24 UTC (rev 6043)
+++ pve-manager/pve2/www/new/data/DiffStore.js	2011-05-30 11:23:08 UTC (rev 6044)
@@ -24,6 +24,8 @@
 
 	me.callParent([config]);
 
+	var first_load = true;
+
 	var cond_add_item = function(data, id) {
 	    var olditem = me.getById(id);
 	    if (olditem) {
@@ -36,7 +38,7 @@
 		olditem.commit(); 
 	    } else {
 		var newrec = Ext.ModelMgr.create(data, me.model, id);
-		var pos = me.appendAtStart ? 0 : me.data.length;
+		var pos = (me.appendAtStart && !first_load) ? 0 : me.data.length;
 		me.insert(pos, newrec);
 	    }
 	};
@@ -61,6 +63,8 @@
 	    	
 	    me.filter();
 
+	    first_load = false;
+
 	    me.resumeEvents();
 	    me.fireEvent('datachanged', me);
 	});

Modified: pve-manager/pve2/www/new/data/PVEProxy.js
===================================================================
--- pve-manager/pve2/www/new/data/PVEProxy.js	2011-05-30 10:31:24 UTC (rev 6043)
+++ pve-manager/pve2/www/new/data/PVEProxy.js	2011-05-30 11:23:08 UTC (rev 6044)
@@ -58,4 +58,27 @@
 	idProperty: 'upid'
     });
 
+    Ext.define('pve-cluster-log', {
+	extend: 'Ext.data.Model',
+	fields:  [ 
+	    { name: 'uid' , type: 'int' },
+	    { name: 'time', type : 'date', dateFormat: 'timestamp' }, 
+	    { name: 'pri', type: 'int' },
+	    { name: 'pid', type: 'int' },
+	    'node', 'user', 'tag', 'msg',
+	    {
+		name: 'id',
+		convert: function(value, record) {
+		    var info = record.data;
+		    var text;
+
+		    if (value)
+			return value;
+		    // compute unique ID
+		    return info.uid + ':' + info.node;
+		}
+	    }
+	],
+	idProperty: 'id'
+    });
 });

Modified: pve-manager/pve2/www/new/node/Config.js
===================================================================
--- pve-manager/pve2/www/new/node/Config.js	2011-05-30 10:31:24 UTC (rev 6043)
+++ pve-manager/pve2/www/new/node/Config.js	2011-05-30 11:23:08 UTC (rev 6044)
@@ -44,7 +44,7 @@
 		    xtype: 'pveNodeSyslog'
 		},
 		{
-		    title: 'Tasks',
+		    title: 'Task History',
 		    itemId: 'tasks',
 		    xtype: 'pveNodeTasks'
 		}

Modified: pve-manager/pve2/www/new/panel/StatusPanel.js
===================================================================
--- pve-manager/pve2/www/new/panel/StatusPanel.js	2011-05-30 10:31:24 UTC (rev 6043)
+++ pve-manager/pve2/www/new/panel/StatusPanel.js	2011-05-30 11:23:08 UTC (rev 6044)
@@ -31,7 +31,8 @@
 	    items: [
 		{
 		    itemId: 'clog',
-		    title: 'Cluster log'
+		    title: 'Cluster log',
+		    xtype: 'pveClusterLog'
 		},
 		{
 		    itemId: 'tasks',
@@ -43,6 +44,8 @@
 
 	me.callParent();
 
+	me.items.get(0).fireEvent('show', me.items.get(0));
+
 	var statechange = function(sp, key, state) {
 	    if (key === stateid) {
 		var atab = me.getActiveTab().itemId;
@@ -57,5 +60,6 @@
 	me.on('destroy', function() {
 	    sp.un('statechange', statechange);		    
 	});
+
     }
 });




More information about the pve-devel mailing list