Ignore:
Timestamp:
Dec 20, 2009, 9:45:09 PM (15 years ago)
Author:
broder
Message:

Use RESTful URLs for commands

Location:
package_branches/invirt-web/cherrypy-rebased/code
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • package_branches/invirt-web/cherrypy-rebased/code/static/style.css

    r1318 r2683  
    105105  padding: 0.1em 0.5em;
    106106}
     107
     108form {
     109    display: inline;
     110}
  • package_branches/invirt-web/cherrypy-rebased/code/templates/info.mako

    r2678 r2683  
    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.