[pve-devel] r5482 - pve-manager/pve2/www/manager

svn-commits at proxmox.com svn-commits at proxmox.com
Wed Feb 2 14:41:02 CET 2011


Author: dietmar
Date: 2011-02-02 14:41:02 +0100 (Wed, 02 Feb 2011)
New Revision: 5482

Modified:
   pve-manager/pve2/www/manager/StatusPanel.js
Log:
factor out log viewer


Modified: pve-manager/pve2/www/manager/StatusPanel.js
===================================================================
--- pve-manager/pve2/www/manager/StatusPanel.js	2011-02-02 12:45:44 UTC (rev 5481)
+++ pve-manager/pve2/www/manager/StatusPanel.js	2011-02-02 13:41:02 UTC (rev 5482)
@@ -1,35 +1,27 @@
 Ext.ns("PVE");
 
-PVE.StatusPanel = Ext.extend(Ext.Panel, {
+PVE.LogViewer = Ext.extend(Ext.list.ListView, {
 
     initComponent : function() {
 	var self = this;
 
-	self.title = "Realtime logfile viewer";
-	self.layout = 'fit';
-
 	var fields = [ 
 	    { name:	'time', type : 'date', dateFormat: 'timestamp' }, 
 	    { name: 'pri', type: 'int' },
 	    { name: 'pid', type: 'int' },
 	    'node', 'user', 'tag', 'msg' ];
 
-	var sysstore = new  PVE.data.UpdateStore({
-	    itype: 'storage',
+	var logstore = new PVE.data.UpdateStore({
+	    itype: 'log',
 	    autoDestroy: true,
-	    url: '/api2/json/nodes/maui/syslog',
+	    url: self.url,
 	    fields: fields
 	});
 
-	var clstore = new  PVE.data.UpdateStore({
-	    itype: 'storage',
-	    autoDestroy: false,
-	    url: '/api2/json/cluster/log',
-	    fields: fields
-	});
-
-	var cllogview = new Ext.list.ListView({
-	    store: clstore,
+	Ext.apply(self, {
+	    store: logstore,
+	    startUpdate: function() { logstore.startUpdate(); },
+	    stopUpdate: function() { logstore.stopUpdate(); },
 	    columnSort: false,
 	    columns: [
 		{ header: "Time", width: 0.10, dataIndex: 'time',
@@ -45,50 +37,38 @@
 		{ header: "Message", dataIndex: 'msg' }
 	    ]});
 
-	var cl_move_to_end = true;
+	var move_to_end = true;
 
-	clstore.on("load", function() {
-	    if (cl_move_to_end) {
-		cl_move_to_end = false;
-		var count = clstore.getCount();
+	logstore.on("load", function() {
+	    if (move_to_end) {
+		move_to_end = false;
+		var count = logstore.getCount();
 		if (count) {
-		    var item = cllogview.getNode(count - 1);
+		    var item = self.getNode(count - 1);
 		    if (item) 
-			Ext.fly(item).scrollIntoView(cllogview.innerBody.dom.parentNode);
+			Ext.fly(item).scrollIntoView(self.innerBody.dom.parentNode);
 		}
 	    }
 	});
+ 
+	PVE.LogViewer.superclass.initComponent.call(self);
+    }
+});
 
-	var sysview = new Ext.list.ListView({
-	    store: sysstore,
-	    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' }
-	    ]});
+PVE.StatusPanel = Ext.extend(Ext.Panel, {
 
-	var sys_move_to_end = true;
+    initComponent : function() {
+	var self = this;
 
-	sysstore.on("load", function() {
-	    if (sys_move_to_end) {
-		sys_move_to_end = false;
-		var count = sysstore.getCount();
-		if (count) {
-		    var item = sysview.getNode(count - 1);
-		    if (item) 
-			Ext.fly(item).scrollIntoView(sysview.innerBody.dom.parentNode);
-		}
-	    }
+	self.title = "Realtime logfile viewer";
+	self.layout = 'fit';
+
+	var syslogview = new PVE.LogViewer({ 
+	    url: '/api2/json/nodes/localhost/syslog'
 	});
+	var cllogview = new PVE.LogViewer({ 
+	    url: '/api2/json/cluster/log',
+	});
 
 	self.items = {
 	    xtype: 'tabpanel',
@@ -104,22 +84,22 @@
 		    items: cllogview,
 		    listeners: {
 			show: function() {
-			    clstore.startUpdate();
+			    cllogview.startUpdate();
 			},
 			hide: function() {
-			    clstore.stopUpdate();
+			    cllogview.stopUpdate();
 			}
 		    }
  		},
 		{
                     title: 'System Log',
-		    items: sysview,
+		    items: syslogview,
 		    listeners: {
 			show: function() {
-			    sysstore.startUpdate();
+			    syslogview.startUpdate();
 			},
 			hide: function() {
-			    sysstore.stopUpdate();
+			    syslogview.stopUpdate();
 			}
 		    }
  		},




More information about the pve-devel mailing list