You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

topmenu.html 7.8KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287
  1. <!--
  2. Main / Top menu
  3. Copyright (C) 2010-2015 Ian Moore (imoore76 at yahoo dot com)
  4. $Id: topmenu.html 595 2015-04-17 09:50:36Z imoore76 $
  5. -->
  6. <span></span>
  7. <script type='text/javascript'>
  8. /*
  9. *
  10. * Main menu at top of interface
  11. *
  12. *
  13. */
  14. // Top menu
  15. var vboxTopMenuBar = new vboxMenuBar({name: 'vboxTop', language_context: 'UIActionPool'});
  16. var menu = {
  17. 'name':'vboxTopFile',
  18. 'label': 'File',
  19. 'menu':[
  20. {
  21. 'name':'fileVMM',
  22. 'label':'Virtual Media Manager...',
  23. 'icon':'diskimage',
  24. 'click':function(){vboxVMMDialog();}
  25. },
  26. {
  27. 'name':'fileImport',
  28. 'label':'Import Appliance...',
  29. 'icon':'import',
  30. 'click':function(){
  31. new vboxWizardImportApplianceDialog().run();
  32. },
  33. 'separator': true
  34. },
  35. {
  36. 'name':'fileExport',
  37. 'label':'Export Appliance...',
  38. 'icon':'export',
  39. 'click':function(){new vboxWizardExportApplianceDialog().run();}
  40. },
  41. {
  42. 'name':'filePrefs',
  43. 'label':'Preferences...',
  44. 'icon':'global_settings',
  45. 'click':function(){vboxGlobalPrefsDialog();},
  46. 'separator':true
  47. }
  48. ]
  49. };
  50. if($('#vboxPane').data('vboxSession').user) {
  51. if ( $('#vboxPane').data('vboxConfig').authCapabilities.canChangePassword )
  52. menu['menu'][menu['menu'].length] = {
  53. 'name' : 'fileChangePW',
  54. 'label' : 'Change Password',
  55. 'language_context': 'UIUsers',
  56. 'icon' : 'register',
  57. 'click': function() {
  58. var l = new vboxLoader();
  59. l.addFileToDOM('panes/userEdit.html');
  60. l.onLoad = function(){
  61. // Set mode
  62. $('#vboxUserEdit').trigger('setMode','changePassword');
  63. var buttons = {};
  64. buttons[trans('OK','QIMessageBox')] = function() {
  65. var o = $('#vboxUserEdit').find('input[name=opass]').first().val();
  66. var n1 = $('#vboxUserEdit').find('input[name=npass1]').first().val();
  67. var n2 = $('#vboxUserEdit').find('input[name=npass2]').first().val();
  68. if(o.length == 0) {
  69. vboxAlert(trans('The password you have entered is invalid.','UIUsers'),{'width':'auto'});
  70. return;
  71. }
  72. if(n1.length == 0 || (n1 != n2)) {
  73. vboxAlert(trans('The passwords you have entered do not match.','UIUsers'),{'width':'auto'});
  74. return;
  75. }
  76. var dialog = this;
  77. var chp = new vboxLoader();
  78. chp.add('changePassword',function(d){
  79. if(d) {
  80. if(d.success) {
  81. vboxAlert(trans('Password changed.','UIUsers'),{'width':'auto'});
  82. $(dialog).remove();
  83. } else {
  84. vboxAlert(trans('The password you have entered is invalid.','UIUsers'),{'width':'auto'});
  85. }
  86. } else {
  87. // unknown error
  88. $(dialog).remove();
  89. }
  90. },{'old':o,'new':n1});
  91. chp.run();
  92. };
  93. buttons[trans('Cancel','QIMessageBox')] = function(){
  94. $(this).remove();
  95. };
  96. $('#vboxUserEdit').dialog({'closeOnEscape':false,'width':400,'height':200,'buttons':buttons,'modal':true,'autoOpen':true,'dialogClass':'vboxDialogContent','title':'<img src="images/vbox/register_16px.png" class="vboxDialogTitleIcon" /> '+trans('Change Password','UIUsers')});
  97. };
  98. l.run();
  99. },
  100. 'separator':true
  101. };
  102. if ( $('#vboxPane').data('vboxConfig').authCapabilities.canLogout )
  103. {
  104. menu['menu'][menu['menu'].length] = {
  105. 'name' : 'fileLogout',
  106. // Pre-translated title to append username
  107. 'label' : trans('Log out - %1','VBoxSelectorWnd').replace('%1',$('#vboxPane').data('vboxSession').user),
  108. 'icon' : 'exit',
  109. 'click': function() {
  110. // Show loading screen
  111. var lm = new vboxLoader();
  112. lm.showLoading();
  113. // Expire data mediator data
  114. vboxVMDataMediator.expireAll();
  115. // Unsubscribe from events
  116. $.when(vboxEventListener.stop()).done(function() {
  117. // remove loading screen
  118. lm.removeLoading();
  119. var l = new vboxLoader();
  120. l.noLoadingScreen = true;
  121. l.add('logout',function(r){
  122. if ( typeof(r.responseData.url) == 'string' )
  123. {
  124. window.location = r.responseData.url;
  125. }
  126. else
  127. {
  128. location.reload(true);
  129. }
  130. });
  131. l.onLoad = function(loader){
  132. loader.hideRoot = false;
  133. };
  134. l.hideRoot = true;
  135. l.run();
  136. });
  137. }
  138. };
  139. }
  140. else
  141. {
  142. menu['menu'][menu['menu'].length] = {
  143. 'name' : 'fileLogout',
  144. 'label' : trans('Logged in as %1','VBoxSelectorWnd').replace('%1',$('#vboxPane').data('vboxSession').user),
  145. 'icon' : 'exit',
  146. 'click': function() {
  147. return false;
  148. }
  149. };
  150. }
  151. }
  152. vboxTopMenuBar.addMenu(menu);
  153. //VM List Context menu for each VM
  154. var sChildren = [];
  155. for(var i = 0; i < vboxVMActions.stop_actions.length; i++) {
  156. sChildren[sChildren.length] = vboxVMActions[vboxVMActions.stop_actions[i]];
  157. }
  158. vboxTopMenuBar.addMenu({
  159. 'name': 'vboxTopMachine',
  160. 'label': 'Machine',
  161. 'enabled' : function(chooser) {
  162. return (!chooser || (chooser.selectionMode != vboxSelectionModeSingleGroup));
  163. },
  164. 'menu':[
  165. vboxVMActions['new'],
  166. vboxVMActions['add'],
  167. vboxVMActions['settings'],
  168. vboxVMActions['clone'],
  169. vboxVMActions['remove'],
  170. vboxVMActions['group'],
  171. $.extend({},vboxVMActions['start'],{'separator':true}),
  172. vboxVMActions['pause'],
  173. vboxVMActions['reset'],
  174. $.extend({},vboxVMActions['stop'],{'children':sChildren}),
  175. $.extend({},vboxVMActions['discard'],{'separator':true}),
  176. vboxVMActions['logs'],
  177. vboxVMActions['refresh'],
  178. ]
  179. });
  180. vboxTopMenuBar.addMenu({
  181. 'name':'vboxTopGroup',
  182. 'label':'Group',
  183. 'enabled' : function(chooser) {
  184. return (chooser && (chooser.selectionMode == vboxSelectionModeSingleGroup));
  185. },
  186. 'menu':[
  187. vboxVMGroupActions['newmachine'],
  188. vboxVMGroupActions['addmachine'],
  189. $.extend({}, vboxVMGroupActions['rename'], {separator:true}),
  190. vboxVMGroupActions['ungroup'],
  191. $.extend({},vboxVMActions['start'],{'name':'start','separator' : true}),
  192. vboxVMActions['pause'],
  193. vboxVMActions['reset'],
  194. $.extend({},vboxVMActions['stop'],{'children':sChildren}),
  195. $.extend({},vboxVMActions['discard'],{'separator' : true}),
  196. vboxVMActions['refresh'],
  197. $.extend({}, vboxVMGroupActions['sort'], {separator:true})
  198. ]
  199. });
  200. vboxTopMenuBar.addMenu({
  201. 'name':'vboxTopHelp',
  202. 'label': 'Help',
  203. 'language_context': 'UIHelpButton',
  204. 'menu':[
  205. {
  206. 'name':'helpvbox',
  207. 'label':'VirtualBox User Manual',
  208. 'icon':'site',
  209. 'click':function(){
  210. window.open('http://www.virtualbox.org/manual/','manual');
  211. }
  212. },
  213. {
  214. 'name':'helpAbout',
  215. 'label':'About',
  216. 'icon':'help',
  217. 'click':function(){
  218. $('#vboxPane').append($('<div />').attr({'id':'vboxAbout','class':'vboxDialogContent','style':'display: none; width: 500px;'}));
  219. var l = new vboxLoader();
  220. l.addFileToDOM('panes/about.html',$('#vboxAbout'));
  221. l.onLoad = function() {
  222. var buttons = {};
  223. buttons[trans('Close','UIVMLogViewer')] = function() { $(this).empty().remove(); };
  224. $('#vboxAbout').dialog({'closeOnEscape':false,'width':500,'height':'auto','buttons':buttons,'modal':true,'autoOpen':true,'dialogClass':'vboxDialogContent','title':'<img src="images/vbox/help_16px.png" class="vboxDialogTitleIcon" /> phpVirtualBox'});
  225. };
  226. l.run();
  227. }
  228. }
  229. ]
  230. });
  231. vboxTopMenuBar.renderTo('vboxMenu');
  232. $('#vboxPane').on('vmSelectionListChanged vmGroupDefsSaving vmGroupDefsSaved',function(e){
  233. vboxTopMenuBar.update(vboxChooser);
  234. }).on('vboxEvents', function(e, eventList) {
  235. var updateMenuBar = false;
  236. for(var i = 0; i < eventList.length && !updateMenuBar; i++) {
  237. switch(eventList[i].eventType) {
  238. case 'OnMachineStateChanged':
  239. case 'OnSessionStateChanged':
  240. if(vboxChooser.isVMSelected(eventList[i].machineId)) {
  241. updateMenuBar = true;
  242. }
  243. break;
  244. }
  245. }
  246. if(updateMenuBar) {
  247. vboxTopMenuBar.update(vboxChooser);
  248. }
  249. });
  250. </script>