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

svn-commits at proxmox.com svn-commits at proxmox.com
Thu Jan 13 14:18:55 CET 2011


Author: dietmar
Date: 2011-01-13 14:18:54 +0100 (Thu, 13 Jan 2011)
New Revision: 5384

Added:
   pve-manager/pve2/www/manager/StatusPanel.js
Modified:
   pve-manager/pve2/ChangeLog
   pve-manager/pve2/lib/PVE/API2/Cluster.pm
   pve-manager/pve2/www/manager/Makefile.am
   pve-manager/pve2/www/manager/PVECache.js
   pve-manager/pve2/www/manager/PVEUtils.js
   pve-manager/pve2/www/manager/Workspace.js
Log:
	* www/manager/StatusPanel.js: a simple log viewer.



Modified: pve-manager/pve2/ChangeLog
===================================================================
--- pve-manager/pve2/ChangeLog	2011-01-13 09:35:08 UTC (rev 5383)
+++ pve-manager/pve2/ChangeLog	2011-01-13 13:18:54 UTC (rev 5384)
@@ -1,3 +1,7 @@
+2011-01-13  root  <root at maui.maurer-it.com>
+
+	* www/manager/StatusPanel.js: a simple log viewer.
+
 2011-01-12  root  <root at maui.maurer-it.com>
 
 	* lib/PVE/Makefile.am: do not install outdated files

Modified: pve-manager/pve2/lib/PVE/API2/Cluster.pm
===================================================================
--- pve-manager/pve2/lib/PVE/API2/Cluster.pm	2011-01-13 09:35:08 UTC (rev 5383)
+++ pve-manager/pve2/lib/PVE/API2/Cluster.pm	2011-01-13 13:18:54 UTC (rev 5384)
@@ -5,6 +5,7 @@
 
 use PVE::SafeSyslog;
 use PVE::Cluster;
+use JSON;
 
 use Data::Dumper; # fixme: remove
 
@@ -12,6 +13,7 @@
 use JSON;
 
 use PVE::RESTHandler;
+use PVE::RPCEnvironment;
 
 use base qw(PVE::RESTHandler);
 
@@ -68,4 +70,43 @@
 	return $result;
     }});
 
+__PACKAGE__->register_method({
+    name => 'log', 
+    path => 'log', 
+    method => 'GET',
+    description => "Read cluster log",
+    parameters => {
+    	additionalProperties => 0,
+	properties => {
+	    max => {
+		type => 'integer',
+		description => "Maximum number of entries.",
+		optional => 1,
+		minimum => 1,
+	    }
+	},
+    },
+    returns => {
+	type => 'array',
+	items => {
+	    type => "object",
+	    properties => {},
+	},
+    },
+    code => sub {
+	my ($param) = @_;
+
+	my $rpcenv = PVE::RPCEnvironment::get();
+
+	my $max = $param->{max} || 0;
+	my $user = $rpcenv->get_user();
+
+	my $res = decode_json(PVE::Cluster::get_cluster_log($user, $max));
+
+	# fixme: can we avoid that?
+	my $list = [ reverse @{$res->{data}} ];
+
+	return $list;
+    }});
+
 1;

Modified: pve-manager/pve2/www/manager/Makefile.am
===================================================================
--- pve-manager/pve2/www/manager/Makefile.am	2011-01-13 09:35:08 UTC (rev 5383)
+++ pve-manager/pve2/www/manager/Makefile.am	2011-01-13 13:18:54 UTC (rev 5384)
@@ -12,6 +12,7 @@
 	data/SearchStore.js				\
 	grid/ObjectView.js				\
 	PVECache.js 					\
+	StatusPanel.js 					\
 	Workspace.js 					\
 	window/ModalDialog.js				\
 	window/LoginWindow.js				\

Modified: pve-manager/pve2/www/manager/PVECache.js
===================================================================
--- pve-manager/pve2/www/manager/PVECache.js	2011-01-13 09:35:08 UTC (rev 5383)
+++ pve-manager/pve2/www/manager/PVECache.js	2011-01-13 13:18:54 UTC (rev 5384)
@@ -61,6 +61,25 @@
   
 	}(),
 
+	cllogstore:  function(){
+
+	    var fields = [ 
+		{ name:	'time', type : 'date', dateFormat: 'timestamp' }, 
+		{ name: 'pri', type: 'int' },
+		{ name: 'pid', type: 'int' },
+		'node', 'user', 'tag', 'msg' ];
+
+	    var store = new  PVE.data.UpdateStore({
+		itype: 'storage',
+		autoDestroy: false,
+		url: '/api2/json/cluster/log',
+		fields: fields
+	    });
+
+	    return store;
+  
+	}(),
+
 	dummy: "ignore me"
     };
 

