Index: trunk/web/templates/info.tmpl
===================================================================
--- trunk/web/templates/info.tmpl	(revision 187)
+++ trunk/web/templates/info.tmpl	(revision 205)
@@ -6,7 +6,5 @@
 #end def
 
-
-#def body
-<h1>Info</h1>
+#def infoTable()
 <p>Info on ${machine.name}:</p>
 <table>
@@ -15,6 +13,18 @@
   #end for
 </table>
+#end def
 
-<p>Commands:</p>
+#def commands()
+<script>
+function commandButton(elt, action){
+  form = elt.up('', 4);
+  cdrom = Form.serialize(form, true).cdrom;
+  new Ajax.Request('command', {method: 'post', 
+  parameters: 'machine_id=$machine.machine_id&js=info&cdrom='+cdrom+'&action='+action,
+  onSuccess: replaceFunc
+  });
+  return false;
+}
+</script>
 <form action="command" action="POST">
   <input type="hidden" name="machine_id" value="$machine.machine_id"/>
@@ -34,47 +44,73 @@
       <tr>
 	#if $on
-	<td><input type="submit" class="button" name="action" value="Power off"/></td>
-	<td><input type="submit" class="button" name="action" value="Shutdown"/></td>
-	<td><input type="submit" class="button" name="action" value="Reboot"/></td>
+	<td><input type="submit" class="button" name="action" value="Power off" onclick="return commandButton(this, 'Power off');"/></td>
+	<td><input type="submit" class="button" name="action" value="Shutdown" onclick="return commandButton(this, 'Shutdown');"/></td>
+	<td><input type="submit" class="button" name="action" value="Reboot" onclick="return commandButton(this, 'Reboot');"/></td>
 	#else
-	<td><input type="submit" class="button" name="action" value="Power on"/></td>
+	<td><input type="submit" class="button" name="action" value="Power on" onclick="return commandButton(this, 'Power on');"/></td>
 	#end if
       <td>Boot CD:</td>
-      <td><select name="cdrom">
-	  <option selected value="">None</option>
-	  #for $cdrom in $cdroms
-	  <option value="$cdrom.cdrom_id">
-	    $cdrom.description
-	  </option>
-	  #end for
-      </select></td>
+      <td>$cdromList($cdroms)</td>
   </tr>
     <tr>
-      <td><input type="submit" class="button" name="action" value="Delete VM"/></td>
+      <td><input type="submit" class="button" name="action" value="Delete VM" onclick="return confirm('Are you sure that you want to delete this VM?');"/></td>
     </tr>
   </table>
 </form>
-<p>Change settings:
+#end def
+
+#def modifyForm()
+#if $err
+<p class="error">We had a problem with your request:</p>
+#else if $varExists('new_machine')
+<p>Successfully modified.</p>
+#end if
 #if $on
 (To edit ram, disk size, or machine name, turn off the machine first.)
 #end if
 </p>
-<form action="modify" method="POST">
-  <input type="hidden" name="machine_id" value="$machine.machine_id"/>
+<form action="modify" method="POST" onsubmit="return jsFormSubmit('modify', this);">
+  <input type="hidden" name="machine_id" value="$defaults.machine_id"/>
   <table>
-    <tr><td>Owner${helppopup("owner")}:</td><td><input type="text" name="owner", value="$machine.owner"/></td></tr>
-    <tr><td>Administrator${helppopup("administrator")}:</td><td><input type="text" name="administrator", value="$machine.administrator"/></td></tr>
-    <tr><td>Contact email:</td><td><input type="text" name="contact" value="$machine.contact"/></td></tr>
+    <tr><td>Owner${helppopup("owner")}:</td><td><input type="text" name="owner", value="$defaults.owner"/></td></tr>
+$errorRow('owner', $err)
+    <tr><td>Administrator${helppopup("administrator")}:</td><td><input type="text" name="administrator", value="$defaults.administrator"/></td></tr>
+$errorRow('administrator', $err)
+    <tr><td>Contact email:</td><td><input type="text" name="contact" value="$defaults.contact"/></td></tr>
+$errorRow('contact', $err)
 #if $machine.nics
-    <tr><td>Hostname:</td><td><input type="text" name="hostname" value="$machine.nics[0].hostname"/>.servers.csail.mit.edu</td></tr>
+    <tr><td>Hostname:</td><td><input type="text" name="hostname" value="$defaults.hostname"/>.servers.csail.mit.edu</td></tr>
 #end if
+$errorRow('hostname', $err)
 #if not $on
-    <tr><td>Machine Name:</td><td><input type="text" name="name" value="$machine.name"/></td></tr>
-    <tr><td>Ram:</td><td><input type="text" size=3 name="memory" value="$machine.memory"/>MB (max $max_mem)</td></tr>
-    <tr><td>Disk:</td><td><input type="text" size=3 name="disk" value="${machine.disks[0].size/1024.}"/>GB (max $max_disk)</td><td>WARNING: Modifying disk size may corrupt your data.</td></tr>
+    <tr><td>Machine Name:</td><td><input type="text" name="name" value="$defaults.name"/></td></tr>
+$errorRow('name', $err)
+    <tr><td>Ram:</td><td><input type="text" size=3 name="memory" value="$defaults.memory"/>MB (max $max_mem)</td></tr>
+$errorRow('memory', $err)
+    <tr><td>Disk:</td><td><input type="text" size=3 name="disk" value="$defaults.disk"/>GB (max $max_disk)</td><td>WARNING: Modifying disk size may corrupt your data.</td></tr>
+$errorRow('disk', $err)
+#else
+$errorRow('name', $err)
+$errorRow('memory', $err)
+$errorRow('disk', $err)
 #end if
     <tr><td><input type="submit" class="button" name="action" value="Change"/></td></tr>
   </table>
 </form>
+#end def
 
+#def body
+<h1>Info</h1>
+<div id="info">
+  $infoTable()
+</div>
+
+<p>Commands:</p>
+<div id="commands">
+  $commands()
+</div>
+<p>Change settings:
+<div id="modify">
+  $modifyForm()
+</div>
 #end def
