[pve-devel] r5986 - in pve-manager/pve2/www/new: . node qemu

svn-commits at proxmox.com svn-commits at proxmox.com
Tue May 17 08:25:40 CEST 2011


Author: dietmar
Date: 2011-05-17 08:25:40 +0200 (Tue, 17 May 2011)
New Revision: 5986

Added:
   pve-manager/pve2/www/new/node/StatusView.js
   pve-manager/pve2/www/new/node/Summary.js
   pve-manager/pve2/www/new/qemu/StatusView.js
   pve-manager/pve2/www/new/qemu/Summary.js
Modified:
   pve-manager/pve2/www/new/Makefile.am
   pve-manager/pve2/www/new/node/Config.js
   pve-manager/pve2/www/new/qemu/Config.js
Log:
split code into seperate files


Modified: pve-manager/pve2/www/new/Makefile.am
===================================================================
--- pve-manager/pve2/www/new/Makefile.am	2011-05-17 05:59:43 UTC (rev 5985)
+++ pve-manager/pve2/www/new/Makefile.am	2011-05-17 06:25:40 UTC (rev 5986)
@@ -31,7 +31,11 @@
 	panel/ConfigPanel.js				\
 	node/TimeView.js				\
 	node/TimeEdit.js				\
+	node/StatusView.js				\
+	node/Summary.js					\
 	node/Config.js					\
+	qemu/StatusView.js				\
+	qemu/Summary.js					\
 	qemu/Config.js					\
 	qemu/HardwareView.js				\
 	qemu/CreateWizard.js				\