Modified: pve-manager/pve2/www/manager/PVEUtils.js
===================================================================
--- pve-manager/pve2/www/manager/PVEUtils.js	2011-01-13 09:35:08 UTC (rev 5383)
+++ pve-manager/pve2/www/manager/PVEUtils.js	2011-01-13 13:18:54 UTC (rev 5384)
@@ -14,6 +14,18 @@
 
 PVE.Utils = function() {
 
+    var log_severity_hash = {
+	0: "panic",
+	1: "alert",
+	2: "critical",
+	3: "error",
+	4: "warning",
+	5: "notice",
+	6: "info",
+	7: "debug"
+    };
+
+
     var utils = {
 
 	authOK: function() {
@@ -142,6 +154,11 @@
 	    return cta.join(', ');
 	},
 
+	render_serverity: function (value) {
+
+	    return log_severity_hash[value] || value;
+	},
+			  
 	render_cpu: function(value, metaData, record, rowIndex, colIndex, store) {
 
 	    var cpu = value;

Added: pve-manager/pve2/www/manager/StatusPanel.js
===================================================================
--- pve-manager/pve2/www/manager/StatusPanel.js	                        (rev 0)
+++ pve-manager/pve2/www/manager/StatusPanel.js	2011-01-13 13:18:54 UTC (rev 5384)
@@ -0,0 +1,73 @@
+Ext.ns("PVE");
+
+PVE.StatusPanel = Ext.extend(Ext.Panel, {
+
+    initComponent : function() {
+	var self = this;
+
+	self.title = "Realtime logfile viewer";
+	self.layout = 'fit';
+
+	var clstore = PVE.Cache.cllogstore;
+	clstore.startUpdate();
+
+	var cllogview = new Ext.list.ListView({
+	    store: clstore,
+	    columnSort: false,
+	    columns: [
+		{ header: "Time", width: 0.10, dataIndex: 'time',
+		  tpl: '{time:date("M d H:i:s")}'
+		},
+		{ header: "Node", width: 0.05, dataIndex: 'node' },
+		{ header: "Tag", width: 0.05, dataIndex: 'tag' },
+		{ header: "PID", width: 0.05, dataIndex: 'pid' },
+		{ header: "User", width: 0.05, dataIndex: 'user' },
+		{ header: "Severity", width: 0.05, dataIndex: 'pri',
+		  tpl: '{[ PVE.Utils.render_serverity(values.pri) ]}'
+		},
+		{ header: "Message", dataIndex: 'msg' }
+	    ]});
+
+	var move_to_end = true;
+
+	clstore.on("load", function() {
+	    if (move_to_end) {
+		move_to_end = false;
+		var count = clstore.getCount();
+		if (count) {
+		    var item = cllogview.getNode(count - 1);
+		    if (item) 
+			Ext.fly(item).scrollIntoView(cllogview.innerBody.dom.parentNode);
+		}
+	    }
+	});
+
+	self.items = {
+	    xtype: 'tabpanel',
+ 	    border: false,
+	    tabPosition: 'bottom',
+            activeTab: 0,
+
+	    defaults: { layout: 'fit' },
+
+	    items: [
+		{
+                    title: 'Cluster Log',
+		    items: cllogview
+ 		},
+		{
+                    title: 'System Log'
+		},
+		{
+                    title: 'Task list'
+		}
+	    ]
+ 	};	
+
+	PVE.StatusPanel.superclass.initComponent.call(self);
+
+    }
+});
+
+Ext.reg('pveStatusPanel', PVE.StatusPanel);
+

Modified: pve-manager/pve2/www/manager/Workspace.js
===================================================================
--- pve-manager/pve2/www/manager/Workspace.js	2011-01-13 09:35:08 UTC (rev 5383)
+++ pve-manager/pve2/www/manager/Workspace.js	2011-01-13 13:18:54 UTC (rev 5384)
@@ -50,11 +50,12 @@
 		    collapsible: true
 		},
 		{
+		    xtype: 'pveStatusPanel',
 		    region:'south',
-		    margins:'0 0 5 0',
-		    split:true,
-		    height: 100,
-		    html: 'just a test status'
+		    margins:'0 0 0 0',
+	    	    height: 200,       
+		    collapsible: true,
+		    split:true
 		}
 	    ]
 	});




More information about the pve-devel mailing list