Ignore:
Timestamp:
Aug 9, 2009, 8:13:20 PM (15 years ago)
Author:
quentin
Message:

Use RESTful URLs for commands

File:
1 edited

Legend:

Unmodified
Added
Removed
  • package_branches/invirt-web/cherrypy/code/templates/info.mako

    r2416 r2417  
    2727 % endif
    2828% endif
    29 <form action="command" method="POST">
    30   <input type="hidden" name="back" value="info"/>
    31   <input type="hidden" name="machine_id" value="${machine.machine_id}"/>
     29<%def name="command_button(title, value, cdrom=False, extra='')">
     30<form action="machine/${machine.machine_id}/command/${value}" method="POST">
     31  <input type="hidden" name="back" value="machine/${machine.machine_id}/info" />
     32  <input type="submit" class="button" name="action" value="${title}" ${extra | n}/>
     33% if cdrom:
     34  Boot CD: ${self.fn.cdromList()}
     35% endif
     36</form>
     37</%def>
    3238  <div>
    3339        % if on:
    34         <button type="submit" class="button" name="action" value="Power off">Power off (hard)</button>
    35         <button type="submit" class="button" name="action" value="Shutdown">Shut down</button>
    36         <input type="submit" class="button" name="action" value="Reboot"/>
     40        ${command_button("Power off", "destroy")}
     41        ${command_button("Shutdown", "shutdown")}
     42        ${command_button("Reboot", "reboot", cdrom=True)}
    3743        % else:
    38         <input type="submit" class="button" name="action" value="Power on"/>
     44        ${command_button("Power on", "create", cdrom=True)}
    3945        % endif
    4046  </div>
    4147  <div>
    42     Boot CD:
    43 ${self.fn.cdromList()}
    44   </div>
    45   <div>
    46       <input type="submit" class="button" name="action" value="Delete VM" onclick="return confirm('Are you sure that you want to delete this VM?');"/>
     48        ${command_button("Delete VM", "delete", extra='''onclick="return confirm('Are you sure that you want to delete this VM?');"''')}
    4749  </div>
    4850</form>
Note: See TracChangeset for help on using the changeset viewer.