Ignore:
Timestamp:
Oct 20, 2007, 8:28:32 AM (17 years ago)
Author:
ecprice
Message:

A monster checkin, with a variety of changes to the web
infrastructure.

Adds some support for javascript and asynchronous updates.

Also added prototype.

The interface is *really* *slow*, though.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/web/templates/list.tmpl

    r186 r205  
    11#from skeleton import skeleton
    22#extends skeleton
     3
    34
    45#def title
     
    67#end def
    78
    8 #def body
    9 #if not $machines
    10    
     9#def createTable()
     10#if $cant_add_vm
     11<p>$cant_add_vm</p>
    1112#else
    12     <p>You have the following VMs:</p>
    13     <table>
    14       <tr>
    15         <td>Name</td>
    16         <td>Memory</td>
    17         <td>owner</td>
    18         <td>IP</td>
    19         <td>Hostname</td>
    20         <td>Uptime</td>
    21         <td>VNC</td>
    22         <td></td>
    23       #for $machine in $machines:
     13<p>Create a new VM:</p>
     14#if $err
     15<p class="error">We had a problem with your request:</p>
     16#else if $varExists('new_machine')
     17<p>Congratulations! You successfully created a new VM called $new_machine.</p>
     18#end if
     19    <form action="create" method="POST" onsubmit="return jsFormSubmit('create', this);">
     20      <table>
     21      $errorRow('create', $err)
     22        <tr>
     23          <td>Name</td>
     24          <td><input type="text" name="name" value="$defaults.name"/></td>
     25        </tr>
     26$errorRow('name', $err)
     27        <tr>
     28          <td>Memory</td>
     29          <td><input type="text" name="memory" value="$defaults.memory" size=3/> megabytes ($max_memory max)</td>
     30        </tr>
     31$errorRow('memory', $err)
     32        <tr>
     33          <td>Disk</td>
     34          <td><input type="text" name="disk" value="$defaults.disk" size=3/> gigabytes (${"%0.1f" % ($max_disk-0.05)} max)</td>
     35        </tr>
     36$errorRow('disk', $err)
     37        <tr>
     38          <td>HVM/ParaVM$helppopup('hvm_paravm')</td>
     39          <td>
     40#for $value, $name in (('hvm', 'HVM'), ('paravm', 'ParaVM'))
     41   <input #slurp
     42#if $defaults.vmtype == $value then 'checked' else ''
     43 type="radio" name="vmtype" value="$value">$name</input>
     44#end for
     45          </td>
     46        </tr>
     47$errorRow('vmtype', $err)
     48        <tr>
     49          <td>Boot CD</td>
     50          <td>$cdromList($cdroms, $defaults.cdrom)</td>
     51        </tr>
     52$errorRow('cdrom', $err)
     53      </table>
     54      <input type="submit" class="button" value="Create it!"/>
     55    </form>
     56#end if
     57#end def
     58
     59#def machineRow($machine)
    2460      <tr>
    2561        <td><a href="info?machine_id=$machine.machine_id">$machine.name</a></td>
     
    3571#end if
    3672<td>#slurp
    37 #if $uptimes[$machine]
    38 $uptimes[$machine]#slurp
     73#if $machine.uptime
     74$machine.uptime#slurp
    3975#else
    4076Off#slurp
     
    4985</td>
    5086        <td>
    51           <form action="command">
     87          <form action="command" method="post" onsubmit="return rowFormSubmit(this, 'list');">
    5288            <input type="hidden" name="machine_id"
    5389                   value="$machine.machine_id"/>
    54 #if $uptimes[$machine]
    55             <input type="submit" class="button" name="action" value="Shutdown"/>
    56 #else
    57             <input type="submit" class="button" name="action" value="Power on"/>
    58 #end if
     90<input type="submit" class="button" name="action" value="#slurp
     91#if $machine.uptime then 'Shutdown' else 'Power on'
     92"/>
    5993          </form>
    6094        </td>
    6195      </tr>
     96#end def
     97
     98#def machineList($machines)
     99    <table>
     100      <tr>
     101        <td>Name</td>
     102        <td>Memory</td>
     103        <td>owner</td>
     104        <td>IP</td>
     105        <td>Hostname</td>
     106        <td>Uptime</td>
     107        <td>VNC</td>
     108        <td></td>
     109      #for $machine in $machines:
     110        $machineRow($machine)
    62111      #end for
    63112    </table>
     113#end def
     114
     115
     116#def body
     117#if not $machines
     118<p>You don't currently control any VMs.</p>   
     119#else
     120    <p>You have the following VMs:</p>
    64121#end if
    65 #if $can_add_vm
    66     <p>Create a new VM:</p>
    67     <form action="create" method="POST">
    68       <table>
    69         <tr>
    70           <td>Name</td>
    71           <td><input type="text" name="name" value=""/></td>
    72         </tr>
    73         <tr>
    74           <td>Memory</td>
    75           <td><input type="text" name="memory" value="$default_mem" size=3/> megabytes ($max_mem max)</td>
    76         </tr>
    77         <tr>
    78           <td>Disk</td>
    79           <td><input type="text" name="disk" value="$default_disk" size=3/> gigabytes (${"%0.1f" % ($max_disk-0.05)} max)</td>
    80         </tr>
    81         <tr>
    82           <td>HVM/ParaVM$helppopup('hvm_paravm')</td>
    83           <td>
    84             <input checked type="radio" name="vmtype" value="hvm">HVM</input>
    85             <input type="radio" name="vmtype" value="paravm">ParaVM</input>
    86           </td>
    87         </tr>
    88         <tr>
    89           <td>Boot CD</td>
    90           <td>
    91             <select name="cdrom">
    92               <option selected value="">None</option>
    93               #for $cdrom in $cdroms
    94               <option value="$cdrom.cdrom_id">
    95                 $cdrom.description
    96               </option>
    97               #end for
    98             </select>
    99           </td>
    100         </tr>
    101       </table>
    102       <input type="submit" class="button" value="Create it!"/>
    103     </form>
    104 #else
    105 <p>You are at the maximum number of VMs.</p>
    106 #end if
     122    <p><a href="list" onclick="new Ajax.Updater('machinelist', 'list?js=machinelist', {method: 'get' });return false">refresh</a></p>
     123    <div id="machinelist">
     124    $machineList($machines)
     125    </div>
     126<div id="createtable">
     127$createTable()
     128</div>
    107129#end def
Note: See TracChangeset for help on using the changeset viewer.