Fixing VNC client height and turning off "service is being changed" message
[invirt/packages/invirt-web.git] / templates / list.tmpl
index f820385..19b4c6e 100644 (file)
 #from skeleton import skeleton
 #extends skeleton
 
 #from skeleton import skeleton
 #extends skeleton
 
+
 #def title
 List of your VMs
 #end def
 
 #def title
 List of your VMs
 #end def
 
-#def body
-#if not $machines
-   
-#else
-    <p>You have the following VMs:</p>
-    <table>
-      <tr>
-       <td>Name</td>
-       <td>Memory</td>
-       <td>owner</td>
-       <td>IP</td>
-       <td>MAC Address</td>
-       <td>Hostname</td>
-       <td>Status</td>
-       <td>VNC</td>
-       <td>Restart?</td>
-      #for $machine in $machines:
-      <tr> 
-       <td><a href="info?machine_id=$machine.machine_id">$machine.name</a></td>
-       <td>${machine.memory}M</td>
-       <td>$machine.owner</td>
-#if $machine.nics
-#set $nic = $machine.nics[0]
-       <td>$nic.ip</td>
-       <td>$nic.mac_addr</td>
-       <td>$nic.hostname</td>
+#def createTable()
+#if $cant_add_vm
+<p>$cant_add_vm</p>
 #else
 #else
-       <td></td>
-       <td></td>
-       <td></td>
+<p>Create a new VM:</p>
+#if $err
+<p class="error">We had a problem with your request:</p>
+#else if $varExists('new_machine')
+<p>Congratulations! You successfully created a new VM called $new_machine.</p>
 #end if
 #end if
-       <td>Good!</td>
-       <td><a href="vnc?machine_id=$machine.machine_id">Console</a></td>
-       <td>
-         <form action="restart">
-           <input type="hidden" name="machine_id"
-                  value="$machine.machine_id"/>
-           <input type="submit" class="button"
-                  value="restart"/>
-         </form>
-       </td>
-      </tr>
-      #end for
-    </table>
-#end if
-
-    <p>Create a new VM:</p>
-    <form action="create">
+    <form action="create" method="POST">
+    <input type="hidden" name="back" value="list"/>
       <table>
       <table>
+      $errorRow('create', $err)
        <tr>
          <td>Name</td>
        <tr>
          <td>Name</td>
-         <td><input type="text" name="name" value="$user.username"/></td>
+         <td><input type="text" name="name" value="$defaults.name"/></td>
        </tr>
        </tr>
+$errorRow('name', $err)
        <tr>
        <tr>
-         #set $maxmem=256
          <td>Memory</td>
          <td>Memory</td>
-         <td><input type="text" name="memory" value="$maxmem" size=3/> megabytes ($maxmem max)</td>
+         <td><input type="text" name="memory" value="$defaults.memory" size=3/> MiB ($max_memory max)</td>
        </tr>
        </tr>
+$errorRow('memory', $err)
        <tr>
        <tr>
-         #set $maxdisk=1.5
          <td>Disk</td>
          <td>Disk</td>
-         <td><input type="text" name="disk" value="$maxdisk" size=3/> gigabytes ($maxdisk max)</td>
+         <td><input type="text" name="disk" value="$defaults.disk" size=3/> GiB (${"%0.1f" % ($max_disk-0.05)} max)</td>
        </tr>
        </tr>
+$errorRow('disk', $err)
        <tr>
        <tr>
-         <td>HVM/ParaVM</td>
+         <td>HVM/ParaVM$helppopup('hvm_paravm')</td>
          <td>
          <td>
-           <input checked type="radio" name="vmtype" value="hvm">HVM</input>
-           <input type="radio" name="vmtype" value="paravm">ParaVM</input>
+#for $value, $name in (('hvm', 'HVM'), ('paravm', 'ParaVM'))
+   <input #slurp
+#if $defaults.vmtype == $value then 'checked' else ''
+ type="radio" name="vmtype" value="$value">$name</input>
+#end for
          </td>
        </tr>
          </td>
        </tr>
+$errorRow('vmtype', $err)
        <tr>
        <tr>
-         <td>Initial Install</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>Boot CD</td>
+         <td>$cdromList($cdroms, $defaults.cdrom)</td>
        </tr>
        </tr>
+$errorRow('cdrom', $err)
+       <tr>
+         <td>Owner</td>
+         <td><input type="text" name="owner" value="$defaults.owner"/></td>
+       </tr>
+       $errorRow('owner', $err)
       </table>
       <input type="submit" class="button" value="Create it!"/>
     </form>
       </table>
       <input type="submit" class="button" value="Create it!"/>
     </form>
+#end if
+#end def
+
+#def machineRow($machine)
+      <tr> 
+       <td><a href="info?machine_id=$machine.machine_id">$machine.name</a></td>
+       <td>${machine.memory}M</td>
+       <td>$machine.owner</td>
+       <td>$machine.administrator</td>
+#if $machine.nics
+#set $nic = $machine.nics[0]
+       <td>$nic.ip</td>
+#else
+       <td></td>
+#end if
+<td>#slurp
+#if $machine.uptime
+$machine.uptime#slurp
+#else
+Off#slurp
+#end if
+</td>
+       <td>#slurp
+#if $has_vnc[$machine] == True
+<a href="vnc?machine_id=$machine.machine_id">Console</a>#slurp
+#else
+$has_vnc[$machine]
+#end if
+</td>
+       <td>
+         <form action="command" method="post">
+           <input type="hidden" name="back" value="list"/>
+           <input type="hidden" name="machine_id"
+                  value="$machine.machine_id"/>
+<input type="submit" class="button" name="action" value="#slurp
+#if $machine.uptime then 'Power off' else 'Power on'
+"/>
+         </form>
+       </td>
+      </tr>
+#end def
 
 
+#def machineList($machines)
+    <table>
+      <tr>
+       <td>Name</td>
+       <td>Memory</td>
+       <td>Owner</td>
+        <td>Administrator</td>
+       <td>IP</td>
+       <td>Uptime</td>
+       <td>VNC</td>
+       <td></td>
+      #for $machine in $machines:
+       $machineRow($machine)
+      #end for
+    </table>
+#end def
+
+
+#def body
+#if not $machines
+<p>You don't currently control any VMs.</p>   
+#else
+    <p>You have the following VMs:</p>
+#end if
+    <p><a href="list">refresh</a></p>
+    <div id="machinelist">
+    $machineList($machines)
+    </div>
+<div id="createtable">
+$createTable()
+</div>
 #end def
 #end def