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/info.tmpl

    r187 r205  
    66#end def
    77
    8 
    9 #def body
    10 <h1>Info</h1>
     8#def infoTable()
    119<p>Info on ${machine.name}:</p>
    1210<table>
     
    1513  #end for
    1614</table>
     15#end def
    1716
    18 <p>Commands:</p>
     17#def commands()
     18<script>
     19function commandButton(elt, action){
     20  form = elt.up('', 4);
     21  cdrom = Form.serialize(form, true).cdrom;
     22  new Ajax.Request('command', {method: 'post',
     23  parameters: 'machine_id=$machine.machine_id&js=info&cdrom='+cdrom+'&action='+action,
     24  onSuccess: replaceFunc
     25  });
     26  return false;
     27}
     28</script>
    1929<form action="command" action="POST">
    2030  <input type="hidden" name="machine_id" value="$machine.machine_id"/>
     
    3444      <tr>
    3545        #if $on
    36         <td><input type="submit" class="button" name="action" value="Power off"/></td>
    37         <td><input type="submit" class="button" name="action" value="Shutdown"/></td>
    38         <td><input type="submit" class="button" name="action" value="Reboot"/></td>
     46        <td><input type="submit" class="button" name="action" value="Power off" onclick="return commandButton(this, 'Power off');"/></td>
     47        <td><input type="submit" class="button" name="action" value="Shutdown" onclick="return commandButton(this, 'Shutdown');"/></td>
     48        <td><input type="submit" class="button" name="action" value="Reboot" onclick="return commandButton(this, 'Reboot');"/></td>
    3949        #else
    40         <td><input type="submit" class="button" name="action" value="Power on"/></td>
     50        <td><input type="submit" class="button" name="action" value="Power on" onclick="return commandButton(this, 'Power on');"/></td>
    4151        #end if
    4252      <td>Boot CD:</td>
    43       <td><select name="cdrom">
    44           <option selected value="">None</option>
    45           #for $cdrom in $cdroms
    46           <option value="$cdrom.cdrom_id">
    47             $cdrom.description
    48           </option>
    49           #end for
    50       </select></td>
     53      <td>$cdromList($cdroms)</td>
    5154  </tr>
    5255    <tr>
    53       <td><input type="submit" class="button" name="action" value="Delete VM"/></td>
     56      <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>
    5457    </tr>
    5558  </table>
    5659</form>
    57 <p>Change settings:
     60#end def
     61
     62#def modifyForm()
     63#if $err
     64<p class="error">We had a problem with your request:</p>
     65#else if $varExists('new_machine')
     66<p>Successfully modified.</p>
     67#end if
    5868#if $on
    5969(To edit ram, disk size, or machine name, turn off the machine first.)
    6070#end if
    6171</p>
    62 <form action="modify" method="POST">
    63   <input type="hidden" name="machine_id" value="$machine.machine_id"/>
     72<form action="modify" method="POST" onsubmit="return jsFormSubmit('modify', this);">
     73  <input type="hidden" name="machine_id" value="$defaults.machine_id"/>
    6474  <table>
    65     <tr><td>Owner${helppopup("owner")}:</td><td><input type="text" name="owner", value="$machine.owner"/></td></tr>
    66     <tr><td>Administrator${helppopup("administrator")}:</td><td><input type="text" name="administrator", value="$machine.administrator"/></td></tr>
    67     <tr><td>Contact email:</td><td><input type="text" name="contact" value="$machine.contact"/></td></tr>
     75    <tr><td>Owner${helppopup("owner")}:</td><td><input type="text" name="owner", value="$defaults.owner"/></td></tr>
     76$errorRow('owner', $err)
     77    <tr><td>Administrator${helppopup("administrator")}:</td><td><input type="text" name="administrator", value="$defaults.administrator"/></td></tr>
     78$errorRow('administrator', $err)
     79    <tr><td>Contact email:</td><td><input type="text" name="contact" value="$defaults.contact"/></td></tr>
     80$errorRow('contact', $err)
    6881#if $machine.nics
    69     <tr><td>Hostname:</td><td><input type="text" name="hostname" value="$machine.nics[0].hostname"/>.servers.csail.mit.edu</td></tr>
     82    <tr><td>Hostname:</td><td><input type="text" name="hostname" value="$defaults.hostname"/>.servers.csail.mit.edu</td></tr>
    7083#end if
     84$errorRow('hostname', $err)
    7185#if not $on
    72     <tr><td>Machine Name:</td><td><input type="text" name="name" value="$machine.name"/></td></tr>
    73     <tr><td>Ram:</td><td><input type="text" size=3 name="memory" value="$machine.memory"/>MB (max $max_mem)</td></tr>
    74     <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>
     86    <tr><td>Machine Name:</td><td><input type="text" name="name" value="$defaults.name"/></td></tr>
     87$errorRow('name', $err)
     88    <tr><td>Ram:</td><td><input type="text" size=3 name="memory" value="$defaults.memory"/>MB (max $max_mem)</td></tr>
     89$errorRow('memory', $err)
     90    <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>
     91$errorRow('disk', $err)
     92#else
     93$errorRow('name', $err)
     94$errorRow('memory', $err)
     95$errorRow('disk', $err)
    7596#end if
    7697    <tr><td><input type="submit" class="button" name="action" value="Change"/></td></tr>
    7798  </table>
    7899</form>
     100#end def
    79101
     102#def body
     103<h1>Info</h1>
     104<div id="info">
     105  $infoTable()
     106</div>
     107
     108<p>Commands:</p>
     109<div id="commands">
     110  $commands()
     111</div>
     112<p>Change settings:
     113<div id="modify">
     114  $modifyForm()
     115</div>
    80116#end def
Note: See TracChangeset for help on using the changeset viewer.