Modified: pve-manager/pve2/www/new/node/Config.js
===================================================================
--- pve-manager/pve2/www/new/node/Config.js	2011-05-17 05:59:43 UTC (rev 5985)
+++ pve-manager/pve2/www/new/node/Config.js	2011-05-17 06:25:40 UTC (rev 5986)
@@ -1,194 +1,3 @@
-Ext.define('PVE.node.StatusView', {
-    extend: 'PVE.grid.ObjectGrid',
-    alias: ['widget.pveNodeStatusView'],
-
-    initComponent : function() {
-	var me = this;
-
-	var render_cpuinfo = function(value) {
-	    return value.cpus + " x " + value.model;
-	};
-
-	var render_loadavg = function(value) {
-	    return value[0] + ", " + value[1] + ", " + value[2]; 
-	};
-
-	var render_cpu = function(value) {
-	    var per = value * 100;
-	    return per.toFixed(2) + "%";
-	};
-
-	var render_meminfo = function(value) {
-	    var per = (value.used / value.total)*100;
-	    var text = "<div>Total: " + PVE.Utils.format_size(value.total) + "</div>" + 
-		"<div>Used: " + PVE.Utils.format_size(value.used) + "</div>";
-	    return text;
-	};
-
-	var rows = {
-	    uptime: { header: 'Uptime', required: true, renderer: PVE.Utils.format_duration_long },
-	    loadavg: { header: 'Load average', required: true, renderer: render_loadavg },
-	    cpuinfo: { header: 'CPUs', required: true, renderer: render_cpuinfo },
-	    cpu: { header: 'CPU usage',required: true,  renderer: render_cpu },
-	    wait: { header: 'IO delay', required: true, renderer: render_cpu },
-	    memory: { header: 'RAM usage', required: true, renderer: render_meminfo },
-	    swap: { header: 'SWAP usage', required: true, renderer: render_meminfo },
-	    rootfs: { header: 'HD space (root)', required: true, renderer: render_meminfo },
-	    pveversion: { header: 'PVE Manager version', required: true,},
-	    kversion: { header: 'Kernel version', required: true,}
-	};
-
-	Ext.applyIf(me, {
-	    cwidth1: 150,
-	    interval: 1000,
-	    height: 286,
-	    rows: rows
-	});
-
-	me.callParent();
-    }
-});
-
-Ext.define('PVE.node.Summary', {
-    extend: 'Ext.panel.Panel',
-    alias: 'widget.pveNodeSummary',
-
-    initComponent: function() {
-        var me = this;
-
-	var nodename = me.pveSelNode.data.node;
-	if (!nodename) 
-	    throw "no node name specified";
-
-	rstore = Ext.create('PVE.data.ObjectStore', { 
-	    url: "/api2/json/nodes/" + nodename + "/status",
-	    interval: 1000
-	});
-
-	var node_command = function(cmd) {
-	    me.setLoading(true, true);
-	    PVE.Utils.API2Request({
-		params: { command: cmd },
-		url: '/nodes/' + nodename + '/status',
-		method: 'POST',
-		callback: function() {
-		    me.setLoading(false);
-		},
-		failure: function(response, opts) {
-		    Ext.Msg.alert('Error', response.htmlStatus);
-		}
-	    });
-	};
-
-	var rrdurl = "/api2/png/nodes/" + nodename + "/rrd";
-  
-	var tbar = Ext.create('Ext.toolbar.Toolbar', {
-	    items: [
-		{
-		    itemId: 'reboot',
-		    text: 'Reboot',
-		    handler: function() { 
-			var msg = "Do you really want to reboot node '" + nodename + "'?";
-			Ext.Msg.confirm('Confirm', msg, function(btn) {
-			    if (btn !== 'yes')
-				return;
-			    node_command('reboot');
-			});
-		    }
-		},
-		{ 
-		    itemId: 'shutdown',
-		    text: 'Shutdown', 
-		    handler: function() { 
-			var msg = "Do you really want to shutdown node '" + nodename + "'?";
-			Ext.Msg.confirm('Confirm', msg, function(btn) {
-			    if (btn !== 'yes')
-				return;
-			    node_command('shutdown');
-			});
-		    }
-		},
-		{ 
-		    itemId: 'shell',
-		    text: 'Shell',
-		    handler: function() {
-			var url = Ext.urlEncode({
-			    console: 'shell',
-			    node: nodename
-			});
-			var nw = window.open("?" + url, '_blank', 
-					     "innerWidth=745,innerheight=427");
-			nw.focus();
-		    }
-		}, '->',
-		{
-		    xtype: 'pveRRDTypeSelector'
-		}
-	    ]
-	});
-
-	me.mon(rstore, 'load', function(s, records, success) {
-	    var uptimerec = s.data.get('uptime');
-	    var uptime = uptimerec ? uptimerec.data.value : false;
-
-	    tbar.down('#reboot').setDisabled(!uptime);
-	    tbar.down('#shutdown').setDisabled(!uptime);
-	    tbar.down('#shell').setDisabled(!uptime);
-	});
-
-	Ext.apply(me, {
-	    layout: {
-		type: 'table',
-		columns: 1
-	    },
-	    autoScroll: true,
-	    bodyStyle: 'padding:10px',
-	    defaults: {
-		style: 'padding-bottom:10px'
-	    },		
-	    tbar: tbar,
-	    items: [
-		{
-		    title: 'Status',
-		    xtype: 'pveNodeStatusView',
-		    rstore: rstore,
-		    width: 800
-		},
-		{
-		    xtype: 'pveRRDView',
-		    title: "CPU usage %",
-		    datasource: 'cpu,iowait',
-		    rrdurl: rrdurl
-		},
-		{
-		    xtype: 'pveRRDView',
-		    title: "Server load",
-		    datasource: 'loadavg',
-		    rrdurl: rrdurl
-		},
-		{
-		    xtype: 'pveRRDView',
-		    title: "Memory usage",
-		    datasource: 'memtotal,memused',
-		    rrdurl: rrdurl
-		},
-		{
-		    xtype: 'pveRRDView',
-		    title: "Network traffic",
-		    datasource: 'netin,netout',
-		    rrdurl: rrdurl
-		}
-	    ]
-	});
-
-	me.on('show', rstore.startUpdate);
-	me.on('hide', rstore.stopUpdate);
-	me.on('destroy', rstore.stopUpdate);	
-
-	me.callParent();
-    }
-});
-
 Ext.define('PVE.node.Config', {
     extend: 'PVE.panel.Config',
     alias: 'widget.PVE.node.Config',

Added: pve-manager/pve2/www/new/node/StatusView.js
===================================================================
--- pve-manager/pve2/www/new/node/StatusView.js	                        (rev 0)
+++ pve-manager/pve2/www/new/node/StatusView.js	2011-05-17 06:25:40 UTC (rev 5986)
@@ -0,0 +1,50 @@
+Ext.define('PVE.node.StatusView', {
+    extend: 'PVE.grid.ObjectGrid',
+    alias: ['widget.pveNodeStatusView'],
+
+    initComponent : function() {
+	var me = this;
+
+	var render_cpuinfo = function(value) {
+	    return value.cpus + " x " + value.model;
+	};
+
+	var render_loadavg = function(value) {
+	    return value[0] + ", " + value[1] + ", " + value[2]; 
+	};
+
+	var render_cpu = function(value) {
+	    var per = value * 100;
+	    return per.toFixed(2) + "%";
+	};
+
+	var render_meminfo = function(value) {
+	    var per = (value.used / value.total)*100;
+	    var text = "<div>Total: " + PVE.Utils.format_size(value.total) + "</div>" + 
+		"<div>Used: " + PVE.Utils.format_size(value.used) + "</div>";
+	    return text;
+	};
+
+	var rows = {
+	    uptime: { header: 'Uptime', required: true, renderer: PVE.Utils.format_duration_long },
+	    loadavg: { header: 'Load average', required: true, renderer: render_loadavg },
+	    cpuinfo: { header: 'CPUs', required: true, renderer: render_cpuinfo },
+	    cpu: { header: 'CPU usage',required: true,  renderer: render_cpu },
+	    wait: { header: 'IO delay', required: true, renderer: render_cpu },
+	    memory: { header: 'RAM usage', required: true, renderer: render_meminfo },
+	    swap: { header: 'SWAP usage', required: true, renderer: render_meminfo },
+	    rootfs: { header: 'HD space (root)', required: true, renderer: render_meminfo },
+	    pveversion: { header: 'PVE Manager version', required: true,},
+	    kversion: { header: 'Kernel version', required: true,}
+	};
+
+	Ext.applyIf(me, {
+	    cwidth1: 150,
+	    interval: 1000,
+	    height: 286,
+	    rows: rows
+	});
+
+	me.callParent();
+    }
+});

Added: pve-manager/pve2/www/new/node/Summary.js
===================================================================
--- pve-manager/pve2/www/new/node/Summary.js	                        (rev 0)
+++ pve-manager/pve2/www/new/node/Summary.js	2011-05-17 06:25:40 UTC (rev 5986)
@@ -0,0 +1,139 @@
+Ext.define('PVE.node.Summary', {
+    extend: 'Ext.panel.Panel',
+    alias: 'widget.pveNodeSummary',
+
+    initComponent: function() {
+        var me = this;
+
+	var nodename = me.pveSelNode.data.node;
+	if (!nodename) 
+	    throw "no node name specified";
+
+	rstore = Ext.create('PVE.data.ObjectStore', { 
+	    url: "/api2/json/nodes/" + nodename + "/status",
+	    interval: 1000
+	});
+
+	var node_command = function(cmd) {
+	    me.setLoading(true, true);
+	    PVE.Utils.API2Request({
+		params: { command: cmd },
+		url: '/nodes/' + nodename + '/status',
+		method: 'POST',
+		callback: function() {
+		    me.setLoading(false);
+		},
+		failure: function(response, opts) {
+		    Ext.Msg.alert('Error', response.htmlStatus);
+		}
+	    });
+	};
+
+	var rrdurl = "/api2/png/nodes/" + nodename + "/rrd";
+  
+	var tbar = Ext.create('Ext.toolbar.Toolbar', {
+	    items: [
+		{
+		    itemId: 'reboot',
+		    text: 'Reboot',
+		    handler: function() { 
+			var msg = "Do you really want to reboot node '" + nodename + "'?";
+			Ext.Msg.confirm('Confirm', msg, function(btn) {
+			    if (btn !== 'yes')
+				return;
+			    node_command('reboot');
+			});
+		    }
+		},
+		{ 
+		    itemId: 'shutdown',
+		    text: 'Shutdown', 
+		    handler: function() { 
+			var msg = "Do you really want to shutdown node '" + nodename + "'?";
+			Ext.Msg.confirm('Confirm', msg, function(btn) {
+			    if (btn !== 'yes')
+				return;
+			    node_command('shutdown');
+			});
+		    }
+		},
+		{ 
+		    itemId: 'shell',
+		    text: 'Shell',
+		    handler: function() {
+			var url = Ext.urlEncode({
+			    console: 'shell',
+			    node: nodename
+			});
+			var nw = window.open("?" + url, '_blank', 
+					     "innerWidth=745,innerheight=427");
+			nw.focus();
+		    }
+		}, '->',
+		{
+		    xtype: 'pveRRDTypeSelector'
+		}
+	    ]
+	});
+
+	me.mon(rstore, 'load', function(s, records, success) {
+	    var uptimerec = s.data.get('uptime');
+	    var uptime = uptimerec ? uptimerec.data.value : false;
+
+	    tbar.down('#reboot').setDisabled(!uptime);
+	    tbar.down('#shutdown').setDisabled(!uptime);
+	    tbar.down('#shell').setDisabled(!uptime);
+	});
+
+	Ext.apply(me, {
+	    layout: {
+		type: 'table',
+		columns: 1
+	    },
+	    autoScroll: true,
+	    bodyStyle: 'padding:10px',
+	    defaults: {
+		style: 'padding-bottom:10px'
+	    },		
+	    tbar: tbar,
+	    items: [
+		{
+		    title: 'Status',
+		    xtype: 'pveNodeStatusView',
+		    rstore: rstore,
+		    width: 800
+		},
+		{
+		    xtype: 'pveRRDView',
+		    title: "CPU usage %",
+		    datasource: 'cpu,iowait',
+		    rrdurl: rrdurl
+		},
+		{
+		    xtype: 'pveRRDView',
+		    title: "Server load",
+		    datasource: 'loadavg',
+		    rrdurl: rrdurl
+		},
+		{
+		    xtype: 'pveRRDView',
+		    title: "Memory usage",
+		    datasource: 'memtotal,memused',
+		    rrdurl: rrdurl
+		},
+		{
+		    xtype: 'pveRRDView',
+		    title: "Network traffic",
+		    datasource: 'netin,netout',
+		    rrdurl: rrdurl
+		}
+	    ]
+	});
+
+	me.on('show', rstore.startUpdate);
+	me.on('hide', rstore.stopUpdate);
+	me.on('destroy', rstore.stopUpdate);	
+
+	me.callParent();
+    }
+});

Modified: pve-manager/pve2/www/new/qemu/Config.js
===================================================================
--- pve-manager/pve2/www/new/qemu/Config.js	2011-05-17 05:59:43 UTC (rev 5985)
+++ pve-manager/pve2/www/new/qemu/Config.js	2011-05-17 06:25:40 UTC (rev 5986)
@@ -1,270 +1,3 @@
-Ext.define('PVE.qemu.StatusView', {
-    extend: 'PVE.grid.ObjectGrid',
-    alias: ['widget.pveQemuStatusView'],
-
-    initComponent : function() {
-	var me = this;
-
-	var nodename = me.pveSelNode.data.node;
-	if (!nodename) 
-	    throw "no node name specified";
-
-	var vmid = me.pveSelNode.data.vmid;
-	if (!vmid) 
-	    throw "no VM ID specified";
-
-	var render_cpu = function(value, metaData, record, rowIndex, colIndex, store) {
-	    if (!me.getObjectValue('uptime'))
-		return '-';
-
-	    var maxcpu = me.getObjectValue('cpus', 1);
-	    var uptime = me.getObjectValue('uptime');
-
-	    if (!(Ext.isNumeric(value) && Ext.isNumeric(maxcpu) && (maxcpu >= 1)))
-		return '-'
-
-	    var per = (value * 100) / maxcpu;
-
-	    return per.toFixed(1) + '% of ' + maxcpu + (maxcpu > 1 ? 'CPUs' : 'CPU');
- 	};
-
-	var render_mem = function(value, metaData, record, rowIndex, colIndex, store) {
-	    var maxmem = me.getObjectValue('maxmem', 0);
-	    var per = (value / maxmem)*100;
-	    var text = "<div>Total: " + PVE.Utils.format_size(maxmem) + "</div>" + 
-		"<div>Used: " + PVE.Utils.format_size(value) + "</div>";
-	    return text;
-	};
-
-	var rows = {
-	    name: { header: 'Name', defaultValue: 'no name specified' },
-	    status: { header: 'Status', defaultValue: 'unknown' },
-	    cpu: { header: 'CPU usage', required: true,  renderer: render_cpu },
-	    cpus: { visible: false },
-	    mem: { header: 'Memory usage', required: true,  renderer: render_mem },
-	    maxmem: { visible: false },
-	    uptime: { header: 'Uptime', required: true, renderer: PVE.Utils.render_uptime }
-	};
-
-	Ext.applyIf(me, {
-	    url: "/api2/json/nodes/" + nodename + "/qemu/" + vmid + "/status",
-	    cwidth1: 150,
-	    height: 145,
-	    interval: 1000,
-	    rows: rows,
-	});
-
-	me.callParent();
-    }
-});
-
-Ext.define('PVE.qemu.Summary', {
-    extend: 'Ext.panel.Panel',
-    alias: 'widget.pveQemuSummary',
-
-    initComponent: function() {
-        var me = this;
-
-	var nodename = me.pveSelNode.data.node;
-	if (!nodename) 
-	    throw "no node name specified";
-
-	var vmid = me.pveSelNode.data.vmid;
-	if (!vmid) 
-	    throw "no VM ID specified";
-
-	rstore = Ext.create('PVE.data.ObjectStore', { 
-	    url: "/api2/json/nodes/" + nodename + "/qemu/" + vmid + "/status",
-	    interval: 1000
-	});
-
-	var rrdurl = "/api2/png/nodes/" + nodename + "/qemu/" + vmid + "/rrd";
-
-	var vm_command = function(cmd) {
-	    me.setLoading(true, true);
-	    PVE.Utils.API2Request({
-		params: { command: cmd },
-		url: '/nodes/' + nodename + '/qemu/' + vmid + "/status",
-		method: 'PUT',
-		callback: function() {
-		    me.setLoading(false);
-		},
-		failure: function(response, opts) {
-		    Ext.Msg.alert('Error', response.htmlStatus);
-		}
-	    });
-	};
-
-	var tbar = Ext.create('Ext.toolbar.Toolbar', {
-	    items: [
-		{ 
-		    itemId: 'start',
-		    text: 'Start',
-		    handler: function() {
-			vm_command('start');
-		    }			    
-		}, 
-		{ 
-		    itemId: 'stop',
-		    text: 'Stop',
-		    handler: function() {
-			var msg = "Do you really want to stop the VM?";
-			Ext.Msg.confirm('Confirm', msg, function(btn) {
-			    if (btn !== 'yes')
-				return;
-			    vm_command("stop");
-			}); 
-		    }
-		},
-		{ 
-		    text: 'Reset',
-		    itemId: 'reset',
-		    handler: function() { 
-			var msg = "Do you really want to reset the VM?";
-			Ext.Msg.confirm('Confirm', msg, function(btn) {
-			    if (btn !== 'yes')
-				return;
-			    vm_command("reset");
-			});
-		    }
-		},
-		{ 
-		    itemId: 'shutdown',
-		    text: 'Shutdown',
-		    handler: function() {
-			var msg = "Do you really want to shutdown the VM?";
-			Ext.Msg.confirm('Confirm', msg, function(btn) {
-			    if (btn !== 'yes')
-				return;
-			    vm_command('shutdown');
-			});
-		    }			    
-		}, 
-		{ 
-		    itemId: 'remove',
-		    text: 'Remove',
-		    handler: function() {
-			var msg = 'Are you sure you want to remove VM ' + 
-			    vmid + '? This will permanently erase all VM data.';
-			Ext.Msg.confirm('Confirm', msg, function(btn) {
-			    if (btn !== 'yes')
-				return;
-			    
-			    me.setLoading(true, true);
-			    PVE.Utils.API2Request({
-				url: '/nodes/' + nodename + '/qemu/' + vmid,
-				method: 'DELETE',
-				callback: function() {
-				    me.setLoading(false);
-				},
-				failure: function(response, opts) {
-				    Ext.Msg.alert('Error', response.htmlStatus);
-				}
-			    });
-			}); 
-		    }
-		},
-		{ 
-		    itemId: 'console',
-		    text: 'Console',
-		    handler: function() {
-			var url = Ext.urlEncode({
-			    console: 'kvm',
-			    vmid: vmid,
-			    node: nodename
-			});
-			var nw = window.open("?" + url, '_blank', 
-					     "innerWidth=745,innerheight=427");
-			nw.focus();
-		    }
-		}, '->',
-		{
-		    xtype: 'pveRRDTypeSelector'
-		}
-	    ]
-	});
-
-	me.mon(rstore, 'load', function(s, records, success) {
-	    var statusrec = s.data.get('status');
-	    var status = statusrec ? statusrec.data.value : 'unknown';
-
-	    tbar.down('#start').setDisabled(status === 'running');
-	    tbar.down('#reset').setDisabled(status !== 'running');
-	    tbar.down('#shutdown').setDisabled(status !== 'running');
-	    tbar.down('#stop').setDisabled(status === 'stopped');
-	    tbar.down('#console').setDisabled(status !== 'running');
-	    tbar.down('#remove').setDisabled(status !== 'stopped');
-	});
-
-	Ext.apply(me, {
-	    tbar: tbar,
-	    layout: {
-		type: 'table',
-		columns: 1
-	    },
-	    autoScroll: true,
-	    bodyStyle: 'padding:10px',
-	    defaults: {
-		style: 'padding-bottom:10px'
-	    },		
-	    items: [
-		{
-		    layout: {
-			type: 'hbox',
-			align: 'stretchmax'
-		    },
-		    width: 800,
-		    border: false,
-		    items: [
-			{
-			    title: 'Status',
-			    xtype: 'pveQemuStatusView',
-			    pveSelNode: me.pveSelNode,
-			    rstore: rstore,
-			    width: 400
-			},
-			{
-			    title: 'Comments',
-			    style: 'padding-left:10px',
-			    pveSelNode: me.pveSelNode,
-			    rstore: rstore,
-			    html: "test",
-			    width: 400
-			}
-		    ]
-		},
-		{
-		    xtype: 'pveRRDView',
-		    title: "CPU usage %",
-		    pveSelNode: me.pveSelNode,
-		    datasource: 'cpu',
-		    rrdurl: rrdurl
-		},
-		{
-		    xtype: 'pveRRDView',
-		    title: "Memory usage",
-		    pveSelNode: me.pveSelNode,
-		    datasource: 'mem,maxmem',
-		    rrdurl: rrdurl
-		},
-		{
-		    xtype: 'pveRRDView',
-		    title: "Network traffic",
-		    pveSelNode: me.pveSelNode,
-		    datasource: 'netin,netout',
-		    rrdurl: rrdurl
-		}
-	    ]
-	});
-
-	me.on('show', rstore.startUpdate);
-	me.on('hide', rstore.stopUpdate);
-	me.on('destroy', rstore.stopUpdate);	
-
- 	me.callParent();
-    }
-});
-
 Ext.define('PVE.qemu.Config', {
     extend: 'PVE.panel.Config',
     alias: 'widget.PVE.qemu.Config',

Added: pve-manager/pve2/www/new/qemu/StatusView.js
===================================================================
--- pve-manager/pve2/www/new/qemu/StatusView.js	                        (rev 0)
+++ pve-manager/pve2/www/new/qemu/StatusView.js	2011-05-17 06:25:40 UTC (rev 5986)
@@ -0,0 +1,59 @@
+Ext.define('PVE.qemu.StatusView', {
+    extend: 'PVE.grid.ObjectGrid',
+    alias: ['widget.pveQemuStatusView'],
+
+    initComponent : function() {
+	var me = this;
+
+	var nodename = me.pveSelNode.data.node;
+	if (!nodename) 
+	    throw "no node name specified";
+
+	var vmid = me.pveSelNode.data.vmid;
+	if (!vmid) 
+	    throw "no VM ID specified";
+
+	var render_cpu = function(value, metaData, record, rowIndex, colIndex, store) {
+	    if (!me.getObjectValue('uptime'))
+		return '-';
+
+	    var maxcpu = me.getObjectValue('cpus', 1);
+	    var uptime = me.getObjectValue('uptime');
+
+	    if (!(Ext.isNumeric(value) && Ext.isNumeric(maxcpu) && (maxcpu >= 1)))
+		return '-'
+
+	    var per = (value * 100) / maxcpu;
+
+	    return per.toFixed(1) + '% of ' + maxcpu + (maxcpu > 1 ? 'CPUs' : 'CPU');
+ 	};
+
+	var render_mem = function(value, metaData, record, rowIndex, colIndex, store) {
+	    var maxmem = me.getObjectValue('maxmem', 0);
+	    var per = (value / maxmem)*100;
+	    var text = "<div>Total: " + PVE.Utils.format_size(maxmem) + "</div>" + 
+		"<div>Used: " + PVE.Utils.format_size(value) + "</div>";
+	    return text;
+	};
+
+	var rows = {
+	    name: { header: 'Name', defaultValue: 'no name specified' },
+	    status: { header: 'Status', defaultValue: 'unknown' },
+	    cpu: { header: 'CPU usage', required: true,  renderer: render_cpu },
+	    cpus: { visible: false },
+	    mem: { header: 'Memory usage', required: true,  renderer: render_mem },
+	    maxmem: { visible: false },
+	    uptime: { header: 'Uptime', required: true, renderer: PVE.Utils.render_uptime }
+	};
+
+	Ext.applyIf(me, {
+	    url: "/api2/json/nodes/" + nodename + "/qemu/" + vmid + "/status",
+	    cwidth1: 150,
+	    height: 145,
+	    interval: 1000,
+	    rows: rows,
+	});
+
+	me.callParent();
+    }
+});

Added: pve-manager/pve2/www/new/qemu/Summary.js
===================================================================
--- pve-manager/pve2/www/new/qemu/Summary.js	                        (rev 0)
+++ pve-manager/pve2/www/new/qemu/Summary.js	2011-05-17 06:25:40 UTC (rev 5986)
@@ -0,0 +1,206 @@
+Ext.define('PVE.qemu.Summary', {
+    extend: 'Ext.panel.Panel',
+    alias: 'widget.pveQemuSummary',
+
+    initComponent: function() {
+        var me = this;
+
+	var nodename = me.pveSelNode.data.node;
+	if (!nodename) 
+	    throw "no node name specified";
+
+	var vmid = me.pveSelNode.data.vmid;
+	if (!vmid) 
+	    throw "no VM ID specified";
+
+	rstore = Ext.create('PVE.data.ObjectStore', { 
+	    url: "/api2/json/nodes/" + nodename + "/qemu/" + vmid + "/status",
+	    interval: 1000
+	});
+
+	var rrdurl = "/api2/png/nodes/" + nodename + "/qemu/" + vmid + "/rrd";
+
+	var vm_command = function(cmd) {
+	    me.setLoading(true, true);
+	    PVE.Utils.API2Request({
+		params: { command: cmd },
+		url: '/nodes/' + nodename + '/qemu/' + vmid + "/status",
+		method: 'PUT',
+		callback: function() {
+		    me.setLoading(false);
+		},
+		failure: function(response, opts) {
+		    Ext.Msg.alert('Error', response.htmlStatus);
+		}
+	    });
+	};
+
+	var tbar = Ext.create('Ext.toolbar.Toolbar', {
+	    items: [
+		{ 
+		    itemId: 'start',
+		    text: 'Start',
+		    handler: function() {
+			vm_command('start');
+		    }			    
+		}, 
+		{ 
+		    itemId: 'stop',
+		    text: 'Stop',
+		    handler: function() {
+			var msg = "Do you really want to stop the VM?";
+			Ext.Msg.confirm('Confirm', msg, function(btn) {
+			    if (btn !== 'yes')
+				return;
+			    vm_command("stop");
+			}); 
+		    }
+		},
+		{ 
+		    text: 'Reset',
+		    itemId: 'reset',
+		    handler: function() { 
+			var msg = "Do you really want to reset the VM?";
+			Ext.Msg.confirm('Confirm', msg, function(btn) {
+			    if (btn !== 'yes')
+				return;
+			    vm_command("reset");
+			});
+		    }
+		},
+		{ 
+		    itemId: 'shutdown',
+		    text: 'Shutdown',
+		    handler: function() {
+			var msg = "Do you really want to shutdown the VM?";
+			Ext.Msg.confirm('Confirm', msg, function(btn) {
+			    if (btn !== 'yes')
+				return;
+			    vm_command('shutdown');
+			});
+		    }			    
+		}, 
+		{ 
+		    itemId: 'remove',
+		    text: 'Remove',
+		    handler: function() {
+			var msg = 'Are you sure you want to remove VM ' + 
+			    vmid + '? This will permanently erase all VM data.';
+			Ext.Msg.confirm('Confirm', msg, function(btn) {
+			    if (btn !== 'yes')
+				return;
+			    
+			    me.setLoading(true, true);
+			    PVE.Utils.API2Request({
+				url: '/nodes/' + nodename + '/qemu/' + vmid,
+				method: 'DELETE',
+				callback: function() {
+				    me.setLoading(false);
+				},
+				failure: function(response, opts) {
+				    Ext.Msg.alert('Error', response.htmlStatus);
+				}
+			    });
+			}); 
+		    }
+		},
+		{ 
+		    itemId: 'console',
+		    text: 'Console',
+		    handler: function() {
+			var url = Ext.urlEncode({
+			    console: 'kvm',
+			    vmid: vmid,
+			    node: nodename
+			});
+			var nw = window.open("?" + url, '_blank', 
+					     "innerWidth=745,innerheight=427");
+			nw.focus();
+		    }
+		}, '->',
+		{
+		    xtype: 'pveRRDTypeSelector'
+		}
+	    ]
+	});
+
+	me.mon(rstore, 'load', function(s, records, success) {
+	    var statusrec = s.data.get('status');
+	    var status = statusrec ? statusrec.data.value : 'unknown';
+
+	    tbar.down('#start').setDisabled(status === 'running');
+	    tbar.down('#reset').setDisabled(status !== 'running');
+	    tbar.down('#shutdown').setDisabled(status !== 'running');
+	    tbar.down('#stop').setDisabled(status === 'stopped');
+	    tbar.down('#console').setDisabled(status !== 'running');
+	    tbar.down('#remove').setDisabled(status !== 'stopped');
+	});
+
+	Ext.apply(me, {
+	    tbar: tbar,
+	    layout: {
+		type: 'table',
+		columns: 1
+	    },
+	    autoScroll: true,
+	    bodyStyle: 'padding:10px',
+	    defaults: {
+		style: 'padding-bottom:10px'
+	    },		
+	    items: [
+		{
+		    layout: {
+			type: 'hbox',
+			align: 'stretchmax'
+		    },
+		    width: 800,
+		    border: false,
+		    items: [
+			{
+			    title: 'Status',
+			    xtype: 'pveQemuStatusView',
+			    pveSelNode: me.pveSelNode,
+			    rstore: rstore,
+			    width: 400
+			},
+			{
+			    title: 'Comments',
+			    style: 'padding-left:10px',
+			    pveSelNode: me.pveSelNode,
+			    rstore: rstore,
+			    html: "test",
+			    width: 400
+			}
+		    ]
+		},
+		{
+		    xtype: 'pveRRDView',
+		    title: "CPU usage %",
+		    pveSelNode: me.pveSelNode,
+		    datasource: 'cpu',
+		    rrdurl: rrdurl
+		},
+		{
+		    xtype: 'pveRRDView',
+		    title: "Memory usage",
+		    pveSelNode: me.pveSelNode,
+		    datasource: 'mem,maxmem',
+		    rrdurl: rrdurl
+		},
+		{
+		    xtype: 'pveRRDView',
+		    title: "Network traffic",
+		    pveSelNode: me.pveSelNode,
+		    datasource: 'netin,netout',
+		    rrdurl: rrdurl
+		}
+	    ]
+	});
+
+	me.on('show', rstore.startUpdate);
+	me.on('hide', rstore.stopUpdate);
+	me.on('destroy', rstore.stopUpdate);	
+
+ 	me.callParent();
+    }
+});




More information about the pve-devel mailing list