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

svn-commits at proxmox.com svn-commits at proxmox.com
Fri Jan 28 15:20:26 CET 2011


Author: dietmar
Date: 2011-01-28 15:20:26 +0100 (Fri, 28 Jan 2011)
New Revision: 5466

Modified:
   pve-manager/pve2/www/manager/PVEConsole.js
   pve-manager/pve2/www/manager/Workspace.js
Log:
implement more console commands


Modified: pve-manager/pve2/www/manager/PVEConsole.js
===================================================================
--- pve-manager/pve2/www/manager/PVEConsole.js	2011-01-28 14:17:35 UTC (rev 5465)
+++ pve-manager/pve2/www/manager/PVEConsole.js	2011-01-28 14:20:26 UTC (rev 5466)
@@ -143,19 +143,85 @@
 	    });
 	};
 
-	box.on("afterrender", reload);
+	self.on("show", function() { reload();});
+	self.on("hide", function() { box.update(""); });
 
+	// Hint: we cant display html over the applet (applet z-index bug)
+	// So we need to use aller()/confirm() instead of Ext.Msg
+
+	var vm_command = function(cmd, reload_applet) {
+	    Ext.Ajax.request({
+		url: "/api2/json/vms/qemu/status/" + node + "/" + vmid,
+		params: { command: cmd },
+		method: 'PUT',
+		failure: function(response, opts) {
+		    alert("Command '" + cmd + "' failed" +
+			"- error " + response.status + ": " 
+			  + response.statusText);
+//		    Ext.Msg.show({
+//			title: "Command '" + cmd + "' failed",
+//			msg: "Error " + response.status + ": " 
+//			    + response.statusText,
+//			icon: Ext.MessageBox.ALERT
+//		    });
+		},
+		success: function() {
+		    if (reload_applet) reload.defer(1000, self);
+		}
+	    });
+	};
+
 	var tbar = [ 
-	    { text: 'Start'},
-	    { text: 'Stop'},
-	    { text: 'CAD' ,
-	      handler: function() { 
-		  var applet = Ext.getDom(myid);
-		  applet.sendCtrlAltDel();
-	      }
+	    { 
+		text: 'Start',
+		handler: function() { 
+		    vm_command("start", 1);
+		}
 	    },
+	    { 
+		text: 'Stop',
+		handler: function() {
+		    if (confirm("Do you really want to stop the VM?"))
+			vm_command("stop"); 
+		}
+	    },
+	    { 
+		text: 'Reset',
+		handler: function() { 
+		    if (confirm("Do you really want to reset the VM?"))
+			vm_command("reset"); 
+		}
+	    },
+	    { 
+		text: 'Shutdown',
+		handler: function() {
+		    // normally, the OS ask the user
+		    //if (confirm("Do you really want to shut down the VM?"))
+		    vm_command("shutdown"); 
+		}
+	    },
+	    { 
+		text: 'Suspend',
+		handler: function() {
+		    if (confirm("Do you really want to suspend the VM?"))
+			vm_command("suspend"); 
+		}
+	    },
+	    { 
+		text: 'Resume',
+		handler: function() {
+		    vm_command("resume"); 
+		}
+	    },
             '->',
 	    {
+                text: 'Refresh',
+		handler: function() { 
+		    var applet = Ext.getDom(myid);
+		    applet.sendRefreshRequest();
+ 		}
+	    },
+ 	    {
                 text: 'Reload',
                 handler: reload
 	    },

Modified: pve-manager/pve2/www/manager/Workspace.js
===================================================================
--- pve-manager/pve2/www/manager/Workspace.js	2011-01-28 14:17:35 UTC (rev 5465)
+++ pve-manager/pve2/www/manager/Workspace.js	2011-01-28 14:20:26 UTC (rev 5466)
@@ -79,6 +79,7 @@
 
 	viewport.add(content);
 	viewport.doLayout();	
+	content.show(); // fire 'show' for PVE.Console
     };
 
     var workspace = {




More information about the pve-devel mailing list