- Timestamp:
- Oct 20, 2007, 10:14:51 AM (17 years ago)
- Location:
- trunk/web/templates
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/web/templates/functions.py
r205 r207 34 34 __CHEETAH_version__ = '2.0rc8' 35 35 __CHEETAH_versionTuple__ = (2, 0, 0, 'candidate', 8) 36 __CHEETAH_genTime__ = 119288 3107.256833137 __CHEETAH_genTimestamp__ = 'Sat Oct 20 08:25:072007'36 __CHEETAH_genTime__ = 1192889324.134064 37 __CHEETAH_genTimestamp__ = 'Sat Oct 20 10:08:44 2007' 38 38 __CHEETAH_src__ = 'functions.tmpl' 39 39 __CHEETAH_srcLastModified__ = 'Sat Oct 20 07:34:59 2007' -
trunk/web/templates/info.tmpl
r205 r207 16 16 17 17 #def commands() 18 <script>19 function 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: replaceFunc25 });26 return false;27 }28 </script>29 18 <form action="command" action="POST"> 19 <input type="hidden" name="back" value="info"/> 30 20 <input type="hidden" name="machine_id" value="$machine.machine_id"/> 31 21 <table> … … 44 34 <tr> 45 35 #if $on 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>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> 49 39 #else 50 <td><input type="submit" class="button" name="action" value="Power on" onclick="return commandButton(this, 'Power on');"/></td>40 <td><input type="submit" class="button" name="action" value="Power on"/></td> 51 41 #end if 52 42 <td>Boot CD:</td> … … 70 60 #end if 71 61 </p> 72 <form action="modify" method="POST" onsubmit="return jsFormSubmit('modify', this);">62 <form action="modify" method="POST"> 73 63 <input type="hidden" name="machine_id" value="$defaults.machine_id"/> 74 64 <table> -
trunk/web/templates/list.tmpl
r205 r207 17 17 <p>Congratulations! You successfully created a new VM called $new_machine.</p> 18 18 #end if 19 <form action="create" method="POST" onsubmit="return jsFormSubmit('create', this);"> 19 <form action="create" method="POST"> 20 <input type="hidden" name="back" value="list"/> 20 21 <table> 21 22 $errorRow('create', $err) … … 85 86 </td> 86 87 <td> 87 <form action="command" method="post" onsubmit="return rowFormSubmit(this, 'list');"> 88 <form action="command" method="post"> 89 <input type="hidden" name="back" value="list"/> 88 90 <input type="hidden" name="machine_id" 89 91 value="$machine.machine_id"/> … … 120 122 <p>You have the following VMs:</p> 121 123 #end if 122 <p><a href="list" onclick="new Ajax.Updater('machinelist', 'list?js=machinelist', {method: 'get' });return false">refresh</a></p>124 <p><a href="list">refresh</a></p> 123 125 <div id="machinelist"> 124 126 $machineList($machines) -
trunk/web/templates/main.py
r205 r207 495 495 def create(user, fields): 496 496 """Handler for create requests.""" 497 js = fields.getfirst('js')498 497 try: 499 498 parsed_fields = parseCreate(user, fields) 500 499 machine = createVm(**parsed_fields) 501 500 except InvalidInput, err: 502 if not js: 503 raise 501 pass 504 502 else: 505 503 err = None 506 if not js:507 d = dict(user=user,508 machine=machine)509 return Template(file='create.tmpl', searchList=[d])510 504 g.clear() #Changed global state 511 505 d = getListDict(user) … … 516 510 else: 517 511 d['new_machine'] = parsed_fields['name'] 518 t = Template(file='list.tmpl', searchList=[d]) 519 return JsonDict(createtable=t.createTable(), 520 machinelist=t.machineList(d['machines'])) 512 return Template(file='list.tmpl', searchList=[d]) 521 513 522 514 … … 557 549 """Handler for list requests.""" 558 550 d = getListDict(user) 559 t = Template(file='list.tmpl', searchList=[d]) 560 js = fields.getfirst('js') 561 if not js: 562 return t 563 if js == 'machinelist': 564 return t.machineList(d['machines']) 565 elif js.startswith('machinerow-'): 566 request_machine_id = int(js.split('-')[1]) 567 m = [x for x in d['machines'] if x.id == request_machine_id] 568 return t.machineRow(m) 569 elif js == 'createtable': 570 return t.createTable() 551 return Template(file='list.tmpl', searchList=[d]) 571 552 572 553 def testMachineId(user, machineId, exists=True): … … 758 739 def command(user, fields): 759 740 """Handler for running commands like boot and delete on a VM.""" 760 js = fields.getfirst('js')741 back = fields.getfirst('back') 761 742 try: 762 743 d = commandResult(user, fields) 744 if d['command'] == 'Delete VM': 745 back = 'list' 763 746 except InvalidInput, err: 764 if not js:747 if not back: 765 748 raise 749 print >> sys.stderr, err 766 750 result = None 767 751 else: 768 err = None769 752 result = 'Success!' 770 if not js:753 if not back: 771 754 return Template(file='command.tmpl', searchList=[d]) 772 if js== 'list':755 if back == 'list': 773 756 g.clear() #Changed global state 774 757 d = getListDict(user) 775 t = Template(file='list.tmpl', searchList=[d]) 776 return JsonDict(createtable=t.createTable(), 777 machinelist=t.machineList(d['machines']), 778 result=result, 779 err=err) 780 elif js == 'info': 758 d['result'] = result 759 return Template(file='list.tmpl', searchList=[d]) 760 elif back == 'info': 781 761 machine = testMachineId(user, fields.getfirst('machine_id')) 782 762 d = infoDict(user, machine) 783 t = Template(file='info.tmpl', searchList=[d]) 784 return JsonDict(info=t.infoTable(), 785 commands=t.commands(), 786 modify=t.modifyForm(), 787 result=result, 788 err=err) 763 d['result'] = result 764 return Template(file='info.tmpl', searchList=[d]) 789 765 else: 790 raise InvalidInput(' js', js, 'Not a known js type.')766 raise InvalidInput('back', back, 'Not a known back page.') 791 767 792 768 def testAdmin(user, admin, machine): … … 800 776 'athena.mit.edu'): 801 777 return 'system:'+admin 802 raise InvalidInput('administrator', admin, 803 'You must control the group you move it to.') 778 return admin 779 #raise InvalidInput('administrator', admin, 780 # 'You must control the group you move it to.') 804 781 805 782 def testOwner(user, owner, machine): … … 900 877 def modify(user, fields): 901 878 """Handler for modifying attributes of a machine.""" 902 js = fields.getfirst('js')903 879 try: 904 880 modify_dict = modifyDict(user, fields) 905 881 except InvalidInput, err: 906 if not js: 907 raise 908 result = '' 882 result = None 909 883 machine = testMachineId(user, fields.getfirst('machine_id')) 910 884 else: … … 912 886 result='Success!' 913 887 err = None 914 if not js:915 return Template(file='command.tmpl', searchList=[modify_dict])916 888 info_dict = infoDict(user, machine) 917 889 info_dict['err'] = err … … 919 891 for field in fields.keys(): 920 892 setattr(info_dict['defaults'], field, fields.getfirst(field)) 921 t = Template(file='info.tmpl', searchList=[info_dict]) 922 return JsonDict(info=t.infoTable(), 923 commands=t.commands(), 924 modify=t.modifyForm(), 925 result=result, 926 err=err) 893 info_dict['result'] = result 894 return Template(file='info.tmpl', searchList=[info_dict]) 927 895 928 896 -
trunk/web/templates/skeleton.py
r206 r207 33 33 VFN=valueForName 34 34 currentTime=time.time 35 __CHEETAH_version__ = '2.0rc 7'36 __CHEETAH_versionTuple__ = (2, 0, 0, 'candidate', 7)37 __CHEETAH_genTime__ = 119288 3610.43491738 __CHEETAH_genTimestamp__ = 'Sat Oct 20 08:33:302007'35 __CHEETAH_version__ = '2.0rc8' 36 __CHEETAH_versionTuple__ = (2, 0, 0, 'candidate', 8) 37 __CHEETAH_genTime__ = 1192889324.1837969 38 __CHEETAH_genTimestamp__ = 'Sat Oct 20 10:08:44 2007' 39 39 __CHEETAH_src__ = 'skeleton.tmpl' 40 __CHEETAH_srcLastModified__ = 'Sat Oct 20 08:33:052007'40 __CHEETAH_srcLastModified__ = 'Sat Oct 20 10:08:36 2007' 41 41 __CHEETAH_docstring__ = 'Autogenerated by CHEETAH: The Python-Powered Template Engine' 42 42 … … 101 101 var helpWin = null; 102 102 function closeWin(){ 103 104 105 106 103 \tif (helpWin != null){ 104 \t\tif(!helpWin.closed) 105 \t\t\thelpWin.close(); 106 \t} 107 107 } 108 108 … … 114 114 return false; 115 115 } 116 117 Ajax.Responders.register({118 onCreate: function(){119 if (Ajax.activeRequestCount > 0) {120 document.getElementById("loadingnotice").style.display = 'block';121 }122 },123 onComplete: function(){124 if (Ajax.activeRequestCount == 0) {125 document.getElementById("loadingnotice").style.display = 'none';126 }127 }128 });129 function replaceFunc(transport) {130 try {131 d = transport.responseText.evalJSON();132 } catch (e) {133 $('body').innerHTML = '<pre>'+transport.responseText+'</pre>'134 return;135 }136 for(key in d) {137 $(key).innerHTML = d[key];138 }139 }140 141 function jsFormSubmit(location, elt){142 new Ajax.Request(location, {method: 'post',143 parameters: Form.serialize(elt)+'&js=true',144 onSuccess: replaceFunc,145 onComplete: function() {Form.enable(elt);}146 });147 Form.disable(elt);148 return false;149 }150 151 function rowFormSubmit(elt, retpage){152 new Ajax.Request('command', {method: 'post',153 parameters: Form.serialize(elt)+'&js='+retpage,154 onSuccess: replaceFunc155 });156 return false;157 }158 159 window.onload = function (){160 //Fix bug with disabled elements161 $$('form').each(Form.enable);162 }163 164 116 </script> 165 117 </head> … … 168 120 <div id="err"> 169 121 ''') 170 if VFFSL(SL,"varExists",False)('error_text'): # generated from line 83, col 1 171 write('<p>STDERR:</p><pre>') 172 _v = VFFSL(SL,"error_text",True) # '$error_text' on line 84, col 20 173 if _v is not None: write(_filter(_v, rawExpr='$error_text')) # from line 84, col 20. 174 write('</pre>\n') 175 write('</div>\n\n') 176 if not VFFSL(SL,"varExists",False)('simple') or not VFFSL(SL,"simple",True): # generated from line 88, col 1 177 write('<p>[You are logged in as ') 178 _v = VFFSL(SL,"user.username",True) # '$user.username' on line 89, col 26 179 if _v is not None: write(_filter(_v, rawExpr='$user.username')) # from line 89, col 26. 122 if VFFSL(SL,"varExists",False)('error_text'): # generated from line 35, col 1 123 write('''<p>STDERR:</p><pre>''') 124 _v = VFFSL(SL,"error_text",True) # '$error_text' on line 36, col 20 125 if _v is not None: write(_filter(_v, rawExpr='$error_text')) # from line 36, col 20. 126 write('''</pre> 127 ''') 128 write('''</div> 129 130 ''') 131 if not VFFSL(SL,"varExists",False)('simple') or not VFFSL(SL,"simple",True): # generated from line 40, col 1 132 write('''<p>[You are logged in as ''') 133 _v = VFFSL(SL,"user.username",True) # '$user.username' on line 41, col 26 134 if _v is not None: write(_filter(_v, rawExpr='$user.username')) # from line 41, col 26. 180 135 write('''.]</p> 181 136 … … 183 138 <p><a href="list">List</a> 184 139 ''') 185 if VFFSL(SL,"varExists",False)('machine'): # generated from line 93, col 1 186 write('<a href="info?machine_id=') 187 _v = VFFSL(SL,"machine.machine_id",True) # '$machine.machine_id' on line 94, col 26 188 if _v is not None: write(_filter(_v, rawExpr='$machine.machine_id')) # from line 94, col 26. 189 write('">Info</a>\n<a href="vnc?machine_id=') 190 _v = VFFSL(SL,"machine.machine_id",True) # '$machine.machine_id' on line 95, col 25 191 if _v is not None: write(_filter(_v, rawExpr='$machine.machine_id')) # from line 95, col 25. 192 write('">Console</a>\n') 193 write('<a href="help">Help</a></p>\n') 140 if VFFSL(SL,"varExists",False)('machine'): # generated from line 45, col 1 141 write('''<a href="info?machine_id=''') 142 _v = VFFSL(SL,"machine.machine_id",True) # '$machine.machine_id' on line 46, col 26 143 if _v is not None: write(_filter(_v, rawExpr='$machine.machine_id')) # from line 46, col 26. 144 write('''">Info</a> 145 <a href="vnc?machine_id=''') 146 _v = VFFSL(SL,"machine.machine_id",True) # '$machine.machine_id' on line 47, col 25 147 if _v is not None: write(_filter(_v, rawExpr='$machine.machine_id')) # from line 47, col 25. 148 write('''">Console</a> 149 ''') 150 write('''<a href="help">Help</a></p> 151 ''') 194 152 write('''</div> 195 153 196 154 <div id="loadingnotice" class="loadingnotice">LOADING</div> 197 <div id="result" class="result"></div> 198 199 ''') 200 _v = VFFSL(SL,"body",True) # '$body' on line 104, col 1 201 if _v is not None: write(_filter(_v, rawExpr='$body')) # from line 104, col 1. 202 write('\n') 203 if not VFFSL(SL,"varExists",False)('simple') or not VFFSL(SL,"simple",True): # generated from line 105, col 1 204 write('<hr />\nQuestions? Contact <a href="mailto:sipb-xen-dev@mit.edu">sipb-xen-dev@mit.edu</a>.\n') 205 write('</body>\n</html>\n') 155 <div id="result" class="result"> 156 ''') 157 if VFFSL(SL,"varExists",False)('result'): # generated from line 55, col 1 158 _v = VFFSL(SL,"result",True) # '$result' on line 56, col 1 159 if _v is not None: write(_filter(_v, rawExpr='$result')) # from line 56, col 1. 160 write(''' 161 ''') 162 write('''</div> 163 164 ''') 165 _v = VFFSL(SL,"body",True) # '$body' on line 60, col 1 166 if _v is not None: write(_filter(_v, rawExpr='$body')) # from line 60, col 1. 167 write(''' 168 ''') 169 if not VFFSL(SL,"varExists",False)('simple') or not VFFSL(SL,"simple",True): # generated from line 61, col 1 170 write('''<hr /> 171 Questions? Contact <a href="mailto:sipb-xen-dev@mit.edu">sipb-xen-dev@mit.edu</a>. 172 ''') 173 write('''</body> 174 </html> 175 ''') 206 176 207 177 ######################################## … … 230 200 ## START - generated method body 231 201 232 write('\n') 202 write(''' 203 ''') 233 204 234 205 ######################################## -
trunk/web/templates/skeleton.tmpl
r206 r207 28 28 return false; 29 29 } 30 31 Ajax.Responders.register({32 onCreate: function(){33 if (Ajax.activeRequestCount > 0) {34 document.getElementById("loadingnotice").style.display = 'block';35 }36 },37 onComplete: function(){38 if (Ajax.activeRequestCount == 0) {39 document.getElementById("loadingnotice").style.display = 'none';40 }41 }42 });43 function replaceFunc(transport) {44 try {45 d = transport.responseText.evalJSON();46 } catch (e) {47 \$('body').innerHTML = '<pre>'+transport.responseText+'</pre>'48 return;49 }50 for(key in d) {51 \$(key).innerHTML = d[key];52 }53 }54 55 function jsFormSubmit(location, elt){56 new Ajax.Request(location, {method: 'post',57 parameters: Form.serialize(elt)+'&js=true',58 onSuccess: replaceFunc,59 onComplete: function() {Form.enable(elt);}60 });61 Form.disable(elt);62 return false;63 }64 65 function rowFormSubmit(elt, retpage){66 new Ajax.Request('command', {method: 'post',67 parameters: Form.serialize(elt)+'&js='+retpage,68 onSuccess: replaceFunc69 });70 return false;71 }72 73 window.onload = function (){74 //Fix bug with disabled elements75 \$\$('form').each(Form.enable);76 }77 78 30 </script> 79 31 </head> … … 100 52 101 53 <div id="loadingnotice" class="loadingnotice">LOADING</div> 102 <div id="result" class="result"></div> 54 <div id="result" class="result"> 55 #if $varExists('result') 56 $result 57 #end if 58 </div> 103 59 104 60 $body
Note: See TracChangeset
for help on using the changeset viewer.